resolv.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. /*
  2. * Copyright (c) 1983, 1987, 1989
  3. * The Regents of the University of California. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 4. Neither the name of the University nor the names of its contributors
  14. * may be used to endorse or promote products derived from this software
  15. * without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  21. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. * SUCH DAMAGE.
  28. */
  29. /*
  30. * Portions Copyright (c) 1996-1999 by Internet Software Consortium.
  31. *
  32. * Permission to use, copy, modify, and distribute this software for any
  33. * purpose with or without fee is hereby granted, provided that the above
  34. * copyright notice and this permission notice appear in all copies.
  35. *
  36. * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
  37. * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
  38. * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
  39. * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  40. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  41. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  42. * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  43. * SOFTWARE.
  44. */
  45. /*
  46. * @(#)resolv.h 8.1 (Berkeley) 6/2/93
  47. * $BINDId: resolv.h,v 8.31 2000/03/30 20:16:50 vixie Exp $
  48. */
  49. #ifndef _RESOLV_H_
  50. #define _RESOLV_H_
  51. #include <sys/cdefs.h>
  52. #include <sys/param.h>
  53. #include <sys/types.h>
  54. #include <stdio.h>
  55. #include <netinet/in.h>
  56. #include <arpa/nameser.h>
  57. #include <bits/types/res_state.h>
  58. /*
  59. * Global defines and variables for resolver stub.
  60. */
  61. #define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */
  62. #define RES_TIMEOUT 5 /* min. seconds between retries */
  63. #define RES_MAXNDOTS 15 /* should reflect bit field size */
  64. #define RES_MAXRETRANS 30 /* only for resolv.conf/RES_OPTIONS */
  65. #define RES_MAXRETRY 5 /* only for resolv.conf/RES_OPTIONS */
  66. #define RES_DFLRETRY 2 /* Default #/tries. */
  67. #define RES_MAXTIME 65535 /* Infinity, in milliseconds. */
  68. #define nsaddr nsaddr_list[0] /* for backward compatibility */
  69. /*
  70. * Revision information. This is the release date in YYYYMMDD format.
  71. * It can change every day so the right thing to do with it is use it
  72. * in preprocessor commands such as "#if (__RES > 19931104)". Do not
  73. * compare for equality; rather, use it to determine whether your resolver
  74. * is new enough to contain a certain feature.
  75. */
  76. #define __RES 19991006
  77. /*
  78. * Resolver configuration file.
  79. * Normally not present, but may contain the address of the
  80. * inital name server(s) to query and the domain search list.
  81. */
  82. #ifndef _PATH_RESCONF
  83. #define _PATH_RESCONF "/etc/resolv.conf"
  84. #endif
  85. struct res_sym {
  86. int number; /* Identifying number, like T_MX */
  87. char * name; /* Its symbolic name, like "MX" */
  88. char * humanname; /* Its fun name, like "mail exchanger" */
  89. };
  90. /*
  91. * Resolver options (keep these in synch with res_debug.c, please)
  92. */
  93. #define RES_INIT 0x00000001 /* address initialized */
  94. #define RES_DEBUG 0x00000002 /* print debug messages */
  95. #define RES_AAONLY \
  96. __glibc_macro_warning ("RES_AAONLY is deprecated") 0x00000004
  97. #define RES_USEVC 0x00000008 /* use virtual circuit */
  98. #define RES_PRIMARY \
  99. __glibc_macro_warning ("RES_PRIMARY is deprecated") 0x00000010
  100. #define RES_IGNTC 0x00000020 /* ignore trucation errors */
  101. #define RES_RECURSE 0x00000040 /* recursion desired */
  102. #define RES_DEFNAMES 0x00000080 /* use default domain name */
  103. #define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */
  104. #define RES_DNSRCH 0x00000200 /* search up local domain tree */
  105. #define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */
  106. #define RES_ROTATE 0x00004000 /* rotate ns list after each query */
  107. #define RES_NOCHECKNAME \
  108. __glibc_macro_warning ("RES_NOCHECKNAME is deprecated") 0x00008000
  109. #define RES_KEEPTSIG \
  110. __glibc_macro_warning ("RES_KEEPTSIG is deprecated") 0x00010000
  111. #define RES_BLAST \
  112. __glibc_macro_warning ("RES_BLAST is deprecated") 0x00020000
  113. #define RES_USE_EDNS0 0x00100000 /* Use EDNS0. */
  114. #define RES_SNGLKUP 0x00200000 /* one outstanding request at a time */
  115. #define RES_SNGLKUPREOP 0x00400000 /* -"-, but open new socket for each
  116. request */
  117. #define RES_USE_DNSSEC 0x00800000 /* use DNSSEC using OK bit in OPT */
  118. #define RES_NOTLDQUERY 0x01000000 /* Do not look up unqualified name
  119. as a TLD. */
  120. #define RES_NORELOAD 0x02000000 /* No automatic configuration reload. */
  121. #define RES_TRUSTAD 0x04000000 /* Request AD bit, keep it in responses. */
  122. #define RES_DEFAULT (RES_RECURSE|RES_DEFNAMES|RES_DNSRCH)
  123. /*
  124. * Resolver "pfcode" values. Used by dig.
  125. */
  126. #define RES_PRF_STATS 0x00000001
  127. #define RES_PRF_UPDATE 0x00000002
  128. #define RES_PRF_CLASS 0x00000004
  129. #define RES_PRF_CMD 0x00000008
  130. #define RES_PRF_QUES 0x00000010
  131. #define RES_PRF_ANS 0x00000020
  132. #define RES_PRF_AUTH 0x00000040
  133. #define RES_PRF_ADD 0x00000080
  134. #define RES_PRF_HEAD1 0x00000100
  135. #define RES_PRF_HEAD2 0x00000200
  136. #define RES_PRF_TTLID 0x00000400
  137. #define RES_PRF_HEADX 0x00000800
  138. #define RES_PRF_QUERY 0x00001000
  139. #define RES_PRF_REPLY 0x00002000
  140. #define RES_PRF_INIT 0x00004000
  141. /* 0x00008000 */
  142. /* Things involving an internal (static) resolver context. */
  143. __BEGIN_DECLS
  144. extern struct __res_state *__res_state(void) __attribute__ ((__const__));
  145. __END_DECLS
  146. #define _res (*__res_state())
  147. #define fp_nquery __fp_nquery
  148. #define fp_query __fp_query
  149. #define hostalias __hostalias
  150. #define p_query __p_query
  151. #define res_close __res_close
  152. #define res_init __res_init
  153. #define res_isourserver __res_isourserver
  154. #define res_mkquery __res_mkquery
  155. #define res_query __res_query
  156. #define res_querydomain __res_querydomain
  157. #define res_search __res_search
  158. #define res_send __res_send
  159. __BEGIN_DECLS
  160. void fp_nquery (const unsigned char *, int, FILE *) __THROW;
  161. void fp_query (const unsigned char *, FILE *) __THROW;
  162. const char * hostalias (const char *) __THROW;
  163. void p_query (const unsigned char *) __THROW;
  164. void res_close (void) __THROW;
  165. int res_init (void) __THROW;
  166. int res_isourserver (const struct sockaddr_in *) __THROW;
  167. int res_mkquery (int, const char *, int, int,
  168. const unsigned char *, int, const unsigned char *,
  169. unsigned char *, int) __THROW;
  170. int res_query (const char *, int, int, unsigned char *, int)
  171. __THROW;
  172. int res_querydomain (const char *, const char *, int, int,
  173. unsigned char *, int) __THROW;
  174. int res_search (const char *, int, int, unsigned char *, int)
  175. __THROW;
  176. int res_send (const unsigned char *, int, unsigned char *, int)
  177. __THROW;
  178. __END_DECLS
  179. #define b64_ntop __b64_ntop
  180. #define b64_pton __b64_pton
  181. #define dn_comp __dn_comp
  182. #define dn_count_labels __dn_count_labels
  183. #define dn_expand __dn_expand
  184. #define dn_skipname __dn_skipname
  185. #define fp_resstat __fp_resstat
  186. #define loc_aton __loc_aton
  187. #define loc_ntoa __loc_ntoa
  188. #define p_cdname __p_cdname
  189. #define p_cdnname __p_cdnname
  190. #define p_class __p_class
  191. #define p_fqname __p_fqname
  192. #define p_fqnname __p_fqnname
  193. #define p_option __p_option
  194. #define p_time __p_time
  195. #define p_type __p_type
  196. #define p_rcode __p_rcode
  197. #define putlong __putlong
  198. #define putshort __putshort
  199. #define res_dnok __res_dnok
  200. #define res_hnok __res_hnok
  201. #define res_hostalias __res_hostalias
  202. #define res_mailok __res_mailok
  203. #define res_nameinquery __res_nameinquery
  204. #define res_nclose __res_nclose
  205. #define res_ninit __res_ninit
  206. #define res_nmkquery __res_nmkquery
  207. #define res_nquery __res_nquery
  208. #define res_nquerydomain __res_nquerydomain
  209. #define res_nsearch __res_nsearch
  210. #define res_nsend __res_nsend
  211. #define res_ownok __res_ownok
  212. #define res_queriesmatch __res_queriesmatch
  213. #define res_randomid __res_randomid
  214. #define sym_ntop __sym_ntop
  215. #define sym_ntos __sym_ntos
  216. #define sym_ston __sym_ston
  217. __BEGIN_DECLS
  218. int res_hnok (const char *) __THROW;
  219. int res_ownok (const char *) __THROW;
  220. int res_mailok (const char *) __THROW;
  221. int res_dnok (const char *) __THROW;
  222. int sym_ston (const struct res_sym *, const char *, int *) __THROW;
  223. const char * sym_ntos (const struct res_sym *, int, int *) __THROW;
  224. const char * sym_ntop (const struct res_sym *, int, int *) __THROW;
  225. int b64_ntop (const unsigned char *, size_t, char *, size_t)
  226. __THROW;
  227. int b64_pton (char const *, unsigned char *, size_t) __THROW;
  228. int loc_aton (const char *__ascii, unsigned char *__binary) __THROW;
  229. const char * loc_ntoa (const unsigned char *__binary, char *__ascii) __THROW;
  230. int dn_skipname (const unsigned char *, const unsigned char *)
  231. __THROW;
  232. void putlong (uint32_t, unsigned char *) __THROW;
  233. void putshort (uint16_t, unsigned char *) __THROW;
  234. const char * p_class (int) __THROW;
  235. const char * p_time (uint32_t) __THROW;
  236. const char * p_type (int) __THROW;
  237. const char * p_rcode (int) __THROW;
  238. const unsigned char * p_cdnname (const unsigned char *,
  239. const unsigned char *, int, FILE *) __THROW;
  240. const unsigned char * p_cdname (const unsigned char *, const unsigned char *,
  241. FILE *) __THROW;
  242. const unsigned char * p_fqnname (const unsigned char *__cp,
  243. const unsigned char *__msg,
  244. int, char *, int) __THROW;
  245. const unsigned char * p_fqname (const unsigned char *,
  246. const unsigned char *, FILE *) __THROW;
  247. const char * p_option (unsigned long __option) __THROW;
  248. int dn_count_labels (const char *) __THROW;
  249. int dn_comp (const char *, unsigned char *, int, unsigned char **,
  250. unsigned char **) __THROW;
  251. int dn_expand (const unsigned char *, const unsigned char *,
  252. const unsigned char *, char *, int) __THROW;
  253. unsigned int res_randomid (void) __THROW;
  254. int res_nameinquery (const char *, int, int,
  255. const unsigned char *,
  256. const unsigned char *) __THROW;
  257. int res_queriesmatch (const unsigned char *,
  258. const unsigned char *,
  259. const unsigned char *,
  260. const unsigned char *) __THROW;
  261. /* Things involving a resolver context. */
  262. int res_ninit (res_state) __THROW;
  263. void fp_resstat (const res_state, FILE *) __THROW;
  264. const char * res_hostalias (const res_state, const char *, char *, size_t)
  265. __THROW;
  266. int res_nquery (res_state, const char *, int, int,
  267. unsigned char *, int) __THROW;
  268. int res_nsearch (res_state, const char *, int, int,
  269. unsigned char *, int) __THROW;
  270. int res_nquerydomain (res_state, const char *, const char *, int,
  271. int, unsigned char *, int) __THROW;
  272. int res_nmkquery (res_state, int, const char *, int, int,
  273. const unsigned char *, int,
  274. const unsigned char *, unsigned char *, int)
  275. __THROW;
  276. int res_nsend (res_state, const unsigned char *, int,
  277. unsigned char *, int) __THROW;
  278. void res_nclose (res_state) __THROW;
  279. __END_DECLS
  280. #endif /* !_RESOLV_H_ */