summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/getifaddrs.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/net/getifaddrs.3')
-rw-r--r--src/lib/libc/net/getifaddrs.3161
1 files changed, 161 insertions, 0 deletions
diff --git a/src/lib/libc/net/getifaddrs.3 b/src/lib/libc/net/getifaddrs.3
new file mode 100644
index 0000000000..68c12b552a
--- /dev/null
+++ b/src/lib/libc/net/getifaddrs.3
@@ -0,0 +1,161 @@
1.\" $OpenBSD: getifaddrs.3,v 1.1 2000/02/23 06:55:58 itojun Exp $
2.\" BSDI getifaddrs.3,v 2.4 1999/03/15 20:57:20 jch Exp
3.\"
4.\" Copyright (c) 1995, 1999
5.\" Berkeley Software Design, Inc. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\" notice, this list of conditions and the following disclaimer.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.Dd "October 12, 1995"
25.Dt GETIFADDRS 3
26.Sh NAME
27.Nm getifaddrs
28.Nd get interface addresses
29.Sh SYNOPSIS
30.Fd #include <sys/types.h>
31.Fd #include <sys/socket.h>
32.Fd #include <ifaddrs.h>
33.Ft int
34.Fn getifaddrs "struct ifaddrs **ifap"
35.Sh DESCRIPTION
36The
37.Fn getifaddrs
38function stores a reference to a linked list of the network interfaces
39on the local machine in the memory referenced by
40.Fa ifap .
41The list consists of
42.Nm ifaddrs
43structures, as defined in the include file
44.Aq Pa ifaddrs.h .
45The
46.Nm ifaddrs
47structure contains at least the following entries:
48.Bd -literal
49 struct ifaddrs *ifa_next; /* Pointer to next struct */
50 char *ifa_name; /* Interface name */
51 u_int ifa_flags; /* Interface flags */
52 struct sockaddr *ifa_addr; /* Interface address */
53 struct sockaddr *ifa_netmask; /* Interface netmask */
54 struct sockaddr *ifa_broadaddr; /* Interface broadcast address */
55 struct sockaddr *ifa_dstaddr; /* P2P interface destination */
56 void *ifa_data; /* Address specific data */
57.Ed
58.Pp
59The
60.Li ifa_next
61field contains a pointer to the next structure on the list.
62This field is
63.Dv NULL
64in last structure on the list.
65.Pp
66The
67.Li ifa_name
68field contains the interface name.
69.Pp
70The
71.Li ifa_flags
72field contains the interface flags, as set by
73.Xr ifconfig 8
74utility.
75.Pp
76The
77.Li ifa_addr
78field references either the address of the interface or the link level
79address of the interface, if one exists, otherwise it is NULL.
80(The
81.Li sa_family
82field of the
83.Li ifa_addr
84field should be consulted to determine the format of the
85.Li ifa_addr
86address.)
87.Pp
88The
89.Li ifa_netmask
90field references the netmask associated with
91.Li ifa_addr ,
92if one is set, otherwise it is NULL.
93.Pp
94The
95.Li ifa_broadaddr
96field,
97which should only be referenced for non-P2P interfaces,
98references the broadcast address associated with
99.Li ifa_addr ,
100if one exists, otherwise it is NULL.
101.Pp
102The
103.Li ifa_dstaddr
104field references the destination address on a P2P interface,
105if one exists, otherwise it is NULL.
106.Pp
107The
108.Li ifa_data
109field references address family specific data. For
110.Dv AF_LINK
111addresses it contains a pointer to the
112.Fa struct if_data
113.Pq as defined in include file Aq Pa net/if.h
114which contains various interface attributes and statistics.
115For all other address families, it contains a pointer to the
116.Fa struct ifa_data
117.Pq as defined in include file Aq Pa net/if.h
118which contains per-address interface statistics.
119.Pp
120The data returned by
121.Fn getifaddrs
122is dynamically allocated and should be freed using
123.Fn free
124.Pq see Xr free 3
125when no longer needed.
126.Sh RETURN VALUES
127Upon successful completion, a value of 0 is returned.
128Otherwise, a value of -1 is returned and
129.Va errno
130is set to indicate the error.
131.Sh ERRORS
132The
133.Fn getifaddrs
134may fail and set
135.Va errno
136for any of the errors specified for the library routines
137.Xr ioctl 2 ,
138.Xr socket 2 ,
139.Xr malloc 3
140or
141.Xr sysctl 3 .
142.Sh BUGS
143If both
144.Aq Pa net/if.h
145and
146.Aq Pa ifaddrs.h
147are being included,
148.Aq Pa net/if.h
149.Em must
150be included before
151.Aq Pa ifaddrs.h .
152.Sh SEE ALSO
153.Xr ioctl 2 ,
154.Xr socket 2 ,
155.Xr sysctl 3 ,
156.Xr networking 4 ,
157.Xr ifconfig 8
158.Sh HISTORY
159The
160.Nm
161implementation first appeared in BSDI BSD/OS.