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