diff options
author | Thomas Haller <thaller@redhat.com> | 2020-08-06 17:45:20 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-09-03 11:39:39 +0200 |
commit | f81360bbbf973884b684d8bb9f46aeec128ba5b7 (patch) | |
tree | f306899d4c1f23abd2106fbfa6b89f0b636a7063 | |
parent | aed61588fd092d3b098978cf7b6f3e5aa7404ca2 (diff) | |
download | NetworkManager-f81360bbbf973884b684d8bb9f46aeec128ba5b7.tar.gz |
platform: add nm_platform_ip4_address_addr_to_hash() helper
This will only have one particular use, from NNL3Cfg. However, it seems
general enough to place it in "nm-platform.h".
-rw-r--r-- | src/platform/nm-platform.c | 36 | ||||
-rw-r--r-- | src/platform/nm-platform.h | 3 |
2 files changed, 39 insertions, 0 deletions
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index b3371ed96d..b8302fea95 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -8149,6 +8149,42 @@ nm_platform_ip_address_cmp_expiry (const NMPlatformIPAddress *a, const NMPlatfor return ta < tb ? -1 : 1; } +/*****************************************************************************/ + +GHashTable * +nm_platform_ip4_address_addr_to_hash (NMPlatform *self, + int ifindex) +{ + const NMDedupMultiHeadEntry *head_entry; + NMDedupMultiIter iter; + const NMPObject *obj; + NMPLookup lookup; + GHashTable *hash; + + g_return_val_if_fail (NM_IS_PLATFORM (self), NULL); + g_return_val_if_fail (ifindex > 0, NULL); + + nmp_lookup_init_object (&lookup, NMP_OBJECT_TYPE_IP4_ADDRESS, ifindex); + + head_entry = nmp_cache_lookup (NM_PLATFORM_GET_PRIVATE (self)->cache, + &lookup); + + if (!head_entry) + return NULL; + + hash = g_hash_table_new (nm_direct_hash, NULL); + + nmp_cache_iter_for_each (&iter, head_entry, &obj) { + const NMPlatformIP4Address *a = NMP_OBJECT_CAST_IP4_ADDRESS (obj); + + g_hash_table_add (hash, GUINT_TO_POINTER (a->address)); + } + + return hash; +} + +/*****************************************************************************/ + const char * nm_platform_signal_change_type_to_string (NMPlatformSignalChangeType change_type) { diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index e946709abb..cece00dfe9 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -2038,6 +2038,9 @@ int nm_platform_ip6_address_pretty_sort_cmp (const NMPlatformIP6Address *a1, const NMPlatformIP6Address *a2, gboolean prefer_temp); +GHashTable *nm_platform_ip4_address_addr_to_hash (NMPlatform *self, + int ifindex); + int nm_platform_ip4_route_cmp (const NMPlatformIP4Route *a, const NMPlatformIP4Route *b, NMPlatformIPRouteCmpType cmp_type); int nm_platform_ip6_route_cmp (const NMPlatformIP6Route *a, const NMPlatformIP6Route *b, NMPlatformIPRouteCmpType cmp_type); |