diff options
author | Thomas Haller <thaller@redhat.com> | 2021-08-06 19:08:35 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-08-11 14:17:24 +0200 |
commit | 4d0e295317c00705a536d5e202797810466b727a (patch) | |
tree | 5025ae8e067ace58200001008c31c1064ae752fe | |
parent | 1d789ca44b3ac077a29886bccd34f978f4862701 (diff) | |
download | NetworkManager-4d0e295317c00705a536d5e202797810466b727a.tar.gz |
ndisc: add nm_ndisc_dhcp_level_to_string() helper
-rw-r--r-- | src/core/ndisc/nm-ndisc.c | 27 | ||||
-rw-r--r-- | src/core/ndisc/nm-ndisc.h | 2 |
2 files changed, 13 insertions, 16 deletions
diff --git a/src/core/ndisc/nm-ndisc.c b/src/core/ndisc/nm-ndisc.c index 655a2523ad..80ab38b480 100644 --- a/src/core/ndisc/nm-ndisc.c +++ b/src/core/ndisc/nm-ndisc.c @@ -96,6 +96,16 @@ static gboolean timeout_expire_cb(gpointer user_data); /*****************************************************************************/ +NM_UTILS_LOOKUP_STR_DEFINE(nm_ndisc_dhcp_level_to_string, + NMNDiscDHCPLevel, + NM_UTILS_LOOKUP_DEFAULT("INVALID"), + NM_UTILS_LOOKUP_STR_ITEM(NM_NDISC_DHCP_LEVEL_UNKNOWN, "unknown"), + NM_UTILS_LOOKUP_STR_ITEM(NM_NDISC_DHCP_LEVEL_NONE, "none"), + NM_UTILS_LOOKUP_STR_ITEM(NM_NDISC_DHCP_LEVEL_OTHERCONF, "otherconf"), + NM_UTILS_LOOKUP_STR_ITEM(NM_NDISC_DHCP_LEVEL_MANAGED, "managed"), ); + +/*****************************************************************************/ + NML3ConfigData * nm_ndisc_data_to_l3cd(NMDedupMultiIndex * multi_idx, int ifindex, @@ -1211,21 +1221,6 @@ config_map_to_string(NMNDiscConfigMap map, char *p) *p = '\0'; } -static const char * -dhcp_level_to_string(NMNDiscDHCPLevel dhcp_level) -{ - switch (dhcp_level) { - case NM_NDISC_DHCP_LEVEL_NONE: - return "none"; - case NM_NDISC_DHCP_LEVEL_OTHERCONF: - return "otherconf"; - case NM_NDISC_DHCP_LEVEL_MANAGED: - return "managed"; - default: - return "INVALID"; - } -} - static void _config_changed_log(NMNDisc *ndisc, NMNDiscConfigMap changed) { @@ -1248,7 +1243,7 @@ _config_changed_log(NMNDisc *ndisc, NMNDiscConfigMap changed) config_map_to_string(changed, changedstr); _LOGD("neighbor discovery configuration changed [%s]:", changedstr); - _LOGD(" dhcp-level %s", dhcp_level_to_string(priv->rdata.public.dhcp_level)); + _LOGD(" dhcp-level %s", nm_ndisc_dhcp_level_to_string(priv->rdata.public.dhcp_level)); if (rdata->public.hop_limit) _LOGD(" hop limit : %d", rdata->public.hop_limit); diff --git a/src/core/ndisc/nm-ndisc.h b/src/core/ndisc/nm-ndisc.h index 15f95d206d..968f739ee2 100644 --- a/src/core/ndisc/nm-ndisc.h +++ b/src/core/ndisc/nm-ndisc.h @@ -48,6 +48,8 @@ typedef enum { NM_NDISC_DHCP_LEVEL_MANAGED } NMNDiscDHCPLevel; +const char *nm_ndisc_dhcp_level_to_string(NMNDiscDHCPLevel level); + #define NM_NDISC_INFINITY_U32 ((uint32_t) -1) /* It's important that this is G_MAXINT64, so that we can meaningfully do |