ares_nameser.h 13 KB

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