17c478bd9Sstevel@tonic-gate /* 29525b14bSRao Shoaib * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 37c478bd9Sstevel@tonic-gate * Use is subject to license terms. 4b31320a7SChris Fraire * Copyright (c) 2016, Chris Fraire <cfraire@me.com>. 57c478bd9Sstevel@tonic-gate */ 67c478bd9Sstevel@tonic-gate 77c478bd9Sstevel@tonic-gate /* 87c478bd9Sstevel@tonic-gate * Copyright (c) 1983, 1989, 1993 97c478bd9Sstevel@tonic-gate * The Regents of the University of California. All rights reserved. 107c478bd9Sstevel@tonic-gate * 117c478bd9Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without 127c478bd9Sstevel@tonic-gate * modification, are permitted provided that the following conditions 137c478bd9Sstevel@tonic-gate * are met: 147c478bd9Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright 157c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer. 167c478bd9Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright 177c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the 187c478bd9Sstevel@tonic-gate * documentation and/or other materials provided with the distribution. 197c478bd9Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this software 207c478bd9Sstevel@tonic-gate * must display the following acknowledgement: 216e270ca8SMarcel Telka * This product includes software developed by the University of 226e270ca8SMarcel Telka * California, Berkeley and its contributors. 237c478bd9Sstevel@tonic-gate * 4. Neither the name of the University nor the names of its contributors 247c478bd9Sstevel@tonic-gate * may be used to endorse or promote products derived from this software 257c478bd9Sstevel@tonic-gate * without specific prior written permission. 267c478bd9Sstevel@tonic-gate * 277c478bd9Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 287c478bd9Sstevel@tonic-gate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 297c478bd9Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 307c478bd9Sstevel@tonic-gate * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 317c478bd9Sstevel@tonic-gate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 327c478bd9Sstevel@tonic-gate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 337c478bd9Sstevel@tonic-gate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 347c478bd9Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 357c478bd9Sstevel@tonic-gate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 367c478bd9Sstevel@tonic-gate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 377c478bd9Sstevel@tonic-gate * SUCH DAMAGE. 387c478bd9Sstevel@tonic-gate */ 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate /* 419525b14bSRao Shoaib * Portions Copyright (C) 2004, 2005, 2008, 2009 429525b14bSRao Shoaib * Internet Systems Consortium, Inc. ("ISC") 439525b14bSRao Shoaib * Portions Copyright (C) 1996-2003 Internet Software Consortium. 447c478bd9Sstevel@tonic-gate * 459525b14bSRao Shoaib * Permission to use, copy, modify, and/or distribute this software for any 467c478bd9Sstevel@tonic-gate * purpose with or without fee is hereby granted, provided that the above 477c478bd9Sstevel@tonic-gate * copyright notice and this permission notice appear in all copies. 487c478bd9Sstevel@tonic-gate * 499525b14bSRao Shoaib * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 509525b14bSRao Shoaib * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 519525b14bSRao Shoaib * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 529525b14bSRao Shoaib * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 539525b14bSRao Shoaib * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 549525b14bSRao Shoaib * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 559525b14bSRao Shoaib * PERFORMANCE OF THIS SOFTWARE. 567c478bd9Sstevel@tonic-gate */ 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* 597c478bd9Sstevel@tonic-gate * $Id: nameser.h,v 8.50 2003/05/27 23:36:52 marka Exp $ 607c478bd9Sstevel@tonic-gate */ 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate #ifndef _ARPA_NAMESER_H 637c478bd9Sstevel@tonic-gate #define _ARPA_NAMESER_H 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate #ifdef __cplusplus 697c478bd9Sstevel@tonic-gate extern "C" { 707c478bd9Sstevel@tonic-gate #endif 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate #define BIND_4_COMPAT 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate /* 757c478bd9Sstevel@tonic-gate * Revision information. This is the release date in YYYYMMDD format. 767c478bd9Sstevel@tonic-gate * It can change every day so the right thing to do with it is use it 777c478bd9Sstevel@tonic-gate * in preprocessor commands such as "#if (__NAMESER > 19931104)". Do not 787c478bd9Sstevel@tonic-gate * compare for equality; rather, use it to determine whether your libresolv 797c478bd9Sstevel@tonic-gate * contains a new enough lib/nameser/ to support the feature you need. 807c478bd9Sstevel@tonic-gate */ 817c478bd9Sstevel@tonic-gate 829525b14bSRao Shoaib #define __NAMESER 20090302 /* New interface version stamp. */ 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate /* 857c478bd9Sstevel@tonic-gate * Define constants based on RFC 883, RFC 1034, RFC 1035 867c478bd9Sstevel@tonic-gate */ 877c478bd9Sstevel@tonic-gate #define NS_PACKETSZ 512 /* default UDP packet size */ 887c478bd9Sstevel@tonic-gate #define NS_MAXDNAME 1025 /* maximum domain name */ 897c478bd9Sstevel@tonic-gate #define NS_MAXMSG 65535 /* maximum message size */ 907c478bd9Sstevel@tonic-gate #define NS_MAXCDNAME 255 /* maximum compressed domain name */ 917c478bd9Sstevel@tonic-gate #define NS_MAXLABEL 63 /* maximum length of domain label */ 929525b14bSRao Shoaib #define NS_MAXLABELS 128 /* theoretical max #/labels per domain name */ 939525b14bSRao Shoaib #define NS_MAXNNAME 256 /* maximum uncompressed (binary) domain name */ 949525b14bSRao Shoaib #define NS_MAXPADDR (sizeof ("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")) 957c478bd9Sstevel@tonic-gate #define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */ 967c478bd9Sstevel@tonic-gate #define NS_QFIXEDSZ 4 /* #/bytes of fixed data in query */ 977c478bd9Sstevel@tonic-gate #define NS_RRFIXEDSZ 10 /* #/bytes of fixed data in r record */ 987c478bd9Sstevel@tonic-gate #define NS_INT32SZ 4 /* #/bytes of data in a u_int32_t */ 997c478bd9Sstevel@tonic-gate #define NS_INT16SZ 2 /* #/bytes of data in a u_int16_t */ 1007c478bd9Sstevel@tonic-gate #define NS_INT8SZ 1 /* #/bytes of data in a u_int8_t */ 1017c478bd9Sstevel@tonic-gate #define NS_INADDRSZ 4 /* IPv4 T_A */ 1027c478bd9Sstevel@tonic-gate #define NS_IN6ADDRSZ 16 /* IPv6 T_AAAA */ 1037c478bd9Sstevel@tonic-gate #define NS_CMPRSFLGS 0xc0 /* Flag bits indicating name compression. */ 1047c478bd9Sstevel@tonic-gate #define NS_DEFAULTPORT 53 /* For both TCP and UDP. */ 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate /* 1077c478bd9Sstevel@tonic-gate * These can be expanded with synonyms, just keep ns_parse.c:ns_parserecord() 1087c478bd9Sstevel@tonic-gate * in synch with it. 1097c478bd9Sstevel@tonic-gate */ 1107c478bd9Sstevel@tonic-gate typedef enum __ns_sect { 1117c478bd9Sstevel@tonic-gate ns_s_qd = 0, /* Query: Question. */ 1127c478bd9Sstevel@tonic-gate ns_s_zn = 0, /* Update: Zone. */ 1137c478bd9Sstevel@tonic-gate ns_s_an = 1, /* Query: Answer. */ 1147c478bd9Sstevel@tonic-gate ns_s_pr = 1, /* Update: Prerequisites. */ 1157c478bd9Sstevel@tonic-gate ns_s_ns = 2, /* Query: Name servers. */ 1167c478bd9Sstevel@tonic-gate ns_s_ud = 2, /* Update: Update. */ 1177c478bd9Sstevel@tonic-gate ns_s_ar = 3, /* Query|Update: Additional records. */ 1187c478bd9Sstevel@tonic-gate ns_s_max = 4 1197c478bd9Sstevel@tonic-gate } ns_sect; 1207c478bd9Sstevel@tonic-gate 1219525b14bSRao Shoaib /* 1229525b14bSRao Shoaib * Network name (compressed or not) type. Equivalent to a pointer when used 1239525b14bSRao Shoaib * in a function prototype. Can be const'd. 1249525b14bSRao Shoaib */ 1259525b14bSRao Shoaib typedef uchar_t ns_nname[NS_MAXNNAME]; 1269525b14bSRao Shoaib typedef const uchar_t *ns_nname_ct; 1279525b14bSRao Shoaib typedef uchar_t *ns_nname_t; 1289525b14bSRao Shoaib 1299525b14bSRao Shoaib struct ns_namemap { ns_nname_ct base; int len; }; 1309525b14bSRao Shoaib typedef struct ns_namemap *ns_namemap_t; 1319525b14bSRao Shoaib typedef const struct ns_namemap *ns_namemap_ct; 1329525b14bSRao Shoaib 1337c478bd9Sstevel@tonic-gate /* 1347c478bd9Sstevel@tonic-gate * This is a message handle. It is caller allocated and has no dynamic data. 1357c478bd9Sstevel@tonic-gate * This structure is intended to be opaque to all but ns_parse.c, thus the 1367c478bd9Sstevel@tonic-gate * leading _'s on the member names. Use the accessor functions, not the _'s. 1377c478bd9Sstevel@tonic-gate */ 1387c478bd9Sstevel@tonic-gate typedef struct __ns_msg { 1397c478bd9Sstevel@tonic-gate const uchar_t *_msg, *_eom; 1407c478bd9Sstevel@tonic-gate uint16_t _id, _flags, _counts[ns_s_max]; 1417c478bd9Sstevel@tonic-gate const uchar_t *_sections[ns_s_max]; 1427c478bd9Sstevel@tonic-gate ns_sect _sect; 1437c478bd9Sstevel@tonic-gate int _rrnum; 1447c478bd9Sstevel@tonic-gate const uchar_t *_msg_ptr; 1457c478bd9Sstevel@tonic-gate } ns_msg; 1467c478bd9Sstevel@tonic-gate 1479525b14bSRao Shoaib /* 1489525b14bSRao Shoaib * This is a newmsg handle, used when constructing new messages with 1499525b14bSRao Shoaib * ns_newmsg_init, et al. 1509525b14bSRao Shoaib */ 1519525b14bSRao Shoaib struct ns_newmsg { 1529525b14bSRao Shoaib ns_msg msg; 1539525b14bSRao Shoaib const uchar_t *dnptrs[25]; 1549525b14bSRao Shoaib const uchar_t **lastdnptr; 1559525b14bSRao Shoaib }; 1569525b14bSRao Shoaib typedef struct ns_newmsg ns_newmsg; 1579525b14bSRao Shoaib 1587c478bd9Sstevel@tonic-gate /* Private data structure - do not use from outside library. */ 1597c478bd9Sstevel@tonic-gate struct _ns_flagdata { int mask, shift; }; 1607c478bd9Sstevel@tonic-gate extern struct _ns_flagdata _ns_flagdata[]; 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate /* Accessor macros - this is part of the public interface. */ 1637c478bd9Sstevel@tonic-gate #define ns_msg_id(handle) ((handle)._id + 0) 1647c478bd9Sstevel@tonic-gate #define ns_msg_base(handle) ((handle)._msg + 0) 1657c478bd9Sstevel@tonic-gate #define ns_msg_end(handle) ((handle)._eom + 0) 1667c478bd9Sstevel@tonic-gate #define ns_msg_size(handle) ((handle)._eom - (handle)._msg) 1677c478bd9Sstevel@tonic-gate #define ns_msg_count(handle, section) ((handle)._counts[section] + 0) 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate /* 1707c478bd9Sstevel@tonic-gate * This is a parsed record. It is caller allocated and has no dynamic data. 1717c478bd9Sstevel@tonic-gate */ 1727c478bd9Sstevel@tonic-gate typedef struct __ns_rr { 1737c478bd9Sstevel@tonic-gate char name[NS_MAXDNAME]; 1747c478bd9Sstevel@tonic-gate uint16_t type; 1757c478bd9Sstevel@tonic-gate uint16_t rr_class; 1767c478bd9Sstevel@tonic-gate uint32_t ttl; 1777c478bd9Sstevel@tonic-gate uint16_t rdlength; 1787c478bd9Sstevel@tonic-gate const uchar_t *rdata; 1797c478bd9Sstevel@tonic-gate } ns_rr; 1807c478bd9Sstevel@tonic-gate 1819525b14bSRao Shoaib /* 1829525b14bSRao Shoaib * Same thing, but using uncompressed network binary names, and real C types. 1839525b14bSRao Shoaib */ 1849525b14bSRao Shoaib typedef struct __ns_rr2 { 1859525b14bSRao Shoaib ns_nname nname; 1869525b14bSRao Shoaib size_t nnamel; 1879525b14bSRao Shoaib int type; 1889525b14bSRao Shoaib int rr_class; 1899525b14bSRao Shoaib uint_t ttl; 1909525b14bSRao Shoaib int rdlength; 1919525b14bSRao Shoaib const uchar_t *rdata; 1929525b14bSRao Shoaib } ns_rr2; 1939525b14bSRao Shoaib 1947c478bd9Sstevel@tonic-gate /* Accessor macros - this is part of the public interface. */ 1957c478bd9Sstevel@tonic-gate #define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".") 1969525b14bSRao Shoaib #define ns_rr_nname(rr) ((const ns_nname_t)(rr).nname) 1979525b14bSRao Shoaib #define ns_rr_nnamel(rr) ((rr).nnamel + 0) 1987c478bd9Sstevel@tonic-gate #define ns_rr_type(rr) ((ns_type)((rr).type + 0)) 1997c478bd9Sstevel@tonic-gate #define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0)) 2007c478bd9Sstevel@tonic-gate #define ns_rr_ttl(rr) ((rr).ttl + 0) 2017c478bd9Sstevel@tonic-gate #define ns_rr_rdlen(rr) ((rr).rdlength + 0) 2027c478bd9Sstevel@tonic-gate #define ns_rr_rdata(rr) ((rr).rdata + 0) 2037c478bd9Sstevel@tonic-gate 2047c478bd9Sstevel@tonic-gate /* 2057c478bd9Sstevel@tonic-gate * These don't have to be in the same order as in the packet flags word, 2067c478bd9Sstevel@tonic-gate * and they can even overlap in some cases, but they will need to be kept 2077c478bd9Sstevel@tonic-gate * in synch with ns_parse.c:ns_flagdata[]. 2087c478bd9Sstevel@tonic-gate */ 2097c478bd9Sstevel@tonic-gate typedef enum __ns_flag { 2107c478bd9Sstevel@tonic-gate ns_f_qr, /* Question/Response. */ 2117c478bd9Sstevel@tonic-gate ns_f_opcode, /* Operation code. */ 2127c478bd9Sstevel@tonic-gate ns_f_aa, /* Authoritative Answer. */ 2137c478bd9Sstevel@tonic-gate ns_f_tc, /* Truncation occurred. */ 2147c478bd9Sstevel@tonic-gate ns_f_rd, /* Recursion Desired. */ 2157c478bd9Sstevel@tonic-gate ns_f_ra, /* Recursion Available. */ 2167c478bd9Sstevel@tonic-gate ns_f_z, /* MBZ. */ 2177c478bd9Sstevel@tonic-gate ns_f_ad, /* Authentic Data (DNSSEC). */ 2187c478bd9Sstevel@tonic-gate ns_f_cd, /* Checking Disabled (DNSSEC). */ 2197c478bd9Sstevel@tonic-gate ns_f_rcode, /* Response code. */ 2207c478bd9Sstevel@tonic-gate ns_f_max 2217c478bd9Sstevel@tonic-gate } ns_flag; 2227c478bd9Sstevel@tonic-gate 2237c478bd9Sstevel@tonic-gate /* 2247c478bd9Sstevel@tonic-gate * Currently defined opcodes. 2257c478bd9Sstevel@tonic-gate */ 2267c478bd9Sstevel@tonic-gate typedef enum __ns_opcode { 2277c478bd9Sstevel@tonic-gate ns_o_query = 0, /* Standard query. */ 2287c478bd9Sstevel@tonic-gate ns_o_iquery = 1, /* Inverse query (deprecated/unsupported). */ 2297c478bd9Sstevel@tonic-gate ns_o_status = 2, /* Name server status query (unsupported). */ 2307c478bd9Sstevel@tonic-gate /* Opcode 3 is undefined/reserved. */ 2317c478bd9Sstevel@tonic-gate ns_o_notify = 4, /* Zone change notification. */ 2327c478bd9Sstevel@tonic-gate ns_o_update = 5, /* Zone update message. */ 2337c478bd9Sstevel@tonic-gate ns_o_max = 6 2347c478bd9Sstevel@tonic-gate } ns_opcode; 2357c478bd9Sstevel@tonic-gate 2367c478bd9Sstevel@tonic-gate /* 2377c478bd9Sstevel@tonic-gate * Currently defined response codes. 2387c478bd9Sstevel@tonic-gate */ 2397c478bd9Sstevel@tonic-gate typedef enum __ns_rcode { 2407c478bd9Sstevel@tonic-gate ns_r_noerror = 0, /* No error occurred. */ 2417c478bd9Sstevel@tonic-gate ns_r_formerr = 1, /* Format error. */ 2427c478bd9Sstevel@tonic-gate ns_r_servfail = 2, /* Server failure. */ 2437c478bd9Sstevel@tonic-gate ns_r_nxdomain = 3, /* Name error. */ 2447c478bd9Sstevel@tonic-gate ns_r_notimpl = 4, /* Unimplemented. */ 2457c478bd9Sstevel@tonic-gate ns_r_refused = 5, /* Operation refused. */ 2467c478bd9Sstevel@tonic-gate /* these are for BIND_UPDATE */ 2477c478bd9Sstevel@tonic-gate ns_r_yxdomain = 6, /* Name exists */ 2487c478bd9Sstevel@tonic-gate ns_r_yxrrset = 7, /* RRset exists */ 2497c478bd9Sstevel@tonic-gate ns_r_nxrrset = 8, /* RRset does not exist */ 2507c478bd9Sstevel@tonic-gate ns_r_notauth = 9, /* Not authoritative for zone */ 2517c478bd9Sstevel@tonic-gate ns_r_notzone = 10, /* Zone of record different from zone section */ 2527c478bd9Sstevel@tonic-gate ns_r_max = 11, 2537c478bd9Sstevel@tonic-gate /* The following are EDNS extended rcodes */ 2547c478bd9Sstevel@tonic-gate ns_r_badvers = 16, 2557c478bd9Sstevel@tonic-gate /* The following are TSIG errors */ 2567c478bd9Sstevel@tonic-gate ns_r_badsig = 16, 2577c478bd9Sstevel@tonic-gate ns_r_badkey = 17, 2587c478bd9Sstevel@tonic-gate ns_r_badtime = 18 2597c478bd9Sstevel@tonic-gate } ns_rcode; 2607c478bd9Sstevel@tonic-gate 2617c478bd9Sstevel@tonic-gate /* BIND_UPDATE */ 2627c478bd9Sstevel@tonic-gate typedef enum __ns_update_operation { 2637c478bd9Sstevel@tonic-gate ns_uop_delete = 0, 2647c478bd9Sstevel@tonic-gate ns_uop_add = 1, 2657c478bd9Sstevel@tonic-gate ns_uop_max = 2 2667c478bd9Sstevel@tonic-gate } ns_update_operation; 2677c478bd9Sstevel@tonic-gate 2687c478bd9Sstevel@tonic-gate /* 2697c478bd9Sstevel@tonic-gate * This RR-like structure is particular to UPDATE. 2707c478bd9Sstevel@tonic-gate */ 2717c478bd9Sstevel@tonic-gate struct ns_updrec { 2727c478bd9Sstevel@tonic-gate struct ns_updrec *r_prev; /* prev record */ 2737c478bd9Sstevel@tonic-gate struct ns_updrec *r_next; /* next record */ 2749525b14bSRao Shoaib uint8_t r_section; /* ZONE/PREREQUISITE/UPDATE */ 2757c478bd9Sstevel@tonic-gate char *r_dname; /* owner of the RR */ 2767c478bd9Sstevel@tonic-gate uint16_t r_class; /* class number */ 2777c478bd9Sstevel@tonic-gate uint16_t r_type; /* type number */ 2787c478bd9Sstevel@tonic-gate uint32_t r_ttl; /* time to live */ 2797c478bd9Sstevel@tonic-gate uchar_t *r_data; /* rdata fields as text string */ 2807c478bd9Sstevel@tonic-gate uint16_t r_size; /* size of r_data field */ 2817c478bd9Sstevel@tonic-gate int r_opcode; /* type of operation */ 2827c478bd9Sstevel@tonic-gate /* following fields for private use by the resolver/server routines */ 2837c478bd9Sstevel@tonic-gate struct ns_updrec *r_grpnext; /* next record when grouped */ 2847c478bd9Sstevel@tonic-gate struct databuf *r_dp; /* databuf to process */ 2857c478bd9Sstevel@tonic-gate struct databuf *r_deldp; /* databuf's deleted/overwritten */ 2867c478bd9Sstevel@tonic-gate uint16_t r_zone; /* zone number on server */ 2877c478bd9Sstevel@tonic-gate }; 2887c478bd9Sstevel@tonic-gate typedef struct ns_updrec ns_updrec; 2897c478bd9Sstevel@tonic-gate 2907c478bd9Sstevel@tonic-gate /* 2917c478bd9Sstevel@tonic-gate * This structure is used for TSIG authenticated messages 2927c478bd9Sstevel@tonic-gate */ 2937c478bd9Sstevel@tonic-gate struct ns_tsig_key { 2947c478bd9Sstevel@tonic-gate char name[NS_MAXDNAME], alg[NS_MAXDNAME]; 2957c478bd9Sstevel@tonic-gate unsigned char *data; 2967c478bd9Sstevel@tonic-gate int len; 2977c478bd9Sstevel@tonic-gate }; 2987c478bd9Sstevel@tonic-gate typedef struct ns_tsig_key ns_tsig_key; 2997c478bd9Sstevel@tonic-gate 3007c478bd9Sstevel@tonic-gate /* 3017c478bd9Sstevel@tonic-gate * This structure is used for TSIG authenticated TCP messages 3027c478bd9Sstevel@tonic-gate */ 3037c478bd9Sstevel@tonic-gate struct ns_tcp_tsig_state { 3047c478bd9Sstevel@tonic-gate int counter; 3057c478bd9Sstevel@tonic-gate struct dst_key *key; 3067c478bd9Sstevel@tonic-gate void *ctx; 3077c478bd9Sstevel@tonic-gate unsigned char sig[NS_PACKETSZ]; 3087c478bd9Sstevel@tonic-gate int siglen; 3097c478bd9Sstevel@tonic-gate }; 3107c478bd9Sstevel@tonic-gate typedef struct ns_tcp_tsig_state ns_tcp_tsig_state; 3117c478bd9Sstevel@tonic-gate 3127c478bd9Sstevel@tonic-gate #define NS_TSIG_FUDGE 300 3137c478bd9Sstevel@tonic-gate #define NS_TSIG_TCP_COUNT 100 3147c478bd9Sstevel@tonic-gate #define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT" 3157c478bd9Sstevel@tonic-gate 3167c478bd9Sstevel@tonic-gate #define NS_TSIG_ERROR_NO_TSIG -10 3177c478bd9Sstevel@tonic-gate #define NS_TSIG_ERROR_NO_SPACE -11 3187c478bd9Sstevel@tonic-gate #define NS_TSIG_ERROR_FORMERR -12 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate /* 3217c478bd9Sstevel@tonic-gate * Currently defined type values for resources and queries. 3227c478bd9Sstevel@tonic-gate */ 3237c478bd9Sstevel@tonic-gate typedef enum __ns_type { 3247c478bd9Sstevel@tonic-gate ns_t_invalid = 0, /* Cookie. */ 3257c478bd9Sstevel@tonic-gate ns_t_a = 1, /* Host address. */ 3267c478bd9Sstevel@tonic-gate ns_t_ns = 2, /* Authoritative server. */ 3277c478bd9Sstevel@tonic-gate ns_t_md = 3, /* Mail destination. */ 3287c478bd9Sstevel@tonic-gate ns_t_mf = 4, /* Mail forwarder. */ 3297c478bd9Sstevel@tonic-gate ns_t_cname = 5, /* Canonical name. */ 3307c478bd9Sstevel@tonic-gate ns_t_soa = 6, /* Start of authority zone. */ 3317c478bd9Sstevel@tonic-gate ns_t_mb = 7, /* Mailbox domain name. */ 3327c478bd9Sstevel@tonic-gate ns_t_mg = 8, /* Mail group member. */ 3337c478bd9Sstevel@tonic-gate ns_t_mr = 9, /* Mail rename name. */ 3347c478bd9Sstevel@tonic-gate ns_t_null = 10, /* Null resource record. */ 3357c478bd9Sstevel@tonic-gate ns_t_wks = 11, /* Well known service. */ 3367c478bd9Sstevel@tonic-gate ns_t_ptr = 12, /* Domain name pointer. */ 3377c478bd9Sstevel@tonic-gate ns_t_hinfo = 13, /* Host information. */ 3387c478bd9Sstevel@tonic-gate ns_t_minfo = 14, /* Mailbox information. */ 3397c478bd9Sstevel@tonic-gate ns_t_mx = 15, /* Mail routing information. */ 3407c478bd9Sstevel@tonic-gate ns_t_txt = 16, /* Text strings. */ 3417c478bd9Sstevel@tonic-gate ns_t_rp = 17, /* Responsible person. */ 3427c478bd9Sstevel@tonic-gate ns_t_afsdb = 18, /* AFS cell database. */ 3437c478bd9Sstevel@tonic-gate ns_t_x25 = 19, /* X_25 calling address. */ 3447c478bd9Sstevel@tonic-gate ns_t_isdn = 20, /* ISDN calling address. */ 3457c478bd9Sstevel@tonic-gate ns_t_rt = 21, /* Router. */ 3467c478bd9Sstevel@tonic-gate ns_t_nsap = 22, /* NSAP address. */ 3477c478bd9Sstevel@tonic-gate ns_t_nsap_ptr = 23, /* Reverse NSAP lookup (deprecated). */ 3487c478bd9Sstevel@tonic-gate ns_t_sig = 24, /* Security signature. */ 3497c478bd9Sstevel@tonic-gate ns_t_key = 25, /* Security key. */ 3507c478bd9Sstevel@tonic-gate ns_t_px = 26, /* X.400 mail mapping. */ 3517c478bd9Sstevel@tonic-gate ns_t_gpos = 27, /* Geographical position (withdrawn). */ 3527c478bd9Sstevel@tonic-gate ns_t_aaaa = 28, /* IPv6 Address. */ 3537c478bd9Sstevel@tonic-gate ns_t_loc = 29, /* Location Information. */ 3547c478bd9Sstevel@tonic-gate ns_t_nxt = 30, /* Next domain (security). */ 3557c478bd9Sstevel@tonic-gate ns_t_eid = 31, /* Endpoint identifier. */ 3567c478bd9Sstevel@tonic-gate ns_t_nimloc = 32, /* Nimrod Locator. */ 3577c478bd9Sstevel@tonic-gate ns_t_srv = 33, /* Server Selection. */ 3587c478bd9Sstevel@tonic-gate ns_t_atma = 34, /* ATM Address */ 3597c478bd9Sstevel@tonic-gate ns_t_naptr = 35, /* Naming Authority PoinTeR */ 3607c478bd9Sstevel@tonic-gate ns_t_kx = 36, /* Key Exchange */ 3617c478bd9Sstevel@tonic-gate ns_t_cert = 37, /* Certification record */ 3627c478bd9Sstevel@tonic-gate ns_t_a6 = 38, /* IPv6 address (deprecated) */ 3637c478bd9Sstevel@tonic-gate ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */ 3647c478bd9Sstevel@tonic-gate ns_t_sink = 40, /* Kitchen sink (experimentatl) */ 3657c478bd9Sstevel@tonic-gate ns_t_opt = 41, /* EDNS0 option (meta-RR) */ 3667c478bd9Sstevel@tonic-gate ns_t_apl = 42, /* Address prefix list (RFC 3123) */ 3679525b14bSRao Shoaib ns_t_ds = 43, /* Delegation Signer */ 3689525b14bSRao Shoaib ns_t_sshfp = 44, /* SSH Fingerprint */ 3699525b14bSRao Shoaib ns_t_ipseckey = 45, /* IPSEC Key */ 3709525b14bSRao Shoaib ns_t_rrsig = 46, /* RRset Signature */ 3719525b14bSRao Shoaib ns_t_nsec = 47, /* Negative security */ 3729525b14bSRao Shoaib ns_t_dnskey = 48, /* DNS Key */ 3739525b14bSRao Shoaib ns_t_dhcid = 49, /* Dynamic host configuratin identifier */ 3749525b14bSRao Shoaib ns_t_nsec3 = 50, /* Negative security type 3 */ 3759525b14bSRao Shoaib ns_t_nsec3param = 51, /* Negative security type 3 parameters */ 376*ffe0b5faSSebastian Wiedenroth ns_t_tlsa = 52, /* TLSA (RFC 6698) */ 377*ffe0b5faSSebastian Wiedenroth ns_t_smimea = 53, /* S/MIME cert association (RFC 8162) */ 3789525b14bSRao Shoaib ns_t_hip = 55, /* Host Identity Protocol */ 379*ffe0b5faSSebastian Wiedenroth ns_t_cds = 59, /* Child DS (RFC 7344) */ 380*ffe0b5faSSebastian Wiedenroth ns_t_cdnskey = 60, /* DNSKEY(s) the Child wants reflected in DS */ 381*ffe0b5faSSebastian Wiedenroth ns_t_openpgpkey = 61, /* OpenPGP Key (RFC 7929) */ 382*ffe0b5faSSebastian Wiedenroth ns_t_csync = 62, /* Child-To-Parent Synchronization (RFC 7477) */ 3839525b14bSRao Shoaib ns_t_spf = 99, /* Sender Policy Framework */ 3847c478bd9Sstevel@tonic-gate ns_t_tkey = 249, /* Transaction key */ 3857c478bd9Sstevel@tonic-gate ns_t_tsig = 250, /* Transaction signature. */ 3867c478bd9Sstevel@tonic-gate ns_t_ixfr = 251, /* Incremental zone transfer. */ 3877c478bd9Sstevel@tonic-gate ns_t_axfr = 252, /* Transfer zone of authority. */ 3887c478bd9Sstevel@tonic-gate ns_t_mailb = 253, /* Transfer mailbox records. */ 3897c478bd9Sstevel@tonic-gate ns_t_maila = 254, /* Transfer mail agent records. */ 3907c478bd9Sstevel@tonic-gate ns_t_any = 255, /* Wildcard match. */ 3917c478bd9Sstevel@tonic-gate ns_t_zxfr = 256, /* BIND-specific, nonstandard. */ 392*ffe0b5faSSebastian Wiedenroth ns_t_caa = 257, /* Certification Authority Restriction */ 3939525b14bSRao Shoaib ns_t_dlv = 32769, /* DNSSEC look-aside validatation. */ 3947c478bd9Sstevel@tonic-gate ns_t_max = 65536 3957c478bd9Sstevel@tonic-gate } ns_type; 3967c478bd9Sstevel@tonic-gate 3977c478bd9Sstevel@tonic-gate /* Exclusively a QTYPE? (not also an RTYPE) */ 3987c478bd9Sstevel@tonic-gate #define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \ 3997c478bd9Sstevel@tonic-gate (t) == ns_t_mailb || (t) == ns_t_maila) 4007c478bd9Sstevel@tonic-gate /* Some kind of meta-RR? (not a QTYPE, but also not an RTYPE) */ 4017c478bd9Sstevel@tonic-gate #define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt) 4027c478bd9Sstevel@tonic-gate /* Exclusively an RTYPE? (not also a QTYPE or a meta-RR) */ 4037c478bd9Sstevel@tonic-gate #define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t)) 4047c478bd9Sstevel@tonic-gate #define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr) 4057c478bd9Sstevel@tonic-gate #define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \ 4067c478bd9Sstevel@tonic-gate (t) == ns_t_zxfr) 4077c478bd9Sstevel@tonic-gate 4087c478bd9Sstevel@tonic-gate /* 4097c478bd9Sstevel@tonic-gate * Values for class field 4107c478bd9Sstevel@tonic-gate */ 4117c478bd9Sstevel@tonic-gate typedef enum __ns_class { 4127c478bd9Sstevel@tonic-gate ns_c_invalid = 0, /* Cookie. */ 4137c478bd9Sstevel@tonic-gate ns_c_in = 1, /* Internet. */ 4147c478bd9Sstevel@tonic-gate ns_c_2 = 2, /* unallocated/unsupported. */ 4157c478bd9Sstevel@tonic-gate ns_c_chaos = 3, /* MIT Chaos-net. */ 4167c478bd9Sstevel@tonic-gate ns_c_hs = 4, /* MIT Hesiod. */ 4177c478bd9Sstevel@tonic-gate /* Query class values which do not appear in resource records */ 4187c478bd9Sstevel@tonic-gate ns_c_none = 254, /* for prereq. sections in update requests */ 4197c478bd9Sstevel@tonic-gate ns_c_any = 255, /* Wildcard match. */ 4207c478bd9Sstevel@tonic-gate ns_c_max = 65536 4217c478bd9Sstevel@tonic-gate } ns_class; 4227c478bd9Sstevel@tonic-gate 4237c478bd9Sstevel@tonic-gate /* DNSSEC constants. */ 4247c478bd9Sstevel@tonic-gate 4257c478bd9Sstevel@tonic-gate typedef enum __ns_key_types { 4267c478bd9Sstevel@tonic-gate ns_kt_rsa = 1, /* key type RSA/MD5 */ 4277c478bd9Sstevel@tonic-gate ns_kt_dh = 2, /* Diffie Hellman */ 4287c478bd9Sstevel@tonic-gate ns_kt_dsa = 3, /* Digital Signature Standard (MANDATORY) */ 4297c478bd9Sstevel@tonic-gate ns_kt_private = 254 /* Private key type starts with OID */ 4307c478bd9Sstevel@tonic-gate } ns_key_types; 4317c478bd9Sstevel@tonic-gate 4327c478bd9Sstevel@tonic-gate typedef enum __ns_cert_types { 4337c478bd9Sstevel@tonic-gate cert_t_pkix = 1, /* PKIX (X.509v3) */ 4347c478bd9Sstevel@tonic-gate cert_t_spki = 2, /* SPKI */ 4357c478bd9Sstevel@tonic-gate cert_t_pgp = 3, /* PGP */ 4367c478bd9Sstevel@tonic-gate cert_t_url = 253, /* URL private type */ 4377c478bd9Sstevel@tonic-gate cert_t_oid = 254 /* OID private type */ 4387c478bd9Sstevel@tonic-gate } ns_cert_types; 4397c478bd9Sstevel@tonic-gate 4407c478bd9Sstevel@tonic-gate /* Flags field of the KEY RR rdata. */ 4417c478bd9Sstevel@tonic-gate #define NS_KEY_TYPEMASK 0xC000 /* Mask for "type" bits */ 4427c478bd9Sstevel@tonic-gate #define NS_KEY_TYPE_AUTH_CONF 0x0000 /* Key usable for both */ 4437c478bd9Sstevel@tonic-gate #define NS_KEY_TYPE_CONF_ONLY 0x8000 /* Key usable for confidentiality */ 4447c478bd9Sstevel@tonic-gate #define NS_KEY_TYPE_AUTH_ONLY 0x4000 /* Key usable for authentication */ 4457c478bd9Sstevel@tonic-gate #define NS_KEY_TYPE_NO_KEY 0xC000 /* No key usable for either; no key */ 4467c478bd9Sstevel@tonic-gate /* The type bits can also be interpreted independently, as single bits: */ 4477c478bd9Sstevel@tonic-gate #define NS_KEY_NO_AUTH 0x8000 /* Key unusable for authentication */ 4487c478bd9Sstevel@tonic-gate #define NS_KEY_NO_CONF 0x4000 /* Key unusable for confidentiality */ 4497c478bd9Sstevel@tonic-gate #define NS_KEY_RESERVED2 0x2000 /* Security is *mandatory* if bit=0 */ 4507c478bd9Sstevel@tonic-gate #define NS_KEY_EXTENDED_FLAGS 0x1000 /* reserved - must be zero */ 4517c478bd9Sstevel@tonic-gate #define NS_KEY_RESERVED4 0x0800 /* reserved - must be zero */ 4527c478bd9Sstevel@tonic-gate #define NS_KEY_RESERVED5 0x0400 /* reserved - must be zero */ 4537c478bd9Sstevel@tonic-gate #define NS_KEY_NAME_TYPE 0x0300 /* these bits determine the type */ 4547c478bd9Sstevel@tonic-gate #define NS_KEY_NAME_USER 0x0000 /* key is assoc. with user */ 4557c478bd9Sstevel@tonic-gate #define NS_KEY_NAME_ENTITY 0x0200 /* key is assoc. with entity eg host */ 4567c478bd9Sstevel@tonic-gate #define NS_KEY_NAME_ZONE 0x0100 /* key is zone key */ 4577c478bd9Sstevel@tonic-gate #define NS_KEY_NAME_RESERVED 0x0300 /* reserved meaning */ 4587c478bd9Sstevel@tonic-gate #define NS_KEY_RESERVED8 0x0080 /* reserved - must be zero */ 4597c478bd9Sstevel@tonic-gate #define NS_KEY_RESERVED9 0x0040 /* reserved - must be zero */ 4607c478bd9Sstevel@tonic-gate #define NS_KEY_RESERVED10 0x0020 /* reserved - must be zero */ 4617c478bd9Sstevel@tonic-gate #define NS_KEY_RESERVED11 0x0010 /* reserved - must be zero */ 4627c478bd9Sstevel@tonic-gate #define NS_KEY_SIGNATORYMASK 0x000F /* key can sign RR's of same name */ 4637c478bd9Sstevel@tonic-gate #define NS_KEY_RESERVED_BITMASK (NS_KEY_RESERVED2 | \ 4647c478bd9Sstevel@tonic-gate NS_KEY_RESERVED4 | \ 4657c478bd9Sstevel@tonic-gate NS_KEY_RESERVED5 | \ 4667c478bd9Sstevel@tonic-gate NS_KEY_RESERVED8 | \ 4677c478bd9Sstevel@tonic-gate NS_KEY_RESERVED9 | \ 4687c478bd9Sstevel@tonic-gate NS_KEY_RESERVED10 | \ 4697c478bd9Sstevel@tonic-gate NS_KEY_RESERVED11) 4707c478bd9Sstevel@tonic-gate #define NS_KEY_RESERVED_BITMASK2 0xFFFF /* no bits defined here */ 4717c478bd9Sstevel@tonic-gate 4727c478bd9Sstevel@tonic-gate /* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */ 4737c478bd9Sstevel@tonic-gate #define NS_ALG_MD5RSA 1 /* MD5 with RSA */ 4747c478bd9Sstevel@tonic-gate #define NS_ALG_DH 2 /* Diffie Hellman KEY */ 4757c478bd9Sstevel@tonic-gate #define NS_ALG_DSA 3 /* DSA KEY */ 4767c478bd9Sstevel@tonic-gate #define NS_ALG_DSS NS_ALG_DSA 4777c478bd9Sstevel@tonic-gate #define NS_ALG_EXPIRE_ONLY 253 /* No alg, no security */ 4787c478bd9Sstevel@tonic-gate #define NS_ALG_PRIVATE_OID 254 /* Key begins with OID giving alg */ 4797c478bd9Sstevel@tonic-gate 4807c478bd9Sstevel@tonic-gate /* Protocol values */ 4817c478bd9Sstevel@tonic-gate /* value 0 is reserved */ 4827c478bd9Sstevel@tonic-gate #define NS_KEY_PROT_TLS 1 4837c478bd9Sstevel@tonic-gate #define NS_KEY_PROT_EMAIL 2 4847c478bd9Sstevel@tonic-gate #define NS_KEY_PROT_DNSSEC 3 4857c478bd9Sstevel@tonic-gate #define NS_KEY_PROT_IPSEC 4 4867c478bd9Sstevel@tonic-gate #define NS_KEY_PROT_ANY 255 4877c478bd9Sstevel@tonic-gate 4887c478bd9Sstevel@tonic-gate /* Signatures */ 4897c478bd9Sstevel@tonic-gate #define NS_MD5RSA_MIN_BITS 512 /* Size of a mod or exp in bits */ 4907c478bd9Sstevel@tonic-gate #define NS_MD5RSA_MAX_BITS 4096 4917c478bd9Sstevel@tonic-gate /* Total of binary mod and exp */ 4927c478bd9Sstevel@tonic-gate #define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3) 4937c478bd9Sstevel@tonic-gate /* Max length of text sig block */ 4947c478bd9Sstevel@tonic-gate #define NS_MD5RSA_MAX_BASE64 (((NS_MD5RSA_MAX_BYTES+2)/3)*4) 4957c478bd9Sstevel@tonic-gate #define NS_MD5RSA_MIN_SIZE ((NS_MD5RSA_MIN_BITS+7)/8) 4967c478bd9Sstevel@tonic-gate #define NS_MD5RSA_MAX_SIZE ((NS_MD5RSA_MAX_BITS+7)/8) 4977c478bd9Sstevel@tonic-gate 4987c478bd9Sstevel@tonic-gate #define NS_DSA_SIG_SIZE 41 4997c478bd9Sstevel@tonic-gate #define NS_DSA_MIN_SIZE 213 5007c478bd9Sstevel@tonic-gate #define NS_DSA_MAX_BYTES 405 5017c478bd9Sstevel@tonic-gate 5027c478bd9Sstevel@tonic-gate /* Offsets into SIG record rdata to find various values */ 5037c478bd9Sstevel@tonic-gate #define NS_SIG_TYPE 0 /* Type flags */ 5047c478bd9Sstevel@tonic-gate #define NS_SIG_ALG 2 /* Algorithm */ 5057c478bd9Sstevel@tonic-gate #define NS_SIG_LABELS 3 /* How many labels in name */ 5067c478bd9Sstevel@tonic-gate #define NS_SIG_OTTL 4 /* Original TTL */ 5077c478bd9Sstevel@tonic-gate #define NS_SIG_EXPIR 8 /* Expiration time */ 5087c478bd9Sstevel@tonic-gate #define NS_SIG_SIGNED 12 /* Signature time */ 5097c478bd9Sstevel@tonic-gate #define NS_SIG_FOOT 16 /* Key footprint */ 5107c478bd9Sstevel@tonic-gate #define NS_SIG_SIGNER 18 /* Domain name of who signed it */ 5117c478bd9Sstevel@tonic-gate 5127c478bd9Sstevel@tonic-gate /* How RR types are represented as bit-flags in NXT records */ 5137c478bd9Sstevel@tonic-gate #define NS_NXT_BITS 8 5147c478bd9Sstevel@tonic-gate #define NS_NXT_BIT_SET(n, p) \ 5157c478bd9Sstevel@tonic-gate (p[(n)/NS_NXT_BITS] |= (0x80>>((n)%NS_NXT_BITS))) 5167c478bd9Sstevel@tonic-gate #define NS_NXT_BIT_CLEAR(n, p) \ 5177c478bd9Sstevel@tonic-gate (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS))) 5187c478bd9Sstevel@tonic-gate #define NS_NXT_BIT_ISSET(n, p) \ 5197c478bd9Sstevel@tonic-gate (p[(n)/NS_NXT_BITS] & (0x80>>((n)%NS_NXT_BITS))) 5207c478bd9Sstevel@tonic-gate #define NS_NXT_MAX 127 5217c478bd9Sstevel@tonic-gate 5227c478bd9Sstevel@tonic-gate /* 5237c478bd9Sstevel@tonic-gate * EDNS0 extended flags, host order. 5247c478bd9Sstevel@tonic-gate */ 5257c478bd9Sstevel@tonic-gate #define NS_OPT_DNSSEC_OK 0x8000U 5269525b14bSRao Shoaib #define NS_OPT_NSID 3 5277c478bd9Sstevel@tonic-gate 5287c478bd9Sstevel@tonic-gate /* 5297c478bd9Sstevel@tonic-gate * Inline versions of get/put short/long. Pointer is advanced. 5307c478bd9Sstevel@tonic-gate */ 5317c478bd9Sstevel@tonic-gate #define NS_GET16(s, cp) do { \ 5327c478bd9Sstevel@tonic-gate register const uchar_t *t_cp = (const uchar_t *)(cp); \ 5337c478bd9Sstevel@tonic-gate (s) = ((uint16_t)t_cp[0] << 8) \ 5347c478bd9Sstevel@tonic-gate | ((uint16_t)t_cp[1]) \ 5357c478bd9Sstevel@tonic-gate ; \ 5367c478bd9Sstevel@tonic-gate (cp) += NS_INT16SZ; \ 5377c478bd9Sstevel@tonic-gate } while (0) 5387c478bd9Sstevel@tonic-gate 5397c478bd9Sstevel@tonic-gate #define NS_GET32(l, cp) do { \ 5407c478bd9Sstevel@tonic-gate register const uchar_t *t_cp = (const uchar_t *)(cp); \ 5417c478bd9Sstevel@tonic-gate (l) = ((uint32_t)t_cp[0] << 24) \ 5427c478bd9Sstevel@tonic-gate | ((uint32_t)t_cp[1] << 16) \ 5437c478bd9Sstevel@tonic-gate | ((uint32_t)t_cp[2] << 8) \ 5447c478bd9Sstevel@tonic-gate | ((uint32_t)t_cp[3]) \ 5457c478bd9Sstevel@tonic-gate ; \ 5467c478bd9Sstevel@tonic-gate (cp) += NS_INT32SZ; \ 5477c478bd9Sstevel@tonic-gate } while (0) 5487c478bd9Sstevel@tonic-gate 5497c478bd9Sstevel@tonic-gate #define NS_PUT16(s, cp) do { \ 5507c478bd9Sstevel@tonic-gate register uint16_t t_s = (uint16_t)(s); \ 5517c478bd9Sstevel@tonic-gate register uchar_t *t_cp = (uchar_t *)(cp); \ 5527c478bd9Sstevel@tonic-gate *t_cp++ = t_s >> 8; \ 5537c478bd9Sstevel@tonic-gate *t_cp = t_s; \ 5547c478bd9Sstevel@tonic-gate (cp) += NS_INT16SZ; \ 5557c478bd9Sstevel@tonic-gate } while (0) 5567c478bd9Sstevel@tonic-gate 5577c478bd9Sstevel@tonic-gate #define NS_PUT32(l, cp) do { \ 5587c478bd9Sstevel@tonic-gate register uint32_t t_l = (uint32_t)(l); \ 5597c478bd9Sstevel@tonic-gate register uchar_t *t_cp = (uchar_t *)(cp); \ 5607c478bd9Sstevel@tonic-gate *t_cp++ = t_l >> 24; \ 5617c478bd9Sstevel@tonic-gate *t_cp++ = t_l >> 16; \ 5627c478bd9Sstevel@tonic-gate *t_cp++ = t_l >> 8; \ 5637c478bd9Sstevel@tonic-gate *t_cp = t_l; \ 5647c478bd9Sstevel@tonic-gate (cp) += NS_INT32SZ; \ 5657c478bd9Sstevel@tonic-gate } while (0) 5667c478bd9Sstevel@tonic-gate 5677c478bd9Sstevel@tonic-gate /* 5687c478bd9Sstevel@tonic-gate * ANSI C identifier hiding. 5697c478bd9Sstevel@tonic-gate */ 5707c478bd9Sstevel@tonic-gate #define ns_msg_getflag __ns_msg_getflag 5717c478bd9Sstevel@tonic-gate #define ns_get16 __ns_get16 5727c478bd9Sstevel@tonic-gate #define ns_get32 __ns_get32 5737c478bd9Sstevel@tonic-gate #define ns_put16 __ns_put16 5747c478bd9Sstevel@tonic-gate #define ns_put32 __ns_put32 5757c478bd9Sstevel@tonic-gate #define ns_initparse __ns_initparse 5767c478bd9Sstevel@tonic-gate #define ns_skiprr __ns_skiprr 5777c478bd9Sstevel@tonic-gate #define ns_parserr __ns_parserr 5789525b14bSRao Shoaib #define ns_parserr2 __ns_parserr2 5797c478bd9Sstevel@tonic-gate #define ns_sprintrr __ns_sprintrr 5807c478bd9Sstevel@tonic-gate #define ns_sprintrrf __ns_sprintrrf 5817c478bd9Sstevel@tonic-gate #define ns_format_ttl __ns_format_ttl 5827c478bd9Sstevel@tonic-gate #define ns_parse_ttl __ns_parse_ttl 5837c478bd9Sstevel@tonic-gate #define ns_datetosecs __ns_datetosecs 5847c478bd9Sstevel@tonic-gate #define ns_name_ntol __ns_name_ntol 5857c478bd9Sstevel@tonic-gate #define ns_name_ntop __ns_name_ntop 5867c478bd9Sstevel@tonic-gate #define ns_name_pton __ns_name_pton 587b31320a7SChris Fraire #define ns_name_pton2 __ns_name_pton2 5887c478bd9Sstevel@tonic-gate #define ns_name_unpack __ns_name_unpack 5897c478bd9Sstevel@tonic-gate #define ns_name_pack __ns_name_pack 5907c478bd9Sstevel@tonic-gate #define ns_name_compress __ns_name_compress 5917c478bd9Sstevel@tonic-gate #define ns_name_uncompress __ns_name_uncompress 5927c478bd9Sstevel@tonic-gate #define ns_name_skip __ns_name_skip 5937c478bd9Sstevel@tonic-gate #define ns_name_rollback __ns_name_rollback 5949525b14bSRao Shoaib #define ns_name_length __ns_name_length 5959525b14bSRao Shoaib #define ns_name_eq __ns_name_eq 5969525b14bSRao Shoaib #define ns_name_owned __ns_name_owned 5979525b14bSRao Shoaib #define ns_name_map __ns_name_map 5989525b14bSRao Shoaib #define ns_name_labels __ns_name_labels 5997c478bd9Sstevel@tonic-gate #define ns_sign __ns_sign 6007c478bd9Sstevel@tonic-gate #define ns_sign2 __ns_sign2 6017c478bd9Sstevel@tonic-gate #define ns_sign_tcp __ns_sign_tcp 6027c478bd9Sstevel@tonic-gate #define ns_sign_tcp2 __ns_sign_tcp2 6037c478bd9Sstevel@tonic-gate #define ns_sign_tcp_init __ns_sign_tcp_init 6047c478bd9Sstevel@tonic-gate #define ns_find_tsig __ns_find_tsig 6057c478bd9Sstevel@tonic-gate #define ns_verify __ns_verify 6067c478bd9Sstevel@tonic-gate #define ns_verify_tcp __ns_verify_tcp 6077c478bd9Sstevel@tonic-gate #define ns_verify_tcp_init __ns_verify_tcp_init 6087c478bd9Sstevel@tonic-gate #define ns_samedomain __ns_samedomain 6097c478bd9Sstevel@tonic-gate #define ns_subdomain __ns_subdomain 6107c478bd9Sstevel@tonic-gate #define ns_makecanon __ns_makecanon 6117c478bd9Sstevel@tonic-gate #define ns_samename __ns_samename 6129525b14bSRao Shoaib #define ns_newmsg_init __ns_newmsg_init 6139525b14bSRao Shoaib #define ns_newmsg_copy __ns_newmsg_copy 6149525b14bSRao Shoaib #define ns_newmsg_id __ns_newmsg_id 6159525b14bSRao Shoaib #define ns_newmsg_flag __ns_newmsg_flag 6169525b14bSRao Shoaib #define ns_newmsg_q __ns_newmsg_q 6179525b14bSRao Shoaib #define ns_newmsg_rr __ns_newmsg_rr 6189525b14bSRao Shoaib #define ns_newmsg_done __ns_newmsg_done 6199525b14bSRao Shoaib #define ns_rdata_unpack __ns_rdata_unpack 6209525b14bSRao Shoaib #define ns_rdata_equal __ns_rdata_equal 6219525b14bSRao Shoaib #define ns_rdata_refers __ns_rdata_refers 6227c478bd9Sstevel@tonic-gate 6237c478bd9Sstevel@tonic-gate int ns_msg_getflag(ns_msg, int); 6247c478bd9Sstevel@tonic-gate uint_t ns_get16(const uchar_t *); 6257c478bd9Sstevel@tonic-gate ulong_t ns_get32(const uchar_t *); 6267c478bd9Sstevel@tonic-gate void ns_put16(uint_t, uchar_t *); 6277c478bd9Sstevel@tonic-gate void ns_put32(ulong_t, uchar_t *); 6287c478bd9Sstevel@tonic-gate int ns_initparse(const uchar_t *, int, ns_msg *); 6297c478bd9Sstevel@tonic-gate int ns_skiprr(const uchar_t *, const uchar_t *, ns_sect, int); 6307c478bd9Sstevel@tonic-gate int ns_parserr(ns_msg *, ns_sect, int, ns_rr *); 6319525b14bSRao Shoaib int ns_parserr2(ns_msg *, ns_sect, int, ns_rr2 *); 6327c478bd9Sstevel@tonic-gate int ns_sprintrr(const ns_msg *, const ns_rr *, 6337c478bd9Sstevel@tonic-gate const char *, const char *, char *, size_t); 6347c478bd9Sstevel@tonic-gate int ns_sprintrrf(const uchar_t *, size_t, const char *, 6357c478bd9Sstevel@tonic-gate ns_class, ns_type, ulong_t, const uchar_t *, 6367c478bd9Sstevel@tonic-gate size_t, const char *, const char *, 6377c478bd9Sstevel@tonic-gate char *, size_t); 6387c478bd9Sstevel@tonic-gate int ns_format_ttl(ulong_t, char *, size_t); 6397c478bd9Sstevel@tonic-gate int ns_parse_ttl(const char *, ulong_t *); 6407c478bd9Sstevel@tonic-gate uint32_t ns_datetosecs(const char *cp, int *errp); 6417c478bd9Sstevel@tonic-gate int ns_name_ntol(const uchar_t *, uchar_t *, size_t); 6427c478bd9Sstevel@tonic-gate int ns_name_ntop(const uchar_t *, char *, size_t); 6437c478bd9Sstevel@tonic-gate int ns_name_pton(const char *, uchar_t *, size_t); 644b31320a7SChris Fraire int ns_name_pton2(const char *, uchar_t *, size_t, size_t *); 6457c478bd9Sstevel@tonic-gate int ns_name_unpack(const uchar_t *, const uchar_t *, 6467c478bd9Sstevel@tonic-gate const uchar_t *, uchar_t *, size_t); 6477c478bd9Sstevel@tonic-gate int ns_name_pack(const uchar_t *, uchar_t *, int, 6487c478bd9Sstevel@tonic-gate const uchar_t **, const uchar_t **); 6497c478bd9Sstevel@tonic-gate int ns_name_uncompress(const uchar_t *, const uchar_t *, 6507c478bd9Sstevel@tonic-gate const uchar_t *, char *, size_t); 6517c478bd9Sstevel@tonic-gate int ns_name_compress(const char *, uchar_t *, size_t, 6527c478bd9Sstevel@tonic-gate const uchar_t **, const uchar_t **); 6537c478bd9Sstevel@tonic-gate int ns_name_skip(const uchar_t **, const uchar_t *); 6547c478bd9Sstevel@tonic-gate void ns_name_rollback(const uchar_t *, const uchar_t **, 6557c478bd9Sstevel@tonic-gate const uchar_t **); 6569525b14bSRao Shoaib ssize_t ns_name_length(ns_nname_ct, size_t); 6579525b14bSRao Shoaib int ns_name_eq(ns_nname_ct, size_t, ns_nname_ct, size_t); 6589525b14bSRao Shoaib int ns_name_owned(ns_namemap_ct, int, ns_namemap_ct, int); 6599525b14bSRao Shoaib int ns_name_map(ns_nname_ct, size_t, ns_namemap_t, int); 6609525b14bSRao Shoaib int ns_name_labels(ns_nname_ct, size_t); 6617c478bd9Sstevel@tonic-gate int ns_sign(uchar_t *, int *, int, int, void *, 6627c478bd9Sstevel@tonic-gate const uchar_t *, int, uchar_t *, int *, time_t); 6637c478bd9Sstevel@tonic-gate int ns_sign2(uchar_t *, int *, int, int, void *, 6647c478bd9Sstevel@tonic-gate const uchar_t *, int, uchar_t *, int *, time_t, 6657c478bd9Sstevel@tonic-gate uchar_t **, uchar_t **); 6667c478bd9Sstevel@tonic-gate int ns_sign_tcp(uchar_t *, int *, int, int, 6677c478bd9Sstevel@tonic-gate ns_tcp_tsig_state *, int); 6687c478bd9Sstevel@tonic-gate int ns_sign_tcp2(uchar_t *, int *, int, int, 6697c478bd9Sstevel@tonic-gate ns_tcp_tsig_state *, int, 6707c478bd9Sstevel@tonic-gate uchar_t **, uchar_t **); 6717c478bd9Sstevel@tonic-gate int ns_sign_tcp_init(void *, const uchar_t *, int, 6727c478bd9Sstevel@tonic-gate ns_tcp_tsig_state *); 6737c478bd9Sstevel@tonic-gate uchar_t *ns_find_tsig(uchar_t *, uchar_t *); 6747c478bd9Sstevel@tonic-gate int ns_verify(uchar_t *, int *, void *, 6757c478bd9Sstevel@tonic-gate const uchar_t *, int, uchar_t *, int *, 6767c478bd9Sstevel@tonic-gate time_t *, int); 6777c478bd9Sstevel@tonic-gate int ns_verify_tcp(uchar_t *, int *, ns_tcp_tsig_state *, int); 6787c478bd9Sstevel@tonic-gate int ns_verify_tcp_init(void *, const uchar_t *, int, 6797c478bd9Sstevel@tonic-gate ns_tcp_tsig_state *); 6807c478bd9Sstevel@tonic-gate int ns_samedomain(const char *, const char *); 6817c478bd9Sstevel@tonic-gate int ns_subdomain(const char *, const char *); 6827c478bd9Sstevel@tonic-gate int ns_makecanon(const char *, char *, size_t); 6837c478bd9Sstevel@tonic-gate int ns_samename(const char *, const char *); 6849525b14bSRao Shoaib int ns_newmsg_init(uchar_t *buffer, size_t bufsiz, ns_newmsg *); 6859525b14bSRao Shoaib int ns_newmsg_copy(ns_newmsg *, ns_msg *); 6869525b14bSRao Shoaib void ns_newmsg_id(ns_newmsg *handle, uint16_t id); 6879525b14bSRao Shoaib void ns_newmsg_flag(ns_newmsg *handle, ns_flag flag, uint_t value); 6889525b14bSRao Shoaib int ns_newmsg_q(ns_newmsg *handle, ns_nname_ct qname, 6899525b14bSRao Shoaib ns_type qtype, ns_class qclass); 6909525b14bSRao Shoaib int ns_newmsg_rr(ns_newmsg *handle, ns_sect sect, 6919525b14bSRao Shoaib ns_nname_ct name, ns_type type, 6929525b14bSRao Shoaib ns_class rr_class, uint32_t ttl, 6939525b14bSRao Shoaib uint16_t rdlen, const uchar_t *rdata); 6949525b14bSRao Shoaib size_t ns_newmsg_done(ns_newmsg *handle); 6959525b14bSRao Shoaib ssize_t ns_rdata_unpack(const uchar_t *, const uchar_t *, ns_type, 6969525b14bSRao Shoaib const uchar_t *, size_t, uchar_t *, size_t); 6979525b14bSRao Shoaib int ns_rdata_equal(ns_type, const uchar_t *, size_t, 6989525b14bSRao Shoaib const uchar_t *, size_t); 6999525b14bSRao Shoaib int ns_rdata_refers(ns_type, 7009525b14bSRao Shoaib const uchar_t *, size_t, 7019525b14bSRao Shoaib const uchar_t *); 7027c478bd9Sstevel@tonic-gate 7037c478bd9Sstevel@tonic-gate #ifdef BIND_4_COMPAT 7047c478bd9Sstevel@tonic-gate #include <arpa/nameser_compat.h> 7057c478bd9Sstevel@tonic-gate #endif 7067c478bd9Sstevel@tonic-gate 7077c478bd9Sstevel@tonic-gate #ifdef __cplusplus 7087c478bd9Sstevel@tonic-gate } 7097c478bd9Sstevel@tonic-gate #endif 7107c478bd9Sstevel@tonic-gate 7117c478bd9Sstevel@tonic-gate #endif /* !_ARPA_NAMESER_H */ 712