1 /* getifaddrs -- get names and addresses of all network interfaces
2 Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25 #include <netinet/in.h>
26 #include <netpacket/packet.h>
31 #include <sys/ioctl.h>
32 #include <sys/socket.h>
37 #include "netlinkaccess.h"
40 /* We don't know if we have NETLINK support compiled in in our
41 Kernel, so include the old implementation as fallback. */
42 #if __ASSUME_NETLINK_SUPPORT == 0
43 int __no_netlink_support attribute_hidden
;
45 # define getifaddrs fallback_getifaddrs
46 # include "sysdeps/gnu/ifaddrs.c"
51 /* struct to hold the data for one ifaddrs entry, so we can allocate
52 everything at once. */
53 struct ifaddrs_storage
58 /* Save space for the biggest of the four used sockaddr types and
59 avoid a lot of casts. */
61 struct sockaddr_ll sl
;
62 struct sockaddr_in s4
;
63 struct sockaddr_in6 s6
;
64 } addr
, netmask
, broadaddr
;
65 char name
[IF_NAMESIZE
+ 1];
70 __netlink_free_handle (struct netlink_handle
*h
)
72 struct netlink_res
*ptr
;
73 int saved_errno
= errno
;
78 struct netlink_res
*tmpptr
;
85 __set_errno (saved_errno
);
90 __netlink_sendreq (struct netlink_handle
*h
, int type
)
97 struct sockaddr_nl nladdr
;
100 h
->seq
= time (NULL
);
102 req
.nlh
.nlmsg_len
= sizeof (req
);
103 req
.nlh
.nlmsg_type
= type
;
104 req
.nlh
.nlmsg_flags
= NLM_F_ROOT
| NLM_F_MATCH
| NLM_F_REQUEST
;
105 req
.nlh
.nlmsg_pid
= 0;
106 req
.nlh
.nlmsg_seq
= h
->seq
;
107 req
.g
.rtgen_family
= AF_UNSPEC
;
109 memset (&nladdr
, '\0', sizeof (nladdr
));
110 nladdr
.nl_family
= AF_NETLINK
;
112 return TEMP_FAILURE_RETRY (__sendto (h
->fd
, (void *) &req
, sizeof (req
), 0,
113 (struct sockaddr
*) &nladdr
,
119 __netlink_request (struct netlink_handle
*h
, int type
)
121 struct netlink_res
*nlm_next
;
122 struct netlink_res
**new_nlm_list
;
123 static volatile size_t buf_size
= 4096;
125 struct sockaddr_nl nladdr
;
126 struct nlmsghdr
*nlmh
;
129 bool use_malloc
= false;
131 if (__netlink_sendreq (h
, type
) < 0)
134 size_t this_buf_size
= buf_size
;
135 if (__libc_use_alloca (this_buf_size
))
136 buf
= alloca (this_buf_size
);
139 buf
= malloc (this_buf_size
);
146 struct iovec iov
= { buf
, this_buf_size
};
148 if (h
->nlm_list
!= NULL
)
149 new_nlm_list
= &h
->end_ptr
->next
;
151 new_nlm_list
= &h
->nlm_list
;
157 (void *) &nladdr
, sizeof (nladdr
),
163 read_len
= TEMP_FAILURE_RETRY (__recvmsg (h
->fd
, &msg
, 0));
167 if (nladdr
.nl_pid
!= 0)
170 if (__builtin_expect (msg
.msg_flags
& MSG_TRUNC
, 0))
172 if (this_buf_size
>= SIZE_MAX
/ 2)
175 nlm_next
= *new_nlm_list
;
176 while (nlm_next
!= NULL
)
178 struct netlink_res
*tmpptr
;
180 tmpptr
= nlm_next
->next
;
184 *new_nlm_list
= NULL
;
186 if (__libc_use_alloca (2 * this_buf_size
))
187 buf
= extend_alloca (buf
, this_buf_size
, 2 * this_buf_size
);
192 char *new_buf
= realloc (use_malloc
? buf
: NULL
, this_buf_size
);
199 buf_size
= this_buf_size
;
202 iov
.iov_len
= this_buf_size
;
204 /* Increase sequence number, so that we can distinguish
205 between old and new request messages. */
208 if (__netlink_sendreq (h
, type
) < 0)
215 size_t remaining_len
= read_len
;
216 for (nlmh
= (struct nlmsghdr
*) buf
;
217 NLMSG_OK (nlmh
, remaining_len
);
218 nlmh
= (struct nlmsghdr
*) NLMSG_NEXT (nlmh
, remaining_len
))
220 if ((pid_t
) nlmh
->nlmsg_pid
!= h
->pid
221 || nlmh
->nlmsg_seq
!= h
->seq
)
225 if (nlmh
->nlmsg_type
== NLMSG_DONE
)
227 /* We found the end, leave the loop. */
231 if (nlmh
->nlmsg_type
== NLMSG_ERROR
)
233 struct nlmsgerr
*nlerr
= (struct nlmsgerr
*) NLMSG_DATA (nlmh
);
234 if (nlmh
->nlmsg_len
< NLMSG_LENGTH (sizeof (struct nlmsgerr
)))
237 errno
= -nlerr
->error
;
242 /* If there was nothing with the expected nlmsg_pid and nlmsg_seq,
243 there is no point to record it. */
247 nlm_next
= (struct netlink_res
*) malloc (sizeof (struct netlink_res
)
249 if (nlm_next
== NULL
)
251 nlm_next
->next
= NULL
;
252 nlm_next
->nlh
= memcpy (nlm_next
+ 1, buf
, read_len
);
253 nlm_next
->size
= read_len
;
254 nlm_next
->seq
= h
->seq
;
255 if (h
->nlm_list
== NULL
)
256 h
->nlm_list
= nlm_next
;
258 h
->end_ptr
->next
= nlm_next
;
259 h
->end_ptr
= nlm_next
;
274 __netlink_close (struct netlink_handle
*h
)
276 /* Don't modify errno. */
277 INTERNAL_SYSCALL_DECL (err
);
278 (void) INTERNAL_SYSCALL (close
, err
, 1, h
->fd
);
282 /* Open a NETLINK socket. */
284 __netlink_open (struct netlink_handle
*h
)
286 struct sockaddr_nl nladdr
;
288 h
->fd
= __socket (PF_NETLINK
, SOCK_RAW
, NETLINK_ROUTE
);
292 memset (&nladdr
, '\0', sizeof (nladdr
));
293 nladdr
.nl_family
= AF_NETLINK
;
294 if (__bind (h
->fd
, (struct sockaddr
*) &nladdr
, sizeof (nladdr
)) < 0)
299 #if __ASSUME_NETLINK_SUPPORT == 0
300 __no_netlink_support
= 1;
304 /* Determine the ID the kernel assigned for this netlink connection.
305 It is not necessarily the PID if there is more than one socket
307 socklen_t addr_len
= sizeof (nladdr
);
308 if (__getsockname (h
->fd
, (struct sockaddr
*) &nladdr
, &addr_len
) < 0)
310 h
->pid
= nladdr
.nl_pid
;
315 /* We know the number of RTM_NEWLINK entries, so we reserve the first
316 # of entries for this type. All RTM_NEWADDR entries have an index
317 pointer to the RTM_NEWLINK entry. To find the entry, create
318 a table to map kernel index entries to our index numbers.
319 Since we get at first all RTM_NEWLINK entries, it can never happen
320 that a RTM_NEWADDR index is not known to this map. */
323 map_newlink (int index
, struct ifaddrs_storage
*ifas
, int *map
, int max
)
327 for (i
= 0; i
< max
; i
++)
333 ifas
[i
- 1].ifa
.ifa_next
= &ifas
[i
].ifa
;
336 else if (map
[i
] == index
)
339 /* This should never be reached. If this will be reached, we have
340 a very big problem. */
345 /* Create a linked list of `struct ifaddrs' structures, one for each
346 network interface on the host machine. If successful, store the
347 list in *IFAP and return 0. On errors, return -1 and set `errno'. */
349 getifaddrs (struct ifaddrs
**ifap
)
351 struct netlink_handle nh
= { 0, 0, 0, NULL
, NULL
};
352 struct netlink_res
*nlp
;
353 struct ifaddrs_storage
*ifas
;
354 unsigned int i
, newlink
, newaddr
, newaddr_idx
;
355 int *map_newlink_data
;
356 size_t ifa_data_size
= 0; /* Size to allocate for all ifa_data. */
357 char *ifa_data_ptr
; /* Pointer to the unused part of memory for
364 if (! __no_netlink_support
&& __netlink_open (&nh
) < 0)
366 #if __ASSUME_NETLINK_SUPPORT != 0
371 #if __ASSUME_NETLINK_SUPPORT == 0
372 if (__no_netlink_support
)
373 return fallback_getifaddrs (ifap
);
376 /* Tell the kernel that we wish to get a list of all
377 active interfaces, collect all data for every interface. */
378 if (__netlink_request (&nh
, RTM_GETLINK
) < 0)
384 /* Now ask the kernel for all addresses which are assigned
385 to an interface and collect all data for every interface.
386 Since we store the addresses after the interfaces in the
387 list, we will later always find the interface before the
388 corresponding addresses. */
390 if (__netlink_request (&nh
, RTM_GETADDR
) < 0)
396 /* Count all RTM_NEWLINK and RTM_NEWADDR entries to allocate
398 newlink
= newaddr
= 0;
399 for (nlp
= nh
.nlm_list
; nlp
; nlp
= nlp
->next
)
401 struct nlmsghdr
*nlh
;
402 size_t size
= nlp
->size
;
404 if (nlp
->nlh
== NULL
)
407 /* Walk through all entries we got from the kernel and look, which
408 message type they contain. */
409 for (nlh
= nlp
->nlh
; NLMSG_OK (nlh
, size
); nlh
= NLMSG_NEXT (nlh
, size
))
411 /* Check if the message is what we want. */
412 if ((pid_t
) nlh
->nlmsg_pid
!= nh
.pid
|| nlh
->nlmsg_seq
!= nlp
->seq
)
415 if (nlh
->nlmsg_type
== NLMSG_DONE
)
418 if (nlh
->nlmsg_type
== RTM_NEWLINK
)
420 /* A RTM_NEWLINK message can have IFLA_STATS data. We need to
421 know the size before creating the list to allocate enough
423 struct ifinfomsg
*ifim
= (struct ifinfomsg
*) NLMSG_DATA (nlh
);
424 struct rtattr
*rta
= IFLA_RTA (ifim
);
425 size_t rtasize
= IFLA_PAYLOAD (nlh
);
427 while (RTA_OK (rta
, rtasize
))
429 size_t rta_payload
= RTA_PAYLOAD (rta
);
431 if (rta
->rta_type
== IFLA_STATS
)
433 ifa_data_size
+= rta_payload
;
437 rta
= RTA_NEXT (rta
, rtasize
);
441 else if (nlh
->nlmsg_type
== RTM_NEWADDR
)
446 /* Return if no interface is up. */
447 if ((newlink
+ newaddr
) == 0)
450 /* Allocate memory for all entries we have and initialize next
452 ifas
= (struct ifaddrs_storage
*) calloc (1,
454 * sizeof (struct ifaddrs_storage
)
462 /* Table for mapping kernel index to entry in our list. */
463 map_newlink_data
= alloca (newlink
* sizeof (int));
464 memset (map_newlink_data
, '\xff', newlink
* sizeof (int));
466 ifa_data_ptr
= (char *) &ifas
[newlink
+ newaddr
];
467 newaddr_idx
= 0; /* Counter for newaddr index. */
469 /* Walk through the list of data we got from the kernel. */
470 for (nlp
= nh
.nlm_list
; nlp
; nlp
= nlp
->next
)
472 struct nlmsghdr
*nlh
;
473 size_t size
= nlp
->size
;
475 if (nlp
->nlh
== NULL
)
478 /* Walk through one message and look at the type: If it is our
479 message, we need RTM_NEWLINK/RTM_NEWADDR and stop if we reach
480 the end or we find the end marker (in this case we ignore the
482 for (nlh
= nlp
->nlh
; NLMSG_OK (nlh
, size
); nlh
= NLMSG_NEXT (nlh
, size
))
486 /* Check if the message is the one we want */
487 if ((pid_t
) nlh
->nlmsg_pid
!= nh
.pid
|| nlh
->nlmsg_seq
!= nlp
->seq
)
490 if (nlh
->nlmsg_type
== NLMSG_DONE
)
493 if (nlh
->nlmsg_type
== RTM_NEWLINK
)
495 /* We found a new interface. Now extract everything from the
496 interface data we got and need. */
497 struct ifinfomsg
*ifim
= (struct ifinfomsg
*) NLMSG_DATA (nlh
);
498 struct rtattr
*rta
= IFLA_RTA (ifim
);
499 size_t rtasize
= IFLA_PAYLOAD (nlh
);
501 /* Interfaces are stored in the first "newlink" entries
502 of our list, starting in the order as we got from the
504 ifa_index
= map_newlink (ifim
->ifi_index
- 1, ifas
,
505 map_newlink_data
, newlink
);
506 ifas
[ifa_index
].ifa
.ifa_flags
= ifim
->ifi_flags
;
508 while (RTA_OK (rta
, rtasize
))
510 char *rta_data
= RTA_DATA (rta
);
511 size_t rta_payload
= RTA_PAYLOAD (rta
);
513 switch (rta
->rta_type
)
516 if (rta_payload
<= sizeof (ifas
[ifa_index
].addr
))
518 ifas
[ifa_index
].addr
.sl
.sll_family
= AF_PACKET
;
519 memcpy (ifas
[ifa_index
].addr
.sl
.sll_addr
,
520 (char *) rta_data
, rta_payload
);
521 ifas
[ifa_index
].addr
.sl
.sll_halen
= rta_payload
;
522 ifas
[ifa_index
].addr
.sl
.sll_ifindex
524 ifas
[ifa_index
].addr
.sl
.sll_hatype
= ifim
->ifi_type
;
526 ifas
[ifa_index
].ifa
.ifa_addr
527 = &ifas
[ifa_index
].addr
.sa
;
532 if (rta_payload
<= sizeof (ifas
[ifa_index
].broadaddr
))
534 ifas
[ifa_index
].broadaddr
.sl
.sll_family
= AF_PACKET
;
535 memcpy (ifas
[ifa_index
].broadaddr
.sl
.sll_addr
,
536 (char *) rta_data
, rta_payload
);
537 ifas
[ifa_index
].broadaddr
.sl
.sll_halen
= rta_payload
;
538 ifas
[ifa_index
].broadaddr
.sl
.sll_ifindex
540 ifas
[ifa_index
].broadaddr
.sl
.sll_hatype
543 ifas
[ifa_index
].ifa
.ifa_broadaddr
544 = &ifas
[ifa_index
].broadaddr
.sa
;
548 case IFLA_IFNAME
: /* Name of Interface */
549 if ((rta_payload
+ 1) <= sizeof (ifas
[ifa_index
].name
))
551 ifas
[ifa_index
].ifa
.ifa_name
= ifas
[ifa_index
].name
;
552 *(char *) __mempcpy (ifas
[ifa_index
].name
, rta_data
,
557 case IFLA_STATS
: /* Statistics of Interface */
558 ifas
[ifa_index
].ifa
.ifa_data
= ifa_data_ptr
;
559 ifa_data_ptr
+= rta_payload
;
560 memcpy (ifas
[ifa_index
].ifa
.ifa_data
, rta_data
,
576 rta
= RTA_NEXT (rta
, rtasize
);
579 else if (nlh
->nlmsg_type
== RTM_NEWADDR
)
581 struct ifaddrmsg
*ifam
= (struct ifaddrmsg
*) NLMSG_DATA (nlh
);
582 struct rtattr
*rta
= IFA_RTA (ifam
);
583 size_t rtasize
= IFA_PAYLOAD (nlh
);
585 /* New Addresses are stored in the order we got them from
586 the kernel after the interfaces. Theoretically it is possible
587 that we have holes in the interface part of the list,
588 but we always have already the interface for this address. */
589 ifa_index
= newlink
+ newaddr_idx
;
590 ifas
[ifa_index
].ifa
.ifa_flags
591 = ifas
[map_newlink (ifam
->ifa_index
- 1, ifas
,
592 map_newlink_data
, newlink
)].ifa
.ifa_flags
;
594 ifas
[ifa_index
- 1].ifa
.ifa_next
= &ifas
[ifa_index
].ifa
;
597 while (RTA_OK (rta
, rtasize
))
599 char *rta_data
= RTA_DATA (rta
);
600 size_t rta_payload
= RTA_PAYLOAD (rta
);
602 switch (rta
->rta_type
)
608 if (ifas
[ifa_index
].ifa
.ifa_addr
!= NULL
)
610 /* In a point-to-poing network IFA_ADDRESS
611 contains the destination address, local
612 address is supplied in IFA_LOCAL attribute.
613 destination address and broadcast address
614 are stored in an union, so it doesn't matter
615 which name we use. */
616 ifas
[ifa_index
].ifa
.ifa_broadaddr
617 = &ifas
[ifa_index
].broadaddr
.sa
;
618 sa
= &ifas
[ifa_index
].broadaddr
.sa
;
622 ifas
[ifa_index
].ifa
.ifa_addr
623 = &ifas
[ifa_index
].addr
.sa
;
624 sa
= &ifas
[ifa_index
].addr
.sa
;
627 sa
->sa_family
= ifam
->ifa_family
;
629 switch (ifam
->ifa_family
)
632 /* Size must match that of an address for IPv4. */
633 if (rta_payload
== 4)
634 memcpy (&((struct sockaddr_in
*) sa
)->sin_addr
,
635 rta_data
, rta_payload
);
639 /* Size must match that of an address for IPv6. */
640 if (rta_payload
== 16)
642 memcpy (&((struct sockaddr_in6
*) sa
)->sin6_addr
,
643 rta_data
, rta_payload
);
644 if (IN6_IS_ADDR_LINKLOCAL (rta_data
)
645 || IN6_IS_ADDR_MC_LINKLOCAL (rta_data
))
646 ((struct sockaddr_in6
*) sa
)->sin6_scope_id
652 if (rta_payload
<= sizeof (ifas
[ifa_index
].addr
))
653 memcpy (sa
->sa_data
, rta_data
, rta_payload
);
660 if (ifas
[ifa_index
].ifa
.ifa_addr
!= NULL
)
662 /* If ifa_addr is set and we get IFA_LOCAL,
663 assume we have a point-to-point network.
664 Move address to correct field. */
665 ifas
[ifa_index
].broadaddr
= ifas
[ifa_index
].addr
;
666 ifas
[ifa_index
].ifa
.ifa_broadaddr
667 = &ifas
[ifa_index
].broadaddr
.sa
;
668 memset (&ifas
[ifa_index
].addr
, '\0',
669 sizeof (ifas
[ifa_index
].addr
));
672 ifas
[ifa_index
].ifa
.ifa_addr
= &ifas
[ifa_index
].addr
.sa
;
673 ifas
[ifa_index
].ifa
.ifa_addr
->sa_family
676 switch (ifam
->ifa_family
)
679 /* Size must match that of an address for IPv4. */
680 if (rta_payload
== 4)
681 memcpy (&ifas
[ifa_index
].addr
.s4
.sin_addr
,
682 rta_data
, rta_payload
);
686 /* Size must match that of an address for IPv6. */
687 if (rta_payload
== 16)
689 memcpy (&ifas
[ifa_index
].addr
.s6
.sin6_addr
,
690 rta_data
, rta_payload
);
691 if (IN6_IS_ADDR_LINKLOCAL (rta_data
)
692 || IN6_IS_ADDR_MC_LINKLOCAL (rta_data
))
693 ifas
[ifa_index
].addr
.s6
.sin6_scope_id
=
699 if (rta_payload
<= sizeof (ifas
[ifa_index
].addr
))
700 memcpy (ifas
[ifa_index
].addr
.sa
.sa_data
,
701 rta_data
, rta_payload
);
707 /* We get IFA_BROADCAST, so IFA_LOCAL was too much. */
708 if (ifas
[ifa_index
].ifa
.ifa_broadaddr
!= NULL
)
709 memset (&ifas
[ifa_index
].broadaddr
, '\0',
710 sizeof (ifas
[ifa_index
].broadaddr
));
712 ifas
[ifa_index
].ifa
.ifa_broadaddr
713 = &ifas
[ifa_index
].broadaddr
.sa
;
714 ifas
[ifa_index
].ifa
.ifa_broadaddr
->sa_family
717 switch (ifam
->ifa_family
)
720 /* Size must match that of an address for IPv4. */
721 if (rta_payload
== 4)
722 memcpy (&ifas
[ifa_index
].broadaddr
.s4
.sin_addr
,
723 rta_data
, rta_payload
);
727 /* Size must match that of an address for IPv6. */
728 if (rta_payload
== 16)
730 memcpy (&ifas
[ifa_index
].broadaddr
.s6
.sin6_addr
,
731 rta_data
, rta_payload
);
732 if (IN6_IS_ADDR_LINKLOCAL (rta_data
)
733 || IN6_IS_ADDR_MC_LINKLOCAL (rta_data
))
734 ifas
[ifa_index
].broadaddr
.s6
.sin6_scope_id
740 if (rta_payload
<= sizeof (ifas
[ifa_index
].addr
))
741 memcpy (&ifas
[ifa_index
].broadaddr
.sa
.sa_data
,
742 rta_data
, rta_payload
);
748 if (rta_payload
+ 1 <= sizeof (ifas
[ifa_index
].name
))
750 ifas
[ifa_index
].ifa
.ifa_name
= ifas
[ifa_index
].name
;
751 *(char *) __mempcpy (ifas
[ifa_index
].name
, rta_data
,
766 rta
= RTA_NEXT (rta
, rtasize
);
769 /* If we didn't get the interface name with the
770 address, use the name from the interface entry. */
771 if (ifas
[ifa_index
].ifa
.ifa_name
== NULL
)
772 ifas
[ifa_index
].ifa
.ifa_name
773 = ifas
[map_newlink (ifam
->ifa_index
- 1, ifas
,
774 map_newlink_data
, newlink
)].ifa
.ifa_name
;
776 /* Calculate the netmask. */
777 if (ifas
[ifa_index
].ifa
.ifa_addr
778 && ifas
[ifa_index
].ifa
.ifa_addr
->sa_family
!= AF_UNSPEC
779 && ifas
[ifa_index
].ifa
.ifa_addr
->sa_family
!= AF_PACKET
)
781 uint32_t max_prefixlen
= 0;
784 ifas
[ifa_index
].ifa
.ifa_netmask
785 = &ifas
[ifa_index
].netmask
.sa
;
787 switch (ifas
[ifa_index
].ifa
.ifa_addr
->sa_family
)
790 cp
= (char *) &ifas
[ifa_index
].netmask
.s4
.sin_addr
;
795 cp
= (char *) &ifas
[ifa_index
].netmask
.s6
.sin6_addr
;
800 ifas
[ifa_index
].ifa
.ifa_netmask
->sa_family
801 = ifas
[ifa_index
].ifa
.ifa_addr
->sa_family
;
806 unsigned int preflen
;
808 if ((max_prefixlen
> 0) &&
809 (ifam
->ifa_prefixlen
> max_prefixlen
))
810 preflen
= max_prefixlen
;
812 preflen
= ifam
->ifa_prefixlen
;
814 for (i
= 0; i
< (preflen
/ 8); i
++)
817 c
<<= (8 - (preflen
% 8));
825 assert (ifa_data_ptr
<= (char *) &ifas
[newlink
+ newaddr
] + ifa_data_size
);
829 for (i
= 0; i
< newlink
; ++i
)
830 if (map_newlink_data
[i
] == -1)
832 /* We have fewer links then we anticipated. Adjust the
833 forward pointer to the first address entry. */
834 ifas
[i
- 1].ifa
.ifa_next
= &ifas
[newlink
].ifa
;
837 if (i
== 0 && newlink
> 0)
838 /* No valid link, but we allocated memory. We have to
839 populate the first entry. */
840 memmove (ifas
, &ifas
[newlink
], sizeof (struct ifaddrs_storage
));
844 *ifap
= &ifas
[0].ifa
;
847 __netlink_free_handle (&nh
);
848 __netlink_close (&nh
);
852 libc_hidden_def (getifaddrs
)
855 #if __ASSUME_NETLINK_SUPPORT != 0
857 freeifaddrs (struct ifaddrs
*ifa
)
861 libc_hidden_def (freeifaddrs
)