summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2021-08-06 19:08:35 +0200
committerThomas Haller <thaller@redhat.com>2021-08-11 14:17:24 +0200
commit4d0e295317c00705a536d5e202797810466b727a (patch)
tree5025ae8e067ace58200001008c31c1064ae752fe
parent1d789ca44b3ac077a29886bccd34f978f4862701 (diff)
downloadNetworkManager-4d0e295317c00705a536d5e202797810466b727a.tar.gz
ndisc: add nm_ndisc_dhcp_level_to_string() helper
-rw-r--r--src/core/ndisc/nm-ndisc.c27
-rw-r--r--src/core/ndisc/nm-ndisc.h2
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