summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-03-04 22:00:24 +0100
committerThomas Haller <thaller@redhat.com>2014-03-13 21:40:42 +0100
commit2331f9b00d27ab67aeaa2417ea40a74670b141b6 (patch)
treeeb771940595e93df66a0a9611b9e03b1c5b64a62
parentc6374debe8810ca136d2f6a690a76ec9ddc2182c (diff)
downloadNetworkManager-2331f9b00d27ab67aeaa2417ea40a74670b141b6.tar.gz
platform: extract function nm_platform_addr_flags2str() to wrap rtnl_addr_flags2str()
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--src/platform/nm-platform.c40
-rw-r--r--src/platform/nm-platform.h2
2 files changed, 27 insertions, 15 deletions
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
index a738e898db..a42910f2c1 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -1938,6 +1938,30 @@ nm_platform_ip4_address_to_string (const NMPlatformIP4Address *address)
}
/**
+ * nm_platform_addr_flags2str: wrapper for rtnl_addr_flags2str(),
+ * which might not yet support some recent address flags.
+ **/
+void
+nm_platform_addr_flags2str (int flags, char *buf, size_t size)
+{
+ rtnl_addr_flags2str(flags, buf, size);
+
+ /* There are two recent flags IFA_F_MANAGETEMPADDR and IFA_F_NOPREFIXROUTE.
+ * If libnl does not yet support them, add them by hand.
+ * These two flags were introduced together with the extended ifa_flags,
+ * so, check for that.
+ */
+ if ((flags & IFA_F_MANAGETEMPADDR) && !nm_platform_check_support_libnl_extended_ifa_flags ()) {
+ strncat (buf, buf[0] ? "," IFA_F_MANAGETEMPADDR_STR : IFA_F_MANAGETEMPADDR_STR,
+ size - strlen (buf) - 1);
+ }
+ if ((flags & IFA_F_NOPREFIXROUTE) && !nm_platform_check_support_libnl_extended_ifa_flags ()) {
+ strncat (buf, buf[0] ? "," IFA_F_NOPREFIXROUTE_STR : IFA_F_NOPREFIXROUTE_STR,
+ size - strlen (buf) - 1);
+ }
+}
+
+/**
* nm_platform_ip6_address_to_string:
* @route: pointer to NMPlatformIP6Address address structure
*
@@ -1970,21 +1994,7 @@ nm_platform_ip6_address_to_string (const NMPlatformIP6Address *address)
_to_string_dev (address->ifindex, str_dev, sizeof (str_dev));
- rtnl_addr_flags2str(address->flags, s_flags, sizeof (s_flags));
-
- /* There are two recent flags IFA_F_MANAGETEMPADDR and IFA_F_NOPREFIXROUTE.
- * If libnl does not yet support them, add them by hand.
- * These two flags were introduced together with the extended ifa_flags,
- * so, check for that.
- **/
- if ((address->flags & IFA_F_MANAGETEMPADDR) && !nm_platform_check_support_libnl_extended_ifa_flags ()) {
- strncat (s_flags, s_flags[0] ? "," IFA_F_MANAGETEMPADDR_STR : IFA_F_MANAGETEMPADDR_STR,
- sizeof (s_flags) - strlen (s_flags) - 1);
- }
- if ((address->flags & IFA_F_NOPREFIXROUTE) && !nm_platform_check_support_libnl_extended_ifa_flags ()) {
- strncat (s_flags, s_flags[0] ? "," IFA_F_NOPREFIXROUTE_STR : IFA_F_NOPREFIXROUTE_STR,
- sizeof (s_flags) - strlen (s_flags) - 1);
- }
+ nm_platform_addr_flags2str (address->flags, s_flags, sizeof (s_flags));
str_flags = s_flags[0] ? g_strconcat (" flags ", s_flags, NULL) : NULL;
diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
index 263cd9153a..cf41ad85fd 100644
--- a/src/platform/nm-platform.h
+++ b/src/platform/nm-platform.h
@@ -516,6 +516,8 @@ int nm_platform_ip6_route_cmp (const NMPlatformIP6Route *a, const NMPlatformIP6R
gboolean nm_platform_check_support_libnl_extended_ifa_flags (void);
gboolean nm_platform_check_support_kernel_extended_ifa_flags (void);
+void nm_platform_addr_flags2str (int flags, char *buf, size_t size);
+
#define auto_g_free __attribute__((cleanup(put_g_free)))
static void __attribute__((unused))
put_g_free (void *ptr)