You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ares_nameser.h 12 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. #ifndef ARES_NAMESER_H
  2. #define ARES_NAMESER_H
  3. #include "ares_build.h"
  4. #ifdef CARES_HAVE_ARPA_NAMESER_H
  5. #include <arpa/nameser.h>
  6. #endif
  7. #ifdef CARES_HAVE_ARPA_NAMESER_COMPAT_H
  8. #include <arpa/nameser_compat.h>
  9. #endif
  10. /* ============================================================================
  11. * arpa/nameser.h may or may not provide ALL of the below defines, so check
  12. * each one individually and set if not
  13. * ============================================================================
  14. */
  15. #ifndef NS_PACKETSZ
  16. #define NS_PACKETSZ 512 /* maximum packet size */
  17. #endif
  18. #ifndef NS_MAXDNAME
  19. #define NS_MAXDNAME 256 /* maximum domain name */
  20. #endif
  21. #ifndef NS_MAXCDNAME
  22. #define NS_MAXCDNAME 255 /* maximum compressed domain name */
  23. #endif
  24. #ifndef NS_MAXLABEL
  25. #define NS_MAXLABEL 63
  26. #endif
  27. #ifndef NS_HFIXEDSZ
  28. #define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */
  29. #endif
  30. #ifndef NS_QFIXEDSZ
  31. #define NS_QFIXEDSZ 4 /* #/bytes of fixed data in query */
  32. #endif
  33. #ifndef NS_RRFIXEDSZ
  34. #define NS_RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
  35. #endif
  36. #ifndef NS_INT16SZ
  37. #define NS_INT16SZ 2
  38. #endif
  39. #ifndef NS_INADDRSZ
  40. #define NS_INADDRSZ 4
  41. #endif
  42. #ifndef NS_IN6ADDRSZ
  43. #define NS_IN6ADDRSZ 16
  44. #endif
  45. #ifndef NS_CMPRSFLGS
  46. #define NS_CMPRSFLGS 0xc0 /* Flag bits indicating name compression. */
  47. #endif
  48. #ifndef NS_DEFAULTPORT
  49. #define NS_DEFAULTPORT 53 /* For both TCP and UDP. */
  50. #endif
  51. /* ============================================================================
  52. * arpa/nameser.h should provide these enumerations always, so if not found,
  53. * provide them
  54. * ============================================================================
  55. */
  56. #ifndef CARES_HAVE_ARPA_NAMESER_H
  57. typedef enum __ns_class
  58. {
  59. ns_c_invalid = 0, /* Cookie. */
  60. ns_c_in = 1, /* Internet. */
  61. ns_c_2 = 2, /* unallocated/unsupported. */
  62. ns_c_chaos = 3, /* MIT Chaos-net. */
  63. ns_c_hs = 4, /* MIT Hesiod. */
  64. /* Query class values which do not appear in resource records */
  65. ns_c_none = 254, /* for prereq. sections in update requests */
  66. ns_c_any = 255, /* Wildcard match. */
  67. ns_c_max = 65536
  68. } ns_class;
  69. typedef enum __ns_type
  70. {
  71. ns_t_invalid = 0, /* Cookie. */
  72. ns_t_a = 1, /* Host address. */
  73. ns_t_ns = 2, /* Authoritative server. */
  74. ns_t_md = 3, /* Mail destination. */
  75. ns_t_mf = 4, /* Mail forwarder. */
  76. ns_t_cname = 5, /* Canonical name. */
  77. ns_t_soa = 6, /* Start of authority zone. */
  78. ns_t_mb = 7, /* Mailbox domain name. */
  79. ns_t_mg = 8, /* Mail group member. */
  80. ns_t_mr = 9, /* Mail rename name. */
  81. ns_t_null = 10, /* Null resource record. */
  82. ns_t_wks = 11, /* Well known service. */
  83. ns_t_ptr = 12, /* Domain name pointer. */
  84. ns_t_hinfo = 13, /* Host information. */
  85. ns_t_minfo = 14, /* Mailbox information. */
  86. ns_t_mx = 15, /* Mail routing information. */
  87. ns_t_txt = 16, /* Text strings. */
  88. ns_t_rp = 17, /* Responsible person. */
  89. ns_t_afsdb = 18, /* AFS cell database. */
  90. ns_t_x25 = 19, /* X_25 calling address. */
  91. ns_t_isdn = 20, /* ISDN calling address. */
  92. ns_t_rt = 21, /* Router. */
  93. ns_t_nsap = 22, /* NSAP address. */
  94. ns_t_nsap_ptr = 23, /* Reverse NSAP lookup (deprecated). */
  95. ns_t_sig = 24, /* Security signature. */
  96. ns_t_key = 25, /* Security key. */
  97. ns_t_px = 26, /* X.400 mail mapping. */
  98. ns_t_gpos = 27, /* Geographical position (withdrawn). */
  99. ns_t_aaaa = 28, /* Ip6 Address. */
  100. ns_t_loc = 29, /* Location Information. */
  101. ns_t_nxt = 30, /* Next domain (security). */
  102. ns_t_eid = 31, /* Endpoint identifier. */
  103. ns_t_nimloc = 32, /* Nimrod Locator. */
  104. ns_t_srv = 33, /* Server Selection. */
  105. ns_t_atma = 34, /* ATM Address */
  106. ns_t_naptr = 35, /* Naming Authority PoinTeR */
  107. ns_t_kx = 36, /* Key Exchange */
  108. ns_t_cert = 37, /* Certification record */
  109. ns_t_a6 = 38, /* IPv6 address (deprecates AAAA) */
  110. ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */
  111. ns_t_sink = 40, /* Kitchen sink (experimentatl) */
  112. ns_t_opt = 41, /* EDNS0 option (meta-RR) */
  113. ns_t_apl = 42, /* Address prefix list (RFC3123) */
  114. ns_t_ds = 43, /* Delegation Signer (RFC4034) */
  115. ns_t_sshfp = 44, /* SSH Key Fingerprint (RFC4255) */
  116. ns_t_rrsig = 46, /* Resource Record Signature (RFC4034) */
  117. ns_t_nsec = 47, /* Next Secure (RFC4034) */
  118. ns_t_dnskey = 48, /* DNS Public Key (RFC4034) */
  119. ns_t_tkey = 249, /* Transaction key */
  120. ns_t_tsig = 250, /* Transaction signature. */
  121. ns_t_ixfr = 251, /* Incremental zone transfer. */
  122. ns_t_axfr = 252, /* Transfer zone of authority. */
  123. ns_t_mailb = 253, /* Transfer mailbox records. */
  124. ns_t_maila = 254, /* Transfer mail agent records. */
  125. ns_t_any = 255, /* Wildcard match. */
  126. ns_t_uri = 256, /* Uniform Resource Identifier (RFC7553) */
  127. ns_t_caa = 257, /* Certification Authority Authorization. */
  128. ns_t_max = 65536
  129. } ns_type;
  130. typedef enum __ns_opcode
  131. {
  132. ns_o_query = 0, /* Standard query. */
  133. ns_o_iquery = 1, /* Inverse query (deprecated/unsupported). */
  134. ns_o_status = 2, /* Name server status query (unsupported). */
  135. /* Opcode 3 is undefined/reserved. */
  136. ns_o_notify = 4, /* Zone change notification. */
  137. ns_o_update = 5, /* Zone update message. */
  138. ns_o_max = 6
  139. } ns_opcode;
  140. typedef enum __ns_rcode
  141. {
  142. ns_r_noerror = 0, /* No error occurred. */
  143. ns_r_formerr = 1, /* Format error. */
  144. ns_r_servfail = 2, /* Server failure. */
  145. ns_r_nxdomain = 3, /* Name error. */
  146. ns_r_notimpl = 4, /* Unimplemented. */
  147. ns_r_refused = 5, /* Operation refused. */
  148. /* these are for BIND_UPDATE */
  149. ns_r_yxdomain = 6, /* Name exists */
  150. ns_r_yxrrset = 7, /* RRset exists */
  151. ns_r_nxrrset = 8, /* RRset does not exist */
  152. ns_r_notauth = 9, /* Not authoritative for zone */
  153. ns_r_notzone = 10, /* Zone of record different from zone section */
  154. ns_r_max = 11,
  155. /* The following are TSIG extended errors */
  156. ns_r_badsig = 16,
  157. ns_r_badkey = 17,
  158. ns_r_badtime = 18
  159. } ns_rcode;
  160. #endif /* CARES_HAVE_ARPA_NAMESER_H */
  161. /* ============================================================================
  162. * arpa/nameser_compat.h typically sets these. However on some systems
  163. * arpa/nameser.h does, but may not set all of them. Lets conditionally
  164. * define each
  165. * ============================================================================
  166. */
  167. #ifndef PACKETSZ
  168. #define PACKETSZ NS_PACKETSZ
  169. #endif
  170. #ifndef MAXDNAME
  171. #define MAXDNAME NS_MAXDNAME
  172. #endif
  173. #ifndef MAXCDNAME
  174. #define MAXCDNAME NS_MAXCDNAME
  175. #endif
  176. #ifndef MAXLABEL
  177. #define MAXLABEL NS_MAXLABEL
  178. #endif
  179. #ifndef HFIXEDSZ
  180. #define HFIXEDSZ NS_HFIXEDSZ
  181. #endif
  182. #ifndef QFIXEDSZ
  183. #define QFIXEDSZ NS_QFIXEDSZ
  184. #endif
  185. #ifndef RRFIXEDSZ
  186. #define RRFIXEDSZ NS_RRFIXEDSZ
  187. #endif
  188. #ifndef INDIR_MASK
  189. #define INDIR_MASK NS_CMPRSFLGS
  190. #endif
  191. #ifndef NAMESERVER_PORT
  192. #define NAMESERVER_PORT NS_DEFAULTPORT
  193. #endif
  194. /* opcodes */
  195. #ifndef O_QUERY
  196. #define O_QUERY 0 /* ns_o_query */
  197. #endif
  198. #ifndef O_IQUERY
  199. #define O_IQUERY 1 /* ns_o_iquery */
  200. #endif
  201. #ifndef O_STATUS
  202. #define O_STATUS 2 /* ns_o_status */
  203. #endif
  204. #ifndef O_NOTIFY
  205. #define O_NOTIFY 4 /* ns_o_notify */
  206. #endif
  207. #ifndef O_UPDATE
  208. #define O_UPDATE 5 /* ns_o_update */
  209. #endif
  210. /* response codes */
  211. #ifndef SERVFAIL
  212. #define SERVFAIL ns_r_servfail
  213. #endif
  214. #ifndef NOTIMP
  215. #define NOTIMP ns_r_notimpl
  216. #endif
  217. #ifndef REFUSED
  218. #define REFUSED ns_r_refused
  219. #endif
  220. #if defined(_WIN32) && !defined(HAVE_ARPA_NAMESER_COMPAT_H) && defined(NOERROR)
  221. #undef NOERROR /* it seems this is already defined in winerror.h */
  222. #endif
  223. #ifndef NOERROR
  224. #define NOERROR ns_r_noerror
  225. #endif
  226. #ifndef FORMERR
  227. #define FORMERR ns_r_formerr
  228. #endif
  229. #ifndef NXDOMAIN
  230. #define NXDOMAIN ns_r_nxdomain
  231. #endif
  232. /* Non-standard response codes, use numeric values */
  233. #ifndef YXDOMAIN
  234. #define YXDOMAIN 6 /* ns_r_yxdomain */
  235. #endif
  236. #ifndef YXRRSET
  237. #define YXRRSET 7 /* ns_r_yxrrset */
  238. #endif
  239. #ifndef NXRRSET
  240. #define NXRRSET 8 /* ns_r_nxrrset */
  241. #endif
  242. #ifndef NOTAUTH
  243. #define NOTAUTH 9 /* ns_r_notauth */
  244. #endif
  245. #ifndef NOTZONE
  246. #define NOTZONE 10 /* ns_r_notzone */
  247. #endif
  248. #ifndef TSIG_BADSIG
  249. #define TSIG_BADSIG 16 /* ns_r_badsig */
  250. #endif
  251. #ifndef TSIG_BADKEY
  252. #define TSIG_BADKEY 17 /* ns_r_badkey */
  253. #endif
  254. #ifndef TSIG_BADTIME
  255. #define TSIG_BADTIME 18 /* ns_r_badtime */
  256. #endif
  257. /* classes */
  258. #ifndef C_IN
  259. #define C_IN 1 /* ns_c_in */
  260. #endif
  261. #ifndef C_CHAOS
  262. #define C_CHAOS 3 /* ns_c_chaos */
  263. #endif
  264. #ifndef C_HS
  265. #define C_HS 4 /* ns_c_hs */
  266. #endif
  267. #ifndef C_NONE
  268. #define C_NONE 254 /* ns_c_none */
  269. #endif
  270. #ifndef C_ANY
  271. #define C_ANY 255 /* ns_c_any */
  272. #endif
  273. /* types */
  274. #ifndef T_A
  275. #define T_A 1 /* ns_t_a */
  276. #endif
  277. #ifndef T_NS
  278. #define T_NS 2 /* ns_t_ns */
  279. #endif
  280. #ifndef T_MD
  281. #define T_MD 3 /* ns_t_md */
  282. #endif
  283. #ifndef T_MF
  284. #define T_MF 4 /* ns_t_mf */
  285. #endif
  286. #ifndef T_CNAME
  287. #define T_CNAME 5 /* ns_t_cname */
  288. #endif
  289. #ifndef T_SOA
  290. #define T_SOA 6 /* ns_t_soa */
  291. #endif
  292. #ifndef T_MB
  293. #define T_MB 7 /* ns_t_mb */
  294. #endif
  295. #ifndef T_MG
  296. #define T_MG 8 /* ns_t_mg */
  297. #endif
  298. #ifndef T_MR
  299. #define T_MR 9 /* ns_t_mr */
  300. #endif
  301. #ifndef T_NULL
  302. #define T_NULL 10 /* ns_t_null */
  303. #endif
  304. #ifndef T_WKS
  305. #define T_WKS 11 /* ns_t_wks */
  306. #endif
  307. #ifndef T_PTR
  308. #define T_PTR 12 /* ns_t_ptr */
  309. #endif
  310. #ifndef T_HINFO
  311. #define T_HINFO 13 /* ns_t_hinfo */
  312. #endif
  313. #ifndef T_MINFO
  314. #define T_MINFO 14 /* ns_t_minfo */
  315. #endif
  316. #ifndef T_MX
  317. #define T_MX 15 /* ns_t_mx */
  318. #endif
  319. #ifndef T_TXT
  320. #define T_TXT 16 /* ns_t_txt */
  321. #endif
  322. #ifndef T_RP
  323. #define T_RP 17 /* ns_t_rp */
  324. #endif
  325. #ifndef T_AFSDB
  326. #define T_AFSDB 18 /* ns_t_afsdb */
  327. #endif
  328. #ifndef T_X25
  329. #define T_X25 19 /* ns_t_x25 */
  330. #endif
  331. #ifndef T_ISDN
  332. #define T_ISDN 20 /* ns_t_isdn */
  333. #endif
  334. #ifndef T_RT
  335. #define T_RT 21 /* ns_t_rt */
  336. #endif
  337. #ifndef T_NSAP
  338. #define T_NSAP 22 /* ns_t_nsap */
  339. #endif
  340. #ifndef T_NSAP_PTR
  341. #define T_NSAP_PTR 23 /* ns_t_nsap_ptr */
  342. #endif
  343. #ifndef T_SIG
  344. #define T_SIG 24 /* ns_t_sig */
  345. #endif
  346. #ifndef T_KEY
  347. #define T_KEY 25 /* ns_t_key */
  348. #endif
  349. #ifndef T_PX
  350. #define T_PX 26 /* ns_t_px */
  351. #endif
  352. #ifndef T_GPOS
  353. #define T_GPOS 27 /* ns_t_gpos */
  354. #endif
  355. #ifndef T_AAAA
  356. #define T_AAAA 28 /* ns_t_aaaa */
  357. #endif
  358. #ifndef T_LOC
  359. #define T_LOC 29 /* ns_t_loc */
  360. #endif
  361. #ifndef T_NXT
  362. #define T_NXT 30 /* ns_t_nxt */
  363. #endif
  364. #ifndef T_EID
  365. #define T_EID 31 /* ns_t_eid */
  366. #endif
  367. #ifndef T_NIMLOC
  368. #define T_NIMLOC 32 /* ns_t_nimloc */
  369. #endif
  370. #ifndef T_SRV
  371. #define T_SRV 33 /* ns_t_srv */
  372. #endif
  373. #ifndef T_ATMA
  374. #define T_ATMA 34 /* ns_t_atma */
  375. #endif
  376. #ifndef T_NAPTR
  377. #define T_NAPTR 35 /* ns_t_naptr */
  378. #endif
  379. #ifndef T_KX
  380. #define T_KX 36 /* ns_t_kx */
  381. #endif
  382. #ifndef T_CERT
  383. #define T_CERT 37 /* ns_t_cert */
  384. #endif
  385. #ifndef T_A6
  386. #define T_A6 38 /* ns_t_a6 */
  387. #endif
  388. #ifndef T_DNAME
  389. #define T_DNAME 39 /* ns_t_dname */
  390. #endif
  391. #ifndef T_SINK
  392. #define T_SINK 40 /* ns_t_sink */
  393. #endif
  394. #ifndef T_OPT
  395. #define T_OPT 41 /* ns_t_opt */
  396. #endif
  397. #ifndef T_APL
  398. #define T_APL 42 /* ns_t_apl */
  399. #endif
  400. #ifndef T_DS
  401. #define T_DS 43 /* ns_t_ds */
  402. #endif
  403. #ifndef T_SSHFP
  404. #define T_SSHFP 44 /* ns_t_sshfp */
  405. #endif
  406. #ifndef T_RRSIG
  407. #define T_RRSIG 46 /* ns_t_rrsig */
  408. #endif
  409. #ifndef T_NSEC
  410. #define T_NSEC 47 /* ns_t_nsec */
  411. #endif
  412. #ifndef T_DNSKEY
  413. #define T_DNSKEY 48 /* ns_t_dnskey */
  414. #endif
  415. #ifndef T_TKEY
  416. #define T_TKEY 249 /* ns_t_tkey */
  417. #endif
  418. #ifndef T_TSIG
  419. #define T_TSIG 250 /* ns_t_tsig */
  420. #endif
  421. #ifndef T_IXFR
  422. #define T_IXFR 251 /* ns_t_ixfr */
  423. #endif
  424. #ifndef T_AXFR
  425. #define T_AXFR 252 /* ns_t_axfr */
  426. #endif
  427. #ifndef T_MAILB
  428. #define T_MAILB 253 /* ns_t_mailb */
  429. #endif
  430. #ifndef T_MAILA
  431. #define T_MAILA 254 /* ns_t_maila */
  432. #endif
  433. #ifndef T_ANY
  434. #define T_ANY 255 /* ns_t_any */
  435. #endif
  436. #ifndef T_URI
  437. #define T_URI 256 /* ns_t_uri */
  438. #endif
  439. #ifndef T_CAA
  440. #define T_CAA 257 /* ns_t_caa */
  441. #endif
  442. #ifndef T_MAX
  443. #define T_MAX 65536 /* ns_t_max */
  444. #endif
  445. #endif /* ARES_NAMESER_H */