Skip to content
Snippets Groups Projects
Commit f10842f5 authored by Nevadita's avatar Nevadita
Browse files

hosts: fix to only get ipv4address

parent 09940191
No related branches found
No related tags found
Loading
Pipeline #19117 passed with warnings
...@@ -247,7 +247,13 @@ int host_get_netlink_ip(uint8_t *mac_addr, char *ipv4_str, char *device) ...@@ -247,7 +247,13 @@ int host_get_netlink_ip(uint8_t *mac_addr, char *ipv4_str, char *device)
ipaddr = rtnl_neigh_get_dst(neigh); ipaddr = rtnl_neigh_get_dst(neigh);
if (ipaddr) { if (ipaddr) {
ip.family = nl_addr_get_family(ipaddr); ip.family = nl_addr_get_family(ipaddr);
if (ip.family == AF_INET6 || ip.family == AF_INET) { if (ip.family == AF_INET6) {
nl_object_put((struct nl_object *) neigh);
nobj = nl_cache_get_next(nobj);
neigh = (struct rtnl_neigh *)nobj;
continue;
}
if (ip.family == AF_INET) {
memcpy(&ip.addr, nl_addr_get_binary_addr(ipaddr), memcpy(&ip.addr, nl_addr_get_binary_addr(ipaddr),
nl_addr_get_len(ipaddr)); nl_addr_get_len(ipaddr));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment