mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 12:28:11 +02:00
platform: add nm_platform_ip_address_get() helper
(cherry picked from commita815212214) (cherry picked from commitaa764f5fcc)
This commit is contained in:
parent
02110433aa
commit
579edd886f
2 changed files with 40 additions and 0 deletions
|
|
@ -3592,6 +3592,41 @@ nm_platform_ip6_address_delete(NMPlatform *self, int ifindex, struct in6_addr ad
|
||||||
return klass->ip6_address_delete(self, ifindex, address, plen);
|
return klass->ip6_address_delete(self, ifindex, address, plen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const NMPObject *
|
||||||
|
nm_platform_ip_address_get(NMPlatform *self,
|
||||||
|
int addr_family,
|
||||||
|
int ifindex,
|
||||||
|
gconstpointer /* (NMPlatformIPAddress *) */ needle)
|
||||||
|
{
|
||||||
|
const NMPlatformIPXAddress *addr;
|
||||||
|
NMPObject obj_id;
|
||||||
|
const NMPObject *obj;
|
||||||
|
|
||||||
|
nm_assert(NM_IS_PLATFORM(self));
|
||||||
|
nm_assert_addr_family(addr_family);
|
||||||
|
nm_assert(needle);
|
||||||
|
|
||||||
|
addr = needle;
|
||||||
|
|
||||||
|
if (ifindex <= 0) {
|
||||||
|
/* We allow the caller to override the ifindex. */
|
||||||
|
ifindex = addr->ax.ifindex;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NM_IS_IPv4(addr_family)) {
|
||||||
|
nmp_object_stackinit_id_ip4_address(&obj_id,
|
||||||
|
ifindex,
|
||||||
|
addr->a4.address,
|
||||||
|
addr->a4.plen,
|
||||||
|
addr->a4.peer_address);
|
||||||
|
} else
|
||||||
|
nmp_object_stackinit_id_ip6_address(&obj_id, ifindex, &addr->a6.address);
|
||||||
|
|
||||||
|
obj = nmp_cache_lookup_obj(nm_platform_get_cache(self), &obj_id);
|
||||||
|
nm_assert(!obj || nmp_object_is_visible(obj));
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
const NMPlatformIP4Address *
|
const NMPlatformIP4Address *
|
||||||
nm_platform_ip4_address_get(NMPlatform *self,
|
nm_platform_ip4_address_get(NMPlatform *self,
|
||||||
int ifindex,
|
int ifindex,
|
||||||
|
|
|
||||||
|
|
@ -2062,6 +2062,11 @@ gboolean nm_platform_wpan_set_channel(NMPlatform *self, int ifindex, guint8 page
|
||||||
void nm_platform_ip4_address_set_addr(NMPlatformIP4Address *addr, in_addr_t address, guint8 plen);
|
void nm_platform_ip4_address_set_addr(NMPlatformIP4Address *addr, in_addr_t address, guint8 plen);
|
||||||
const struct in6_addr *nm_platform_ip6_address_get_peer(const NMPlatformIP6Address *addr);
|
const struct in6_addr *nm_platform_ip6_address_get_peer(const NMPlatformIP6Address *addr);
|
||||||
|
|
||||||
|
const NMPObject *nm_platform_ip_address_get(NMPlatform *self,
|
||||||
|
int addr_family,
|
||||||
|
int ifindex,
|
||||||
|
gconstpointer /* (NMPlatformIPAddress *) */ needle);
|
||||||
|
|
||||||
const NMPlatformIP4Address *nm_platform_ip4_address_get(NMPlatform *self,
|
const NMPlatformIP4Address *nm_platform_ip4_address_get(NMPlatform *self,
|
||||||
int ifindex,
|
int ifindex,
|
||||||
in_addr_t address,
|
in_addr_t address,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue