summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authormillert <>2004-12-20 22:20:43 +0000
committermillert <>2004-12-20 22:20:43 +0000
commit31e753210b2697032bfefd2e04ea48716adc1b9a (patch)
treeaea6068e2a9348a3df268161ebe684abdcfc3204 /src/lib
parent0da1ac8b717c0ccf897a470c7a8e965a7998226f (diff)
downloadopenbsd-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.339
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
111and 111and
112.Tn TCP . 112.Tn TCP .
113.El
114.Pp
115This implementation allows experimental numeric IPv6 address notation with
116scope identifier.
117IPv6 link-local address will appear as a string like
118.Dq Li fe80::1%ne0 .
119Refer to
120.Xr getaddrinfo 3
121for more information.
113.Sh RETURN VALUES 122.Sh RETURN VALUES
114.Fn getnameinfo 123.Fn getnameinfo
115returns zero on success or one of the error codes listed in 124returns zero on success or one of the error codes listed in
116.Xr gai_strerror 3 125.Xr gai_strerror 3
117if an error occurs. 126if an error occurs.
127.Sh EXAMPLES
128The following code tries to get a numeric host name, and service name,
129for a given socket address.
130Observe that there is no hardcoded reference to a particular address family.
131.Bd -literal -offset indent
132struct sockaddr *sa; /* input */
133char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
134
135if (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}
140printf("host=%s, serv=%s\en", hbuf, sbuf);
141.Ed
142.Pp
143The following version checks if the socket address has a reverse address mapping:
144.Bd -literal -offset indent
145struct sockaddr *sa; /* input */
146char hbuf[NI_MAXHOST];
147
148if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), NULL, 0,
149 NI_NAMEREQD)) {
150 errx(1, "could not resolve hostname");
151 /*NOTREACHED*/
152}
153printf("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 ,