ares_nameser.h 13 KB

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