ares_query.3 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. .\"
  2. .\" Copyright 1998 by the Massachusetts Institute of Technology.
  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_QUERY 3 "24 July 1998"
  17. .SH NAME
  18. ares_query \- Initiate a single-question DNS query
  19. .SH SYNOPSIS
  20. .nf
  21. #include <ares.h>
  22. typedef void (*ares_callback)(void *\fIarg\fP, int \fIstatus\fP,
  23. int \fItimeouts\fP, unsigned char *\fIabuf\fP,
  24. int \fIalen\fP)
  25. void ares_query(ares_channel \fIchannel\fP, const char *\fIname\fP,
  26. int \fIdnsclass\fP, int \fItype\fP,
  27. ares_callback \fIcallback\fP, void *\fIarg\fP)
  28. .fi
  29. .SH DESCRIPTION
  30. The
  31. .B ares_query
  32. function initiates a single-question DNS query on the name service
  33. channel identified by
  34. .IR channel .
  35. The parameter
  36. .I name
  37. gives the query name as a NUL-terminated C string of period-separated
  38. labels optionally ending with a period; periods and backslashes within
  39. a label must be escaped with a backslash. The parameters
  40. .I dnsclass
  41. and
  42. .I type
  43. give the class and type of the query using the values defined in
  44. .BR <arpa/nameser.h> .
  45. When the query is complete or has failed, the ares library will invoke
  46. .IR callback .
  47. Completion or failure of the query may happen immediately, or may
  48. happen during a later call to
  49. .BR ares_process (3)
  50. or
  51. .BR ares_destroy (3).
  52. .PP
  53. The callback argument
  54. .I arg
  55. is copied from the
  56. .B ares_query
  57. argument
  58. .IR arg .
  59. The callback argument
  60. .I status
  61. indicates whether the query succeeded and, if not, how it failed. It
  62. may have any of the following values:
  63. .TP 19
  64. .B ARES_SUCCESS
  65. The query completed successfully.
  66. .TP 19
  67. .B ARES_ENODATA
  68. The query completed but contains no answers.
  69. .TP 19
  70. .B ARES_EFORMERR
  71. The query completed but the server claims that the query was
  72. malformatted.
  73. .TP 19
  74. .B ARES_ESERVFAIL
  75. The query completed but the server claims to have experienced a
  76. failure. (This code can only occur if the
  77. .B ARES_FLAG_NOCHECKRESP
  78. flag was specified at channel initialization time; otherwise, such
  79. responses are ignored at the
  80. .BR ares_send (3)
  81. level.)
  82. .TP 19
  83. .B ARES_ENOTFOUND
  84. The query completed but the queried-for domain name was not found.
  85. .TP 19
  86. .B ARES_ENOTIMP
  87. The query completed but the server does not implement the operation
  88. requested by the query. (This code can only occur if the
  89. .B ARES_FLAG_NOCHECKRESP
  90. flag was specified at channel initialization time; otherwise, such
  91. responses are ignored at the
  92. .BR ares_send (3)
  93. level.)
  94. .TP 19
  95. .B ARES_EREFUSED
  96. The query completed but the server refused the query. (This code can
  97. only occur if the
  98. .B ARES_FLAG_NOCHECKRESP
  99. flag was specified at channel initialization time; otherwise, such
  100. responses are ignored at the
  101. .BR ares_send (3)
  102. level.)
  103. .TP 19
  104. .B ARES_EBADNAME
  105. The query name
  106. .I name
  107. could not be encoded as a domain name, either because it contained a
  108. zero-length label or because it contained a label of more than 63
  109. characters.
  110. .TP 19
  111. .B ARES_ETIMEOUT
  112. No name servers responded within the timeout period.
  113. .TP 19
  114. .B ARES_ECONNREFUSED
  115. No name servers could be contacted.
  116. .TP 19
  117. .B ARES_ENOMEM
  118. Memory was exhausted.
  119. .TP 19
  120. .B ARES_ECANCELLED
  121. The query was cancelled.
  122. .TP 19
  123. .B ARES_EDESTRUCTION
  124. The name service channel
  125. .I channel
  126. is being destroyed; the query will not be completed.
  127. .PP
  128. The callback argument
  129. .I timeouts
  130. reports how many times a query timed out during the execution of the
  131. given request.
  132. .PP
  133. If the query completed (even if there was something wrong with it, as
  134. indicated by some of the above error codes), the callback argument
  135. .I abuf
  136. points to a result buffer of length
  137. .IR alen .
  138. If the query did not complete,
  139. .I abuf
  140. will be NULL and
  141. .I alen
  142. will be 0.
  143. .SH SEE ALSO
  144. .BR ares_process (3)
  145. .SH AUTHOR
  146. Greg Hudson, MIT Information Systems
  147. .br
  148. Copyright 1998 by the Massachusetts Institute of Technology.