summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorderaadt <>1999-07-03 20:26:55 +0000
committerderaadt <>1999-07-03 20:26:55 +0000
commitfa1ff4d7c9e3e11ade89bbcf0fdb6d4a24cc8eae (patch)
tree0e20e61bfdadc60456daf40355efcd3f27316282
parentc078dc2c32bc3dbb78efe49ded77e3dbf16e00c6 (diff)
downloadopenbsd-fa1ff4d7c9e3e11ade89bbcf0fdb6d4a24cc8eae.tar.gz
openbsd-fa1ff4d7c9e3e11ade89bbcf0fdb6d4a24cc8eae.tar.bz2
openbsd-fa1ff4d7c9e3e11ade89bbcf0fdb6d4a24cc8eae.zip
cleaner
-rw-r--r--src/lib/libc/net/Makefile.inc6
-rw-r--r--src/lib/libc/net/getaddrinfo.312
-rw-r--r--src/lib/libc/net/getnameinfo.3199
3 files changed, 208 insertions, 9 deletions
diff --git a/src/lib/libc/net/Makefile.inc b/src/lib/libc/net/Makefile.inc
index 66e4794057..7b44515aa9 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.22 1999/07/03 20:22:21 deraadt Exp $ 1# $OpenBSD: Makefile.inc,v 1.23 1999/07/03 20:26:55 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
@@ -30,8 +30,8 @@ MAN+= byteorder.3 ethers.3 gethostbyname.3 getnetent.3 getprotoent.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 31 getnameinfo.3 getaddrinfo.3 if_indextoname.3
32 32
33MLINKS+= getnameinfo.3 freeaddrinfo.3 33MLINKS+= getaddrinfo.3 freeaddrinfo.3
34MLINKS+= getnameinfo.3 gai_strerror.3 34MLINKS+= getaddrinfo.3 gai_strerror.3
35MLINKS+= if_indextoname.3 if_nametoindex.3 35MLINKS+= if_indextoname.3 if_nametoindex.3
36MLINKS+= if_indextoname.3 if_nameindex.3 36MLINKS+= if_indextoname.3 if_nameindex.3
37 37
diff --git a/src/lib/libc/net/getaddrinfo.3 b/src/lib/libc/net/getaddrinfo.3
index cff60d9d4e..5d644ba549 100644
--- a/src/lib/libc/net/getaddrinfo.3
+++ b/src/lib/libc/net/getaddrinfo.3
@@ -30,7 +30,7 @@
30.\" SUCH DAMAGE. 30.\" SUCH DAMAGE.
31.\" 31.\"
32.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 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 $ 33.\" $Id: getaddrinfo.3,v 1.2 1999/07/03 20:26:55 deraadt Exp $
34.\" 34.\"
35.Dd May 25, 1995 35.Dd May 25, 1995
36.Dt GETADDRINFO 3 36.Dt GETADDRINFO 3
@@ -54,11 +54,11 @@
54The 54The
55.Fn getaddrinfo 55.Fn getaddrinfo
56function is defined for protocol-independent nodename-to-address translation. 56function is defined for protocol-independent nodename-to-address translation.
57It performs functionality of 57It performs the functionality of
58.Xr gethostbyname 3 58.Xr gethostbyname 3
59and 59and
60.Xr getservbyname 3 , 60.Xr getservbyname 3 ,
61in more sophisticated manner. 61but in a more sophisticated manner.
62.Pp 62.Pp
63The addrinfo structure is defined as a result of including the 63The addrinfo structure is defined as a result of including the
64.Li <netdb.h> 64.Li <netdb.h>
@@ -256,7 +256,7 @@ Otherwise an error of
256.Dv EAI_NONAME 256.Dv EAI_NONAME
257is returned. 257is returned.
258This flag prevents any type of name resolution service (e.g., the DNS) 258This flag prevents any type of name resolution service (e.g., the DNS)
259from being called. 259from being called.
260.Pp 260.Pp
261All of the information returned by 261All of the information returned by
262.Fn getaddrinfo 262.Fn getaddrinfo
@@ -299,7 +299,7 @@ indicate an unknown error.
299.It Pa /etc/resolv.conf 299.It Pa /etc/resolv.conf
300.El 300.El
301.Sh DIAGNOSTICS 301.Sh DIAGNOSTICS
302Error return status from 302Error return status from
303.Fn getaddrinfo 303.Fn getaddrinfo
304is zero on success and non-zero on errors. 304is zero on success and non-zero on errors.
305Non-zero error codes are defined in 305Non-zero error codes are defined in
@@ -307,7 +307,7 @@ Non-zero error codes are defined in
307and as follows: 307and as follows:
308.Pp 308.Pp
309.Bl -tag -width EAI_ADDRFAMILY -compact 309.Bl -tag -width EAI_ADDRFAMILY -compact
310.It Dv EAI_ADDRFAMILY 310.It Dv EAI_ADDRFAMILY
311address family for nodename not supported 311address family for nodename not supported
312.It Dv EAI_AGAIN 312.It Dv EAI_AGAIN
313temporary failure in name resolution 313temporary failure in name resolution
diff --git a/src/lib/libc/net/getnameinfo.3 b/src/lib/libc/net/getnameinfo.3
new file mode 100644
index 0000000000..a1b3bdabb6
--- /dev/null
+++ b/src/lib/libc/net/getnameinfo.3
@@ -0,0 +1,199 @@
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: getnameinfo.3,v 1.1 1999/07/03 20:26:55 deraadt Exp $
34.\"
35.Dd May 25, 1995
36.Dt GETNAMEINFO 3
37.Os KAME
38.Sh NAME
39.Nm getnameinfo
40.Nd address-to-nodename translation in protocol-independent manner
41.Sh SYNOPSIS
42.Fd #include <sys/socket.h>
43.Fd #include <netdb.h>
44.Ft int
45.Fn getnameinfo "const struct sockaddr *sa" "socklen_t salen" \
46"char *host" "size_t hostlen" "char *serv" "size_t servlen" "int flags"
47.Sh DESCRIPTION
48The
49.Fn getnameinfo
50function is defined for protocol-independent address-to-nodename translation.
51Its functionality is a reverse conversion of
52.Xr getaddrinfo 3 ,
53and implements similar functionality with
54.Xr gethostbyaddr 3 and
55.Xr getservbyport 3
56in more sophisticated manner.
57.Pp
58This function looks up an IP address and port number provided by the
59caller in the DNS and system-specific database, and returns text
60strings for both in buffers provided by the caller.
61The function indicates successful completion by a zero return value;
62a non-zero return value indicates failure.
63.Pp
64The first argument,
65.Fa sa ,
66points to either a
67.Fa sockaddr_in
68structure (for IPv4) or a
69.Fa sockaddr_in6
70structure (for IPv6) that holds the IP address and port number.
71The
72.Fa salen
73argument gives the length of the
74.Fa sockaddr_in
75or
76.Fa sockaddr_in6
77structure.
78.Pp
79The function returns the nodename associated with the IP address in
80the buffer pointed to by the
81.Fa host
82argument.
83The caller provides the size of this buffer via the
84.Fa hostlen
85argument.
86The service name associated with the port number is returned in the buffer
87pointed to by
88.Fa serv ,
89and the
90.Fa servlen
91argument gives the length of this buffer.
92The caller specifies not to return either string by providing a zero
93value for the
94.Fa hostlen
95or
96.Fa servlen
97arguments.
98Otherwise, the caller must provide buffers large enough to hold the
99nodename and the service name, including the terminating null characters.
100.Pp
101Unfortunately most systems do not provide constants that specify the
102maximum size of either a fully-qualified domain name or a service name.
103Therefore to aid the application in allocating buffers for these two
104returned strings the following constants are defined in
105.Li <netdb.h> :
106.Bd -literal -offset
107#define NI_MAXHOST 1025
108#define NI_MAXSERV 32
109.Ed
110.Pp
111The first value is actually defined as the constant
112.Dv MAXDNAME
113in recent versions of BIND's
114.Li <arpa/nameser.h>
115header
116.Po
117older versions of BIND define this constant to be 256
118.Pc
119and the second is a guess based on the services listed in the current
120Assigned Numbers RFC.
121.Pp
122The final argument is a
123.Fa flag
124that changes the default actions of this function.
125By default the fully-qualified domain name (FQDN) for the host is
126looked up in the DNS and returned.
127If the flag bit
128.Dv NI_NOFQDN
129is set, only the nodename portion of the FQDN is returned for local hosts.
130.Pp
131If the
132.Fa flag
133bit
134.Dv NI_NUMERICHOST
135is set, or if the host's name cannot be located in the DNS,
136the numeric form of the host's address is returned instead of its name
137.Po
138e.g., by calling
139.Fn inet_ntop
140instead of
141.Fn getnodebyaddr
142.Pc .
143If the
144.Fa flag
145bit
146.Dv NI_NAMEREQD
147is set, an error is returned if the host's name cannot be located in the DNS.
148.Pp
149If the flag bit
150.Dv NI_NUMERICSERV
151is set, the numeric form of the service address is returned
152.Pq e.g., its port number
153instead of its name.
154The two
155.Dv NI_NUMERICxxx
156flags are required to support the
157.Li "-n"
158flag that many commands provide.
159.Pp
160A fifth flag bit,
161.Dv NI_DGRAM ,
162specifies that the service is a datagram service, and causes
163.Fn getservbyport
164to be called with a second argument of "udp" instead of its default of "tcp".
165This is required for the few ports (512-514)
166that have different services for UDP and TCP.
167.Pp
168These
169.Dv NI_xxx
170flags are defined in
171.Li <netdb.h> .
172.Sh FILES
173.Bl -tag -width /etc/resolv.conf -compact
174.It Pa /etc/hosts
175.It Pa /etc/host.conf
176.It Pa /etc/resolv.conf
177.El
178.Sh DIAGNOSTICS
179The function indicates successful completion by a zero return value;
180a non-zero return value indicates failure.
181.Sh SEE ALSO
182.Xr getaddrinfo 3 ,
183.Xr gethostbyaddr 3 ,
184.Xr getservbyport 3 ,
185.Xr hosts 5 ,
186.Xr services 5 ,
187.Xr hostname 7 ,
188.Xr named 8
189.Pp
190R. Gilligan, S. Thomson, J. Bound, and W. Stevens,
191``Basic Socket Interface Extensions for IPv6,'' RFC2553, March 1999.
192.Sh STANDARDS
193The
194.Fn getaddrinfo
195function is defined IEEE POSIX 1003.1g draft specification,
196and documented in ``Basic Socket Interface Extensions for IPv6''
197.Pq RFC2533 .
198.Sh BUGS
199The text was shamelessly copied from RFC2553.