diff options
author | deraadt <> | 1999-07-03 20:22:21 +0000 |
---|---|---|
committer | deraadt <> | 1999-07-03 20:22:21 +0000 |
commit | c078dc2c32bc3dbb78efe49ded77e3dbf16e00c6 (patch) | |
tree | 479ca631e7f3c5da9c302d6639d79e2eba03b9a8 /src/lib | |
parent | d3448bc163f4d5dfba64b773db80a0206f7ce0fc (diff) | |
download | openbsd-c078dc2c32bc3dbb78efe49ded77e3dbf16e00c6.tar.gz openbsd-c078dc2c32bc3dbb78efe49ded77e3dbf16e00c6.tar.bz2 openbsd-c078dc2c32bc3dbb78efe49ded77e3dbf16e00c6.zip |
man pages from WIDE
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libc/net/Makefile.inc | 10 | ||||
-rw-r--r-- | src/lib/libc/net/getaddrinfo.3 | 359 | ||||
-rw-r--r-- | src/lib/libc/net/if_indextoname.3 | 131 |
3 files changed, 498 insertions, 2 deletions
diff --git a/src/lib/libc/net/Makefile.inc b/src/lib/libc/net/Makefile.inc index 97e11ba794..66e4794057 100644 --- a/src/lib/libc/net/Makefile.inc +++ b/src/lib/libc/net/Makefile.inc | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile.inc,v 1.21 1999/07/03 19:56:26 deraadt Exp $ | 1 | # $OpenBSD: Makefile.inc,v 1.22 1999/07/03 20:22:21 deraadt Exp $ |
2 | 2 | ||
3 | # net sources | 3 | # net sources |
4 | .PATH: ${LIBCSRCDIR}/arch/${MACHINE_ARCH}/net ${LIBCSRCDIR}/net | 4 | .PATH: ${LIBCSRCDIR}/arch/${MACHINE_ARCH}/net ${LIBCSRCDIR}/net |
@@ -27,7 +27,13 @@ SRCS+= base64.c freeaddrinfo.c gai_strerror.c getaddrinfo.c gethostnamadr.c \ | |||
27 | 27 | ||
28 | MAN+= byteorder.3 ethers.3 gethostbyname.3 getnetent.3 getprotoent.3 \ | 28 | MAN+= byteorder.3 ethers.3 gethostbyname.3 getnetent.3 getprotoent.3 \ |
29 | getservent.3 inet.3 inet_net.3 iso_addr.3 link_addr.3 ns.3 ipx.3 \ | 29 | getservent.3 inet.3 inet_net.3 iso_addr.3 link_addr.3 ns.3 ipx.3 \ |
30 | rcmd.3 rcmdsh.3 resolver.3 net_addrcmp.3 | 30 | rcmd.3 rcmdsh.3 resolver.3 net_addrcmp.3 \ |
31 | getnameinfo.3 getaddrinfo.3 if_indextoname.3 | ||
32 | |||
33 | MLINKS+= getnameinfo.3 freeaddrinfo.3 | ||
34 | MLINKS+= getnameinfo.3 gai_strerror.3 | ||
35 | MLINKS+= if_indextoname.3 if_nametoindex.3 | ||
36 | MLINKS+= if_indextoname.3 if_nameindex.3 | ||
31 | 37 | ||
32 | MLINKS+=byteorder.3 htonl.3 byteorder.3 htons.3 byteorder.3 ntohl.3 \ | 38 | MLINKS+=byteorder.3 htonl.3 byteorder.3 htons.3 byteorder.3 ntohl.3 \ |
33 | byteorder.3 ntohs.3 byteorder.3 htobe16.3 byteorder.3 htobe32.3 \ | 39 | byteorder.3 ntohs.3 byteorder.3 htobe16.3 byteorder.3 htobe32.3 \ |
diff --git a/src/lib/libc/net/getaddrinfo.3 b/src/lib/libc/net/getaddrinfo.3 new file mode 100644 index 0000000000..cff60d9d4e --- /dev/null +++ b/src/lib/libc/net/getaddrinfo.3 | |||
@@ -0,0 +1,359 @@ | |||
1 | .\" Copyright (c) 1983, 1987, 1991, 1993 | ||
2 | .\" The Regents of the University of California. All rights reserved. | ||
3 | .\" | ||
4 | .\" Redistribution and use in source and binary forms, with or without | ||
5 | .\" modification, are permitted provided that the following conditions | ||
6 | .\" are met: | ||
7 | .\" 1. Redistributions of source code must retain the above copyright | ||
8 | .\" notice, this list of conditions and the following disclaimer. | ||
9 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
10 | .\" notice, this list of conditions and the following disclaimer in the | ||
11 | .\" documentation and/or other materials provided with the distribution. | ||
12 | .\" 3. All advertising materials mentioning features or use of this software | ||
13 | .\" must display the following acknowledgement: | ||
14 | .\" This product includes software developed by the University of | ||
15 | .\" California, Berkeley and its contributors. | ||
16 | .\" 4. Neither the name of the University nor the names of its contributors | ||
17 | .\" may be used to endorse or promote products derived from this software | ||
18 | .\" without specific prior written permission. | ||
19 | .\" | ||
20 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
21 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
23 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
24 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
25 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
26 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
27 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
28 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
30 | .\" SUCH DAMAGE. | ||
31 | .\" | ||
32 | .\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 | ||
33 | .\" $Id: getaddrinfo.3,v 1.1 1999/07/03 20:22:21 deraadt Exp $ | ||
34 | .\" | ||
35 | .Dd May 25, 1995 | ||
36 | .Dt GETADDRINFO 3 | ||
37 | .Os KAME | ||
38 | .Sh NAME | ||
39 | .Nm getaddrinfo | ||
40 | .Nm freeaddrinfo , | ||
41 | .Nm gai_strerror | ||
42 | .Nd nodename-to-address translation in protocol-independent manner | ||
43 | .Sh SYNOPSIS | ||
44 | .Fd #include <sys/socket.h> | ||
45 | .Fd #include <netdb.h> | ||
46 | .Ft int | ||
47 | .Fn getaddrinfo "const char *nodename" "const char *servname" \ | ||
48 | "const struct addrinfo *hints" "struct addrinfo **res" | ||
49 | .Ft void | ||
50 | .Fn freeaddrinfo "struct addrinfo *ai" | ||
51 | .Ft "char *" | ||
52 | .Fn gai_strerror "int ecode" | ||
53 | .Sh DESCRIPTION | ||
54 | The | ||
55 | .Fn getaddrinfo | ||
56 | function is defined for protocol-independent nodename-to-address translation. | ||
57 | It performs functionality of | ||
58 | .Xr gethostbyname 3 | ||
59 | and | ||
60 | .Xr getservbyname 3 , | ||
61 | in more sophisticated manner. | ||
62 | .Pp | ||
63 | The addrinfo structure is defined as a result of including the | ||
64 | .Li <netdb.h> | ||
65 | header: | ||
66 | .Bd -literal -offset | ||
67 | struct addrinfo { * | ||
68 | int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */ | ||
69 | int ai_family; /* PF_xxx */ | ||
70 | int ai_socktype; /* SOCK_xxx */ | ||
71 | int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ | ||
72 | size_t ai_addrlen; /* length of ai_addr */ | ||
73 | char *ai_canonname; /* canonical name for nodename */ | ||
74 | struct sockaddr *ai_addr; /* binary address */ | ||
75 | struct addrinfo *ai_next; /* next structure in linked list */ | ||
76 | }; | ||
77 | .Ed | ||
78 | .Pp | ||
79 | The | ||
80 | .Fa nodename | ||
81 | and | ||
82 | .Fa servname | ||
83 | arguments are pointers to null-terminated strings or | ||
84 | .Dv NULL . | ||
85 | One or both of these two arguments must be a | ||
86 | .Pf non Dv -NULL | ||
87 | pointer. | ||
88 | In the normal client scenario, both the | ||
89 | .Fa nodename | ||
90 | and | ||
91 | .Fa servname | ||
92 | are specified. | ||
93 | In the normal server scenario, only the | ||
94 | .Fa servname | ||
95 | is specified. | ||
96 | A | ||
97 | .Pf non Dv -NULL | ||
98 | .Fa nodename | ||
99 | string can be either a node name or a numeric host address string | ||
100 | .Po | ||
101 | i.e., a dotted-decimal IPv4 address or an IPv6 hex address | ||
102 | .Pc . | ||
103 | A | ||
104 | .Pf non Dv -NULL | ||
105 | .Fa servname | ||
106 | string can be either a service name or a decimal port number. | ||
107 | .Pp | ||
108 | The caller can optionally pass an | ||
109 | .Li addrinfo | ||
110 | structure, pointed to by the third argument, | ||
111 | to provide hints concerning the type of socket that the caller supports. | ||
112 | In this | ||
113 | .Fa hints | ||
114 | structure all members other than | ||
115 | .Fa ai_flags , | ||
116 | .Fa ai_family , | ||
117 | .Fa ai_socktype , | ||
118 | and | ||
119 | .Fa ai_protocol | ||
120 | must be zero or a | ||
121 | .Dv NULL | ||
122 | pointer. | ||
123 | A value of | ||
124 | .Dv PF_UNSPEC | ||
125 | for | ||
126 | .Fa ai_family | ||
127 | means the caller will accept any protocol family. | ||
128 | A value of 0 for | ||
129 | .Fa ai_socktype | ||
130 | means the caller will accept any socket type. | ||
131 | A value of 0 for | ||
132 | .Fa ai_protocol | ||
133 | means the caller will accept any protocol. | ||
134 | For example, if the caller handles only TCP and not UDP, then the | ||
135 | .Fa ai_socktype | ||
136 | member of the hints structure should be set to | ||
137 | .Dv SOCK_STREAM | ||
138 | when | ||
139 | .Fn getaddrinfo | ||
140 | is called. | ||
141 | If the caller handles only IPv4 and not IPv6, then the | ||
142 | .Fa ai_family | ||
143 | member of the | ||
144 | .Fa hints | ||
145 | structure should be set to | ||
146 | .Dv PF_INET | ||
147 | when | ||
148 | .Fn getaddrinfo | ||
149 | is called. | ||
150 | If the third argument to | ||
151 | .Fn getaddrinfo | ||
152 | is a | ||
153 | .Dv NULL | ||
154 | pointer, this is the same as if the caller had filled in an | ||
155 | .Li addrinfo | ||
156 | structure initialized to zero with | ||
157 | .Fa ai_family | ||
158 | set to PF_UNSPEC. | ||
159 | .Pp | ||
160 | Upon successful return a pointer to a linked list of one or more | ||
161 | .Li addrinfo | ||
162 | structures is returned through the final argument. | ||
163 | The caller can process each | ||
164 | .Li addrinfo | ||
165 | structure in this list by following the | ||
166 | .Fa ai_next | ||
167 | pointer, until a | ||
168 | .Dv NULL | ||
169 | pointer is encountered. | ||
170 | In each returned | ||
171 | .Li addrinfo | ||
172 | structure the three members | ||
173 | .Fa ai_family , | ||
174 | .Fa ai_socktype , | ||
175 | and | ||
176 | .Fa ai_protocol | ||
177 | are the corresponding arguments for a call to the | ||
178 | .Fn socket | ||
179 | function. | ||
180 | In each | ||
181 | .Li addrinfo | ||
182 | structure the | ||
183 | .Fa ai_addr | ||
184 | member points to a filled-in socket address structure whose length is | ||
185 | specified by the | ||
186 | .Fa ai_addrlen | ||
187 | member. | ||
188 | .Pp | ||
189 | If the | ||
190 | .Dv AI_PASSIVE | ||
191 | bit is set in the | ||
192 | .Fa ai_flags | ||
193 | member of the | ||
194 | .Fa hints | ||
195 | structure, then the caller plans to use the returned socket address | ||
196 | structure in a call to | ||
197 | .Fn bind . | ||
198 | In this case, if the | ||
199 | .Fa nodename | ||
200 | argument is a | ||
201 | .Dv NULL | ||
202 | pointer, then the IP address portion of the socket | ||
203 | address structure will be set to | ||
204 | .Dv INADDR_ANY | ||
205 | for an IPv4 address or | ||
206 | .Dv IN6ADDR_ANY_INIT | ||
207 | for an IPv6 address. | ||
208 | .Pp | ||
209 | If the | ||
210 | .Dv AI_PASSIVE | ||
211 | bit is not set in the | ||
212 | .Fa ai_flags | ||
213 | member of the | ||
214 | .Fa hints | ||
215 | structure, then the returned socket address structure will be ready for a | ||
216 | call to | ||
217 | .Fn connect | ||
218 | .Pq for a connection-oriented protocol | ||
219 | or either | ||
220 | .Fn connect , | ||
221 | .Fn sendto , or | ||
222 | .Fn sendmsg | ||
223 | .Pq for a connectionless protocol . | ||
224 | In this case, if the | ||
225 | .Fa nodename | ||
226 | argument is a | ||
227 | .Dv NULL | ||
228 | pointer, then the IP address portion of the | ||
229 | socket address structure will be set to the loopback address. | ||
230 | .Pp | ||
231 | If the | ||
232 | .Dv AI_CANONNAME | ||
233 | bit is set in the | ||
234 | .Fa ai_flags | ||
235 | member of the | ||
236 | .Fa hints | ||
237 | structure, then upon successful return the | ||
238 | .Fa ai_canonname | ||
239 | member of the first | ||
240 | .Li addrinfo | ||
241 | structure in the linked list will point to a null-terminated string | ||
242 | containing the canonical name of the specified | ||
243 | .Fa nodename . | ||
244 | .Pp | ||
245 | If the | ||
246 | .Dv AI_NUMERICHOST | ||
247 | bit is set in the | ||
248 | .Fa ai_flags | ||
249 | member of the | ||
250 | .Fa hints | ||
251 | structure, then a | ||
252 | .Pf non Dv -NULL | ||
253 | .Fa nodename | ||
254 | string must be a numeric host address string. | ||
255 | Otherwise an error of | ||
256 | .Dv EAI_NONAME | ||
257 | is returned. | ||
258 | This flag prevents any type of name resolution service (e.g., the DNS) | ||
259 | from being called. | ||
260 | .Pp | ||
261 | All of the information returned by | ||
262 | .Fn getaddrinfo | ||
263 | is dynamically allocated: | ||
264 | the | ||
265 | .Li addrinfo | ||
266 | structures, and the socket address structures and canonical node name | ||
267 | strings pointed to by the addrinfo structures. | ||
268 | To return this information to the system the function | ||
269 | .Fn freeaddrinfo | ||
270 | is called. | ||
271 | The | ||
272 | .Fa addrinfo | ||
273 | structure pointed to by the | ||
274 | .Fa ai argument | ||
275 | is freed, along with any dynamic storage pointed to by the structure. | ||
276 | This operation is repeated until a | ||
277 | .Dv NULL | ||
278 | .Fa ai_next | ||
279 | pointer is encountered. | ||
280 | .Pp | ||
281 | To aid applications in printing error messages based on the | ||
282 | .Dv EAI_xxx | ||
283 | codes returned by | ||
284 | .Fn getaddrinfo , | ||
285 | .Fn gai_strerror | ||
286 | is defined. | ||
287 | The argument is one of the | ||
288 | .Dv EAI_xxx | ||
289 | values defined earlier and the return value points to a string describing | ||
290 | the error. | ||
291 | If the argument is not one of the | ||
292 | .Dv EAI_xxx | ||
293 | values, the function still returns a pointer to a string whose contents | ||
294 | indicate an unknown error. | ||
295 | .Sh FILES | ||
296 | .Bl -tag -width /etc/resolv.conf -compact | ||
297 | .It Pa /etc/hosts | ||
298 | .It Pa /etc/host.conf | ||
299 | .It Pa /etc/resolv.conf | ||
300 | .El | ||
301 | .Sh DIAGNOSTICS | ||
302 | Error return status from | ||
303 | .Fn getaddrinfo | ||
304 | is zero on success and non-zero on errors. | ||
305 | Non-zero error codes are defined in | ||
306 | .Li <netdb.h> , | ||
307 | and as follows: | ||
308 | .Pp | ||
309 | .Bl -tag -width EAI_ADDRFAMILY -compact | ||
310 | .It Dv EAI_ADDRFAMILY | ||
311 | address family for nodename not supported | ||
312 | .It Dv EAI_AGAIN | ||
313 | temporary failure in name resolution | ||
314 | .It Dv EAI_BADFLAGS | ||
315 | invalid value for ai_flags | ||
316 | .It Dv EAI_FAIL | ||
317 | non-recoverable failure in name resolution | ||
318 | .It Dv EAI_FAMILY | ||
319 | ai_family not supported | ||
320 | .It Dv EAI_MEMORY | ||
321 | memory allocation failure | ||
322 | .It Dv EAI_NODATA | ||
323 | no address associated with nodename | ||
324 | .It Dv EAI_NONAME | ||
325 | nodename nor servname provided, or not known | ||
326 | .It Dv EAI_SERVICE | ||
327 | servname not supported for ai_socktype | ||
328 | .It Dv EAI_SOCKTYPE | ||
329 | ai_socktype not supported | ||
330 | .It Dv EAI_SYSTEM | ||
331 | system error returned in errno | ||
332 | .El | ||
333 | .Pp | ||
334 | If called with proper argument, | ||
335 | .Fn gai_strerror | ||
336 | returns a pointer to a string describing the given error code. | ||
337 | If the argument is not one of the | ||
338 | .Dv EAI_xxx | ||
339 | values, the function still returns a pointer to a string whose contents | ||
340 | indicate an unknown error. | ||
341 | .Sh SEE ALSO | ||
342 | .Xr getnameinfo 3 , | ||
343 | .Xr gethostbyname 3 , | ||
344 | .Xr getservbyname 3 , | ||
345 | .Xr hosts 5 , | ||
346 | .Xr services 5 , | ||
347 | .Xr hostname 7 , | ||
348 | .Xr named 8 | ||
349 | .Pp | ||
350 | R. Gilligan, S. Thomson, J. Bound, and W. Stevens, | ||
351 | ``Basic Socket Interface Extensions for IPv6,'' RFC2553, March 1999. | ||
352 | .Sh STANDARDS | ||
353 | The | ||
354 | .Fn getaddrinfo | ||
355 | function is defined IEEE POSIX 1003.1g draft specification, | ||
356 | and documented in ``Basic Socket Interface Extensions for IPv6'' | ||
357 | .Pq RFC2533 . | ||
358 | .Sh BUGS | ||
359 | The text was shamelessly copied from RFC2553. | ||
diff --git a/src/lib/libc/net/if_indextoname.3 b/src/lib/libc/net/if_indextoname.3 new file mode 100644 index 0000000000..c8bb212536 --- /dev/null +++ b/src/lib/libc/net/if_indextoname.3 | |||
@@ -0,0 +1,131 @@ | |||
1 | .\" Copyright (c) 1983, 1991, 1993 | ||
2 | .\" The Regents of the University of California. All rights reserved. | ||
3 | .\" | ||
4 | .\" Redistribution and use in source and binary forms, with or without | ||
5 | .\" modification, are permitted provided that the following conditions | ||
6 | .\" are met: | ||
7 | .\" 1. Redistributions of source code must retain the above copyright | ||
8 | .\" notice, this list of conditions and the following disclaimer. | ||
9 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
10 | .\" notice, this list of conditions and the following disclaimer in the | ||
11 | .\" documentation and/or other materials provided with the distribution. | ||
12 | .\" 3. All advertising materials mentioning features or use of this software | ||
13 | .\" must display the following acknowledgement: | ||
14 | .\" This product includes software developed by the University of | ||
15 | .\" California, Berkeley and its contributors. | ||
16 | .\" 4. Neither the name of the University nor the names of its contributors | ||
17 | .\" may be used to endorse or promote products derived from this software | ||
18 | .\" without specific prior written permission. | ||
19 | .\" | ||
20 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
21 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
23 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
24 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
25 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
26 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
27 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
28 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
30 | .\" SUCH DAMAGE. | ||
31 | .\" | ||
32 | .\" From: @(#)rcmd.3 8.1 (Berkeley) 6/4/93 | ||
33 | .\" $Id: if_indextoname.3,v 1.1 1999/07/03 20:22:21 deraadt Exp $ | ||
34 | .\" | ||
35 | .Dd May 21, 1998 | ||
36 | .Dt IF_NAMETOINDEX 3 | ||
37 | .Os KAME | ||
38 | .Sh NAME | ||
39 | .Nm if_nametoindex , | ||
40 | .Nm if_indextoname , | ||
41 | .Nm if_nameindex , | ||
42 | .Nd convert interface index to name, and vice versa | ||
43 | .Sh SYNOPSIS | ||
44 | .Fd #include <net/if.h> | ||
45 | .Ft "unsigned int" | ||
46 | .Fn if_nametoindex "const char *ifname" | ||
47 | .Ft "char *" | ||
48 | .Fn if_indextoname "unsigned int ifindex" "char *ifname" | ||
49 | .Ft "struct if_nameindex *" | ||
50 | .Fn if_nameindex "void" | ||
51 | .Ft "void" | ||
52 | .Sh DESCRIPTION | ||
53 | The functions map interface index to readable interface name | ||
54 | .Po | ||
55 | such as | ||
56 | .Li ``lo0'' | ||
57 | .Pc | ||
58 | , and vice versa. | ||
59 | .Pp | ||
60 | .Fn if_nametoindex | ||
61 | converts readable interface name to interface index | ||
62 | .Pp positive integer value . | ||
63 | If the specified interface does not exist, 0 will be returned. | ||
64 | .Pp | ||
65 | .Fn if_indextoname | ||
66 | converts interface index to readable interface name. | ||
67 | The | ||
68 | .Fa ifname | ||
69 | argument must point to a buffer of at least | ||
70 | .Dv IF_NAMESIZE | ||
71 | bytes into which the interface name corresponding to the specified index is | ||
72 | returned. | ||
73 | .Po | ||
74 | .Dv IF_NAMESIZE | ||
75 | is also defined in | ||
76 | .Li <net/if.h> | ||
77 | and its value includes a terminating null byte at the end of the | ||
78 | interface name. | ||
79 | .Pc | ||
80 | This pointer is also the return value of the function. | ||
81 | If there is no interface corresponding to the specified index, | ||
82 | .Dv NULL | ||
83 | is returned. | ||
84 | .Pp | ||
85 | .Fn if_nameindex | ||
86 | returns an array of | ||
87 | .Fa if_nameindex | ||
88 | structures. | ||
89 | .Fa if_nametoindex | ||
90 | is also defined in | ||
91 | .Li <net/if.h> , | ||
92 | and is as follows: | ||
93 | .Bd -literal -offset | ||
94 | struct if_nameindex { | ||
95 | unsigned int if_index; /* 1, 2, ... */ | ||
96 | char *if_name; /* null terminated name: "le0", ... */ | ||
97 | }; | ||
98 | .Ed | ||
99 | .Pp | ||
100 | The end of the array of structures is indicated by a structure with | ||
101 | an | ||
102 | .Fa if_index | ||
103 | of 0 and an | ||
104 | .Fa if_name | ||
105 | of | ||
106 | .Dv NULL . | ||
107 | The function returns a | ||
108 | .Dv NULL | ||
109 | pointer upon an error. | ||
110 | The memory used for this array of structures along with the interface | ||
111 | names pointed to by the | ||
112 | .Fa if_name | ||
113 | members is obtained dynamically. | ||
114 | This memory is freed by the | ||
115 | .Xr free 3 | ||
116 | function. | ||
117 | .Sh DIAGNOSTICS | ||
118 | .Fn if_nametoindex | ||
119 | returns 0 on error, positive integer on success. | ||
120 | .Fn if_indextoname | ||
121 | and | ||
122 | .Fn if_nameindex | ||
123 | return | ||
124 | .Dv NULL | ||
125 | on errors. | ||
126 | .Sh SEE ALSO | ||
127 | R. Gilligan, S. Thomson, J. Bound, and W. Stevens, | ||
128 | ``Basic Socket Interface Extensions for IPv6,'' RFC2553, March 1999. | ||
129 | .Sh STANDARDS | ||
130 | These functions are defined in ``Basic Socket Interface Extensions for IPv6'' | ||
131 | .Pq RFC2533 . | ||