1 /* getifaddrs -- get names and addresses of all network interfaces
2 Copyright (C) 2003, 2004, 2005, 2006, 2007 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
)
98 struct sockaddr_nl nladdr
;
101 h
->seq
= time (NULL
);
103 req
.nlh
.nlmsg_len
= sizeof (req
);
104 req
.nlh
.nlmsg_type
= type
;
105 req
.nlh
.nlmsg_flags
= NLM_F_ROOT
| NLM_F_MATCH
| NLM_F_REQUEST
;
106 req
.nlh
.nlmsg_pid
= 0;
107 req
.nlh
.nlmsg_seq
= h
->seq
;
108 req
.g
.rtgen_family
= AF_UNSPEC
;
109 if (sizeof (req
) != offsetof (struct req
, pad
))
110 memset (req
.pad
, '\0', sizeof (req
) - offsetof (struct req
, pad
));
112 memset (&nladdr
, '\0', sizeof (nladdr
));
113 nladdr
.nl_family
= AF_NETLINK
;
115 return TEMP_FAILURE_RETRY (__sendto (h
->fd
, (void *) &req
, sizeof (req
), 0,
116 (struct sockaddr
*) &nladdr
,
122 __netlink_request (struct netlink_handle
*h
, int type
)
124 struct netlink_res
*nlm_next
;
125 struct netlink_res
**new_nlm_list
;
126 static volatile size_t buf_size
= 4096;
128 struct sockaddr_nl nladdr
;
129 struct nlmsghdr
*nlmh
;
132 bool use_malloc
= false;
134 if (__netlink_sendreq (h
, type
) < 0)
137 size_t this_buf_size
= buf_size
;
138 if (__libc_use_alloca (this_buf_size
))
139 buf
= alloca (this_buf_size
);
142 buf
= malloc (this_buf_size
);
149 struct iovec iov
= { buf
, this_buf_size
};
151 if (h
->nlm_list
!= NULL
)
152 new_nlm_list
= &h
->end_ptr
->next
;
154 new_nlm_list
= &h
->nlm_list
;
160 (void *) &nladdr
, sizeof (nladdr
),
166 read_len
= TEMP_FAILURE_RETRY (__recvmsg (h
->fd
, &msg
, 0));
170 if (nladdr
.nl_pid
!= 0)
173 if (__builtin_expect (msg
.msg_flags
& MSG_TRUNC
, 0))
175 if (this_buf_size
>= SIZE_MAX
/ 2)
178 nlm_next
= *new_nlm_list
;
179 while (nlm_next
!= NULL
)
181 struct netlink_res
*tmpptr
;
183 tmpptr
= nlm_next
->next
;
187 *new_nlm_list
= NULL
;
189 if (__libc_use_alloca (2 * this_buf_size
))
190 buf
= extend_alloca (buf
, this_buf_size
, 2 * this_buf_size
);
195 char *new_buf
= realloc (use_malloc
? buf
: NULL
, this_buf_size
);
202 buf_size
= this_buf_size
;
205 iov
.iov_len
= this_buf_size
;
207 /* Increase sequence number, so that we can distinguish
208 between old and new request messages. */
211 if (__netlink_sendreq (h
, type
) < 0)
218 size_t remaining_len
= read_len
;
219 for (nlmh
= (struct nlmsghdr
*) buf
;
220 NLMSG_OK (nlmh
, remaining_len
);
221 nlmh
= (struct nlmsghdr
*) NLMSG_NEXT (nlmh
, remaining_len
))
223 if ((pid_t
) nlmh
->nlmsg_pid
!= h
->pid
224 || nlmh
->nlmsg_seq
!= h
->seq
)
228 if (nlmh
->nlmsg_type
== NLMSG_DONE
)
230 /* We found the end, leave the loop. */
234 if (nlmh
->nlmsg_type
== NLMSG_ERROR
)
236 struct nlmsgerr
*nlerr
= (struct nlmsgerr
*) NLMSG_DATA (nlmh
);
237 if (nlmh
->nlmsg_len
< NLMSG_LENGTH (sizeof (struct nlmsgerr
)))
240 errno
= -nlerr
->error
;
245 /* If there was nothing with the expected nlmsg_pid and nlmsg_seq,
246 there is no point to record it. */
250 nlm_next
= (struct netlink_res
*) malloc (sizeof (struct netlink_res
)
252 if (nlm_next
== NULL
)
254 nlm_next
->next
= NULL
;
255 nlm_next
->nlh
= memcpy (nlm_next
+ 1, buf
, read_len
);
256 nlm_next
->size
= read_len
;
257 nlm_next
->seq
= h
->seq
;
258 if (h
->nlm_list
== NULL
)
259 h
->nlm_list
= nlm_next
;
261 h
->end_ptr
->next
= nlm_next
;
262 h
->end_ptr
= nlm_next
;
277 __netlink_close (struct netlink_handle
*h
)
279 /* Don't modify errno. */
280 INTERNAL_SYSCALL_DECL (err
);
281 (void) INTERNAL_SYSCALL (close
, err
, 1, h
->fd
);
285 /* Open a NETLINK socket. */
287 __netlink_open (struct netlink_handle
*h
)
289 struct sockaddr_nl nladdr
;
291 h
->fd
= __socket (PF_NETLINK
, SOCK_RAW
, NETLINK_ROUTE
);
295 memset (&nladdr
, '\0', sizeof (nladdr
));
296 nladdr
.nl_family
= AF_NETLINK
;
297 if (__bind (h
->fd
, (struct sockaddr
*) &nladdr
, sizeof (nladdr
)) < 0)
302 #if __ASSUME_NETLINK_SUPPORT == 0
303 __no_netlink_support
= 1;
307 /* Determine the ID the kernel assigned for this netlink connection.
308 It is not necessarily the PID if there is more than one socket
310 socklen_t addr_len
= sizeof (nladdr
);
311 if (__getsockname (h
->fd
, (struct sockaddr
*) &nladdr
, &addr_len
) < 0)
313 h
->pid
= nladdr
.nl_pid
;
318 /* We know the number of RTM_NEWLINK entries, so we reserve the first
319 # of entries for this type. All RTM_NEWADDR entries have an index
320 pointer to the RTM_NEWLINK entry. To find the entry, create
321 a table to map kernel index entries to our index numbers.
322 Since we get at first all RTM_NEWLINK entries, it can never happen
323 that a RTM_NEWADDR index is not known to this map. */
326 map_newlink (int index
, struct ifaddrs_storage
*ifas
, int *map
, int max
)
330 for (i
= 0; i
< max
; i
++)
336 ifas
[i
- 1].ifa
.ifa_next
= &ifas
[i
].ifa
;
339 else if (map
[i
] == index
)
342 /* This should never be reached. If this will be reached, we have
343 a very big problem. */
348 /* Create a linked list of `struct ifaddrs' structures, one for each
349 network interface on the host machine. If successful, store the
350 list in *IFAP and return 0. On errors, return -1 and set `errno'. */
352 getifaddrs (struct ifaddrs
**ifap
)
354 struct netlink_handle nh
= { 0, 0, 0, NULL
, NULL
};
355 struct netlink_res
*nlp
;
356 struct ifaddrs_storage
*ifas
;
357 unsigned int i
, newlink
, newaddr
, newaddr_idx
;
358 int *map_newlink_data
;
359 size_t ifa_data_size
= 0; /* Size to allocate for all ifa_data. */
360 char *ifa_data_ptr
; /* Pointer to the unused part of memory for
366 if (! __no_netlink_support
&& __netlink_open (&nh
) < 0)
368 #if __ASSUME_NETLINK_SUPPORT != 0
373 #if __ASSUME_NETLINK_SUPPORT == 0
374 if (__no_netlink_support
)
375 return fallback_getifaddrs (ifap
);
378 /* Tell the kernel that we wish to get a list of all
379 active interfaces, collect all data for every interface. */
380 if (__netlink_request (&nh
, RTM_GETLINK
) < 0)
386 /* Now ask the kernel for all addresses which are assigned
387 to an interface and collect all data for every interface.
388 Since we store the addresses after the interfaces in the
389 list, we will later always find the interface before the
390 corresponding addresses. */
392 if (__netlink_request (&nh
, RTM_GETADDR
) < 0)
398 /* Count all RTM_NEWLINK and RTM_NEWADDR entries to allocate
400 newlink
= newaddr
= 0;
401 for (nlp
= nh
.nlm_list
; nlp
; nlp
= nlp
->next
)
403 struct nlmsghdr
*nlh
;
404 size_t size
= nlp
->size
;
406 if (nlp
->nlh
== NULL
)
409 /* Walk through all entries we got from the kernel and look, which
410 message type they contain. */
411 for (nlh
= nlp
->nlh
; NLMSG_OK (nlh
, size
); nlh
= NLMSG_NEXT (nlh
, size
))
413 /* Check if the message is what we want. */
414 if ((pid_t
) nlh
->nlmsg_pid
!= nh
.pid
|| nlh
->nlmsg_seq
!= nlp
->seq
)
417 if (nlh
->nlmsg_type
== NLMSG_DONE
)
420 if (nlh
->nlmsg_type
== RTM_NEWLINK
)
422 /* A RTM_NEWLINK message can have IFLA_STATS data. We need to
423 know the size before creating the list to allocate enough
425 struct ifinfomsg
*ifim
= (struct ifinfomsg
*) NLMSG_DATA (nlh
);
426 struct rtattr
*rta
= IFLA_RTA (ifim
);
427 size_t rtasize
= IFLA_PAYLOAD (nlh
);
429 while (RTA_OK (rta
, rtasize
))
431 size_t rta_payload
= RTA_PAYLOAD (rta
);
433 if (rta
->rta_type
== IFLA_STATS
)
435 ifa_data_size
+= rta_payload
;
439 rta
= RTA_NEXT (rta
, rtasize
);
443 else if (nlh
->nlmsg_type
== RTM_NEWADDR
)
448 /* Return if no interface is up. */
449 if ((newlink
+ newaddr
) == 0)
452 /* Allocate memory for all entries we have and initialize next
454 ifas
= (struct ifaddrs_storage
*) calloc (1,
456 * sizeof (struct ifaddrs_storage
)
464 /* Table for mapping kernel index to entry in our list. */
465 map_newlink_data
= alloca (newlink
* sizeof (int));
466 memset (map_newlink_data
, '\xff', newlink
* sizeof (int));
468 ifa_data_ptr
= (char *) &ifas
[newlink
+ newaddr
];
469 newaddr_idx
= 0; /* Counter for newaddr index. */
471 /* Walk through the list of data we got from the kernel. */
472 for (nlp
= nh
.nlm_list
; nlp
; nlp
= nlp
->next
)
474 struct nlmsghdr
*nlh
;
475 size_t size
= nlp
->size
;
477 if (nlp
->nlh
== NULL
)
480 /* Walk through one message and look at the type: If it is our
481 message, we need RTM_NEWLINK/RTM_NEWADDR and stop if we reach
482 the end or we find the end marker (in this case we ignore the
484 for (nlh
= nlp
->nlh
; NLMSG_OK (nlh
, size
); nlh
= NLMSG_NEXT (nlh
, size
))
488 /* Check if the message is the one we want */
489 if ((pid_t
) nlh
->nlmsg_pid
!= nh
.pid
|| nlh
->nlmsg_seq
!= nlp
->seq
)
492 if (nlh
->nlmsg_type
== NLMSG_DONE
)
495 if (nlh
->nlmsg_type
== RTM_NEWLINK
)
497 /* We found a new interface. Now extract everything from the
498 interface data we got and need. */
499 struct ifinfomsg
*ifim
= (struct ifinfomsg
*) NLMSG_DATA (nlh
);
500 struct rtattr
*rta
= IFLA_RTA (ifim
);
501 size_t rtasize
= IFLA_PAYLOAD (nlh
);
503 /* Interfaces are stored in the first "newlink" entries
504 of our list, starting in the order as we got from the
506 ifa_index
= map_newlink (ifim
->ifi_index
- 1, ifas
,
507 map_newlink_data
, newlink
);
508 ifas
[ifa_index
].ifa
.ifa_flags
= ifim
->ifi_flags
;
510 while (RTA_OK (rta
, rtasize
))
512 char *rta_data
= RTA_DATA (rta
);
513 size_t rta_payload
= RTA_PAYLOAD (rta
);
515 switch (rta
->rta_type
)
518 if (rta_payload
<= sizeof (ifas
[ifa_index
].addr
))
520 ifas
[ifa_index
].addr
.sl
.sll_family
= AF_PACKET
;
521 memcpy (ifas
[ifa_index
].addr
.sl
.sll_addr
,
522 (char *) rta_data
, rta_payload
);
523 ifas
[ifa_index
].addr
.sl
.sll_halen
= rta_payload
;
524 ifas
[ifa_index
].addr
.sl
.sll_ifindex
526 ifas
[ifa_index
].addr
.sl
.sll_hatype
= ifim
->ifi_type
;
528 ifas
[ifa_index
].ifa
.ifa_addr
529 = &ifas
[ifa_index
].addr
.sa
;
534 if (rta_payload
<= sizeof (ifas
[ifa_index
].broadaddr
))
536 ifas
[ifa_index
].broadaddr
.sl
.sll_family
= AF_PACKET
;
537 memcpy (ifas
[ifa_index
].broadaddr
.sl
.sll_addr
,
538 (char *) rta_data
, rta_payload
);
539 ifas
[ifa_index
].broadaddr
.sl
.sll_halen
= rta_payload
;
540 ifas
[ifa_index
].broadaddr
.sl
.sll_ifindex
542 ifas
[ifa_index
].broadaddr
.sl
.sll_hatype
545 ifas
[ifa_index
].ifa
.ifa_broadaddr
546 = &ifas
[ifa_index
].broadaddr
.sa
;
550 case IFLA_IFNAME
: /* Name of Interface */
551 if ((rta_payload
+ 1) <= sizeof (ifas
[ifa_index
].name
))
553 ifas
[ifa_index
].ifa
.ifa_name
= ifas
[ifa_index
].name
;
554 *(char *) __mempcpy (ifas
[ifa_index
].name
, rta_data
,
559 case IFLA_STATS
: /* Statistics of Interface */
560 ifas
[ifa_index
].ifa
.ifa_data
= ifa_data_ptr
;
561 ifa_data_ptr
+= rta_payload
;
562 memcpy (ifas
[ifa_index
].ifa
.ifa_data
, rta_data
,
578 rta
= RTA_NEXT (rta
, rtasize
);
581 else if (nlh
->nlmsg_type
== RTM_NEWADDR
)
583 struct ifaddrmsg
*ifam
= (struct ifaddrmsg
*) NLMSG_DATA (nlh
);
584 struct rtattr
*rta
= IFA_RTA (ifam
);
585 size_t rtasize
= IFA_PAYLOAD (nlh
);
587 /* New Addresses are stored in the order we got them from
588 the kernel after the interfaces. Theoretically it is possible
589 that we have holes in the interface part of the list,
590 but we always have already the interface for this address. */
591 ifa_index
= newlink
+ newaddr_idx
;
592 ifas
[ifa_index
].ifa
.ifa_flags
593 = ifas
[map_newlink (ifam
->ifa_index
- 1, ifas
,
594 map_newlink_data
, newlink
)].ifa
.ifa_flags
;
596 ifas
[ifa_index
- 1].ifa
.ifa_next
= &ifas
[ifa_index
].ifa
;
599 while (RTA_OK (rta
, rtasize
))
601 char *rta_data
= RTA_DATA (rta
);
602 size_t rta_payload
= RTA_PAYLOAD (rta
);
604 switch (rta
->rta_type
)
610 if (ifas
[ifa_index
].ifa
.ifa_addr
!= NULL
)
612 /* In a point-to-poing network IFA_ADDRESS
613 contains the destination address, local
614 address is supplied in IFA_LOCAL attribute.
615 destination address and broadcast address
616 are stored in an union, so it doesn't matter
617 which name we use. */
618 ifas
[ifa_index
].ifa
.ifa_broadaddr
619 = &ifas
[ifa_index
].broadaddr
.sa
;
620 sa
= &ifas
[ifa_index
].broadaddr
.sa
;
624 ifas
[ifa_index
].ifa
.ifa_addr
625 = &ifas
[ifa_index
].addr
.sa
;
626 sa
= &ifas
[ifa_index
].addr
.sa
;
629 sa
->sa_family
= ifam
->ifa_family
;
631 switch (ifam
->ifa_family
)
634 /* Size must match that of an address for IPv4. */
635 if (rta_payload
== 4)
636 memcpy (&((struct sockaddr_in
*) sa
)->sin_addr
,
637 rta_data
, rta_payload
);
641 /* Size must match that of an address for IPv6. */
642 if (rta_payload
== 16)
644 memcpy (&((struct sockaddr_in6
*) sa
)->sin6_addr
,
645 rta_data
, rta_payload
);
646 if (IN6_IS_ADDR_LINKLOCAL (rta_data
)
647 || IN6_IS_ADDR_MC_LINKLOCAL (rta_data
))
648 ((struct sockaddr_in6
*) sa
)->sin6_scope_id
654 if (rta_payload
<= sizeof (ifas
[ifa_index
].addr
))
655 memcpy (sa
->sa_data
, rta_data
, rta_payload
);
662 if (ifas
[ifa_index
].ifa
.ifa_addr
!= NULL
)
664 /* If ifa_addr is set and we get IFA_LOCAL,
665 assume we have a point-to-point network.
666 Move address to correct field. */
667 ifas
[ifa_index
].broadaddr
= ifas
[ifa_index
].addr
;
668 ifas
[ifa_index
].ifa
.ifa_broadaddr
669 = &ifas
[ifa_index
].broadaddr
.sa
;
670 memset (&ifas
[ifa_index
].addr
, '\0',
671 sizeof (ifas
[ifa_index
].addr
));
674 ifas
[ifa_index
].ifa
.ifa_addr
= &ifas
[ifa_index
].addr
.sa
;
675 ifas
[ifa_index
].ifa
.ifa_addr
->sa_family
678 switch (ifam
->ifa_family
)
681 /* Size must match that of an address for IPv4. */
682 if (rta_payload
== 4)
683 memcpy (&ifas
[ifa_index
].addr
.s4
.sin_addr
,
684 rta_data
, rta_payload
);
688 /* Size must match that of an address for IPv6. */
689 if (rta_payload
== 16)
691 memcpy (&ifas
[ifa_index
].addr
.s6
.sin6_addr
,
692 rta_data
, rta_payload
);
693 if (IN6_IS_ADDR_LINKLOCAL (rta_data
)
694 || IN6_IS_ADDR_MC_LINKLOCAL (rta_data
))
695 ifas
[ifa_index
].addr
.s6
.sin6_scope_id
=
701 if (rta_payload
<= sizeof (ifas
[ifa_index
].addr
))
702 memcpy (ifas
[ifa_index
].addr
.sa
.sa_data
,
703 rta_data
, rta_payload
);
709 /* We get IFA_BROADCAST, so IFA_LOCAL was too much. */
710 if (ifas
[ifa_index
].ifa
.ifa_broadaddr
!= NULL
)
711 memset (&ifas
[ifa_index
].broadaddr
, '\0',
712 sizeof (ifas
[ifa_index
].broadaddr
));
714 ifas
[ifa_index
].ifa
.ifa_broadaddr
715 = &ifas
[ifa_index
].broadaddr
.sa
;
716 ifas
[ifa_index
].ifa
.ifa_broadaddr
->sa_family
719 switch (ifam
->ifa_family
)
722 /* Size must match that of an address for IPv4. */
723 if (rta_payload
== 4)
724 memcpy (&ifas
[ifa_index
].broadaddr
.s4
.sin_addr
,
725 rta_data
, rta_payload
);
729 /* Size must match that of an address for IPv6. */
730 if (rta_payload
== 16)
732 memcpy (&ifas
[ifa_index
].broadaddr
.s6
.sin6_addr
,
733 rta_data
, rta_payload
);
734 if (IN6_IS_ADDR_LINKLOCAL (rta_data
)
735 || IN6_IS_ADDR_MC_LINKLOCAL (rta_data
))
736 ifas
[ifa_index
].broadaddr
.s6
.sin6_scope_id
742 if (rta_payload
<= sizeof (ifas
[ifa_index
].addr
))
743 memcpy (&ifas
[ifa_index
].broadaddr
.sa
.sa_data
,
744 rta_data
, rta_payload
);
750 if (rta_payload
+ 1 <= sizeof (ifas
[ifa_index
].name
))
752 ifas
[ifa_index
].ifa
.ifa_name
= ifas
[ifa_index
].name
;
753 *(char *) __mempcpy (ifas
[ifa_index
].name
, rta_data
,
768 rta
= RTA_NEXT (rta
, rtasize
);
771 /* If we didn't get the interface name with the
772 address, use the name from the interface entry. */
773 if (ifas
[ifa_index
].ifa
.ifa_name
== NULL
)
774 ifas
[ifa_index
].ifa
.ifa_name
775 = ifas
[map_newlink (ifam
->ifa_index
- 1, ifas
,
776 map_newlink_data
, newlink
)].ifa
.ifa_name
;
778 /* Calculate the netmask. */
779 if (ifas
[ifa_index
].ifa
.ifa_addr
780 && ifas
[ifa_index
].ifa
.ifa_addr
->sa_family
!= AF_UNSPEC
781 && ifas
[ifa_index
].ifa
.ifa_addr
->sa_family
!= AF_PACKET
)
783 uint32_t max_prefixlen
= 0;
786 ifas
[ifa_index
].ifa
.ifa_netmask
787 = &ifas
[ifa_index
].netmask
.sa
;
789 switch (ifas
[ifa_index
].ifa
.ifa_addr
->sa_family
)
792 cp
= (char *) &ifas
[ifa_index
].netmask
.s4
.sin_addr
;
797 cp
= (char *) &ifas
[ifa_index
].netmask
.s6
.sin6_addr
;
802 ifas
[ifa_index
].ifa
.ifa_netmask
->sa_family
803 = ifas
[ifa_index
].ifa
.ifa_addr
->sa_family
;
808 unsigned int preflen
;
810 if ((max_prefixlen
> 0) &&
811 (ifam
->ifa_prefixlen
> max_prefixlen
))
812 preflen
= max_prefixlen
;
814 preflen
= ifam
->ifa_prefixlen
;
816 for (i
= 0; i
< (preflen
/ 8); i
++)
819 c
<<= (8 - (preflen
% 8));
827 assert (ifa_data_ptr
<= (char *) &ifas
[newlink
+ newaddr
] + ifa_data_size
);
831 for (i
= 0; i
< newlink
; ++i
)
832 if (map_newlink_data
[i
] == -1)
834 /* We have fewer links then we anticipated. Adjust the
835 forward pointer to the first address entry. */
836 ifas
[i
- 1].ifa
.ifa_next
= &ifas
[newlink
].ifa
;
839 if (i
== 0 && newlink
> 0)
840 /* No valid link, but we allocated memory. We have to
841 populate the first entry. */
842 memmove (ifas
, &ifas
[newlink
], sizeof (struct ifaddrs_storage
));
845 *ifap
= &ifas
[0].ifa
;
848 __netlink_free_handle (&nh
);
849 __netlink_close (&nh
);
853 libc_hidden_def (getifaddrs
)
856 #if __ASSUME_NETLINK_SUPPORT != 0
858 freeifaddrs (struct ifaddrs
*ifa
)
862 libc_hidden_def (freeifaddrs
)