diff options
author | millert <> | 2004-12-20 22:20:43 +0000 |
---|---|---|
committer | millert <> | 2004-12-20 22:20:43 +0000 |
commit | 31e753210b2697032bfefd2e04ea48716adc1b9a (patch) | |
tree | aea6068e2a9348a3df268161ebe684abdcfc3204 /src/lib | |
parent | 0da1ac8b717c0ccf897a470c7a8e965a7998226f (diff) | |
download | openbsd-31e753210b2697032bfefd2e04ea48716adc1b9a.tar.gz openbsd-31e753210b2697032bfefd2e04ea48716adc1b9a.tar.bz2 openbsd-31e753210b2697032bfefd2e04ea48716adc1b9a.zip |
Add back EXAMPLE section and scopeid info which are from KAME, not the
RFC text.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libc/net/getnameinfo.3 | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/lib/libc/net/getnameinfo.3 b/src/lib/libc/net/getnameinfo.3 index f9ada350cd..2dfe60ad59 100644 --- a/src/lib/libc/net/getnameinfo.3 +++ b/src/lib/libc/net/getnameinfo.3 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: getnameinfo.3,v 1.30 2004/12/20 22:15:29 millert Exp $ | 1 | .\" $OpenBSD: getnameinfo.3,v 1.31 2004/12/20 22:20:43 millert Exp $ |
2 | .\" | 2 | .\" |
3 | .\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") | 3 | .\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") |
4 | .\" Copyright (C) 2000, 2001 Internet Software Consortium. | 4 | .\" Copyright (C) 2000, 2001 Internet Software Consortium. |
@@ -110,11 +110,48 @@ for | |||
110 | .Tn UDP | 110 | .Tn UDP |
111 | and | 111 | and |
112 | .Tn TCP . | 112 | .Tn TCP . |
113 | .El | ||
114 | .Pp | ||
115 | This implementation allows experimental numeric IPv6 address notation with | ||
116 | scope identifier. | ||
117 | IPv6 link-local address will appear as a string like | ||
118 | .Dq Li fe80::1%ne0 . | ||
119 | Refer to | ||
120 | .Xr getaddrinfo 3 | ||
121 | for more information. | ||
113 | .Sh RETURN VALUES | 122 | .Sh RETURN VALUES |
114 | .Fn getnameinfo | 123 | .Fn getnameinfo |
115 | returns zero on success or one of the error codes listed in | 124 | returns zero on success or one of the error codes listed in |
116 | .Xr gai_strerror 3 | 125 | .Xr gai_strerror 3 |
117 | if an error occurs. | 126 | if an error occurs. |
127 | .Sh EXAMPLES | ||
128 | The following code tries to get a numeric host name, and service name, | ||
129 | for a given socket address. | ||
130 | Observe that there is no hardcoded reference to a particular address family. | ||
131 | .Bd -literal -offset indent | ||
132 | struct sockaddr *sa; /* input */ | ||
133 | char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; | ||
134 | |||
135 | if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), sbuf, | ||
136 | sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV)) { | ||
137 | errx(1, "could not get numeric hostname"); | ||
138 | /*NOTREACHED*/ | ||
139 | } | ||
140 | printf("host=%s, serv=%s\en", hbuf, sbuf); | ||
141 | .Ed | ||
142 | .Pp | ||
143 | The following version checks if the socket address has a reverse address mapping: | ||
144 | .Bd -literal -offset indent | ||
145 | struct sockaddr *sa; /* input */ | ||
146 | char hbuf[NI_MAXHOST]; | ||
147 | |||
148 | if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), NULL, 0, | ||
149 | NI_NAMEREQD)) { | ||
150 | errx(1, "could not resolve hostname"); | ||
151 | /*NOTREACHED*/ | ||
152 | } | ||
153 | printf("host=%s\en", hbuf); | ||
154 | .Ed | ||
118 | .Sh SEE ALSO | 155 | .Sh SEE ALSO |
119 | .Xr inet_ntop 3 , | 156 | .Xr inet_ntop 3 , |
120 | .Xr gai_strerror 3 , | 157 | .Xr gai_strerror 3 , |