platform: add nm_platform_ip6_address_match()

This commit is contained in:
Thomas Haller 2020-09-11 12:33:40 +02:00
parent 345aeefaf3
commit 94fbc7bdba
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 37 additions and 0 deletions

View file

@ -3400,6 +3400,38 @@ nm_platform_ip6_address_get_peer (const NMPlatformIP6Address *addr)
return &addr->peer_address;
}
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,

View file

@ -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__ */