summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-02-13 09:43:08 +0100
committerThomas Haller <thaller@redhat.com>2020-02-13 10:46:34 +0100
commit5a731747c529cc1a62bfa0f54f17d5e3f3c71c4c (patch)
treebafaa1fee2285cd8f54ba09f9cbe4e609182789e
parent487141d4a86282ce5cc6b98847af8acd11ca90b9 (diff)
libnm: use NM_UTILS_STRING_TABLE_LOOKUP_DEFINE() to implement _nm_setting_bond_mode_from_string()
-rw-r--r--libnm-core/nm-setting-bond.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/libnm-core/nm-setting-bond.c b/libnm-core/nm-setting-bond.c
index 52da8ccf1..40341c59f 100644
--- a/libnm-core/nm-setting-bond.c
+++ b/libnm-core/nm-setting-bond.c
@@ -461,28 +461,19 @@ _nm_setting_bond_get_option_type (NMSettingBond *setting, const char *name)
g_assert_not_reached ();
}
-NMBondMode
-_nm_setting_bond_mode_from_string (const char *str)
-{
- g_return_val_if_fail (str, NM_BOND_MODE_UNKNOWN);
-
- if (nm_streq (str, "balance-rr"))
- return NM_BOND_MODE_ROUNDROBIN;
- if (nm_streq (str, "active-backup"))
- return NM_BOND_MODE_ACTIVEBACKUP;
- if (nm_streq (str, "balance-xor"))
- return NM_BOND_MODE_XOR;
- if (nm_streq (str, "broadcast"))
- return NM_BOND_MODE_BROADCAST;
- if (nm_streq (str, "802.3ad"))
- return NM_BOND_MODE_8023AD;
- if (nm_streq (str, "balance-tlb"))
- return NM_BOND_MODE_TLB;
- if (nm_streq (str, "balance-alb"))
- return NM_BOND_MODE_ALB;
-
- return NM_BOND_MODE_UNKNOWN;
-}
+NM_UTILS_STRING_TABLE_LOOKUP_DEFINE (
+ _nm_setting_bond_mode_from_string,
+ NMBondMode,
+ { g_return_val_if_fail (name, NM_BOND_MODE_UNKNOWN); },
+ { return NM_BOND_MODE_UNKNOWN; },
+ { "802.3ad", NM_BOND_MODE_8023AD },
+ { "active-backup", NM_BOND_MODE_ACTIVEBACKUP },
+ { "balance-alb", NM_BOND_MODE_ALB },
+ { "balance-rr", NM_BOND_MODE_ROUNDROBIN },
+ { "balance-tlb", NM_BOND_MODE_TLB },
+ { "balance-xor", NM_BOND_MODE_XOR },
+ { "broadcast", NM_BOND_MODE_BROADCAST },
+);
/*****************************************************************************/