1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License, Version 1.0 only
   6  * (the "License").  You may not use this file except in compliance
   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*
  28  * Copyright(c) 1983,   1989
  29  *    The Regents of the University of California.  All rights reserved.
  30  *
  31  * Redistribution and use in source and binary forms, with or without
  32  * modification, are permitted provided that the following conditions
  33  * are met:
  34  * 1. Redistributions of source code must retain the above copyright
  35  *    notice, this list of conditions and the following disclaimer.
  36  * 2. Redistributions in binary form must reproduce the above copyright
  37  *    notice, this list of conditions and the following disclaimer in the
  38  *    documentation and/or other materials provided with the distribution.
  39  * 3. All advertising materials mentioning features or use of this software
  40  *    must display the following acknowledgement:
  41  *      This product includes software developed by the University of
  42  *      California, Berkeley and its contributors.
  43  * 4. Neither the name of the University nor the names of its contributors
  44  *    may be used to endorse or promote products derived from this software
  45  *    without specific prior written permission.
  46  *
  47  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  48  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  49  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  50  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  51  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  52  * DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  53  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  54  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  55  * LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  56  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  57  * SUCH DAMAGE.
  58  */
  59 
  60 /*
  61  *      from nameser.h  8.1 (Berkeley) 6/2/93
  62  *      $Id: nameser_compat.h,v 8.15 2002/07/17 07:01:02 marka Exp $
  63  */
  64 
  65 #ifndef _ARPA_NAMESER_COMPAT_H
  66 #define _ARPA_NAMESER_COMPAT_H
  67 
  68 #pragma ident   "%Z%%M% %I%     %E% SMI"
  69 
  70 #ifdef  __cplusplus
  71 extern "C" {
  72 #endif
  73 
  74 #define __BIND          19950621        /* (DEAD) interface version stamp. */
  75 
  76 #ifndef BYTE_ORDER
  77 #if (BSD >= 199103)
  78 #include <machine/endian.h>
  79 #else
  80 #ifdef linux
  81 #include <endian.h>
  82 #else
  83 #define LITTLE_ENDIAN   1234    /* least-significant byte first (vax, pc) */
  84 #define BIG_ENDIAN      4321    /* most-significant byte first (IBM, net) */
  85 #define PDP_ENDIAN      3412    /* LSB first in word, MSW first in long (pdp) */
  86 
  87 #if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
  88         defined(__i386) || defined(__amd64) || \
  89         defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
  90         defined(__alpha__) || defined(__alpha) || \
  91         (defined(__Lynx__) && defined(__x86__))
  92 #define BYTE_ORDER      LITTLE_ENDIAN
  93 #endif
  94 
  95 #if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
  96     defined(__sparc) || \
  97     defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
  98     defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
  99     defined(apollo) || defined(__convex__) || defined(_CRAY) || \
 100     defined(__hppa) || defined(__hp9000) || \
 101     defined(__hp9000s300) || defined(__hp9000s700) || \
 102     defined(__hp3000s900) || defined(MPE) || \
 103     defined(BIT_ZERO_ON_LEFT) || defined(m68k) || \
 104         (defined(__Lynx__) && \
 105         (defined(__68k__) || defined(__sparc__) || defined(__powerpc__)))
 106 #define BYTE_ORDER      BIG_ENDIAN
 107 #endif
 108 #endif /* linux */
 109 #endif /* BSD */
 110 #endif /* BYTE_ORDER */
 111 
 112 #if !defined(BYTE_ORDER) || \
 113         (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \
 114     BYTE_ORDER != PDP_ENDIAN)
 115         /*
 116          * you must determine what the correct bit order is for
 117          * your compiler - the next line is an intentional error
 118          * which will force your compiles to bomb until you fix
 119          * the above macros.
 120          */
 121         error "Undefined or invalid BYTE_ORDER";
 122 #endif
 123 
 124 /*
 125  * Structure for query header.  The order of the fields is machine- and
 126  * compiler-dependent, depending on the byte/bit order and the layout
 127  * of bit fields.  We use bit fields only in int variables, as this
 128  * is all ANSI requires.  This requires a somewhat confusing rearrangement.
 129  */
 130 
 131 typedef struct {
 132         unsigned        id :16;         /* query identification number */
 133 #if BYTE_ORDER == BIG_ENDIAN
 134                         /* fields in third byte */
 135         unsigned        qr: 1;          /* response flag */
 136         unsigned        opcode: 4;      /* purpose of message */
 137         unsigned        aa: 1;          /* authoritive answer */
 138         unsigned        tc: 1;          /* truncated message */
 139         unsigned        rd: 1;          /* recursion desired */
 140                         /* fields in fourth byte */
 141         unsigned        ra: 1;          /* recursion available */
 142         unsigned        unused :1;      /* unused bits (MBZ as of 4.9.3a3) */
 143         unsigned        ad: 1;          /* authentic data from named */
 144         unsigned        cd: 1;          /* checking disabled by resolver */
 145         unsigned        rcode :4;       /* response code */
 146 #endif
 147 #if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
 148                         /* fields in third byte */
 149         unsigned        rd :1;          /* recursion desired */
 150         unsigned        tc :1;          /* truncated message */
 151         unsigned        aa :1;          /* authoritive answer */
 152         unsigned        opcode :4;      /* purpose of message */
 153         unsigned        qr :1;          /* response flag */
 154                         /* fields in fourth byte */
 155         unsigned        rcode :4;       /* response code */
 156         unsigned        cd: 1;          /* checking disabled by resolver */
 157         unsigned        ad: 1;          /* authentic data from named */
 158         unsigned        unused :1;      /* unused bits (MBZ as of 4.9.3a3) */
 159         unsigned        ra :1;          /* recursion available */
 160 #endif
 161                         /* remaining bytes */
 162         unsigned        qdcount :16;    /* number of question entries */
 163         unsigned        ancount :16;    /* number of answer entries */
 164         unsigned        nscount :16;    /* number of authority entries */
 165         unsigned        arcount :16;    /* number of resource entries */
 166 } HEADER;
 167 
 168 #define PACKETSZ        NS_PACKETSZ
 169 #define MAXDNAME        NS_MAXDNAME
 170 #define MAXCDNAME       NS_MAXCDNAME
 171 #define MAXLABEL        NS_MAXLABEL
 172 #define HFIXEDSZ        NS_HFIXEDSZ
 173 #define QFIXEDSZ        NS_QFIXEDSZ
 174 #define RRFIXEDSZ       NS_RRFIXEDSZ
 175 #define INT32SZ         NS_INT32SZ
 176 #define INT16SZ         NS_INT16SZ
 177 #define INT8SZ          NS_INT8SZ
 178 #define INADDRSZ        NS_INADDRSZ
 179 #define IN6ADDRSZ       NS_IN6ADDRSZ
 180 #define INDIR_MASK      NS_CMPRSFLGS
 181 #define NAMESERVER_PORT NS_DEFAULTPORT
 182 
 183 #define S_ZONE          ns_s_zn
 184 #define S_PREREQ        ns_s_pr
 185 #define S_UPDATE        ns_s_ud
 186 #define S_ADDT          ns_s_ar
 187 
 188 #define QUERY           ns_o_query
 189 #define IQUERY          ns_o_iquery
 190 #define STATUS          ns_o_status
 191 #define NS_NOTIFY_OP    ns_o_notify
 192 #define NS_UPDATE_OP    ns_o_update
 193 
 194 #define NOERROR         ns_r_noerror
 195 #define FORMERR         ns_r_formerr
 196 #define SERVFAIL        ns_r_servfail
 197 #define NXDOMAIN        ns_r_nxdomain
 198 #define NOTIMP          ns_r_notimpl
 199 #define REFUSED         ns_r_refused
 200 #define YXDOMAIN        ns_r_yxdomain
 201 #define YXRRSET         ns_r_yxrrset
 202 #define NXRRSET         ns_r_nxrrset
 203 #define NOTAUTH         ns_r_notauth
 204 #define NOTZONE         ns_r_notzone
 205 /* #define      BADSIG          ns_r_badsig */
 206 /* #define      BADKEY          ns_r_badkey */
 207 /* #define      BADTIME         ns_r_badtime */
 208 
 209 #define DELETE          ns_uop_delete
 210 #ifndef ADD
 211 #define ADD             ns_uop_add
 212 #endif
 213 
 214 #define T_A             ns_t_a
 215 #define T_NS            ns_t_ns
 216 #define T_MD            ns_t_md
 217 #define T_MF            ns_t_mf
 218 #define T_CNAME         ns_t_cname
 219 #define T_SOA           ns_t_soa
 220 #define T_MB            ns_t_mb
 221 #define T_MG            ns_t_mg
 222 #define T_MR            ns_t_mr
 223 #define T_NULL          ns_t_null
 224 #define T_WKS           ns_t_wks
 225 #define T_PTR           ns_t_ptr
 226 #define T_HINFO         ns_t_hinfo
 227 #define T_MINFO         ns_t_minfo
 228 #define T_MX            ns_t_mx
 229 #define T_TXT           ns_t_txt
 230 #define T_RP            ns_t_rp
 231 #define T_AFSDB         ns_t_afsdb
 232 #define T_X25           ns_t_x25
 233 #define T_ISDN          ns_t_isdn
 234 #define T_RT            ns_t_rt
 235 #define T_NSAP          ns_t_nsap
 236 #define T_NSAP_PTR      ns_t_nsap_ptr
 237 #define T_SIG           ns_t_sig
 238 #define T_KEY           ns_t_key
 239 #define T_PX            ns_t_px
 240 #define T_GPOS          ns_t_gpos
 241 #define T_AAAA          ns_t_aaaa
 242 #define T_LOC           ns_t_loc
 243 #define T_NXT           ns_t_nxt
 244 #define T_EID           ns_t_eid
 245 #define T_NIMLOC        ns_t_nimloc
 246 #define T_SRV           ns_t_srv
 247 #define T_ATMA          ns_t_atma
 248 #define T_NAPTR         ns_t_naptr
 249 #define T_A6            ns_t_a6
 250 #define T_TSIG          ns_t_tsig
 251 #define T_IXFR          ns_t_ixfr
 252 #define T_AXFR          ns_t_axfr
 253 #define T_MAILB         ns_t_mailb
 254 #define T_MAILA         ns_t_maila
 255 #define T_ANY           ns_t_any
 256 
 257 #define C_IN            ns_c_in
 258 #define C_CHAOS         ns_c_chaos
 259 #define C_HS            ns_c_hs
 260 /* BIND_UPDATE */
 261 #define C_NONE          ns_c_none
 262 #define C_ANY           ns_c_any
 263 
 264 #define GETSHORT                NS_GET16
 265 #define GETLONG                 NS_GET32
 266 #define PUTSHORT                NS_PUT16
 267 #define PUTLONG                 NS_PUT32
 268 
 269 #ifdef  __cplusplus
 270 }
 271 #endif
 272 
 273 #endif  /* _ARPA_NAMESER_COMPAT_H */