diff options
author | Thomas Haller <thaller@redhat.com> | 2020-09-11 12:33:40 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-09-11 16:18:40 +0200 |
commit | 94fbc7bdba10b9a82aaf5b69ca5911c3e34759dc (patch) | |
tree | f83066cd85d05f5dabf9f57c12476d34d50da022 | |
parent | 345aeefaf330ced2294bb64adaabf4b9429a3010 (diff) | |
download | NetworkManager-94fbc7bdba10b9a82aaf5b69ca5911c3e34759dc.tar.gz |
platform: add nm_platform_ip6_address_match()
-rw-r--r-- | src/platform/nm-platform.c | 32 | ||||
-rw-r--r-- | src/platform/nm-platform.h | 5 |
2 files changed, 37 insertions, 0 deletions
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index b8302fea95..c75fb1a947 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -3401,6 +3401,38 @@ nm_platform_ip6_address_get_peer (const NMPlatformIP6Address *addr) } gboolean +nm_platform_ip6_address_match (const NMPlatformIP6Address *addr, + NMPlatformMatchFlags match_flag) +{ + nm_assert (!NM_FLAGS_ANY (match_flag, ~( NM_PLATFORM_MATCH_WITH_ADDRTYPE__ANY + | NM_PLATFORM_MATCH_WITH_ADDRSTATE__ANY))); + nm_assert (NM_FLAGS_ANY (match_flag, NM_PLATFORM_MATCH_WITH_ADDRTYPE__ANY)); + nm_assert (NM_FLAGS_ANY (match_flag, NM_PLATFORM_MATCH_WITH_ADDRSTATE__ANY)); + + if (IN6_IS_ADDR_LINKLOCAL (&addr->address)) { + if (!NM_FLAGS_HAS (match_flag, NM_PLATFORM_MATCH_WITH_ADDRTYPE_LINKLOCAL)) + return FALSE; + } else { + if (!NM_FLAGS_HAS (match_flag, NM_PLATFORM_MATCH_WITH_ADDRTYPE_NORMAL)) + return FALSE; + } + + if (NM_FLAGS_HAS (addr->n_ifa_flags, IFA_F_DADFAILED)) { + if (!NM_FLAGS_HAS (match_flag, NM_PLATFORM_MATCH_WITH_ADDRSTATE_DADFAILED)) + return FALSE; + } else if ( NM_FLAGS_HAS (addr->n_ifa_flags, IFA_F_TENTATIVE) + && !NM_FLAGS_HAS (addr->n_ifa_flags, IFA_F_OPTIMISTIC)) { + if (!NM_FLAGS_HAS (match_flag, NM_PLATFORM_MATCH_WITH_ADDRSTATE_TENTATIVE)) + return FALSE; + } else { + if (!NM_FLAGS_HAS (match_flag, NM_PLATFORM_MATCH_WITH_ADDRSTATE_NORMAL)) + return FALSE; + } + + return TRUE; +} + +gboolean nm_platform_ip4_address_add (NMPlatform *self, int ifindex, in_addr_t address, diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 53bfcaf486..8fbb703677 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -2158,4 +2158,9 @@ void nm_platform_ip4_dev_route_blacklist_set (NMPlatform *self, struct _NMDedupMultiIndex *nm_platform_get_multi_idx (NMPlatform *self); +/*****************************************************************************/ + +gboolean nm_platform_ip6_address_match (const NMPlatformIP6Address *addr, + NMPlatformMatchFlags match_flag); + #endif /* __NETWORKMANAGER_PLATFORM_H__ */ |