getconf: don't include xpg4 bits, gcc7 includes xpg6 bits for us
[unleashed.git] / share / man / man3xnet / getnameinfo.3xnet
blobef884ac048fd417dc490828ad7f6cea2441e737d
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright (c) 2001, The IEEE and The Open Group.  All Rights Reserved.
44 .\" Portions Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved.
45 .\"
46 .TH GETNAMEINFO 3XNET "Nov 1, 2003"
47 .SH NAME
48 getnameinfo \- get name information
49 .SH SYNOPSIS
50 .LP
51 .nf
52 \fBcc\fR [ \fIflag\fR ... ] \fIfile\fR ... [ \fIlibrary\fR ... ]
53 #include <sys/socket.h>
54 #include <netdb.h>
56 \fBint\fR \fBgetnameinfo\fR(\fBconst struct sockaddr *restrict\fR \fIsa\fR, \fBsocklen_t\fR \fIsalen\fR,
57      \fBchar *restrict\fR \fInode\fR, \fBsocklen_t\fR \fInodelen\fR, \fBchar *restrict\fR \fIservice\fR,
58      \fBsocklen_t\fR \fIservicelen\fR, \fBunsigned\fR \fIflags\fR);
59 .fi
61 .SH DESCRIPTION
62 .LP
63 The \fBgetnameinfo()\fR function translates a socket address to a node name and
64 service location, all of which are defined as in \fBgetaddrinfo\fR(3XNET).
65 .sp
66 .LP
67 The \fIsa\fR argument points to a socket address structure to be translated. If
68 the socket address structure contains an IPv4-mapped IPv6 address or an
69 IPv4-compatible IPv6 address, the implementation extracts the embedded IPv4
70 address and lookup the node name for that IPv4 address.
71 .sp
72 .LP
73 If the \fInode\fR argument is non-\fINULL\fR and the nodelen argument is
74 non-zero, then the \fInode\fR argument points to a buffer able to contain up to
75 \fInodelen\fR characters that receives the node name as a null-terminated
76 string. If the \fInode\fR argument is \fINULL\fR or the \fInodelen\fR argument
77 is zero, the node name is not returned. If the node's name cannot be located,
78 the numeric form of the node's address is returned instead of its name.
79 .sp
80 .LP
81 If the \fIservice\fR argument is non-\fINULL\fR and the \fIservicelen\fR
82 argument is non-zero, then the \fIservice\fR argument points to a buffer able
83 to contain up to \fIservicelen\fR bytes that receives the service name as a
84 null-terminated string. If the \fIservice\fR argument is \fINULL\fR or the
85 \fIservicelen\fR argument is zero, the service name is not returned. If the
86 service's name cannot be located, the numeric form of the service address (for
87 example, its port number) is returned instead of its name.
88 .sp
89 .LP
90 The \fIflags\fR argument is a flag that changes the default actions of the
91 function. By default the fully-qualified domain name (FQDN) for the host is
92 returned, but:
93 .RS +4
94 .TP
95 .ie t \(bu
96 .el o
97 If the flag bit \fBNI_NOFQDN\fR is set, only the node name portion of the FQDN
98 is returned for local hosts.
99 .RE
100 .RS +4
102 .ie t \(bu
103 .el o
104 If the flag bit \fBNI_NUMERICHOST\fR is set, the numeric form of the host's
105 address is returned instead of its name, under all circumstances.
107 .RS +4
109 .ie t \(bu
110 .el o
111 If the flag bit \fBNI_NAMEREQD\fR is set, an error is returned if the host's
112 name cannot be located.
114 .RS +4
116 .ie t \(bu
117 .el o
118 If the flag bit \fBNI_NUMERICSERV\fR is set, the numeric form of the service
119 address is returned (for example, its port number) instead of its name, under
120 all circumstances.
122 .RS +4
124 .ie t \(bu
125 .el o
126 If the flag bit \fBNI_DGRAM\fR is set, this indicates that the service is a
127 datagram service (\fBSOCK_DGRAM\fR). The default behavior assumes that the
128 service is a stream service (\fBSOCK_STREAM\fR).
130 .SH RETURN VALUES
132 A 0 return value for \fBgetnameinfo()\fR indicates successful completion; a
133 non-zero return value indicates failure. The possible values for the failures
134 are listed in the ERRORS section.
137 Upon successful completion, \fBgetnameinfo()\fR returns the node and service
138 names, if requested, in the buffers provided. The returned names are always
139 null-terminated strings.
140 .SH ERRORS
142 The \fBgetnameinfo()\fR function will fail if:
144 .ne 2
146 \fB\fBEAI_AGAIN\fR\fR
148 .RS 16n
149 The name could not be resolved at this time. Future attempts might succeed.
153 .ne 2
155 \fB\fBEAI_BADFLAGS\fR\fR
157 .RS 16n
158 The \fIflags\fR argument had an invalid value.
162 .ne 2
164 \fB\fBEAI_FAIL\fR\fR
166 .RS 16n
167 A non-recoverable error occurred.
171 .ne 2
173 \fB\fBEAI_FAMILY\fR\fR
175 .RS 16n
176 The address family was not recognized or the address length was invalid for the
177 specified family.
181 .ne 2
183 \fB\fBEAI_MEMORY\fR\fR
185 .RS 16n
186 There was a memory allocation failure.
190 .ne 2
192 \fB\fBEAI_NONAME\fR\fR
194 .RS 16n
195 The name does not resolve for the supplied parameters.       \fBNI_NAMEREQD\fR
196 is set and the host's name cannot be located, or both \fInodename\fR and
197 \fIservname\fR were \fINULL\fR.
201 .ne 2
203 \fB\fBEAI_SYSTEM\fR\fR
205 .RS 16n
206 A system error occurred. The error code can be found in \fBerrno\fR.
209 .SH USAGE
211 If the returned values are to be used as part of any further name resolution
212 (for example, passed to \fBgetaddrinfo()\fR), applications should provide
213 buffers large enough to store any result possible on the system.
216 Given the IPv4-mapped IPv6 address "::ffff:1.2.3.4", the implementation
217 performs a lookup as if the socket address structure contains the IPv4 address
218 "1.2.3.4".
219 .SH ATTRIBUTES
221 See \fBattributes\fR(5) for descriptions of the following attributes:
226 box;
227 c | c
228 l | l .
229 ATTRIBUTE TYPE  ATTRIBUTE VALUE
231 Interface Stability     Standard
233 MT-Level        MT-Safe
236 .SH SEE ALSO
238 \fBsockaddr\fR(3SOCKET),
239 \fBgai_strerror\fR(3XNET), \fBgetaddrinfo\fR(3XNET),
240 \fBgetservbyname\fR(3XNET), \fBsocket\fR(3XNET), \fBattributes\fR(5),
241 \fBstandards\fR(5)
242 .SH NOTES
244 The IPv6 unspecified address ("::") and the IPv6 loopback address ("::1") are
245 not IPv4-compatible addresses. If the address is the IPv6 unspecified address
246 ("::"), a lookup is not performed, and the \fBEAI_NONAME\fR error is returned.
249 The two \fBNI_NUMERIC\fR\fIxxx\fR flags are required to support the \fB-n\fR
250 flag that many commands provide.
253 The \fBNI_DGRAM\fR flag is required for the few \fBAF_INET\fR and
254 \fBAF_INET6\fR port numbers (for example, [512,514]) that represent different
255 services for UDP and TCP.