diff options
author | itojun <> | 2000-01-17 08:16:58 +0000 |
---|---|---|
committer | itojun <> | 2000-01-17 08:16:58 +0000 |
commit | 2bfc7e66c2e632f418c7896053db7d24d893e473 (patch) | |
tree | 0c113eaa5f183d2778cbc68b9cd6f926d528eae6 /src/lib/libc/net/getnameinfo.3 | |
parent | 10703049627aeae9e576798dac91d9f903cf661b (diff) | |
download | openbsd-2bfc7e66c2e632f418c7896053db7d24d893e473.tar.gz openbsd-2bfc7e66c2e632f418c7896053db7d24d893e473.tar.bz2 openbsd-2bfc7e66c2e632f418c7896053db7d24d893e473.zip |
sync with latest KAME version. now includes description on scoped addr
extension. add examples (good enough? >deraadt)
Diffstat (limited to 'src/lib/libc/net/getnameinfo.3')
-rw-r--r-- | src/lib/libc/net/getnameinfo.3 | 77 |
1 files changed, 74 insertions, 3 deletions
diff --git a/src/lib/libc/net/getnameinfo.3 b/src/lib/libc/net/getnameinfo.3 index 98e4c2e866..2dd1bce4d6 100644 --- a/src/lib/libc/net/getnameinfo.3 +++ b/src/lib/libc/net/getnameinfo.3 | |||
@@ -1,3 +1,5 @@ | |||
1 | .\" $OpenBSD: getnameinfo.3,v 1.4 2000/01/17 08:16:58 itojun Exp $ | ||
2 | .\" | ||
1 | .\" Copyright (c) 1983, 1987, 1991, 1993 | 3 | .\" Copyright (c) 1983, 1987, 1991, 1993 |
2 | .\" The Regents of the University of California. All rights reserved. | 4 | .\" The Regents of the University of California. All rights reserved. |
3 | .\" | 5 | .\" |
@@ -30,14 +32,16 @@ | |||
30 | .\" SUCH DAMAGE. | 32 | .\" SUCH DAMAGE. |
31 | .\" | 33 | .\" |
32 | .\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 | 34 | .\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 |
33 | .\" $Id: getnameinfo.3,v 1.3 2000/01/06 22:00:18 deraadt Exp $ | 35 | .\" KAME Id: getnameinfo.3,v 1.7 2000/01/17 08:13:04 itojun Exp |
34 | .\" | 36 | .\" |
35 | .Dd May 25, 1995 | 37 | .Dd May 25, 1995 |
36 | .Dt GETNAMEINFO 3 | 38 | .Dt GETNAMEINFO 3 |
37 | .Os | 39 | .Os |
40 | .\" | ||
38 | .Sh NAME | 41 | .Sh NAME |
39 | .Nm getnameinfo | 42 | .Nm getnameinfo |
40 | .Nd address-to-nodename translation in protocol-independent manner | 43 | .Nd address-to-nodename translation in protocol-independent manner |
44 | .\" | ||
41 | .Sh SYNOPSIS | 45 | .Sh SYNOPSIS |
42 | .Fd #include <sys/types.h> | 46 | .Fd #include <sys/types.h> |
43 | .Fd #include <sys/socket.h> | 47 | .Fd #include <sys/socket.h> |
@@ -45,6 +49,7 @@ | |||
45 | .Ft int | 49 | .Ft int |
46 | .Fn getnameinfo "const struct sockaddr *sa" "socklen_t salen" \ | 50 | .Fn getnameinfo "const struct sockaddr *sa" "socklen_t salen" \ |
47 | "char *host" "size_t hostlen" "char *serv" "size_t servlen" "int flags" | 51 | "char *host" "size_t hostlen" "char *serv" "size_t servlen" "int flags" |
52 | .\" | ||
48 | .Sh DESCRIPTION | 53 | .Sh DESCRIPTION |
49 | The | 54 | The |
50 | .Fn getnameinfo | 55 | .Fn getnameinfo |
@@ -170,15 +175,61 @@ These | |||
170 | .Dv NI_xxx | 175 | .Dv NI_xxx |
171 | flags are defined in | 176 | flags are defined in |
172 | .Aq Pa netdb.h . | 177 | .Aq Pa netdb.h . |
178 | .\" | ||
179 | .Sh EXTENSION | ||
180 | The implementation allows experimental numeric IPv6 address notation with | ||
181 | scope identifier. | ||
182 | IPv6 link-local address will appear as string like | ||
183 | .Dq Li fe80::1@ne0 , | ||
184 | if | ||
185 | .Dv NI_WITHSCOPEID | ||
186 | bit is enabled in | ||
187 | .Ar flags | ||
188 | argument. | ||
189 | Refer to | ||
190 | .Xr getaddrinfo 3 | ||
191 | for the notation. | ||
192 | .\" | ||
193 | .Sh EXAMPLES | ||
194 | The following code tries to get numeric hostname, and service name, | ||
195 | for given socket address. | ||
196 | Observe that there is no hardcoded reference to particular address family. | ||
197 | .Bd -literal -offset indent | ||
198 | struct sockaddr *sa; /* input */ | ||
199 | char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; | ||
200 | |||
201 | if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), sbuf, | ||
202 | sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV)) { | ||
203 | errx(1, "could not get numeric hostname"); | ||
204 | /*NOTREACHED*/ | ||
205 | } | ||
206 | printf("host=%s, serv=%s\\n", hbuf, sbuf); | ||
207 | .Ed | ||
208 | .Pp | ||
209 | The following version checks if the socket address has reverse address mapping. | ||
210 | .Bd -literal -offset indent | ||
211 | struct sockaddr *sa; /* input */ | ||
212 | char hbuf[NI_MAXHOST]; | ||
213 | |||
214 | if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), NULL, 0, | ||
215 | NI_NAMEREQD)) { | ||
216 | errx(1, "could not resolve hostname"); | ||
217 | /*NOTREACHED*/ | ||
218 | } | ||
219 | printf("host=%s\\n", hbuf); | ||
220 | .Ed | ||
221 | .\" | ||
173 | .Sh FILES | 222 | .Sh FILES |
174 | .Bl -tag -width /etc/resolv.conf -compact | 223 | .Bl -tag -width /etc/resolv.conf -compact |
175 | .It Pa /etc/hosts | 224 | .It Pa /etc/hosts |
176 | .It Pa /etc/host.conf | 225 | .It Pa /etc/host.conf |
177 | .It Pa /etc/resolv.conf | 226 | .It Pa /etc/resolv.conf |
178 | .El | 227 | .El |
228 | .\" | ||
179 | .Sh DIAGNOSTICS | 229 | .Sh DIAGNOSTICS |
180 | The function indicates successful completion by a zero return value; | 230 | The function indicates successful completion by a zero return value; |
181 | a non-zero return value indicates failure. | 231 | a non-zero return value indicates failure. |
232 | .\" | ||
182 | .Sh SEE ALSO | 233 | .Sh SEE ALSO |
183 | .Xr getaddrinfo 3 , | 234 | .Xr getaddrinfo 3 , |
184 | .Xr gethostbyaddr 3 , | 235 | .Xr gethostbyaddr 3 , |
@@ -188,8 +239,27 @@ a non-zero return value indicates failure. | |||
188 | .Xr hostname 7 , | 239 | .Xr hostname 7 , |
189 | .Xr named 8 | 240 | .Xr named 8 |
190 | .Pp | 241 | .Pp |
191 | R. Gilligan, S. Thomson, J. Bound, and W. Stevens, | 242 | .Rs |
192 | ``Basic Socket Interface Extensions for IPv6,'' RFC2553, March 1999. | 243 | .%A R. Gilligan |
244 | .%A S. Thomson | ||
245 | .%A J. Bound | ||
246 | .%A W. Stevens | ||
247 | .%T Basic Socket Interface Extensions for IPv6 | ||
248 | .%R RFC2553 | ||
249 | .%D March 1999 | ||
250 | .Re | ||
251 | .Rs | ||
252 | .%A Tatsuya Jinmei | ||
253 | .%A Atsushi Onoe | ||
254 | .%T "An Extension of Format for IPv6 Scoped Addresses" | ||
255 | .%R internet draft | ||
256 | .%N draft-ietf-ipngwg-scopedaddr-format-00.txt | ||
257 | .%O work in progress material | ||
258 | .Re | ||
259 | .\" | ||
260 | .Sh HISTORY | ||
261 | The implementation first appeared in WIDE Hydrangea IPv6 protocol stack kit. | ||
262 | .\" | ||
193 | .Sh STANDARDS | 263 | .Sh STANDARDS |
194 | The | 264 | The |
195 | .Fn getaddrinfo | 265 | .Fn getaddrinfo |
@@ -197,5 +267,6 @@ function is defined IEEE POSIX 1003.1g draft specification, | |||
197 | and documented in | 267 | and documented in |
198 | .Dq Basic Socket Interface Extensions for IPv6 | 268 | .Dq Basic Socket Interface Extensions for IPv6 |
199 | .Pq RFC2533 . | 269 | .Pq RFC2533 . |
270 | .\" | ||
200 | .Sh BUGS | 271 | .Sh BUGS |
201 | The text was shamelessly copied from RFC2553. | 272 | The text was shamelessly copied from RFC2553. |