mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 14:49:24 +01:00
rtnlutil: Add parser for IPv6 RTNL packet
At this time, we are only looking for IFA_ADDRESS attribute that represents the IPv6 IP address.
This commit is contained in:
parent
d954eee0cc
commit
c8eb33c2c2
@ -418,3 +418,33 @@ uint32_t rtnl_route_ipv4_add_gateway(struct l_netlink *rtnl, int ifindex,
|
||||
gateway, src, priority_offset, proto, cb,
|
||||
user_data, destroy);
|
||||
}
|
||||
|
||||
void rtnl_ifaddr_ipv6_extract(const struct ifaddrmsg *ifa, int len, char **ip)
|
||||
{
|
||||
struct in6_addr in6_addr;
|
||||
struct rtattr *attr;
|
||||
char address[128];
|
||||
|
||||
for (attr = IFA_RTA(ifa); RTA_OK(attr, len);
|
||||
attr = RTA_NEXT(attr, len)) {
|
||||
switch (attr->rta_type) {
|
||||
case IFA_ADDRESS:
|
||||
if (!ip)
|
||||
break;
|
||||
|
||||
memcpy(&in6_addr.s6_addr, RTA_DATA(attr),
|
||||
sizeof(in6_addr.s6_addr));
|
||||
|
||||
if (!inet_ntop(AF_INET6, &in6_addr, address,
|
||||
INET6_ADDRSTRLEN)) {
|
||||
|
||||
l_error("rtnl: Failed to extract IPv6 address");
|
||||
break;
|
||||
}
|
||||
|
||||
*ip = l_strdup(address);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,3 +67,6 @@ uint32_t rtnl_route_ipv4_add_gateway(struct l_netlink *rtnl, int ifindex,
|
||||
l_netlink_command_func_t cb,
|
||||
void *user_data,
|
||||
l_netlink_destroy_func_t destroy);
|
||||
|
||||
void rtnl_ifaddr_ipv6_extract(const struct ifaddrmsg *ifa, int bytes,
|
||||
char **ip);
|
||||
|
Loading…
Reference in New Issue
Block a user