mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 13:00:16 +01:00
core: add nm_utils_ip_address_same_prefix_cmp() helper
This commit is contained in:
parent
1a4cc800f6
commit
63b788dad2
1 changed files with 22 additions and 0 deletions
|
|
@ -113,6 +113,22 @@ nm_utils_ip4_address_same_prefix_cmp (in_addr_t addr_a, in_addr_t addr_b, guint8
|
|||
|
||||
int nm_utils_ip6_address_same_prefix_cmp (const struct in6_addr *addr_a, const struct in6_addr *addr_b, guint8 plen);
|
||||
|
||||
static inline int
|
||||
nm_utils_ip_address_same_prefix_cmp (int addr_family, gconstpointer addr_a, gconstpointer addr_b, guint8 plen)
|
||||
{
|
||||
nm_assert_addr_family (addr_family);
|
||||
|
||||
NM_CMP_SELF (addr_a, addr_b);
|
||||
|
||||
if (NM_IS_IPv4 (addr_family)) {
|
||||
return nm_utils_ip4_address_same_prefix_cmp (*((const in_addr_t *) addr_a),
|
||||
*((const in_addr_t *) addr_b),
|
||||
plen);
|
||||
}
|
||||
|
||||
return nm_utils_ip6_address_same_prefix_cmp (addr_a, addr_b, plen);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
nm_utils_ip4_address_same_prefix (in_addr_t addr_a, in_addr_t addr_b, guint8 plen)
|
||||
{
|
||||
|
|
@ -125,6 +141,12 @@ nm_utils_ip6_address_same_prefix (const struct in6_addr *addr_a, const struct in
|
|||
return nm_utils_ip6_address_same_prefix_cmp (addr_a, addr_b, plen) == 0;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
nm_utils_ip_address_same_prefix (int addr_family, gconstpointer addr_a, gconstpointer addr_b, guint8 plen)
|
||||
{
|
||||
return nm_utils_ip_address_same_prefix_cmp (addr_family, addr_a, addr_b, plen) == 0;
|
||||
}
|
||||
|
||||
#define NM_CMP_DIRECT_IN4ADDR_SAME_PREFIX(a, b, plen) \
|
||||
NM_CMP_RETURN (nm_utils_ip4_address_same_prefix_cmp ((a), (b), (plen)))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue