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