xref: /netbsd-src/external/bsd/libbind/dist/doc/getnameinfo.3 (revision 5bbd2a12505d72a8177929a37b5cee489d0a1cfd)
1.\"	$NetBSD: getnameinfo.3,v 1.1.1.2 2012/09/09 16:07:45 christos Exp $
2.\"
3.\" Copyright (C) 2009  Internet Systems Consortium, Inc. ("ISC")
4.\"
5.\" Permission to use, copy, modify, and/or distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10.\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11.\" AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12.\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13.\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15.\" PERFORMANCE OF THIS SOFTWARE.
16.\"
17.\" Id: getnameinfo.3,v 1.4 2009/02/21 01:31:39 jreed Exp
18.\"
19.Dd January 11, 1999
20.Dt GETNAMEINFO @LIB_NETWORK_EXT@
21.Sh NAME
22.Nm getnameinfo
23.Nd address-to-name translation in protocol-independent manner
24.Sh SYNOPSIS
25.Fd #include <sys/socket.h>
26.Fd #include <netdb.h>
27.Ft int
28.Fn getnameinfo "const struct sockaddr *sa" "socklen_t salen" \
29"char *host" "size_t hostlen" "char *serv" "size_t servlen" "int flags"
30.Sh DESCRIPTION
31The
32.Fn getnameinfo
33function is defined for protocol-independent address-to-nodename translation.
34It performs functionality of
35.Xr gethostbyaddr @LIB_NETWORK_EXT@
36and
37.Xr getservbyport @LIB_NETWORK_EXT@
38in more sophisticated manner.
39.Pp
40The
41.Fa sa
42arguement is a pointer to a generic socket address structure of size
43.Fa salen .
44The arguements
45.Fa host
46and
47.Fa serv
48are pointers to buffers to hold the return values.
49Their sizes are specified by
50.Fa hostlen
51and
52.Fa servlen
53repectively.
54Either
55.Fa host
56or
57.Fa serv
58may be
59.Dv NULL
60if the hostname  or service name is not required.
61.Pp
62The
63.Fa flags
64arguement modifies the behaviour of
65.Fn getnameinfo
66as follows:
67.Pp
68If
69.Dv NI_NOFQDN
70is set only the unqualified hostname is returned for local fully
71qualified names.
72.Pp
73If
74.Dv NI_NUMERICHOST
75is set then the numeric form of the hostname is returned.
76.Pp
77If
78.Dv NI_NAMEREQD
79is set, then a error is returned if the hostname cannot be looked up.
80.Pp
81If
82.Dv NI_NUMERICSERV
83is set then the service is returned in numeric form.
84.Pp
85If
86.Dv NI_DGRAM
87is set then the service is UDP based rather than TCP based.
88.Sh SEE ALSO
89.Xr getaddrinfo @LIB_NETWORK_EXT@ ,
90.Xr gethostbyaddr @LIB_NETWORK_EXT@ ,
91.Xr getservbyport @LIB_NETWORK_EXT@ ,
92.Xr hosts @FORMAT_EXT@ ,
93.Xr services @FORMAT_EXT@ ,
94.Xr hostname @DESC_EXT@ ,
95.Pp
96R. Gilligan, S.  Thomson, J. Bound, and W. Stevens,
97``Basic Socket Interface Extensions for IPv6,'' RFC2133, April 1997.
98.Sh STANDARDS
99The
100.Fn getaddrinfo
101function is defined IEEE POSIX 1003.1g draft specification,
102and documented in ``Basic Socket Interface Extensions for IPv6''
103(RFC2133).
104