home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1996 May / PCOnline_05_1996.bin / linux / source / n / bind / bind-4.001 / bind-4~ / bind-4.9.3-BETA9 / named / db_defs.h next >
C/C++ Source or Header  |  1994-07-22  |  6KB  |  173 lines

  1. /*
  2.  *    from db.h    4.16 (Berkeley) 6/1/90
  3.  *    $Id: db_defs.h,v 1.11 1994/07/22 08:42:39 vixie Exp $
  4.  */
  5.  
  6. /*
  7.  * ++Copyright++ 1985, 1990
  8.  * -
  9.  * Copyright (c) 1985, 1990
  10.  *    The Regents of the University of California.  All rights reserved.
  11.  * 
  12.  * Redistribution and use in source and binary forms, with or without
  13.  * modification, are permitted provided that the following conditions
  14.  * are met:
  15.  * 1. Redistributions of source code must retain the above copyright
  16.  *    notice, this list of conditions and the following disclaimer.
  17.  * 2. Redistributions in binary form must reproduce the above copyright
  18.  *    notice, this list of conditions and the following disclaimer in the
  19.  *    documentation and/or other materials provided with the distribution.
  20.  * 3. All advertising materials mentioning features or use of this software
  21.  *    must display the following acknowledgement:
  22.  *     This product includes software developed by the University of
  23.  *     California, Berkeley and its contributors.
  24.  * 4. Neither the name of the University nor the names of its contributors
  25.  *    may be used to endorse or promote products derived from this software
  26.  *    without specific prior written permission.
  27.  * 
  28.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  29.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  30.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  31.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  32.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  33.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  34.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  37.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  38.  * SUCH DAMAGE.
  39.  * -
  40.  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
  41.  * 
  42.  * Permission to use, copy, modify, and distribute this software for any
  43.  * purpose with or without fee is hereby granted, provided that the above
  44.  * copyright notice and this permission notice appear in all copies, and that
  45.  * the name of Digital Equipment Corporation not be used in advertising or
  46.  * publicity pertaining to distribution of the document or software without
  47.  * specific, written prior permission.
  48.  * 
  49.  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
  50.  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
  51.  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
  52.  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  53.  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  54.  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  55.  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  56.  * SOFTWARE.
  57.  * -
  58.  * --Copyright--
  59.  */
  60.  
  61. /*
  62.  * Global definitions for data base routines.
  63.  */
  64.  
  65. #define INVBLKSZ    7    /* # of namebuf pointers per block */
  66. #define INVHASHSZ    919    /* size of inverse hash table */
  67.  
  68.     /* max length of data in RR data field */
  69. #define MAXDATA        2048
  70.  
  71. #define DB_ROOT_TIMBUF    3600
  72. #define TIMBUF        300
  73.  
  74. /*
  75.  * Hash table structures.
  76.  */
  77. struct databuf {
  78.     struct databuf    *d_next;    /* linked list */
  79.     u_int32_t    d_ttl;        /* time to live */
  80.                     /* if d_zone == DB_Z_CACHE, then
  81.                      * d_ttl is actually the time when
  82.                      * the record will expire.
  83.                      * otherwise (for authoritative
  84.                      * primary and secondary zones),
  85.                      * d_ttl is the time to live.
  86.                      */
  87.     unsigned    d_flags :7;    /* see below */
  88.     unsigned    d_cred :3;    /* DB_C_{??????} */
  89.     unsigned    d_clev :6;
  90.     int16_t        d_zone;        /* zone number or 0 for the cache */
  91.     int16_t        d_class;    /* class number */
  92.     int16_t        d_type;        /* type number */
  93.     int16_t        d_mark;        /* place to mark data */
  94.     int16_t        d_size;        /* size of data area */
  95. #ifdef NCACHE
  96.     int16_t        d_rcode;    /* rcode added for negative caching */
  97. #endif
  98.     int16_t        d_rcnt;
  99. #ifdef STATS
  100.     struct nameser    *d_ns;        /* NS from whence this came */
  101. #endif
  102. /*XXX*/    u_int32_t       d_nstime;       /* NS response time, milliseconds */
  103.     u_char        d_data[sizeof(char*)]; /* malloc'd (padded) */
  104. };
  105. #define DATASIZE(n) (sizeof(struct databuf) - sizeof(char*) + n)
  106.  
  107. /*
  108.  * d_flags definitions
  109.  */
  110. #define DB_F_HINT       0x01        /* databuf belongs to fcachetab */
  111.  
  112. /*
  113.  * d_cred definitions
  114.  */
  115. #define    DB_C_ZONE    4        /* authoritative zone - best */
  116. #define    DB_C_AUTH    3        /* authoritative answer */
  117. #define    DB_C_ANSWER    2        /* non-authoritative answer */
  118. #define    DB_C_ADDITIONAL    1        /* additional data */
  119. #define    DB_C_CACHE    0        /* cache - worst */
  120.  
  121. struct namebuf {
  122.     char        *n_dname;    /* domain name */
  123.     u_int        n_hashval;    /* hash value of n_dname */
  124.     struct namebuf    *n_next;    /* linked list */
  125.     struct databuf    *n_data;    /* data records */
  126.     struct namebuf    *n_parent;    /* parent domain */
  127.     struct hashbuf    *n_hash;    /* hash table for children */
  128. };
  129.  
  130. #ifdef INVQ
  131. struct invbuf {
  132.     struct invbuf    *i_next;    /* linked list */
  133.     struct namebuf    *i_dname[INVBLKSZ]; /* domain name */
  134. };
  135. #endif
  136.  
  137. struct hashbuf {
  138.     int        h_size;        /* size of hash table */
  139.     int        h_cnt;        /* number of entries */
  140.     struct namebuf    *h_tab[1];    /* malloc'ed as needed */
  141. };
  142. #define HASHSIZE(s) (s*sizeof(struct namebuf *) + 2*sizeof(int))
  143.  
  144. #define HASHSHIFT    3
  145. #define HASHMASK    0x1f
  146.  
  147. /*
  148.  * Flags to updatedb
  149.  */
  150. #define DB_NODATA    0x01    /* data should not exist */
  151. #define DB_MEXIST    0x02    /* data must exist */
  152. #define DB_DELETE    0x04    /* delete data if it exists */
  153. #define DB_NOTAUTH    0x08    /* must not update authoritative data */
  154. #define DB_NOHINTS      0x10    /* don't reflect update in fcachetab */
  155.  
  156. #define DB_Z_CACHE      (0)    /* cache-zone-only db_dump()  */
  157. #define DB_Z_ALL        (-1)    /* normal db_dump() */
  158.  
  159. /*
  160.  * Error return codes
  161.  */
  162. #define OK        0
  163. #define NONAME        -1
  164. #define NOCLASS        -2
  165. #define NOTYPE        -3
  166. #define NODATA        -4
  167. #define DATAEXISTS    -5
  168. #define NODBFILE    -6
  169. #define TOOMANYZONES    -7
  170. #define GOODDB        -8
  171. #define NEWDB        -9
  172. #define AUTH        -10
  173.