2 .\" $KAME: getifaddrs.3,v 1.4 2000/05/17 14:13:14 itojun Exp $
3 .\" BSDI getifaddrs.3,v 2.5 2000/02/23 14:51:59 dab Exp
5 .\" Copyright (c) 1995, 1999
6 .\" Berkeley Software Design, Inc. All rights reserved.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
14 .\" THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 .Dd "October 12, 1995"
29 .Nd get interface addresses
31 .Fd #include <sys/types.h>
32 .Fd #include <sys/socket.h>
33 .Fd #include <ifaddrs.h>
35 .Fn getifaddrs "struct ifaddrs **ifap"
37 .Fn freeifaddrs "struct ifaddrs *ifp"
41 function stores a reference to a linked list of the network interfaces
42 on the local machine in the memory referenced by
46 structures, as defined in the include file
50 structure contains at least the following entries:
52 struct ifaddrs *ifa_next; /* Pointer to next struct */
53 char *ifa_name; /* Interface name */
54 u_int ifa_flags; /* Interface flags */
55 struct sockaddr *ifa_addr; /* Interface address */
56 struct sockaddr *ifa_netmask; /* Interface netmask */
57 struct sockaddr *ifa_broadaddr; /* Interface broadcast address */
58 struct sockaddr *ifa_dstaddr; /* P2P interface destination */
59 void *ifa_data; /* Address specific data */
64 field contains a pointer to the next structure on the list.
67 in last structure on the list.
71 field contains the interface name.
75 field contains the interface flags, as set by
81 field references either the address of the interface or the link level
82 address of the interface, if one exists, otherwise it is NULL.
87 field should be consulted to determine the format of the
93 field references the netmask associated with
95 if one is set, otherwise it is NULL.
100 which should only be referenced for non-P2P interfaces,
101 references the broadcast address associated with
103 if one exists, otherwise it is NULL.
107 field references the destination address on a P2P interface,
108 if one exists, otherwise it is NULL.
112 field references address family specific data. For
114 addresses it contains a pointer to the
116 .Pq as defined in include file Aq Pa net/if.h
117 which contains various interface attributes and statistics.
118 For all other address families, it contains a pointer to the
120 .Pq as defined in include file Aq Pa net/if.h
121 which contains per-address interface statistics.
125 is dynamically allocated and should be freed using
127 when no longer needed.
129 Upon successful completion, a value of 0 is returned.
130 Otherwise, a value of -1 is returned and
132 is set to indicate the error.
138 for any of the errors specified for the library routines
163 implementation first appeared in BSDI BSD/OS.