home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / NETWORK / ISP / bind.4.8.3.lzh / BIND483 / RES / nameser.h < prev    next >
Text File  |  1994-02-01  |  9KB  |  268 lines

  1. /*    @(#)nameser.h    6.1    (ULTRIX)    11/19/91    */
  2. /************************************************************************
  3.  *                                    *
  4.  *            Copyright (c) 1984,1988 by            *
  5.  *        Digital Equipment Corporation, Maynard, MA        *
  6.  *            All rights reserved.                *
  7.  *                                    *
  8.  *   This software is furnished under a license and may be used and    *
  9.  *   copied  only  in accordance with the terms of such license and    *
  10.  *   with the  inclusion  of  the  above  copyright  notice.   This    *
  11.  *   software  or  any  other copies thereof may not be provided or    *
  12.  *   otherwise made available to any other person.  No title to and    *
  13.  *   ownership of the software is hereby transferred.            *
  14.  *                                    *
  15.  *   This software is  derived  from  software  received  from  the    *
  16.  *   University    of   California,   Berkeley,   and   from   Bell    *
  17.  *   Laboratories.  Use, duplication, or disclosure is  subject  to    *
  18.  *   restrictions  under  license  agreements  with  University  of    *
  19.  *   California and with AT&T.                        *
  20.  *                                    *
  21.  *   The information in this software is subject to change  without    *
  22.  *   notice  and should not be construed as a commitment by Digital    *
  23.  *   Equipment Corporation.                        *
  24.  *                                    *
  25.  *   Digital assumes no responsibility for the use  or  reliability    *
  26.  *   of its software on equipment which is not supplied by Digital.    *
  27.  *                                    *
  28.  ************************************************************************/
  29. /*
  30.  * Copyright (c) 1983 Regents of the University of California.
  31.  * All rights reserved.  The Berkeley software License Agreement
  32.  * specifies the terms and conditions for redistribution.
  33.  *
  34.  *    nameser.h    5.17 (Berkeley) 11/17/87
  35.  */
  36.  
  37. /*
  38.  * Define constants based on rfc883
  39.  */
  40. #include <ansi_compat.h>
  41. #define PACKETSZ    512        /* maximum packet size */
  42. #define MAXDNAME    256        /* maximum domain name */
  43. #define MAXCDNAME    255        /* maximum compressed domain name */
  44. #define MAXLABEL    63        /* maximum length of domain label */
  45.     /* Number of bytes of fixed size data in query structure */
  46. #define QFIXEDSZ    4
  47. #ifdef AUTHEN
  48.     /* Number of bytes of fixed size data in authen query structure */
  49. #define AQFIXEDSZ    8
  50. #endif /* AUTHEN */
  51.     /* number of bytes of fixed size data in resource record */
  52. #define RRFIXEDSZ    10
  53.  
  54. #ifdef AUTHEN
  55. #define MAXAUTHTYPE    63        /* maximum authentication type name */
  56. #define MAXAUTHVERSION    63        /* maximum authentication type name */
  57. #endif /* AUTHEN */
  58. /*
  59.  * Internet nameserver port number
  60.  */
  61. #define NAMESERVER_PORT    53
  62.  
  63. /*
  64.  * Currently defined opcodes
  65.  */
  66. #define QUERY        0x0        /* standard query */
  67. #define IQUERY        0x1        /* inverse query */
  68. #define STATUS        0x2        /* nameserver status query */
  69. /*#define xxx        0x3        /* 0x3 reserved */
  70.     /* non standard */
  71. #ifdef AUTHEN
  72. #define AQUERY        0x8        /* nameserver status query */
  73. #endif /* AUTHEN */
  74. #define UPDATEA        0x9        /* add resource record */
  75. #define UPDATED        0xa        /* delete a specific resource record */
  76. #define UPDATEDA    0xb        /* delete all nemed resource record */
  77. #define UPDATEM        0xc        /* modify a specific resource record */
  78. #define UPDATEMA    0xd        /* modify all named resource record */
  79.  
  80. #define ZONEINIT    0xe        /* initial zone transfer */
  81. #define ZONEREF        0xf        /* incremental zone referesh */
  82.  
  83. /*
  84.  * Currently defined response codes
  85.  */
  86. #define NOERROR        0        /* no error */
  87. #define FORMERR        1        /* format error */
  88. #define SERVFAIL    2        /* server failure */
  89. #define NXDOMAIN    3        /* non existent domain */
  90. #define NOTIMP        4        /* not implemented */
  91. #define REFUSED        5        /* query refused */
  92.     /* non standard */
  93. #define AUTHENBAD    0xe        /* query refused */
  94. #define NOCHANGE    0xf        /* update failed to change db */
  95.  
  96. /*
  97.  * Type values for resources and queries
  98.  */
  99. #define T_A        1        /* host address */
  100. #define T_NS        2        /* authoritative server */
  101. #define T_MD        3        /* mail destination */
  102. #define T_MF        4        /* mail forwarder */
  103. #define T_CNAME        5        /* connonical name */
  104. #define T_SOA        6        /* start of authority zone */
  105. #define T_MB        7        /* mailbox domain name */
  106. #define T_MG        8        /* mail group member */
  107. #define T_MR        9        /* mail rename name */
  108. #define T_NULL        10        /* null resource record */
  109. #define T_WKS        11        /* well known service */
  110. #define T_PTR        12        /* domain name pointer */
  111. #define T_HINFO        13        /* host information */
  112. #define T_MINFO        14        /* mailbox information */
  113. #define T_MX        15        /* mail routing information */
  114. #define T_TXT        16        /* text record */
  115.     /* non standard */
  116. #define T_UINFO        100        /* user (finger) information */
  117. #define T_UID        101        /* user ID */
  118. #define T_GID        102        /* group ID */
  119. #define T_UNSPEC    103        /* Unspecified format (binary data) */
  120. #define T_UNSPECA    104        /* Unspecified format - MIT (binary data) */
  121. #ifdef AUTHEN
  122. #define T_CRED        105        /* credentials structure */
  123. #endif /* AUTHEN */
  124.     /* Query type values which do not appear in resource records */
  125. #define T_AXFR        252        /* transfer zone of authority */
  126. #define T_MAILB        253        /* transfer mailbox records */
  127. #define T_MAILA        254        /* transfer mail agent records */
  128. #define T_ANY        255        /* wildcard match */
  129.  
  130. /*
  131.  * Values for class field
  132.  */
  133.  
  134. #define C_IN        1        /* the arpa internet */
  135. #define C_CHAOS        3        /* for chaos net at MIT */
  136. #define C_HS        4        /* for Hesiod type (MIT) */
  137. #define C_HESIOD    4        /* for Hesiod backward comp. */
  138.     /* Query class values which do not appear in resource records */
  139. #define C_ANY        255        /* wildcard match */
  140.  
  141. /*
  142.  * Status return codes for T_UNSPEC conversion routines
  143.  */
  144. #define CONV_SUCCESS 0
  145. #define CONV_OVERFLOW -1
  146. #define CONV_BADFMT -2
  147. #define CONV_BADCKSUM -3
  148. #define CONV_BADBUFLEN -4
  149.  
  150. /*
  151.  * Structure for query header, the order of the fields is machine and
  152.  * compiler dependent, in our case, the bits within a byte are assignd 
  153.  * least significant first, while the order of transmition is most 
  154.  * significant first.  This requires a somewhat confusing rearrangement.
  155.  */
  156.  
  157. /* this is the only clean way since ultrix on mips means little endian */
  158. #ifdef __ultrix
  159. #ifdef __mips
  160. #define BIT_ZERO_ON_RIGHT 1
  161. #endif /* __mips */
  162. #endif /* __ultrix */
  163.  
  164. typedef struct {
  165.     u_short    id;        /* query identification number */
  166. #if defined (__sun) || defined (sel) || defined (pyr) || defined (is68k) \
  167. || defined (tahoe) || defined (BIT_ZERO_ON_LEFT)
  168.     /* Bit zero on left:  Gould and similar architectures */
  169.             /* fields in third byte */
  170.     u_char    qr:1;        /* response flag */
  171.     u_char    opcode:4;    /* purpose of message */
  172.     u_char    aa:1;        /* authoritive answer */
  173.     u_char    tc:1;        /* truncated message */
  174.     u_char    rd:1;        /* recursion desired */
  175.             /* fields in fourth byte */
  176.     u_char    ra:1;        /* recursion available */
  177.     u_char    pr:1;        /* primary server required (non standard) */
  178.     u_char    unused:2;    /* unused bits */
  179.     u_char    rcode:4;    /* response code */
  180. #else
  181. #if defined (__vax) || defined(ns32000) || defined (BIT_ZERO_ON_RIGHT)
  182.     /* Bit zero on right:  VAX */
  183.             /* fields in third byte */
  184.     u_char    rd:1;        /* recursion desired */
  185.     u_char    tc:1;        /* truncated message */
  186.     u_char    aa:1;        /* authoritive answer */
  187.     u_char    opcode:4;    /* purpose of message */
  188.     u_char    qr:1;        /* response flag */
  189.             /* fields in fourth byte */
  190.     u_char    rcode:4;    /* response code */
  191.     u_char    unused:2;    /* unused bits */
  192.     u_char    pr:1;        /* primary server required (non standard) */
  193.     u_char    ra:1;        /* recursion available */
  194. #else
  195.     /* you must determine what the correct bit order is for your compiler */
  196.     UNDEFINED_BIT_ORDER;
  197. #endif
  198. #endif
  199.             /* remaining bytes */
  200.     u_short    qdcount;    /* number of question entries */
  201.     u_short    ancount;    /* number of answer entries */
  202.     u_short    nscount;    /* number of authority entries */
  203.     u_short    arcount;    /* number of resource entries */
  204. } HEADER;
  205.  
  206. /*
  207.  * Defines for handling compressed domain names
  208.  */
  209. #define INDIR_MASK    0xc0
  210.  
  211. /*
  212.  * Structure for passing resource records around.
  213.  */
  214. struct rrec {
  215.     short    r_zone;            /* zone number */
  216.     short    r_class;        /* class number */
  217.     short    r_type;            /* type number */
  218.     u_long    r_ttl;            /* time to live */
  219.     int    r_size;            /* size of data area */
  220.     char    *r_data;        /* pointer to data */
  221. };
  222.  
  223. extern    u_short    _getshort();
  224. extern    u_long    _getlong();
  225.  
  226. /*
  227.  * Inline versions of get/put short/long.
  228.  * Pointer is advanced; we assume that both arguments
  229.  * are lvalues and will already be in registers.
  230.  * cp MUST be u_char *.
  231.  */
  232. #define GETSHORT(s, cp) { \
  233.     (s) = *(cp)++ << 8; \
  234.     (s) |= *(cp)++; \
  235. }
  236.  
  237. #define GETLONG(l, cp) { \
  238.     (l) = *(cp)++ << 8; \
  239.     (l) |= *(cp)++; (l) <<= 8; \
  240.     (l) |= *(cp)++; (l) <<= 8; \
  241.     (l) |= *(cp)++; \
  242. }
  243.  
  244.  
  245. #define PUTSHORT(s, cp) { \
  246.     *(cp)++ = (s) >> 8; \
  247.     *(cp)++ = (s); \
  248. }
  249.  
  250. /*
  251.  * Warning: PUTLONG destroys its first argument.
  252.  */
  253. #define PUTLONG(l, cp) { \
  254.     (cp)[3] = l; \
  255.     (cp)[2] = (l >>= 8); \
  256.     (cp)[1] = (l >>= 8); \
  257.     (cp)[0] = l >> 8; \
  258.     (cp) += sizeof(u_long); \
  259. }
  260.  
  261. #ifdef AUTHEN
  262. #define AUTH_NONE 0
  263. #define AUTH_CACHE 1
  264. #define AUTH_KRB 2
  265. #define ZERO 1
  266. #define ONE 1
  267. #endif /* AUTHEN */
  268.