mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-04 15:40:22 +01:00
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".
This commit is contained in:
parent
aed61588fd
commit
f81360bbbf
2 changed files with 39 additions and 0 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue