summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authormillert <>2004-12-20 22:15:29 +0000
committermillert <>2004-12-20 22:15:29 +0000
commit0da1ac8b717c0ccf897a470c7a8e965a7998226f (patch)
tree64486e2079bdbea45ec1768920c54c5c434bdb9f /src/lib
parente2ef8122f22d670cfea6416a7fc046714fa97705 (diff)
downloadopenbsd-0da1ac8b717c0ccf897a470c7a8e965a7998226f.tar.gz
openbsd-0da1ac8b717c0ccf897a470c7a8e965a7998226f.tar.bz2
openbsd-0da1ac8b717c0ccf897a470c7a8e965a7998226f.zip
New getnameinfo.3 man page, derived from the ISC version and fleshed
out a bit by me. Needs more work.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libc/net/getnameinfo.3171
1 files changed, 171 insertions, 0 deletions
diff --git a/src/lib/libc/net/getnameinfo.3 b/src/lib/libc/net/getnameinfo.3
new file mode 100644
index 0000000000..f9ada350cd
--- /dev/null
+++ b/src/lib/libc/net/getnameinfo.3
@@ -0,0 +1,171 @@
1.\" $OpenBSD: getnameinfo.3,v 1.30 2004/12/20 22:15:29 millert Exp $
2.\"
3.\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
4.\" Copyright (C) 2000, 2001 Internet Software Consortium.
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
11.\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12.\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
13.\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14.\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16.\" PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd December 20, 2004
19.Dt GETNAMEINFO 3
20.Os
21.Sh NAME
22.Nm getnameinfo
23.Nd socket address structure to hostname and service name
24.Sh SYNOPSIS
25.Fd #include <sys/types.h>
26.Fd #include <sys/socket.h>
27.Fd #include <netdb.h>
28.Ft int
29.Fn getnameinfo "const struct sockaddr *sa" "socklen_t salen" "char *host" "size_t hostlen" "char *serv" "size_t servlen" "int flags"
30.Sh DESCRIPTION
31The
32.Fn getnameinfo
33function is used to convert a
34.Li sockaddr
35structure to a pair of host name and service strings.
36It is a replacement for and provides more flexibility than the
37.Xr gethostbyaddr 3
38and
39.Xr getservbyport 3
40functions and is the converse of the
41.Xr getaddrinfo 3
42function.
43.Pp
44The
45.Li sockaddr
46structure
47.Fa sa
48should point to either a
49.Li sockaddr_in
50or
51.Li sockaddr_in6
52structure (for IPv4 or IPv6 respectively) that is
53.Fa salen
54bytes long.
55.Pp
56The host and service names associated with
57.Fa sa
58are stored in
59.Fa host
60and
61.Fa serv
62which have size parameters
63.Fa hostlen
64and
65.Fa servlen .
66The maximum value for
67.Fa hostlen
68is
69.Dv NI_MAXHOST
70and
71the maximum value for
72.Fa servlen
73is
74.Dv NI_MAXSERV
75- 32,
76as defined by
77.Aq Pa netdb.h .
78.Pp
79The
80.Fa flags
81argument is formed by
82.Tn OR Ns 'ing
83the following values:
84.Bl -tag -width "NI_NUMERICHOSTXX"
85.It Dv NI_NOFQDN
86A fully qualified domain name is not required for local hosts.
87The local part of the fully qualified domain name is returned instead.
88.It Dv NI_NUMERICHOST
89Return the address in numeric form, as if calling
90.Xr inet_ntop 3 ,
91instead of a host name.
92.It Dv NI_NAMEREQD
93A name is required.
94If the host name cannot be found in DNS and this flag is set,
95a non-zero error code is returned.
96If the host name is not found and the flag is not set, the
97address is returned in numeric form.
98.It NI_NUMERICSERV
99The service name is returned as a digit string representing the port number.
100.It NI_DGRAM
101Specifies that the service being looked up is a datagram
102service, and causes
103.Xr getservbyport 3
104to be called with a second argument of
105.Dq udp
106instead of its default of
107.Dq tcp .
108This is required for the few ports (512-514) that have different services
109for
110.Tn UDP
111and
112.Tn TCP .
113.Sh RETURN VALUES
114.Fn getnameinfo
115returns zero on success or one of the error codes listed in
116.Xr gai_strerror 3
117if an error occurs.
118.Sh SEE ALSO
119.Xr inet_ntop 3 ,
120.Xr gai_strerror 3 ,
121.Xr getaddrinfo 3 ,
122.Xr gethostbyaddr 3 ,
123.Xr getservbyport 3 ,
124.Xr resolver 3 ,
125.Xr hosts 5 ,
126.Xr resolv.conf 5 ,
127.Xr services 5 ,
128.Xr hostname 7 ,
129.Xr named 8
130.Rs
131.%A R. Gilligan
132.%A S. Thomson
133.%A J. Bound
134.%A W. Stevens
135.%T Basic Socket Interface Extensions for IPv6
136.%R RFC 2553
137.%D March 1999
138.Re
139.Rs
140.%A Tatsuya Jinmei
141.%A Atsushi Onoe
142.%T "An Extension of Format for IPv6 Scoped Addresses"
143.%R internet draft
144.%N draft-ietf-ipngwg-scopedaddr-format-02.txt
145.%O work in progress material
146.Re
147.Rs
148.%A Craig Metz
149.%T Protocol Independence Using the Sockets API
150.%B "Proceedings of the freenix track: 2000 USENIX annual technical conference"
151.%D June 2000
152.Re
153.Sh STANDARDS
154The
155.Fn getnameinfo
156function is defined by the
157.St -p1003.1g-2000
158draft specification and documented in
159.Tn "RFC 2553" ,
160.Dq Basic Socket Interface Extensions for IPv6 .
161.Sh BUGS
162Due to the use of dynamic allocation,
163.Fn getaddrinfo
164is not thread-safe.
165.Pp
166.Ox
167intentionally uses a different
168.Dv NI_MAXHOST
169value from what
170.Tn "RFC 2553"
171suggests, to avoid buffer length handling mistakes.