diff options
Diffstat (limited to 'src/lib/libc/net/getifaddrs.3')
-rw-r--r-- | src/lib/libc/net/getifaddrs.3 | 161 |
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 | ||
36 | The | ||
37 | .Fn getifaddrs | ||
38 | function stores a reference to a linked list of the network interfaces | ||
39 | on the local machine in the memory referenced by | ||
40 | .Fa ifap . | ||
41 | The list consists of | ||
42 | .Nm ifaddrs | ||
43 | structures, as defined in the include file | ||
44 | .Aq Pa ifaddrs.h . | ||
45 | The | ||
46 | .Nm ifaddrs | ||
47 | structure 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 | ||
59 | The | ||
60 | .Li ifa_next | ||
61 | field contains a pointer to the next structure on the list. | ||
62 | This field is | ||
63 | .Dv NULL | ||
64 | in last structure on the list. | ||
65 | .Pp | ||
66 | The | ||
67 | .Li ifa_name | ||
68 | field contains the interface name. | ||
69 | .Pp | ||
70 | The | ||
71 | .Li ifa_flags | ||
72 | field contains the interface flags, as set by | ||
73 | .Xr ifconfig 8 | ||
74 | utility. | ||
75 | .Pp | ||
76 | The | ||
77 | .Li ifa_addr | ||
78 | field references either the address of the interface or the link level | ||
79 | address of the interface, if one exists, otherwise it is NULL. | ||
80 | (The | ||
81 | .Li sa_family | ||
82 | field of the | ||
83 | .Li ifa_addr | ||
84 | field should be consulted to determine the format of the | ||
85 | .Li ifa_addr | ||
86 | address.) | ||
87 | .Pp | ||
88 | The | ||
89 | .Li ifa_netmask | ||
90 | field references the netmask associated with | ||
91 | .Li ifa_addr , | ||
92 | if one is set, otherwise it is NULL. | ||
93 | .Pp | ||
94 | The | ||
95 | .Li ifa_broadaddr | ||
96 | field, | ||
97 | which should only be referenced for non-P2P interfaces, | ||
98 | references the broadcast address associated with | ||
99 | .Li ifa_addr , | ||
100 | if one exists, otherwise it is NULL. | ||
101 | .Pp | ||
102 | The | ||
103 | .Li ifa_dstaddr | ||
104 | field references the destination address on a P2P interface, | ||
105 | if one exists, otherwise it is NULL. | ||
106 | .Pp | ||
107 | The | ||
108 | .Li ifa_data | ||
109 | field references address family specific data. For | ||
110 | .Dv AF_LINK | ||
111 | addresses it contains a pointer to the | ||
112 | .Fa struct if_data | ||
113 | .Pq as defined in include file Aq Pa net/if.h | ||
114 | which contains various interface attributes and statistics. | ||
115 | For 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 | ||
118 | which contains per-address interface statistics. | ||
119 | .Pp | ||
120 | The data returned by | ||
121 | .Fn getifaddrs | ||
122 | is dynamically allocated and should be freed using | ||
123 | .Fn free | ||
124 | .Pq see Xr free 3 | ||
125 | when no longer needed. | ||
126 | .Sh RETURN VALUES | ||
127 | Upon successful completion, a value of 0 is returned. | ||
128 | Otherwise, a value of -1 is returned and | ||
129 | .Va errno | ||
130 | is set to indicate the error. | ||
131 | .Sh ERRORS | ||
132 | The | ||
133 | .Fn getifaddrs | ||
134 | may fail and set | ||
135 | .Va errno | ||
136 | for any of the errors specified for the library routines | ||
137 | .Xr ioctl 2 , | ||
138 | .Xr socket 2 , | ||
139 | .Xr malloc 3 | ||
140 | or | ||
141 | .Xr sysctl 3 . | ||
142 | .Sh BUGS | ||
143 | If both | ||
144 | .Aq Pa net/if.h | ||
145 | and | ||
146 | .Aq Pa ifaddrs.h | ||
147 | are being included, | ||
148 | .Aq Pa net/if.h | ||
149 | .Em must | ||
150 | be 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 | ||
159 | The | ||
160 | .Nm | ||
161 | implementation first appeared in BSDI BSD/OS. | ||