From 8755538e044381b39d55f13f76d81c29245022ab Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 4 Mar 2021 12:53:48 +0100 Subject: glib-aux: move nm_utils_route_type{2str,_by_name}() to libnm-glib-aux --- src/libnm-core-aux-intern/nm-libnm-core-utils.c | 28 ---------------------- src/libnm-core-aux-intern/nm-libnm-core-utils.h | 4 ---- src/libnm-glib-aux/nm-shared-utils.c | 31 +++++++++++++++++++++++++ src/libnm-glib-aux/nm-shared-utils.h | 6 +++++ 4 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/libnm-core-aux-intern/nm-libnm-core-utils.c b/src/libnm-core-aux-intern/nm-libnm-core-utils.c index 87dc1e9ebd..78daac44c2 100644 --- a/src/libnm-core-aux-intern/nm-libnm-core-utils.c +++ b/src/libnm-core-aux-intern/nm-libnm-core-utils.c @@ -276,34 +276,6 @@ nm_client_permission_result_to_string(NMClientPermissionResult permission) return NULL; } -NM_UTILS_STRING_TABLE_LOOKUP_DEFINE( - nm_utils_route_type_by_name, - guint8, - { nm_assert(name); }, - { return RTN_UNSPEC; }, - {"blackhole", RTN_BLACKHOLE}, - {"broadcast", RTN_BROADCAST}, - {"local", RTN_LOCAL}, - {"multicast", RTN_MULTICAST}, - {"nat", RTN_NAT}, - {"prohibit", RTN_PROHIBIT}, - {"throw", RTN_THROW}, - {"unicast", RTN_UNICAST}, - {"unreachable", RTN_UNREACHABLE}, ); - -NM_UTILS_ENUM2STR_DEFINE(nm_utils_route_type2str, - guint8, - NM_UTILS_ENUM2STR(RTN_BLACKHOLE, "blackhole"), - NM_UTILS_ENUM2STR(RTN_BROADCAST, "broadcast"), - NM_UTILS_ENUM2STR(RTN_LOCAL, "local"), - NM_UTILS_ENUM2STR(RTN_MULTICAST, "multicast"), - NM_UTILS_ENUM2STR(RTN_NAT, "nat"), - NM_UTILS_ENUM2STR(RTN_PROHIBIT, "prohibit"), - NM_UTILS_ENUM2STR(RTN_THROW, "throw"), - NM_UTILS_ENUM2STR(RTN_UNICAST, "unicast"), - NM_UTILS_ENUM2STR(RTN_UNREACHABLE, "unreachable"), - NM_UTILS_ENUM2STR(RTN_UNSPEC, "unspecified"), ); - gboolean nm_utils_validate_dhcp4_vendor_class_id(const char *vci, GError **error) { diff --git a/src/libnm-core-aux-intern/nm-libnm-core-utils.h b/src/libnm-core-aux-intern/nm-libnm-core-utils.h index 946c7a2c0e..e2a350e57a 100644 --- a/src/libnm-core-aux-intern/nm-libnm-core-utils.h +++ b/src/libnm-core-aux-intern/nm-libnm-core-utils.h @@ -146,10 +146,6 @@ NMClientPermission nm_auth_permission_from_string(const char *str); NMClientPermissionResult nm_client_permission_result_from_string(const char *nm); const char * nm_client_permission_result_to_string(NMClientPermissionResult permission); -guint8 nm_utils_route_type_by_name(const char *name); - -const char *nm_utils_route_type2str(guint8 val, char *buf, gsize len); - gboolean nm_utils_validate_dhcp4_vendor_class_id(const char *vci, GError **error); /*****************************************************************************/ diff --git a/src/libnm-glib-aux/nm-shared-utils.c b/src/libnm-glib-aux/nm-shared-utils.c index 783ef81dfd..d3effc551d 100644 --- a/src/libnm-glib-aux/nm-shared-utils.c +++ b/src/libnm-glib-aux/nm-shared-utils.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "nm-errno.h" #include "nm-str-buf.h" @@ -6071,3 +6072,33 @@ NM_ASSERT_VALID_PATH_COMPONENT(const char *name) NM_PRINT_FMT_QUOTED(name, "\"", name, "\"", "(null)")); g_assert_not_reached(); } + +/*****************************************************************************/ + +NM_UTILS_STRING_TABLE_LOOKUP_DEFINE( + nm_utils_route_type_by_name, + guint8, + { nm_assert(name); }, + { return RTN_UNSPEC; }, + {"blackhole", RTN_BLACKHOLE}, + {"broadcast", RTN_BROADCAST}, + {"local", RTN_LOCAL}, + {"multicast", RTN_MULTICAST}, + {"nat", RTN_NAT}, + {"prohibit", RTN_PROHIBIT}, + {"throw", RTN_THROW}, + {"unicast", RTN_UNICAST}, + {"unreachable", RTN_UNREACHABLE}, ); + +NM_UTILS_ENUM2STR_DEFINE(nm_utils_route_type2str, + guint8, + NM_UTILS_ENUM2STR(RTN_BLACKHOLE, "blackhole"), + NM_UTILS_ENUM2STR(RTN_BROADCAST, "broadcast"), + NM_UTILS_ENUM2STR(RTN_LOCAL, "local"), + NM_UTILS_ENUM2STR(RTN_MULTICAST, "multicast"), + NM_UTILS_ENUM2STR(RTN_NAT, "nat"), + NM_UTILS_ENUM2STR(RTN_PROHIBIT, "prohibit"), + NM_UTILS_ENUM2STR(RTN_THROW, "throw"), + NM_UTILS_ENUM2STR(RTN_UNICAST, "unicast"), + NM_UTILS_ENUM2STR(RTN_UNREACHABLE, "unreachable"), + NM_UTILS_ENUM2STR(RTN_UNSPEC, "unspecified"), ); diff --git a/src/libnm-glib-aux/nm-shared-utils.h b/src/libnm-glib-aux/nm-shared-utils.h index 90015da381..e28a6f825e 100644 --- a/src/libnm-glib-aux/nm-shared-utils.h +++ b/src/libnm-glib-aux/nm-shared-utils.h @@ -2744,4 +2744,10 @@ gboolean nm_utils_sysctl_ip_conf_is_path(int addr_family, const char *ifname, const char *property); +/*****************************************************************************/ + +guint8 nm_utils_route_type_by_name(const char *name); + +const char *nm_utils_route_type2str(guint8 val, char *buf, gsize len); + #endif /* __NM_SHARED_UTILS_H__ */ -- cgit v1.2.1