ares_getnameinfo.3 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. .\" $Id$
  2. .\"
  3. .\" Copyright 2005 by Dominick Meglio.
  4. .\"
  5. .\" Permission to use, copy, modify, and distribute this
  6. .\" software and its documentation for any purpose and without
  7. .\" fee is hereby granted, provided that the above copyright
  8. .\" notice appear in all copies and that both that copyright
  9. .\" notice and this permission notice appear in supporting
  10. .\" documentation, and that the name of M.I.T. not be used in
  11. .\" advertising or publicity pertaining to distribution of the
  12. .\" software without specific, written prior permission.
  13. .\" M.I.T. makes no representations about the suitability of
  14. .\" this software for any purpose. It is provided "as is"
  15. .\" without express or implied warranty.
  16. .\"
  17. .TH ARES_GETNAMEINFO 3 "1 May 2009"
  18. .SH NAME
  19. ares_getnameinfo \- Address-to-nodename translation in protocol-independent manner
  20. .SH SYNOPSIS
  21. .nf
  22. .B #include <ares.h>
  23. .PP
  24. .B typedef void (*ares_nameinfo_callback)(void *\fIarg\fP, int \fIstatus\fP,
  25. .B int \fItimeouts\fP, char *\fInode\fP, char *\fIservice\fP)
  26. .PP
  27. .B void ares_getnameinfo(ares_channel \fIchannel\fP, const struct sockaddr *\fIsa\fP,
  28. .B ares_socklen_t \fIsalen\fP, int \fIflags\fP, ares_nameinfo_callback \fIcallback\fP,
  29. .B void *\fIarg\fP)
  30. .fi
  31. .SH DESCRIPTION
  32. The
  33. .B ares_getnameinfo
  34. function is defined for protocol-independent address translation. The function
  35. is a combination of \fIares_gethostbyaddr(3)\fP and \fIgetservbyport(3)\fP. The function will
  36. translate the address either by executing a host query on the name service channel
  37. identified by
  38. .IR channel
  39. or it will attempt to resolve it locally if possible.
  40. The parameters
  41. .I sa
  42. and
  43. .I len
  44. give the address as a sockaddr structure, and
  45. .I flags
  46. gives the options that the function will use. Valid flags are listed below:
  47. .TP 19
  48. .B ARES_NI_NOFQDN
  49. Only the nodename portion of the FQDN is returned for local hosts.
  50. .TP 19
  51. .B ARES_NI_NUMERICHOST
  52. The numeric form of the hostname is returned rather than the name.
  53. .TP 19
  54. .B ARES_NI_NAMEREQD
  55. An error is returned if the hostname cannot be found in the DNS.
  56. .TP 19
  57. .B ARES_NI_NUMERICSERV
  58. The numeric form of the service is returned rather than the name.
  59. .TP 19
  60. .B ARES_NI_TCP
  61. The service name is to be looked up for the TCP protocol.
  62. .TP 19
  63. .B ARES_NI_UDP
  64. The service name is to be looked up for the UDP protocol.
  65. .TP 19
  66. .B ARES_NI_SCTP
  67. The service name is to be looked up for the SCTP protocol.
  68. .TP 19
  69. .B ARES_NI_DCCP
  70. The service name is to be looked up for the DCCP protocol.
  71. .TP 19
  72. .B ARES_NI_NUMERICSCOPE
  73. The numeric form of the scope ID is returned rather than the name.
  74. .TP 19
  75. .B ARES_NI_LOOKUPHOST
  76. A hostname lookup is being requested.
  77. .TP 19
  78. .B ARES_NI_LOOKUPSERVICE
  79. A service name lookup is being requested.
  80. .PP
  81. When the query
  82. is complete or has
  83. failed, the ares library will invoke \fIcallback\fP. Completion or failure of
  84. the query may happen immediately, or may happen during a later call to
  85. \fIares_process(3)\fP, \fIares_destroy(3)\fP or \fIares_cancel(3)\fP.
  86. .PP
  87. The callback argument
  88. .I arg
  89. is copied from the
  90. .B ares_getnameinfo
  91. argument
  92. .IR arg .
  93. The callback argument
  94. .I status
  95. indicates whether the query succeeded and, if not, how it failed. It
  96. may have any of the following values:
  97. .TP 19
  98. .B ARES_SUCCESS
  99. The host lookup completed successfully.
  100. .TP 19
  101. .B ARES_ENOTIMP
  102. The ares library does not know how to look up addresses of type
  103. .IR family .
  104. .TP 19
  105. .B ARES_ENOTFOUND
  106. The address
  107. .I addr
  108. was not found.
  109. .TP 19
  110. .B ARES_ENOMEM
  111. Memory was exhausted.
  112. .TP 19
  113. .B ARES_EDESTRUCTION
  114. The name service channel
  115. .I channel
  116. is being destroyed; the query will not be completed.
  117. .TP 19
  118. .B ARES_EBADFLAGS
  119. The
  120. .I flags
  121. parameter contains an illegal value.
  122. .PP
  123. The callback argument
  124. .I timeouts
  125. reports how many times a query timed out during the execution of the
  126. given request.
  127. .PP
  128. On successful completion of the query, the callback argument
  129. .I node
  130. contains a string representing the hostname (assuming
  131. .B ARES_NI_LOOKUPHOST
  132. was specified). Additionally,
  133. .I service
  134. contains a string representing the service name (assuming
  135. .B ARES_NI_LOOKUPSERVICE
  136. was specified).
  137. If the query did not complete successfully, or one of the values
  138. was not requested,
  139. .I node
  140. or
  141. .I service
  142. will be
  143. .BR NULL .
  144. .SH SEE ALSO
  145. .BR ares_process (3),
  146. .BR ares_getaddrinfo (3)
  147. .SH AUTHOR
  148. Dominick Meglio
  149. .br
  150. Copyright 2005 by Dominick Meglio.