diff options
author | Thomas Haller <thaller@redhat.com> | 2015-10-12 13:44:44 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-10-12 18:22:35 +0200 |
commit | ee902930156b7bd291cb912175b73b75826be861 (patch) | |
tree | f73c028be29152fcb7f51efc841b3abced09e29d | |
parent | 8f9a339c4a6049473179dea39579d8bd56270cd9 (diff) | |
download | NetworkManager-th/platform-to-string-bgo756427.tar.gz |
platform: implement gre properties as lnk datath/platform-to-string-bgo756427
-rw-r--r-- | src/nm-types.h | 1 | ||||
-rw-r--r-- | src/platform/nm-platform.c | 33 | ||||
-rw-r--r-- | src/platform/nm-platform.h | 2 | ||||
-rw-r--r-- | src/platform/nmp-object.c | 8 | ||||
-rw-r--r-- | src/platform/nmp-object.h | 4 |
5 files changed, 48 insertions, 0 deletions
diff --git a/src/nm-types.h b/src/nm-types.h index a8dea579ea..ba5b85ba04 100644 --- a/src/nm-types.h +++ b/src/nm-types.h @@ -132,6 +132,7 @@ typedef enum { NMP_OBJECT_TYPE_IP6_ROUTE, NMP_OBJECT_TYPE_LNK_VLAN, + NMP_OBJECT_TYPE_LNK_GRE, __NMP_OBJECT_TYPE_LAST, NMP_OBJECT_TYPE_MAX = __NMP_OBJECT_TYPE_LAST - 1, diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 89c87a1a3f..713462f1fb 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -2464,6 +2464,22 @@ nm_platform_lnk_vlan_to_string (const NMPlatformLnkVlan *lnk, char *buf, gsize l return buf; } +const char * +nm_platform_lnk_gre_to_string (const NMPlatformLnkGre *lnk, char *buf, gsize len) +{ + char buf_local[NM_UTILS_INET_ADDRSTRLEN]; + char buf_remote[NM_UTILS_INET_ADDRSTRLEN]; + + if (!_to_string_buffer_init (lnk, &buf, &len)) + return buf; + + g_snprintf (buf, len, + "gre %s %s", + nm_utils_inet4_ntop (lnk->local, buf_local), + nm_utils_inet4_ntop (lnk->remote, buf_remote)); + return buf; +} + /** * nm_platform_ip4_address_to_string: * @route: pointer to NMPlatformIP4Address address structure @@ -2824,6 +2840,23 @@ nm_platform_lnk_vlan_cmp (const NMPlatformLnkVlan *a, const NMPlatformLnkVlan *b } int +nm_platform_lnk_gre_cmp (const NMPlatformLnkGre *a, const NMPlatformLnkGre *b) +{ + _CMP_POINTER (a, b); + _CMP_FIELD (a, b, parent_ifindex); + _CMP_FIELD (a, b, input_flags); + _CMP_FIELD (a, b, output_flags); + _CMP_FIELD (a, b, input_key); + _CMP_FIELD (a, b, output_key); + _CMP_FIELD (a, b, local); + _CMP_FIELD (a, b, remote); + _CMP_FIELD (a, b, ttl); + _CMP_FIELD (a, b, tos); + _CMP_FIELD_BOOL (a, b, path_mtu_discovery); + return 0; +} + +int nm_platform_ip4_address_cmp (const NMPlatformIP4Address *a, const NMPlatformIP4Address *b) { _CMP_POINTER (a, b); diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 2fcc7d5b43..9a31fa3bc3 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -730,6 +730,7 @@ char _nm_platform_to_string_buffer[256]; const char *nm_platform_link_to_string (const NMPlatformLink *link, char *buf, gsize len); const char *nm_platform_lnk_vlan_to_string (const NMPlatformLnkVlan *lnk, char *buf, gsize len); +const char *nm_platform_lnk_gre_to_string (const NMPlatformLnkGre *lnk, char *buf, gsize len); const char *nm_platform_ip4_address_to_string (const NMPlatformIP4Address *address, char *buf, gsize len); const char *nm_platform_ip6_address_to_string (const NMPlatformIP6Address *address, char *buf, gsize len); const char *nm_platform_ip4_route_to_string (const NMPlatformIP4Route *route, char *buf, gsize len); @@ -737,6 +738,7 @@ const char *nm_platform_ip6_route_to_string (const NMPlatformIP6Route *route, ch int nm_platform_link_cmp (const NMPlatformLink *a, const NMPlatformLink *b); int nm_platform_lnk_vlan_cmp (const NMPlatformLnkVlan *a, const NMPlatformLnkVlan *b); +int nm_platform_lnk_gre_cmp (const NMPlatformLnkGre *a, const NMPlatformLnkGre *b); int nm_platform_ip4_address_cmp (const NMPlatformIP4Address *a, const NMPlatformIP4Address *b); int nm_platform_ip6_address_cmp (const NMPlatformIP6Address *a, const NMPlatformIP6Address *b); int nm_platform_ip4_route_cmp (const NMPlatformIP4Route *a, const NMPlatformIP4Route *b); diff --git a/src/platform/nmp-object.c b/src/platform/nmp-object.c index 2e3b2942c4..bcccdbf2ad 100644 --- a/src/platform/nmp-object.c +++ b/src/platform/nmp-object.c @@ -2212,5 +2212,13 @@ const NMPClass _nmp_classes[NMP_OBJECT_TYPE_MAX] = { .cmd_plobj_to_string = (const char *(*) (const NMPlatformObject *obj, char *buf, gsize len)) nm_platform_lnk_vlan_to_string, .cmd_plobj_cmp = (int (*) (const NMPlatformObject *obj1, const NMPlatformObject *obj2)) nm_platform_lnk_vlan_cmp, }, + [NMP_OBJECT_TYPE_LNK_GRE - 1] = { + .obj_type = NMP_OBJECT_TYPE_LNK_GRE, + .sizeof_data = sizeof (NMPObjectLnkGre), + .sizeof_public = sizeof (NMPlatformLnkGre), + .obj_type_name = "gre", + .cmd_plobj_to_string = (const char *(*) (const NMPlatformObject *obj, char *buf, gsize len)) nm_platform_lnk_gre_to_string, + .cmd_plobj_cmp = (int (*) (const NMPlatformObject *obj1, const NMPlatformObject *obj2)) nm_platform_lnk_gre_cmp, + }, }; diff --git a/src/platform/nmp-object.h b/src/platform/nmp-object.h index 80f1241787..5843168044 100644 --- a/src/platform/nmp-object.h +++ b/src/platform/nmp-object.h @@ -163,6 +163,10 @@ typedef struct { } NMPObjectLnkVlan; typedef struct { + NMPlatformLnkGre _public; +} NMPObjectLnkGre; + +typedef struct { NMPlatformIP4Address _public; } NMPObjectIP4Address; |