summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorderaadt <>1999-07-03 20:22:21 +0000
committerderaadt <>1999-07-03 20:22:21 +0000
commitc078dc2c32bc3dbb78efe49ded77e3dbf16e00c6 (patch)
tree479ca631e7f3c5da9c302d6639d79e2eba03b9a8 /src/lib
parentd3448bc163f4d5dfba64b773db80a0206f7ce0fc (diff)
downloadopenbsd-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.inc10
-rw-r--r--src/lib/libc/net/getaddrinfo.3359
-rw-r--r--src/lib/libc/net/if_indextoname.3131
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
28MAN+= byteorder.3 ethers.3 gethostbyname.3 getnetent.3 getprotoent.3 \ 28MAN+= 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
33MLINKS+= getnameinfo.3 freeaddrinfo.3
34MLINKS+= getnameinfo.3 gai_strerror.3
35MLINKS+= if_indextoname.3 if_nametoindex.3
36MLINKS+= if_indextoname.3 if_nameindex.3
31 37
32MLINKS+=byteorder.3 htonl.3 byteorder.3 htons.3 byteorder.3 ntohl.3 \ 38MLINKS+=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
54The
55.Fn getaddrinfo
56function is defined for protocol-independent nodename-to-address translation.
57It performs functionality of
58.Xr gethostbyname 3
59and
60.Xr getservbyname 3 ,
61in more sophisticated manner.
62.Pp
63The addrinfo structure is defined as a result of including the
64.Li <netdb.h>
65header:
66.Bd -literal -offset
67struct 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
79The
80.Fa nodename
81and
82.Fa servname
83arguments are pointers to null-terminated strings or
84.Dv NULL .
85One or both of these two arguments must be a
86.Pf non Dv -NULL
87pointer.
88In the normal client scenario, both the
89.Fa nodename
90and
91.Fa servname
92are specified.
93In the normal server scenario, only the
94.Fa servname
95is specified.
96A
97.Pf non Dv -NULL
98.Fa nodename
99string can be either a node name or a numeric host address string
100.Po
101i.e., a dotted-decimal IPv4 address or an IPv6 hex address
102.Pc .
103A
104.Pf non Dv -NULL
105.Fa servname
106string can be either a service name or a decimal port number.
107.Pp
108The caller can optionally pass an
109.Li addrinfo
110structure, pointed to by the third argument,
111to provide hints concerning the type of socket that the caller supports.
112In this
113.Fa hints
114structure all members other than
115.Fa ai_flags ,
116.Fa ai_family ,
117.Fa ai_socktype ,
118and
119.Fa ai_protocol
120must be zero or a
121.Dv NULL
122pointer.
123A value of
124.Dv PF_UNSPEC
125for
126.Fa ai_family
127means the caller will accept any protocol family.
128A value of 0 for
129.Fa ai_socktype
130means the caller will accept any socket type.
131A value of 0 for
132.Fa ai_protocol
133means the caller will accept any protocol.
134For example, if the caller handles only TCP and not UDP, then the
135.Fa ai_socktype
136member of the hints structure should be set to
137.Dv SOCK_STREAM
138when
139.Fn getaddrinfo
140is called.
141If the caller handles only IPv4 and not IPv6, then the
142.Fa ai_family
143member of the
144.Fa hints
145structure should be set to
146.Dv PF_INET
147when
148.Fn getaddrinfo
149is called.
150If the third argument to
151.Fn getaddrinfo
152is a
153.Dv NULL
154pointer, this is the same as if the caller had filled in an
155.Li addrinfo
156structure initialized to zero with
157.Fa ai_family
158set to PF_UNSPEC.
159.Pp
160Upon successful return a pointer to a linked list of one or more
161.Li addrinfo
162structures is returned through the final argument.
163The caller can process each
164.Li addrinfo
165structure in this list by following the
166.Fa ai_next
167pointer, until a
168.Dv NULL
169pointer is encountered.
170In each returned
171.Li addrinfo
172structure the three members
173.Fa ai_family ,
174.Fa ai_socktype ,
175and
176.Fa ai_protocol
177are the corresponding arguments for a call to the
178.Fn socket
179function.
180In each
181.Li addrinfo
182structure the
183.Fa ai_addr
184member points to a filled-in socket address structure whose length is
185specified by the
186.Fa ai_addrlen
187member.
188.Pp
189If the
190.Dv AI_PASSIVE
191bit is set in the
192.Fa ai_flags
193member of the
194.Fa hints
195structure, then the caller plans to use the returned socket address
196structure in a call to
197.Fn bind .
198In this case, if the
199.Fa nodename
200argument is a
201.Dv NULL
202pointer, then the IP address portion of the socket
203address structure will be set to
204.Dv INADDR_ANY
205for an IPv4 address or
206.Dv IN6ADDR_ANY_INIT
207for an IPv6 address.
208.Pp
209If the
210.Dv AI_PASSIVE
211bit is not set in the
212.Fa ai_flags
213member of the
214.Fa hints
215structure, then the returned socket address structure will be ready for a
216call to
217.Fn connect
218.Pq for a connection-oriented protocol
219or either
220.Fn connect ,
221.Fn sendto , or
222.Fn sendmsg
223.Pq for a connectionless protocol .
224In this case, if the
225.Fa nodename
226argument is a
227.Dv NULL
228pointer, then the IP address portion of the
229socket address structure will be set to the loopback address.
230.Pp
231If the
232.Dv AI_CANONNAME
233bit is set in the
234.Fa ai_flags
235member of the
236.Fa hints
237structure, then upon successful return the
238.Fa ai_canonname
239member of the first
240.Li addrinfo
241structure in the linked list will point to a null-terminated string
242containing the canonical name of the specified
243.Fa nodename .
244.Pp
245If the
246.Dv AI_NUMERICHOST
247bit is set in the
248.Fa ai_flags
249member of the
250.Fa hints
251structure, then a
252.Pf non Dv -NULL
253.Fa nodename
254string must be a numeric host address string.
255Otherwise an error of
256.Dv EAI_NONAME
257is returned.
258This flag prevents any type of name resolution service (e.g., the DNS)
259from being called.
260.Pp
261All of the information returned by
262.Fn getaddrinfo
263is dynamically allocated:
264the
265.Li addrinfo
266structures, and the socket address structures and canonical node name
267strings pointed to by the addrinfo structures.
268To return this information to the system the function
269.Fn freeaddrinfo
270is called.
271The
272.Fa addrinfo
273structure pointed to by the
274.Fa ai argument
275is freed, along with any dynamic storage pointed to by the structure.
276This operation is repeated until a
277.Dv NULL
278.Fa ai_next
279pointer is encountered.
280.Pp
281To aid applications in printing error messages based on the
282.Dv EAI_xxx
283codes returned by
284.Fn getaddrinfo ,
285.Fn gai_strerror
286is defined.
287The argument is one of the
288.Dv EAI_xxx
289values defined earlier and the return value points to a string describing
290the error.
291If the argument is not one of the
292.Dv EAI_xxx
293values, the function still returns a pointer to a string whose contents
294indicate 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
302Error return status from
303.Fn getaddrinfo
304is zero on success and non-zero on errors.
305Non-zero error codes are defined in
306.Li <netdb.h> ,
307and as follows:
308.Pp
309.Bl -tag -width EAI_ADDRFAMILY -compact
310.It Dv EAI_ADDRFAMILY
311address family for nodename not supported
312.It Dv EAI_AGAIN
313temporary failure in name resolution
314.It Dv EAI_BADFLAGS
315invalid value for ai_flags
316.It Dv EAI_FAIL
317non-recoverable failure in name resolution
318.It Dv EAI_FAMILY
319ai_family not supported
320.It Dv EAI_MEMORY
321memory allocation failure
322.It Dv EAI_NODATA
323no address associated with nodename
324.It Dv EAI_NONAME
325nodename nor servname provided, or not known
326.It Dv EAI_SERVICE
327servname not supported for ai_socktype
328.It Dv EAI_SOCKTYPE
329ai_socktype not supported
330.It Dv EAI_SYSTEM
331system error returned in errno
332.El
333.Pp
334If called with proper argument,
335.Fn gai_strerror
336returns a pointer to a string describing the given error code.
337If the argument is not one of the
338.Dv EAI_xxx
339values, the function still returns a pointer to a string whose contents
340indicate 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
350R. Gilligan, S. Thomson, J. Bound, and W. Stevens,
351``Basic Socket Interface Extensions for IPv6,'' RFC2553, March 1999.
352.Sh STANDARDS
353The
354.Fn getaddrinfo
355function is defined IEEE POSIX 1003.1g draft specification,
356and documented in ``Basic Socket Interface Extensions for IPv6''
357.Pq RFC2533 .
358.Sh BUGS
359The 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
53The functions map interface index to readable interface name
54.Po
55such as
56.Li ``lo0''
57.Pc
58, and vice versa.
59.Pp
60.Fn if_nametoindex
61converts readable interface name to interface index
62.Pp positive integer value .
63If the specified interface does not exist, 0 will be returned.
64.Pp
65.Fn if_indextoname
66converts interface index to readable interface name.
67The
68.Fa ifname
69argument must point to a buffer of at least
70.Dv IF_NAMESIZE
71bytes into which the interface name corresponding to the specified index is
72returned.
73.Po
74.Dv IF_NAMESIZE
75is also defined in
76.Li <net/if.h>
77and its value includes a terminating null byte at the end of the
78interface name.
79.Pc
80This pointer is also the return value of the function.
81If there is no interface corresponding to the specified index,
82.Dv NULL
83is returned.
84.Pp
85.Fn if_nameindex
86returns an array of
87.Fa if_nameindex
88structures.
89.Fa if_nametoindex
90is also defined in
91.Li <net/if.h> ,
92and is as follows:
93.Bd -literal -offset
94struct if_nameindex {
95 unsigned int if_index; /* 1, 2, ... */
96 char *if_name; /* null terminated name: "le0", ... */
97};
98.Ed
99.Pp
100The end of the array of structures is indicated by a structure with
101an
102.Fa if_index
103of 0 and an
104.Fa if_name
105of
106.Dv NULL .
107The function returns a
108.Dv NULL
109pointer upon an error.
110The memory used for this array of structures along with the interface
111names pointed to by the
112.Fa if_name
113members is obtained dynamically.
114This memory is freed by the
115.Xr free 3
116function.
117.Sh DIAGNOSTICS
118.Fn if_nametoindex
119returns 0 on error, positive integer on success.
120.Fn if_indextoname
121and
122.Fn if_nameindex
123return
124.Dv NULL
125on errors.
126.Sh SEE ALSO
127R. Gilligan, S. Thomson, J. Bound, and W. Stevens,
128``Basic Socket Interface Extensions for IPv6,'' RFC2553, March 1999.
129.Sh STANDARDS
130These functions are defined in ``Basic Socket Interface Extensions for IPv6''
131.Pq RFC2533 .