diff options
author | deraadt <> | 1999-07-03 20:26:55 +0000 |
---|---|---|
committer | deraadt <> | 1999-07-03 20:26:55 +0000 |
commit | fa1ff4d7c9e3e11ade89bbcf0fdb6d4a24cc8eae (patch) | |
tree | 0e20e61bfdadc60456daf40355efcd3f27316282 | |
parent | c078dc2c32bc3dbb78efe49ded77e3dbf16e00c6 (diff) | |
download | openbsd-fa1ff4d7c9e3e11ade89bbcf0fdb6d4a24cc8eae.tar.gz openbsd-fa1ff4d7c9e3e11ade89bbcf0fdb6d4a24cc8eae.tar.bz2 openbsd-fa1ff4d7c9e3e11ade89bbcf0fdb6d4a24cc8eae.zip |
cleaner
-rw-r--r-- | src/lib/libc/net/Makefile.inc | 6 | ||||
-rw-r--r-- | src/lib/libc/net/getaddrinfo.3 | 12 | ||||
-rw-r--r-- | src/lib/libc/net/getnameinfo.3 | 199 |
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 | ||
33 | MLINKS+= getnameinfo.3 freeaddrinfo.3 | 33 | MLINKS+= getaddrinfo.3 freeaddrinfo.3 |
34 | MLINKS+= getnameinfo.3 gai_strerror.3 | 34 | MLINKS+= getaddrinfo.3 gai_strerror.3 |
35 | MLINKS+= if_indextoname.3 if_nametoindex.3 | 35 | MLINKS+= if_indextoname.3 if_nametoindex.3 |
36 | MLINKS+= if_indextoname.3 if_nameindex.3 | 36 | MLINKS+= 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 @@ | |||
54 | The | 54 | The |
55 | .Fn getaddrinfo | 55 | .Fn getaddrinfo |
56 | function is defined for protocol-independent nodename-to-address translation. | 56 | function is defined for protocol-independent nodename-to-address translation. |
57 | It performs functionality of | 57 | It performs the functionality of |
58 | .Xr gethostbyname 3 | 58 | .Xr gethostbyname 3 |
59 | and | 59 | and |
60 | .Xr getservbyname 3 , | 60 | .Xr getservbyname 3 , |
61 | in more sophisticated manner. | 61 | but in a more sophisticated manner. |
62 | .Pp | 62 | .Pp |
63 | The addrinfo structure is defined as a result of including the | 63 | The 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 |
257 | is returned. | 257 | is returned. |
258 | This flag prevents any type of name resolution service (e.g., the DNS) | 258 | This flag prevents any type of name resolution service (e.g., the DNS) |
259 | from being called. | 259 | from being called. |
260 | .Pp | 260 | .Pp |
261 | All of the information returned by | 261 | All 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 |
302 | Error return status from | 302 | Error return status from |
303 | .Fn getaddrinfo | 303 | .Fn getaddrinfo |
304 | is zero on success and non-zero on errors. | 304 | is zero on success and non-zero on errors. |
305 | Non-zero error codes are defined in | 305 | Non-zero error codes are defined in |
@@ -307,7 +307,7 @@ Non-zero error codes are defined in | |||
307 | and as follows: | 307 | and 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 |
311 | address family for nodename not supported | 311 | address family for nodename not supported |
312 | .It Dv EAI_AGAIN | 312 | .It Dv EAI_AGAIN |
313 | temporary failure in name resolution | 313 | temporary 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 | ||
48 | The | ||
49 | .Fn getnameinfo | ||
50 | function is defined for protocol-independent address-to-nodename translation. | ||
51 | Its functionality is a reverse conversion of | ||
52 | .Xr getaddrinfo 3 , | ||
53 | and implements similar functionality with | ||
54 | .Xr gethostbyaddr 3 and | ||
55 | .Xr getservbyport 3 | ||
56 | in more sophisticated manner. | ||
57 | .Pp | ||
58 | This function looks up an IP address and port number provided by the | ||
59 | caller in the DNS and system-specific database, and returns text | ||
60 | strings for both in buffers provided by the caller. | ||
61 | The function indicates successful completion by a zero return value; | ||
62 | a non-zero return value indicates failure. | ||
63 | .Pp | ||
64 | The first argument, | ||
65 | .Fa sa , | ||
66 | points to either a | ||
67 | .Fa sockaddr_in | ||
68 | structure (for IPv4) or a | ||
69 | .Fa sockaddr_in6 | ||
70 | structure (for IPv6) that holds the IP address and port number. | ||
71 | The | ||
72 | .Fa salen | ||
73 | argument gives the length of the | ||
74 | .Fa sockaddr_in | ||
75 | or | ||
76 | .Fa sockaddr_in6 | ||
77 | structure. | ||
78 | .Pp | ||
79 | The function returns the nodename associated with the IP address in | ||
80 | the buffer pointed to by the | ||
81 | .Fa host | ||
82 | argument. | ||
83 | The caller provides the size of this buffer via the | ||
84 | .Fa hostlen | ||
85 | argument. | ||
86 | The service name associated with the port number is returned in the buffer | ||
87 | pointed to by | ||
88 | .Fa serv , | ||
89 | and the | ||
90 | .Fa servlen | ||
91 | argument gives the length of this buffer. | ||
92 | The caller specifies not to return either string by providing a zero | ||
93 | value for the | ||
94 | .Fa hostlen | ||
95 | or | ||
96 | .Fa servlen | ||
97 | arguments. | ||
98 | Otherwise, the caller must provide buffers large enough to hold the | ||
99 | nodename and the service name, including the terminating null characters. | ||
100 | .Pp | ||
101 | Unfortunately most systems do not provide constants that specify the | ||
102 | maximum size of either a fully-qualified domain name or a service name. | ||
103 | Therefore to aid the application in allocating buffers for these two | ||
104 | returned 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 | ||
111 | The first value is actually defined as the constant | ||
112 | .Dv MAXDNAME | ||
113 | in recent versions of BIND's | ||
114 | .Li <arpa/nameser.h> | ||
115 | header | ||
116 | .Po | ||
117 | older versions of BIND define this constant to be 256 | ||
118 | .Pc | ||
119 | and the second is a guess based on the services listed in the current | ||
120 | Assigned Numbers RFC. | ||
121 | .Pp | ||
122 | The final argument is a | ||
123 | .Fa flag | ||
124 | that changes the default actions of this function. | ||
125 | By default the fully-qualified domain name (FQDN) for the host is | ||
126 | looked up in the DNS and returned. | ||
127 | If the flag bit | ||
128 | .Dv NI_NOFQDN | ||
129 | is set, only the nodename portion of the FQDN is returned for local hosts. | ||
130 | .Pp | ||
131 | If the | ||
132 | .Fa flag | ||
133 | bit | ||
134 | .Dv NI_NUMERICHOST | ||
135 | is set, or if the host's name cannot be located in the DNS, | ||
136 | the numeric form of the host's address is returned instead of its name | ||
137 | .Po | ||
138 | e.g., by calling | ||
139 | .Fn inet_ntop | ||
140 | instead of | ||
141 | .Fn getnodebyaddr | ||
142 | .Pc . | ||
143 | If the | ||
144 | .Fa flag | ||
145 | bit | ||
146 | .Dv NI_NAMEREQD | ||
147 | is set, an error is returned if the host's name cannot be located in the DNS. | ||
148 | .Pp | ||
149 | If the flag bit | ||
150 | .Dv NI_NUMERICSERV | ||
151 | is set, the numeric form of the service address is returned | ||
152 | .Pq e.g., its port number | ||
153 | instead of its name. | ||
154 | The two | ||
155 | .Dv NI_NUMERICxxx | ||
156 | flags are required to support the | ||
157 | .Li "-n" | ||
158 | flag that many commands provide. | ||
159 | .Pp | ||
160 | A fifth flag bit, | ||
161 | .Dv NI_DGRAM , | ||
162 | specifies that the service is a datagram service, and causes | ||
163 | .Fn getservbyport | ||
164 | to be called with a second argument of "udp" instead of its default of "tcp". | ||
165 | This is required for the few ports (512-514) | ||
166 | that have different services for UDP and TCP. | ||
167 | .Pp | ||
168 | These | ||
169 | .Dv NI_xxx | ||
170 | flags 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 | ||
179 | The function indicates successful completion by a zero return value; | ||
180 | a 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 | ||
190 | R. Gilligan, S. Thomson, J. Bound, and W. Stevens, | ||
191 | ``Basic Socket Interface Extensions for IPv6,'' RFC2553, March 1999. | ||
192 | .Sh STANDARDS | ||
193 | The | ||
194 | .Fn getaddrinfo | ||
195 | function is defined IEEE POSIX 1003.1g draft specification, | ||
196 | and documented in ``Basic Socket Interface Extensions for IPv6'' | ||
197 | .Pq RFC2533 . | ||
198 | .Sh BUGS | ||
199 | The text was shamelessly copied from RFC2553. | ||