ares_getnameinfo.3 4.3 KB

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