ares_query.3 4.2 KB

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