mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 22:40:10 +01:00
libnm-platform: add nm_platform_ip_address_match()
Replace nm_platform_ip6_address_match() with a version generic for
IPv4 and IPv6.
(cherry picked from commit 376c7f8315)
This commit is contained in:
parent
a1f4255f71
commit
786ab294db
3 changed files with 25 additions and 12 deletions
|
|
@ -1644,7 +1644,7 @@ nm_ip6_config_find_first_address(const NMIP6Config *self, NMPlatformMatchFlags m
|
|||
nm_assert(NM_FLAGS_ANY(match_flag, NM_PLATFORM_MATCH_WITH_ADDRSTATE__ANY));
|
||||
|
||||
nm_ip_config_iter_ip6_address_for_each (&iter, self, &addr) {
|
||||
if (nm_platform_ip6_address_match(addr, match_flag))
|
||||
if (nm_platform_ip_address_match(AF_INET6, (NMPlatformIPAddress *) addr, match_flag))
|
||||
return addr;
|
||||
}
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -3413,7 +3413,9 @@ nm_platform_ip6_address_get_peer(const NMPlatformIP6Address *addr)
|
|||
}
|
||||
|
||||
gboolean
|
||||
nm_platform_ip6_address_match(const NMPlatformIP6Address *addr, NMPlatformMatchFlags match_flag)
|
||||
nm_platform_ip_address_match(int addr_family,
|
||||
const NMPlatformIPAddress *address,
|
||||
NMPlatformMatchFlags match_flag)
|
||||
{
|
||||
nm_assert(!NM_FLAGS_ANY(
|
||||
match_flag,
|
||||
|
|
@ -3421,19 +3423,29 @@ nm_platform_ip6_address_match(const NMPlatformIP6Address *addr, NMPlatformMatchF
|
|||
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;
|
||||
if (addr_family == AF_INET) {
|
||||
if (nm_utils_ip4_address_is_link_local(((NMPlatformIP4Address *) address)->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;
|
||||
}
|
||||
} else {
|
||||
if (!NM_FLAGS_HAS(match_flag, NM_PLATFORM_MATCH_WITH_ADDRTYPE_NORMAL))
|
||||
return FALSE;
|
||||
if (IN6_IS_ADDR_LINKLOCAL(address->address_ptr)) {
|
||||
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(address->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)) {
|
||||
} else if (NM_FLAGS_HAS(address->n_ifa_flags, IFA_F_TENTATIVE)
|
||||
&& !NM_FLAGS_HAS(address->n_ifa_flags, IFA_F_OPTIMISTIC)) {
|
||||
if (!NM_FLAGS_HAS(match_flag, NM_PLATFORM_MATCH_WITH_ADDRSTATE_TENTATIVE))
|
||||
return FALSE;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -2380,7 +2380,8 @@ struct _NMDedupMultiIndex *nm_platform_get_multi_idx(NMPlatform *self);
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean nm_platform_ip6_address_match(const NMPlatformIP6Address *addr,
|
||||
NMPlatformMatchFlags match_flag);
|
||||
gboolean nm_platform_ip_address_match(int addr_family,
|
||||
const NMPlatformIPAddress *addr,
|
||||
NMPlatformMatchFlags match_flag);
|
||||
|
||||
#endif /* __NETWORKMANAGER_PLATFORM_H__ */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue