1 /* 2 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 3 * Use is subject to license terms. 4 */ 5 6 /* 7 * Copyright (c) 1983, 1989, 1993 8 * The Regents of the University of California. All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the University of 21 * California, Berkeley and its contributors. 22 * 4. Neither the name of the University nor the names of its contributors 23 * may be used to endorse or promote products derived from this software 24 * without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 */ 38 39 /* 40 * Portions Copyright (C) 2004, 2005, 2008, 2009 41 * Internet Systems Consortium, Inc. ("ISC") 42 * Portions Copyright (C) 1996-2003 Internet Software Consortium. 43 * 44 * Permission to use, copy, modify, and/or distribute this software for any 45 * purpose with or without fee is hereby granted, provided that the above 46 * copyright notice and this permission notice appear in all copies. 47 * 48 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 49 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 50 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 51 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 52 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 53 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 54 * PERFORMANCE OF THIS SOFTWARE. 55 */ 56 57 /* 58 * $Id: nameser.h,v 8.50 2003/05/27 23:36:52 marka Exp $ 59 */ 60 61 #ifndef _ARPA_NAMESER_H 62 #define _ARPA_NAMESER_H 63 64 #include <sys/isa_defs.h> 65 66 67 #ifdef __cplusplus 68 extern "C" { 69 #endif 70 71 #define BIND_4_COMPAT 72 73 /* 74 * Revision information. This is the release date in YYYYMMDD format. 75 * It can change every day so the right thing to do with it is use it 76 * in preprocessor commands such as "#if (__NAMESER > 19931104)". Do not 77 * compare for equality; rather, use it to determine whether your libresolv 78 * contains a new enough lib/nameser/ to support the feature you need. 79 */ 80 81 #define __NAMESER 20090302 /* New interface version stamp. */ 82 83 /* 84 * Define constants based on RFC 883, RFC 1034, RFC 1035 85 */ 86 #define NS_PACKETSZ 512 /* default UDP packet size */ 87 #define NS_MAXDNAME 1025 /* maximum domain name */ 88 #define NS_MAXMSG 65535 /* maximum message size */ 89 #define NS_MAXCDNAME 255 /* maximum compressed domain name */ 90 #define NS_MAXLABEL 63 /* maximum length of domain label */ 91 #define NS_MAXLABELS 128 /* theoretical max #/labels per domain name */ 92 #define NS_MAXNNAME 256 /* maximum uncompressed (binary) domain name */ 93 #define NS_MAXPADDR (sizeof ("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")) 94 #define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */ 95 #define NS_QFIXEDSZ 4 /* #/bytes of fixed data in query */ 96 #define NS_RRFIXEDSZ 10 /* #/bytes of fixed data in r record */ 97 #define NS_INT32SZ 4 /* #/bytes of data in a u_int32_t */ 98 #define NS_INT16SZ 2 /* #/bytes of data in a u_int16_t */ 99 #define NS_INT8SZ 1 /* #/bytes of data in a u_int8_t */ 100 #define NS_INADDRSZ 4 /* IPv4 T_A */ 101 #define NS_IN6ADDRSZ 16 /* IPv6 T_AAAA */ 102 #define NS_CMPRSFLGS 0xc0 /* Flag bits indicating name compression. */ 103 #define NS_DEFAULTPORT 53 /* For both TCP and UDP. */ 104 105 /* 106 * These can be expanded with synonyms, just keep ns_parse.c:ns_parserecord() 107 * in synch with it. 108 */ 109 typedef enum __ns_sect { 110 ns_s_qd = 0, /* Query: Question. */ 111 ns_s_zn = 0, /* Update: Zone. */ 112 ns_s_an = 1, /* Query: Answer. */ 113 ns_s_pr = 1, /* Update: Prerequisites. */ 114 ns_s_ns = 2, /* Query: Name servers. */ 115 ns_s_ud = 2, /* Update: Update. */ 116 ns_s_ar = 3, /* Query|Update: Additional records. */ 117 ns_s_max = 4 118 } ns_sect; 119 120 /* 121 * Network name (compressed or not) type. Equivalent to a pointer when used 122 * in a function prototype. Can be const'd. 123 */ 124 typedef uchar_t ns_nname[NS_MAXNNAME]; 125 typedef const uchar_t *ns_nname_ct; 126 typedef uchar_t *ns_nname_t; 127 128 struct ns_namemap { ns_nname_ct base; int len; }; 129 typedef struct ns_namemap *ns_namemap_t; 130 typedef const struct ns_namemap *ns_namemap_ct; 131 132 /* 133 * This is a message handle. It is caller allocated and has no dynamic data. 134 * This structure is intended to be opaque to all but ns_parse.c, thus the 135 * leading _'s on the member names. Use the accessor functions, not the _'s. 136 */ 137 typedef struct __ns_msg { 138 const uchar_t *_msg, *_eom; 139 uint16_t _id, _flags, _counts[ns_s_max]; 140 const uchar_t *_sections[ns_s_max]; 141 ns_sect _sect; 142 int _rrnum; 143 const uchar_t *_msg_ptr; 144 } ns_msg; 145 146 /* 147 * This is a newmsg handle, used when constructing new messages with 148 * ns_newmsg_init, et al. 149 */ 150 struct ns_newmsg { 151 ns_msg msg; 152 const uchar_t *dnptrs[25]; 153 const uchar_t **lastdnptr; 154 }; 155 typedef struct ns_newmsg ns_newmsg; 156 157 /* Private data structure - do not use from outside library. */ 158 struct _ns_flagdata { int mask, shift; }; 159 extern struct _ns_flagdata _ns_flagdata[]; 160 161 /* Accessor macros - this is part of the public interface. */ 162 #define ns_msg_id(handle) ((handle)._id + 0) 163 #define ns_msg_base(handle) ((handle)._msg + 0) 164 #define ns_msg_end(handle) ((handle)._eom + 0) 165 #define ns_msg_size(handle) ((handle)._eom - (handle)._msg) 166 #define ns_msg_count(handle, section) ((handle)._counts[section] + 0) 167 168 /* 169 * This is a parsed record. It is caller allocated and has no dynamic data. 170 */ 171 typedef struct __ns_rr { 172 char name[NS_MAXDNAME]; 173 uint16_t type; 174 uint16_t rr_class; 175 uint32_t ttl; 176 uint16_t rdlength; 177 const uchar_t *rdata; 178 } ns_rr; 179 180 /* 181 * Same thing, but using uncompressed network binary names, and real C types. 182 */ 183 typedef struct __ns_rr2 { 184 ns_nname nname; 185 size_t nnamel; 186 int type; 187 int rr_class; 188 uint_t ttl; 189 int rdlength; 190 const uchar_t *rdata; 191 } ns_rr2; 192 193 /* Accessor macros - this is part of the public interface. */ 194 #define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".") 195 #define ns_rr_nname(rr) ((const ns_nname_t)(rr).nname) 196 #define ns_rr_nnamel(rr) ((rr).nnamel + 0) 197 #define ns_rr_type(rr) ((ns_type)((rr).type + 0)) 198 #define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0)) 199 #define ns_rr_ttl(rr) ((rr).ttl + 0) 200 #define ns_rr_rdlen(rr) ((rr).rdlength + 0) 201 #define ns_rr_rdata(rr) ((rr).rdata + 0) 202 203 /* 204 * These don't have to be in the same order as in the packet flags word, 205 * and they can even overlap in some cases, but they will need to be kept 206 * in synch with ns_parse.c:ns_flagdata[]. 207 */ 208 typedef enum __ns_flag { 209 ns_f_qr, /* Question/Response. */ 210 ns_f_opcode, /* Operation code. */ 211 ns_f_aa, /* Authoritative Answer. */ 212 ns_f_tc, /* Truncation occurred. */ 213 ns_f_rd, /* Recursion Desired. */ 214 ns_f_ra, /* Recursion Available. */ 215 ns_f_z, /* MBZ. */ 216 ns_f_ad, /* Authentic Data (DNSSEC). */ 217 ns_f_cd, /* Checking Disabled (DNSSEC). */ 218 ns_f_rcode, /* Response code. */ 219 ns_f_max 220 } ns_flag; 221 222 /* 223 * Currently defined opcodes. 224 */ 225 typedef enum __ns_opcode { 226 ns_o_query = 0, /* Standard query. */ 227 ns_o_iquery = 1, /* Inverse query (deprecated/unsupported). */ 228 ns_o_status = 2, /* Name server status query (unsupported). */ 229 /* Opcode 3 is undefined/reserved. */ 230 ns_o_notify = 4, /* Zone change notification. */ 231 ns_o_update = 5, /* Zone update message. */ 232 ns_o_max = 6 233 } ns_opcode; 234 235 /* 236 * Currently defined response codes. 237 */ 238 typedef enum __ns_rcode { 239 ns_r_noerror = 0, /* No error occurred. */ 240 ns_r_formerr = 1, /* Format error. */ 241 ns_r_servfail = 2, /* Server failure. */ 242 ns_r_nxdomain = 3, /* Name error. */ 243 ns_r_notimpl = 4, /* Unimplemented. */ 244 ns_r_refused = 5, /* Operation refused. */ 245 /* these are for BIND_UPDATE */ 246 ns_r_yxdomain = 6, /* Name exists */ 247 ns_r_yxrrset = 7, /* RRset exists */ 248 ns_r_nxrrset = 8, /* RRset does not exist */ 249 ns_r_notauth = 9, /* Not authoritative for zone */ 250 ns_r_notzone = 10, /* Zone of record different from zone section */ 251 ns_r_max = 11, 252 /* The following are EDNS extended rcodes */ 253 ns_r_badvers = 16, 254 /* The following are TSIG errors */ 255 ns_r_badsig = 16, 256 ns_r_badkey = 17, 257 ns_r_badtime = 18 258 } ns_rcode; 259 260 /* BIND_UPDATE */ 261 typedef enum __ns_update_operation { 262 ns_uop_delete = 0, 263 ns_uop_add = 1, 264 ns_uop_max = 2 265 } ns_update_operation; 266 267 /* 268 * This RR-like structure is particular to UPDATE. 269 */ 270 struct ns_updrec { 271 struct ns_updrec *r_prev; /* prev record */ 272 struct ns_updrec *r_next; /* next record */ 273 uint8_t r_section; /* ZONE/PREREQUISITE/UPDATE */ 274 char *r_dname; /* owner of the RR */ 275 uint16_t r_class; /* class number */ 276 uint16_t r_type; /* type number */ 277 uint32_t r_ttl; /* time to live */ 278 uchar_t *r_data; /* rdata fields as text string */ 279 uint16_t r_size; /* size of r_data field */ 280 int r_opcode; /* type of operation */ 281 /* following fields for private use by the resolver/server routines */ 282 struct ns_updrec *r_grpnext; /* next record when grouped */ 283 struct databuf *r_dp; /* databuf to process */ 284 struct databuf *r_deldp; /* databuf's deleted/overwritten */ 285 uint16_t r_zone; /* zone number on server */ 286 }; 287 typedef struct ns_updrec ns_updrec; 288 289 /* 290 * This structure is used for TSIG authenticated messages 291 */ 292 struct ns_tsig_key { 293 char name[NS_MAXDNAME], alg[NS_MAXDNAME]; 294 unsigned char *data; 295 int len; 296 }; 297 typedef struct ns_tsig_key ns_tsig_key; 298 299 /* 300 * This structure is used for TSIG authenticated TCP messages 301 */ 302 struct ns_tcp_tsig_state { 303 int counter; 304 struct dst_key *key; 305 void *ctx; 306 unsigned char sig[NS_PACKETSZ]; 307 int siglen; 308 }; 309 typedef struct ns_tcp_tsig_state ns_tcp_tsig_state; 310 311 #define NS_TSIG_FUDGE 300 312 #define NS_TSIG_TCP_COUNT 100 313 #define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT" 314 315 #define NS_TSIG_ERROR_NO_TSIG -10 316 #define NS_TSIG_ERROR_NO_SPACE -11 317 #define NS_TSIG_ERROR_FORMERR -12 318 319 /* 320 * Currently defined type values for resources and queries. 321 */ 322 typedef enum __ns_type { 323 ns_t_invalid = 0, /* Cookie. */ 324 ns_t_a = 1, /* Host address. */ 325 ns_t_ns = 2, /* Authoritative server. */ 326 ns_t_md = 3, /* Mail destination. */ 327 ns_t_mf = 4, /* Mail forwarder. */ 328 ns_t_cname = 5, /* Canonical name. */ 329 ns_t_soa = 6, /* Start of authority zone. */ 330 ns_t_mb = 7, /* Mailbox domain name. */ 331 ns_t_mg = 8, /* Mail group member. */ 332 ns_t_mr = 9, /* Mail rename name. */ 333 ns_t_null = 10, /* Null resource record. */ 334 ns_t_wks = 11, /* Well known service. */ 335 ns_t_ptr = 12, /* Domain name pointer. */ 336 ns_t_hinfo = 13, /* Host information. */ 337 ns_t_minfo = 14, /* Mailbox information. */ 338 ns_t_mx = 15, /* Mail routing information. */ 339 ns_t_txt = 16, /* Text strings. */ 340 ns_t_rp = 17, /* Responsible person. */ 341 ns_t_afsdb = 18, /* AFS cell database. */ 342 ns_t_x25 = 19, /* X_25 calling address. */ 343 ns_t_isdn = 20, /* ISDN calling address. */ 344 ns_t_rt = 21, /* Router. */ 345 ns_t_nsap = 22, /* NSAP address. */ 346 ns_t_nsap_ptr = 23, /* Reverse NSAP lookup (deprecated). */ 347 ns_t_sig = 24, /* Security signature. */ 348 ns_t_key = 25, /* Security key. */ 349 ns_t_px = 26, /* X.400 mail mapping. */ 350 ns_t_gpos = 27, /* Geographical position (withdrawn). */ 351 ns_t_aaaa = 28, /* IPv6 Address. */ 352 ns_t_loc = 29, /* Location Information. */ 353 ns_t_nxt = 30, /* Next domain (security). */ 354 ns_t_eid = 31, /* Endpoint identifier. */ 355 ns_t_nimloc = 32, /* Nimrod Locator. */ 356 ns_t_srv = 33, /* Server Selection. */ 357 ns_t_atma = 34, /* ATM Address */ 358 ns_t_naptr = 35, /* Naming Authority PoinTeR */ 359 ns_t_kx = 36, /* Key Exchange */ 360 ns_t_cert = 37, /* Certification record */ 361 ns_t_a6 = 38, /* IPv6 address (deprecated) */ 362 ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */ 363 ns_t_sink = 40, /* Kitchen sink (experimentatl) */ 364 ns_t_opt = 41, /* EDNS0 option (meta-RR) */ 365 ns_t_apl = 42, /* Address prefix list (RFC 3123) */ 366 ns_t_ds = 43, /* Delegation Signer */ 367 ns_t_sshfp = 44, /* SSH Fingerprint */ 368 ns_t_ipseckey = 45, /* IPSEC Key */ 369 ns_t_rrsig = 46, /* RRset Signature */ 370 ns_t_nsec = 47, /* Negative security */ 371 ns_t_dnskey = 48, /* DNS Key */ 372 ns_t_dhcid = 49, /* Dynamic host configuratin identifier */ 373 ns_t_nsec3 = 50, /* Negative security type 3 */ 374 ns_t_nsec3param = 51, /* Negative security type 3 parameters */ 375 ns_t_hip = 55, /* Host Identity Protocol */ 376 ns_t_spf = 99, /* Sender Policy Framework */ 377 ns_t_tkey = 249, /* Transaction key */ 378 ns_t_tsig = 250, /* Transaction signature. */ 379 ns_t_ixfr = 251, /* Incremental zone transfer. */ 380 ns_t_axfr = 252, /* Transfer zone of authority. */ 381 ns_t_mailb = 253, /* Transfer mailbox records. */ 382 ns_t_maila = 254, /* Transfer mail agent records. */ 383 ns_t_any = 255, /* Wildcard match. */ 384 ns_t_zxfr = 256, /* BIND-specific, nonstandard. */ 385 ns_t_dlv = 32769, /* DNSSEC look-aside validatation. */ 386 ns_t_max = 65536 387 } ns_type; 388 389 /* Exclusively a QTYPE? (not also an RTYPE) */ 390 #define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \ 391 (t) == ns_t_mailb || (t) == ns_t_maila) 392 /* Some kind of meta-RR? (not a QTYPE, but also not an RTYPE) */ 393 #define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt) 394 /* Exclusively an RTYPE? (not also a QTYPE or a meta-RR) */ 395 #define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t)) 396 #define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr) 397 #define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \ 398 (t) == ns_t_zxfr) 399 400 /* 401 * Values for class field 402 */ 403 typedef enum __ns_class { 404 ns_c_invalid = 0, /* Cookie. */ 405 ns_c_in = 1, /* Internet. */ 406 ns_c_2 = 2, /* unallocated/unsupported. */ 407 ns_c_chaos = 3, /* MIT Chaos-net. */ 408 ns_c_hs = 4, /* MIT Hesiod. */ 409 /* Query class values which do not appear in resource records */ 410 ns_c_none = 254, /* for prereq. sections in update requests */ 411 ns_c_any = 255, /* Wildcard match. */ 412 ns_c_max = 65536 413 } ns_class; 414 415 /* DNSSEC constants. */ 416 417 typedef enum __ns_key_types { 418 ns_kt_rsa = 1, /* key type RSA/MD5 */ 419 ns_kt_dh = 2, /* Diffie Hellman */ 420 ns_kt_dsa = 3, /* Digital Signature Standard (MANDATORY) */ 421 ns_kt_private = 254 /* Private key type starts with OID */ 422 } ns_key_types; 423 424 typedef enum __ns_cert_types { 425 cert_t_pkix = 1, /* PKIX (X.509v3) */ 426 cert_t_spki = 2, /* SPKI */ 427 cert_t_pgp = 3, /* PGP */ 428 cert_t_url = 253, /* URL private type */ 429 cert_t_oid = 254 /* OID private type */ 430 } ns_cert_types; 431 432 /* Flags field of the KEY RR rdata. */ 433 #define NS_KEY_TYPEMASK 0xC000 /* Mask for "type" bits */ 434 #define NS_KEY_TYPE_AUTH_CONF 0x0000 /* Key usable for both */ 435 #define NS_KEY_TYPE_CONF_ONLY 0x8000 /* Key usable for confidentiality */ 436 #define NS_KEY_TYPE_AUTH_ONLY 0x4000 /* Key usable for authentication */ 437 #define NS_KEY_TYPE_NO_KEY 0xC000 /* No key usable for either; no key */ 438 /* The type bits can also be interpreted independently, as single bits: */ 439 #define NS_KEY_NO_AUTH 0x8000 /* Key unusable for authentication */ 440 #define NS_KEY_NO_CONF 0x4000 /* Key unusable for confidentiality */ 441 #define NS_KEY_RESERVED2 0x2000 /* Security is *mandatory* if bit=0 */ 442 #define NS_KEY_EXTENDED_FLAGS 0x1000 /* reserved - must be zero */ 443 #define NS_KEY_RESERVED4 0x0800 /* reserved - must be zero */ 444 #define NS_KEY_RESERVED5 0x0400 /* reserved - must be zero */ 445 #define NS_KEY_NAME_TYPE 0x0300 /* these bits determine the type */ 446 #define NS_KEY_NAME_USER 0x0000 /* key is assoc. with user */ 447 #define NS_KEY_NAME_ENTITY 0x0200 /* key is assoc. with entity eg host */ 448 #define NS_KEY_NAME_ZONE 0x0100 /* key is zone key */ 449 #define NS_KEY_NAME_RESERVED 0x0300 /* reserved meaning */ 450 #define NS_KEY_RESERVED8 0x0080 /* reserved - must be zero */ 451 #define NS_KEY_RESERVED9 0x0040 /* reserved - must be zero */ 452 #define NS_KEY_RESERVED10 0x0020 /* reserved - must be zero */ 453 #define NS_KEY_RESERVED11 0x0010 /* reserved - must be zero */ 454 #define NS_KEY_SIGNATORYMASK 0x000F /* key can sign RR's of same name */ 455 #define NS_KEY_RESERVED_BITMASK (NS_KEY_RESERVED2 | \ 456 NS_KEY_RESERVED4 | \ 457 NS_KEY_RESERVED5 | \ 458 NS_KEY_RESERVED8 | \ 459 NS_KEY_RESERVED9 | \ 460 NS_KEY_RESERVED10 | \ 461 NS_KEY_RESERVED11) 462 #define NS_KEY_RESERVED_BITMASK2 0xFFFF /* no bits defined here */ 463 464 /* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */ 465 #define NS_ALG_MD5RSA 1 /* MD5 with RSA */ 466 #define NS_ALG_DH 2 /* Diffie Hellman KEY */ 467 #define NS_ALG_DSA 3 /* DSA KEY */ 468 #define NS_ALG_DSS NS_ALG_DSA 469 #define NS_ALG_EXPIRE_ONLY 253 /* No alg, no security */ 470 #define NS_ALG_PRIVATE_OID 254 /* Key begins with OID giving alg */ 471 472 /* Protocol values */ 473 /* value 0 is reserved */ 474 #define NS_KEY_PROT_TLS 1 475 #define NS_KEY_PROT_EMAIL 2 476 #define NS_KEY_PROT_DNSSEC 3 477 #define NS_KEY_PROT_IPSEC 4 478 #define NS_KEY_PROT_ANY 255 479 480 /* Signatures */ 481 #define NS_MD5RSA_MIN_BITS 512 /* Size of a mod or exp in bits */ 482 #define NS_MD5RSA_MAX_BITS 4096 483 /* Total of binary mod and exp */ 484 #define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3) 485 /* Max length of text sig block */ 486 #define NS_MD5RSA_MAX_BASE64 (((NS_MD5RSA_MAX_BYTES+2)/3)*4) 487 #define NS_MD5RSA_MIN_SIZE ((NS_MD5RSA_MIN_BITS+7)/8) 488 #define NS_MD5RSA_MAX_SIZE ((NS_MD5RSA_MAX_BITS+7)/8) 489 490 #define NS_DSA_SIG_SIZE 41 491 #define NS_DSA_MIN_SIZE 213 492 #define NS_DSA_MAX_BYTES 405 493 494 /* Offsets into SIG record rdata to find various values */ 495 #define NS_SIG_TYPE 0 /* Type flags */ 496 #define NS_SIG_ALG 2 /* Algorithm */ 497 #define NS_SIG_LABELS 3 /* How many labels in name */ 498 #define NS_SIG_OTTL 4 /* Original TTL */ 499 #define NS_SIG_EXPIR 8 /* Expiration time */ 500 #define NS_SIG_SIGNED 12 /* Signature time */ 501 #define NS_SIG_FOOT 16 /* Key footprint */ 502 #define NS_SIG_SIGNER 18 /* Domain name of who signed it */ 503 504 /* How RR types are represented as bit-flags in NXT records */ 505 #define NS_NXT_BITS 8 506 #define NS_NXT_BIT_SET(n, p) \ 507 (p[(n)/NS_NXT_BITS] |= (0x80>>((n)%NS_NXT_BITS))) 508 #define NS_NXT_BIT_CLEAR(n, p) \ 509 (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS))) 510 #define NS_NXT_BIT_ISSET(n, p) \ 511 (p[(n)/NS_NXT_BITS] & (0x80>>((n)%NS_NXT_BITS))) 512 #define NS_NXT_MAX 127 513 514 /* 515 * EDNS0 extended flags, host order. 516 */ 517 #define NS_OPT_DNSSEC_OK 0x8000U 518 #define NS_OPT_NSID 3 519 520 /* 521 * Inline versions of get/put short/long. Pointer is advanced. 522 */ 523 #define NS_GET16(s, cp) do { \ 524 register const uchar_t *t_cp = (const uchar_t *)(cp); \ 525 (s) = ((uint16_t)t_cp[0] << 8) \ 526 | ((uint16_t)t_cp[1]) \ 527 ; \ 528 (cp) += NS_INT16SZ; \ 529 } while (0) 530 531 #define NS_GET32(l, cp) do { \ 532 register const uchar_t *t_cp = (const uchar_t *)(cp); \ 533 (l) = ((uint32_t)t_cp[0] << 24) \ 534 | ((uint32_t)t_cp[1] << 16) \ 535 | ((uint32_t)t_cp[2] << 8) \ 536 | ((uint32_t)t_cp[3]) \ 537 ; \ 538 (cp) += NS_INT32SZ; \ 539 } while (0) 540 541 #define NS_PUT16(s, cp) do { \ 542 register uint16_t t_s = (uint16_t)(s); \ 543 register uchar_t *t_cp = (uchar_t *)(cp); \ 544 *t_cp++ = t_s >> 8; \ 545 *t_cp = t_s; \ 546 (cp) += NS_INT16SZ; \ 547 } while (0) 548 549 #define NS_PUT32(l, cp) do { \ 550 register uint32_t t_l = (uint32_t)(l); \ 551 register uchar_t *t_cp = (uchar_t *)(cp); \ 552 *t_cp++ = t_l >> 24; \ 553 *t_cp++ = t_l >> 16; \ 554 *t_cp++ = t_l >> 8; \ 555 *t_cp = t_l; \ 556 (cp) += NS_INT32SZ; \ 557 } while (0) 558 559 /* 560 * ANSI C identifier hiding. 561 */ 562 #define ns_msg_getflag __ns_msg_getflag 563 #define ns_get16 __ns_get16 564 #define ns_get32 __ns_get32 565 #define ns_put16 __ns_put16 566 #define ns_put32 __ns_put32 567 #define ns_initparse __ns_initparse 568 #define ns_skiprr __ns_skiprr 569 #define ns_parserr __ns_parserr 570 #define ns_parserr2 __ns_parserr2 571 #define ns_sprintrr __ns_sprintrr 572 #define ns_sprintrrf __ns_sprintrrf 573 #define ns_format_ttl __ns_format_ttl 574 #define ns_parse_ttl __ns_parse_ttl 575 #define ns_datetosecs __ns_datetosecs 576 #define ns_name_ntol __ns_name_ntol 577 #define ns_name_ntop __ns_name_ntop 578 #define ns_name_pton __ns_name_pton 579 #define ns_name_unpack __ns_name_unpack 580 #define ns_name_pack __ns_name_pack 581 #define ns_name_compress __ns_name_compress 582 #define ns_name_uncompress __ns_name_uncompress 583 #define ns_name_skip __ns_name_skip 584 #define ns_name_rollback __ns_name_rollback 585 #define ns_name_length __ns_name_length 586 #define ns_name_eq __ns_name_eq 587 #define ns_name_owned __ns_name_owned 588 #define ns_name_map __ns_name_map 589 #define ns_name_labels __ns_name_labels 590 #define ns_sign __ns_sign 591 #define ns_sign2 __ns_sign2 592 #define ns_sign_tcp __ns_sign_tcp 593 #define ns_sign_tcp2 __ns_sign_tcp2 594 #define ns_sign_tcp_init __ns_sign_tcp_init 595 #define ns_find_tsig __ns_find_tsig 596 #define ns_verify __ns_verify 597 #define ns_verify_tcp __ns_verify_tcp 598 #define ns_verify_tcp_init __ns_verify_tcp_init 599 #define ns_samedomain __ns_samedomain 600 #define ns_subdomain __ns_subdomain 601 #define ns_makecanon __ns_makecanon 602 #define ns_samename __ns_samename 603 #define ns_newmsg_init __ns_newmsg_init 604 #define ns_newmsg_copy __ns_newmsg_copy 605 #define ns_newmsg_id __ns_newmsg_id 606 #define ns_newmsg_flag __ns_newmsg_flag 607 #define ns_newmsg_q __ns_newmsg_q 608 #define ns_newmsg_rr __ns_newmsg_rr 609 #define ns_newmsg_done __ns_newmsg_done 610 #define ns_rdata_unpack __ns_rdata_unpack 611 #define ns_rdata_equal __ns_rdata_equal 612 #define ns_rdata_refers __ns_rdata_refers 613 614 int ns_msg_getflag(ns_msg, int); 615 uint_t ns_get16(const uchar_t *); 616 ulong_t ns_get32(const uchar_t *); 617 void ns_put16(uint_t, uchar_t *); 618 void ns_put32(ulong_t, uchar_t *); 619 int ns_initparse(const uchar_t *, int, ns_msg *); 620 int ns_skiprr(const uchar_t *, const uchar_t *, ns_sect, int); 621 int ns_parserr(ns_msg *, ns_sect, int, ns_rr *); 622 int ns_parserr2(ns_msg *, ns_sect, int, ns_rr2 *); 623 int ns_sprintrr(const ns_msg *, const ns_rr *, 624 const char *, const char *, char *, size_t); 625 int ns_sprintrrf(const uchar_t *, size_t, const char *, 626 ns_class, ns_type, ulong_t, const uchar_t *, 627 size_t, const char *, const char *, 628 char *, size_t); 629 int ns_format_ttl(ulong_t, char *, size_t); 630 int ns_parse_ttl(const char *, ulong_t *); 631 uint32_t ns_datetosecs(const char *cp, int *errp); 632 int ns_name_ntol(const uchar_t *, uchar_t *, size_t); 633 int ns_name_ntop(const uchar_t *, char *, size_t); 634 int ns_name_pton(const char *, uchar_t *, size_t); 635 int ns_name_unpack(const uchar_t *, const uchar_t *, 636 const uchar_t *, uchar_t *, size_t); 637 int ns_name_pack(const uchar_t *, uchar_t *, int, 638 const uchar_t **, const uchar_t **); 639 int ns_name_uncompress(const uchar_t *, const uchar_t *, 640 const uchar_t *, char *, size_t); 641 int ns_name_compress(const char *, uchar_t *, size_t, 642 const uchar_t **, const uchar_t **); 643 int ns_name_skip(const uchar_t **, const uchar_t *); 644 void ns_name_rollback(const uchar_t *, const uchar_t **, 645 const uchar_t **); 646 ssize_t ns_name_length(ns_nname_ct, size_t); 647 int ns_name_eq(ns_nname_ct, size_t, ns_nname_ct, size_t); 648 int ns_name_owned(ns_namemap_ct, int, ns_namemap_ct, int); 649 int ns_name_map(ns_nname_ct, size_t, ns_namemap_t, int); 650 int ns_name_labels(ns_nname_ct, size_t); 651 int ns_sign(uchar_t *, int *, int, int, void *, 652 const uchar_t *, int, uchar_t *, int *, time_t); 653 int ns_sign2(uchar_t *, int *, int, int, void *, 654 const uchar_t *, int, uchar_t *, int *, time_t, 655 uchar_t **, uchar_t **); 656 int ns_sign_tcp(uchar_t *, int *, int, int, 657 ns_tcp_tsig_state *, int); 658 int ns_sign_tcp2(uchar_t *, int *, int, int, 659 ns_tcp_tsig_state *, int, 660 uchar_t **, uchar_t **); 661 int ns_sign_tcp_init(void *, const uchar_t *, int, 662 ns_tcp_tsig_state *); 663 uchar_t *ns_find_tsig(uchar_t *, uchar_t *); 664 int ns_verify(uchar_t *, int *, void *, 665 const uchar_t *, int, uchar_t *, int *, 666 time_t *, int); 667 int ns_verify_tcp(uchar_t *, int *, ns_tcp_tsig_state *, int); 668 int ns_verify_tcp_init(void *, const uchar_t *, int, 669 ns_tcp_tsig_state *); 670 int ns_samedomain(const char *, const char *); 671 int ns_subdomain(const char *, const char *); 672 int ns_makecanon(const char *, char *, size_t); 673 int ns_samename(const char *, const char *); 674 int ns_newmsg_init(uchar_t *buffer, size_t bufsiz, ns_newmsg *); 675 int ns_newmsg_copy(ns_newmsg *, ns_msg *); 676 void ns_newmsg_id(ns_newmsg *handle, uint16_t id); 677 void ns_newmsg_flag(ns_newmsg *handle, ns_flag flag, uint_t value); 678 int ns_newmsg_q(ns_newmsg *handle, ns_nname_ct qname, 679 ns_type qtype, ns_class qclass); 680 int ns_newmsg_rr(ns_newmsg *handle, ns_sect sect, 681 ns_nname_ct name, ns_type type, 682 ns_class rr_class, uint32_t ttl, 683 uint16_t rdlen, const uchar_t *rdata); 684 size_t ns_newmsg_done(ns_newmsg *handle); 685 ssize_t ns_rdata_unpack(const uchar_t *, const uchar_t *, ns_type, 686 const uchar_t *, size_t, uchar_t *, size_t); 687 int ns_rdata_equal(ns_type, const uchar_t *, size_t, 688 const uchar_t *, size_t); 689 int ns_rdata_refers(ns_type, 690 const uchar_t *, size_t, 691 const uchar_t *); 692 693 #ifdef BIND_4_COMPAT 694 #include <arpa/nameser_compat.h> 695 #endif 696 697 #ifdef __cplusplus 698 } 699 #endif 700 701 #endif /* !_ARPA_NAMESER_H */ 702