logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

getnameinfo.3p (7141B)


  1. '\" et
  2. .TH GETNAMEINFO "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. getnameinfo
  12. \(em get name information
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <sys/socket.h>
  17. #include <netdb.h>
  18. .P
  19. int getnameinfo(const struct sockaddr *restrict \fIsa\fP, socklen_t \fIsalen\fP,
  20. char *restrict \fInode\fP, socklen_t \fInodelen\fP, char *restrict \fIservice\fP,
  21. socklen_t \fIservicelen\fP, int \fIflags\fP);
  22. .fi
  23. .SH DESCRIPTION
  24. The
  25. \fIgetnameinfo\fR()
  26. function shall translate a socket address to a node name and service
  27. location, all of which are defined as in
  28. .IR "\fIfreeaddrinfo\fR\^(\|)".
  29. .P
  30. The
  31. .IR sa
  32. argument points to a socket address structure to be translated. The
  33. .IR salen
  34. argument contains the length of the address pointed to by
  35. .IR sa .
  36. .P
  37. If the socket address structure contains an IPv4-mapped IPv6 address or
  38. an IPv4-compatible IPv6 address, the implementation shall extract the
  39. embedded IPv4 address and lookup the node name for that IPv4 address.
  40. .P
  41. If the address is the IPv6 unspecified address (\c
  42. .BR \(dq::\(dq ),
  43. a lookup shall not be performed and the behavior shall be the same as
  44. when the node's name cannot be located.
  45. .P
  46. If the
  47. .IR node
  48. argument is non-NULL and the
  49. .IR nodelen
  50. argument is non-zero, then the
  51. .IR node
  52. argument points to a buffer able to contain up to
  53. .IR nodelen
  54. bytes that receives the node name as a null-terminated string. If the
  55. .IR node
  56. argument is NULL or the
  57. .IR nodelen
  58. argument is zero, the node name shall not be returned. If the node's
  59. name cannot be located, the numeric form of the address contained
  60. in the socket address structure pointed to by the
  61. .IR sa
  62. argument is returned instead of its name.
  63. .P
  64. If the
  65. .IR service
  66. argument is non-NULL and the
  67. .IR servicelen
  68. argument is non-zero, then the
  69. .IR service
  70. argument points to a buffer able to contain up to
  71. .IR servicelen
  72. bytes that receives the service name as a null-terminated string.
  73. If the
  74. .IR service
  75. argument is NULL or the
  76. .IR servicelen
  77. argument is zero, the service name shall not be returned. If the
  78. service's name cannot be located, the numeric form of the service
  79. address (for example, its port number) shall be returned instead of
  80. its name.
  81. .P
  82. The
  83. .IR flags
  84. argument is a flag that changes the default actions of the function. By
  85. default the fully-qualified domain name (FQDN) for the
  86. host shall be returned, but:
  87. .IP " *" 4
  88. If the flag bit NI_NOFQDN is set, only the node name portion of the
  89. FQDN shall be returned for local hosts.
  90. .IP " *" 4
  91. If the flag bit NI_NUMERICHOST is set, the numeric form of the address
  92. contained in the socket address structure pointed to by the
  93. .IR sa
  94. argument shall be returned instead of its name.
  95. .IP " *" 4
  96. If the flag bit NI_NAMEREQD is set, an error shall be returned if the
  97. host's name cannot be located.
  98. .IP " *" 4
  99. If the flag bit NI_NUMERICSERV is set, the numeric form of the service
  100. address shall be returned (for example, its port number) instead of its
  101. name.
  102. .IP " *" 4
  103. If the flag bit NI_NUMERICSCOPE is set, the numeric form of the scope
  104. identifier shall be returned (for example, interface index) instead of
  105. its name. This flag shall be ignored if the
  106. .IR sa
  107. argument is not an IPv6 address.
  108. .IP " *" 4
  109. If the flag bit NI_DGRAM is set, this indicates that the service is a
  110. datagram service (SOCK_DGRAM). The default behavior shall assume that
  111. the service is a stream service (SOCK_STREAM).
  112. .TP 10
  113. .BR Notes:
  114. .RS 10
  115. .IP " 1." 4
  116. The two NI_NUMERICxxx flags are required to support the
  117. .BR \-n
  118. flag that many commands provide.
  119. .IP " 2." 4
  120. The NI_DGRAM flag is required for the few AF_INET and AF_INET6 port
  121. numbers (for example, [512,514]) that represent different services for
  122. UDP and TCP.
  123. .RE
  124. .P
  125. .P
  126. The
  127. \fIgetnameinfo\fR()
  128. function shall be thread-safe.
  129. .SH "RETURN VALUE"
  130. A zero return value for
  131. \fIgetnameinfo\fR()
  132. indicates successful completion; a non-zero return value indicates
  133. failure. The possible values for the failures are listed in the
  134. ERRORS section.
  135. .P
  136. Upon successful completion,
  137. \fIgetnameinfo\fR()
  138. shall return the
  139. .IR node
  140. and
  141. .IR service
  142. names, if requested, in the buffers provided. The returned names are
  143. always null-terminated strings.
  144. .SH ERRORS
  145. The
  146. \fIgetnameinfo\fR()
  147. function shall fail and return the corresponding value if:
  148. .IP [EAI_AGAIN] 12
  149. The name could not be resolved at this time. Future attempts may
  150. succeed.
  151. .IP [EAI_BADFLAGS] 12
  152. .br
  153. The
  154. .IR flags
  155. had an invalid value.
  156. .IP [EAI_FAIL] 12
  157. A non-recoverable error occurred.
  158. .IP [EAI_FAMILY] 12
  159. The address family was not recognized or the address length was invalid
  160. for the specified family.
  161. .IP [EAI_MEMORY] 12
  162. There was a memory allocation failure.
  163. .IP [EAI_NONAME] 12
  164. The name does not resolve for the supplied parameters.
  165. .RS 12
  166. .P
  167. NI_NAMEREQD is set and the host's name cannot be located, or both
  168. .IR nodename
  169. and
  170. .IR servname
  171. were null.
  172. .RE
  173. .IP [EAI_OVERFLOW] 12
  174. .br
  175. An argument buffer overflowed. The buffer pointed to by the
  176. .IR node
  177. argument or the
  178. .IR service
  179. argument was too small.
  180. .IP [EAI_SYSTEM] 12
  181. A system error occurred. The error code can be found in
  182. .IR errno .
  183. .LP
  184. .IR "The following sections are informative."
  185. .SH "EXAMPLES"
  186. None.
  187. .SH "APPLICATION USAGE"
  188. If the returned values are to be used as part of any further name
  189. resolution (for example, passed to
  190. \fIgetaddrinfo\fR()),
  191. applications should provide buffers large enough to store any result
  192. possible on the system.
  193. .P
  194. Given the IPv4-mapped IPv6 address
  195. .BR \(dq::ffff:1.2.3.4\(dq ,
  196. the implementation performs a lookup as if the socket address structure
  197. contains the IPv4 address
  198. .BR \(dq1.2.3.4\(dq .
  199. .P
  200. The IPv6 unspecified address (\c
  201. .BR \(dq::\(dq )
  202. and the IPv6 loopback address (\c
  203. .BR \(dq::1\(dq )
  204. are not IPv4-compatible addresses.
  205. .SH "RATIONALE"
  206. None.
  207. .SH "FUTURE DIRECTIONS"
  208. None.
  209. .SH "SEE ALSO"
  210. .IR "\fIendservent\fR\^(\|)",
  211. .IR "\fIfreeaddrinfo\fR\^(\|)",
  212. .IR "\fIgai_strerror\fR\^(\|)",
  213. .IR "\fIinet_ntop\fR\^(\|)",
  214. .IR "\fIsocket\fR\^(\|)"
  215. .P
  216. The Base Definitions volume of POSIX.1\(hy2017,
  217. .IR "\fB<netdb.h>\fP",
  218. .IR "\fB<sys_socket.h>\fP"
  219. .\"
  220. .SH COPYRIGHT
  221. Portions of this text are reprinted and reproduced in electronic form
  222. from IEEE Std 1003.1-2017, Standard for Information Technology
  223. -- Portable Operating System Interface (POSIX), The Open Group Base
  224. Specifications Issue 7, 2018 Edition,
  225. Copyright (C) 2018 by the Institute of
  226. Electrical and Electronics Engineers, Inc and The Open Group.
  227. In the event of any discrepancy between this version and the original IEEE and
  228. The Open Group Standard, the original IEEE and The Open Group Standard
  229. is the referee document. The original Standard can be obtained online at
  230. http://www.opengroup.org/unix/online.html .
  231. .PP
  232. Any typographical or formatting errors that appear
  233. in this page are most likely
  234. to have been introduced during the conversion of the source files to
  235. man page format. To report such errors, see
  236. https://www.kernel.org/doc/man-pages/reporting_bugs.html .