Annotation of 43BSDReno/usr.sbin/named/ns.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1985, 1990 Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms are permitted provided
                      6:  * that: (1) source distributions retain this entire copyright notice and
                      7:  * comment, and (2) distributions including binaries display the following
                      8:  * acknowledgement:  ``This product includes software developed by the
                      9:  * University of California, Berkeley and its contributors'' in the
                     10:  * documentation or other materials provided with the distribution and in
                     11:  * all advertising materials mentioning features or use of this software.
                     12:  * Neither the name of the University nor the names of its contributors may
                     13:  * be used to endorse or promote products derived from this software without
                     14:  * specific prior written permission.
                     15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     16:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     17:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     18:  *
                     19:  *     @(#)ns.h        4.31 (Berkeley) 6/1/90
                     20:  */
                     21: 
                     22: /*
                     23:  * Global definitions and variables for the name server.
                     24:  */
                     25: 
                     26: #include <arpa/inet.h>
                     27: #include <string.h>
                     28: 
                     29: /*
                     30:  * Timeout time should be around 1 minute or so.  Using the
                     31:  * the current simplistic backoff strategy, the sequence
                     32:  * retrys after 4, 8, and 16 seconds.  With 3 servers, this
                     33:  * dies out in a little more than a minute.
                     34:  * (sequence RETRYBASE, 2*RETRYBASE, 4*RETRYBASE... for MAXRETRY)
                     35:  */
                     36: #define MINROOTS       2               /* min number of root hints */
                     37: #define NSMAX          16              /* max number of NS addrs to try */
                     38: #define RETRYBASE      4               /* base time between retries */
                     39: #define MAXRETRY       3               /* max number of retries per addr */
                     40: #define MAXCNAMES      8               /* max # of CNAMES tried per addr */
                     41: #define MAXQUERIES     20              /* max # of queries to be made */
                     42:                                        /* (prevent "recursive" loops) */
                     43: #define        INIT_REFRESH    600             /* retry time for initial secondary */
                     44:                                        /* contact (10 minutes) */
                     45: 
                     46: #define ALPHA    0.7   /* How much to preserver of old response time */
                     47: #define        BETA     1.2    /* How much to penalize response time on failure */
                     48: #define        GAMMA    0.98   /* How much to decay unused response times */
                     49: 
                     50: struct zoneinfo {
                     51:        int     z_type;                 /* type of zone */
                     52:        int     z_auth;                 /* zone is authoritative */
                     53:        char    *z_origin;              /* root domain name of zone */
                     54:        time_t  z_time;                 /* time for next refresh */
                     55:        time_t  z_lastupdate;           /* time of last refresh */
                     56:        u_long  z_refresh;              /* refresh interval */
                     57:        u_long  z_retry;                /* refresh retry interval */
                     58:        u_long  z_expire;               /* expiration time for cached info */
                     59:        u_long  z_minimum;              /* minimum TTL value */
                     60:        u_long  z_serial;               /* changes if zone modified */
                     61:        char    *z_source;              /* source location of data */
                     62:        time_t  z_ftime;                /* modification time of source file */
                     63:        int     z_addrcnt;              /* address count */
                     64:        struct  in_addr z_addr[NSMAX];  /* list of master servers for zone */
                     65:        int     z_state;                /* state bits; see below */
                     66:        u_short z_xferpid;              /* xfer child pid */
                     67: #ifdef ALLOW_UPDATES
                     68:        int     hasChanged;             /* non-zero if zone has been updated
                     69:                                         * since last checkpoint
                     70:                                         */
                     71: #endif ALLOW_UPDATES
                     72: };
                     73: 
                     74:        /* zone types (z_type) */
                     75: #define Z_PRIMARY      1
                     76: #define Z_SECONDARY    2
                     77: #define Z_CACHE                3
                     78: 
                     79:        /* zone state bits */
                     80: #define        Z_AUTH          0x01            /* should replace z_auth */
                     81: #define        Z_NEED_XFER     0x02            /* waiting to do xfer */
                     82: #define        Z_XFER_RUNNING  0x04            /* asynch. xfer is running */
                     83: #define        Z_NEED_RELOAD   0x08            /* waiting to do reload */
                     84: #define        Z_SYSLOGGED     0x10            /* have logged timeout */
                     85: #define        Z_CHANGED       0x20            /* should replace hasChanged */
                     86: #define        Z_FOUND         0x40            /* found in boot file when reloading */
                     87: #define        Z_INCLUDE       0x80            /* set if include used in file */
                     88: #define        Z_DB_BAD        0x100           /* errors when loading file */
                     89: #define        Z_TMP_FILE      0x200           /* backup file for xfer is temporary */
                     90: #ifdef ALLOW_UPDATES
                     91: #define        Z_DYNAMIC       0x400           /* allow dynamic updates */
                     92: #define        Z_DYNADDONLY    0x800           /* dynamic mode: add new data only */
                     93: #endif ALLOW_UPDATES
                     94: 
                     95:        /* xfer exit codes */
                     96: #define        XFER_UPTODATE   0               /* zone is up-to-date */
                     97: #define        XFER_SUCCESS    1               /* performed transfer successfully */
                     98: #define        XFER_TIMEOUT    2               /* no server reachable/xfer timeout */
                     99: #define        XFER_FAIL       3               /* other failure, has been logged */
                    100: 
                    101: /*
                    102:  * Structure for recording info on forwarded queries.
                    103:  */
                    104: struct qinfo {
                    105:        u_short q_id;                   /* id of query */
                    106:        u_short q_nsid;                 /* id of forwarded query */
                    107:        int     q_dfd;                  /* UDP file descriptor */
                    108:        struct  sockaddr_in q_from;     /* requestor's address */
                    109:        char    *q_msg;                 /* the message */
                    110:        int     q_msglen;               /* len of message */
                    111:        int     q_naddr;                /* number of addr's in q_addr */
                    112:        int     q_curaddr;              /* last addr sent to */
                    113:        struct  fwdinfo *q_fwd;         /* last forwarder used */
                    114:        time_t  q_time;                 /* time to retry */
                    115:        struct  qinfo *q_next;          /* rexmit list (sorted by time) */
                    116:        struct  qinfo *q_link;          /* storage list (random order) */
                    117:        struct  qserv {
                    118:                struct  sockaddr_in ns_addr;    /* addresses of NS's */
                    119:                struct  databuf *ns;    /* databuf for NS record */
                    120:                struct  databuf *nsdata; /* databuf for server address */
                    121:                struct  timeval stime;  /* time first query started */
                    122:                int     nretry;         /* # of times addr retried */
                    123:        } q_addr[NSMAX];                /* addresses of NS's */
                    124:        struct  databuf *q_usedns[NSMAX]; /* databuf for NS that we've tried */
                    125:        int     q_nusedns;
                    126:        int     q_cname;                /* # of cnames found */
                    127:        int     q_nqueries;             /* # of queries required */
                    128:        char    *q_cmsg;                /* the cname message */
                    129:        int     q_cmsglen;              /* len of cname message */
                    130:        struct  qstream *q_stream;      /* TCP stream, null if UDP */
                    131:        int     q_system;               /* boolean, system query */
                    132: };
                    133: 
                    134: #define        Q_NEXTADDR(qp,n)        \
                    135:        (((qp)->q_fwd == (struct fwdinfo *)0) ? \
                    136:         &(qp)->q_addr[n].ns_addr : &(qp)->q_fwd->fwdaddr)
                    137: 
                    138: #define PRIMING_CACHE  42
                    139: #define QINFO_NULL     ((struct qinfo *)0)
                    140: 
                    141: #ifndef XFER
                    142: extern struct qinfo *qfindid();
                    143: extern struct qinfo *qnew();
                    144: extern struct qinfo *retryqp;          /* next query to retry */
                    145: #endif /* XFER */
                    146: 
                    147: /*
                    148:  * Return codes from ns_forw:
                    149:  */
                    150: #define        FW_OK           0
                    151: #define        FW_DUP          1
                    152: #define        FW_NOSERVER     2
                    153: #define        FW_SERVFAIL     3
                    154: 
                    155: struct qstream {
                    156:        int     s_rfd;                  /* stream file descriptor */
                    157:        int     s_size;                 /* expected amount of data to recive */
                    158:        int     s_bufsize;              /* amount of data recived in s_buf */
                    159:        char    *s_buf;                 /* buffer of recived data */
                    160:        char    *s_bufp;                /* pointer into s_buf of recived data */
                    161:        struct  qstream *s_next;        /* next stream */
                    162:        struct  sockaddr_in s_from;     /* address query came from */
                    163:        u_long  s_time;                 /* time stamp of last transaction */
                    164:        int     s_refcnt;               /* number of outstanding queries */
                    165:        u_short s_tempsize;             /* temporary for size from net */
                    166: };
                    167: 
                    168: #define QSTREAM_NULL   ((struct qstream *)0)
                    169: extern struct qstream *streamq;                /* stream queue */
                    170: 
                    171: struct qdatagram {
                    172:        int     dq_dfd;                 /* datagram file descriptor */
                    173:        struct  qdatagram *dq_next;     /* next datagram */
                    174:        struct  in_addr  dq_addr;       /* address of interface */
                    175: };
                    176: 
                    177: #define QDATAGRAM_NULL ((struct qdatagram *)0)
                    178: extern struct qdatagram *datagramq;    /* datagram queue */
                    179: 
                    180: struct netinfo {
                    181:        struct netinfo *next;
                    182:        u_long net;
                    183:        u_long mask;
                    184:        struct in_addr my_addr;
                    185: };
                    186: 
                    187: struct fwdinfo {
                    188:        struct fwdinfo *next;
                    189:        struct sockaddr_in fwdaddr;
                    190: };
                    191: 
                    192: struct nets {
                    193:        char *name;
                    194:        long net;
                    195:        struct nets *next;
                    196: }; 
                    197: 
                    198: /*
                    199:  *  Statistics Defines
                    200:  */
                    201: struct stats {
                    202:        unsigned long   cnt;
                    203:        char    *description;
                    204: };
                    205: 
                    206: /* gross count of UDP packets in and out */
                    207: #define        S_INPKTS        0
                    208: #define        S_OUTPKTS       1
                    209: /* gross count of queries and inverse queries received */
                    210: #define        S_QUERIES       2
                    211: #define        S_IQUERIES      3
                    212: #define S_DUPQUERIES   4
                    213: #define        S_RESPONSES     5
                    214: #define        S_DUPRESP       6
                    215: #define        S_RESPOK        7
                    216: #define        S_RESPFAIL      8
                    217: #define        S_RESPFORMERR   9
                    218: #define        S_SYSQUERIES    10
                    219: #define        S_PRIMECACHE    11
                    220: #define        S_CHECKNS       12
                    221: #define        S_BADRESPONSES  13
                    222: #define        S_MARTIANS      14
                    223: #define S_NSTATS       15      /* Careful! */
                    224: #ifdef STATS
                    225: extern struct stats stats[S_NSTATS];
                    226: extern unsigned long typestats[T_ANY+1];
                    227: #endif
                    228: 
                    229: #ifndef VOID
                    230: /* Support posix signals and old systems equally */
                    231: #define VOID void
                    232: #endif
                    233: 
                    234: #ifdef DEBUG
                    235: extern int debug;                      /* debug flag */
                    236: extern FILE *ddt;                      /* debug file discriptor */
                    237: #endif
                    238: #ifndef XFER
                    239: extern int ds;                         /* datagram socket */
                    240: extern struct qdatagram *dqp;
                    241: extern struct timeval tt;              /* place to store time */
                    242: 
                    243: extern struct itimerval ival;          /* maintenance interval */
                    244: extern struct zoneinfo *zones;         /* zone information */
                    245: extern int nzones;                     /* number of zones in use */
                    246: 
                    247: extern int forward_only;               /* true on slave server */
                    248: #endif /* XFER */
                    249: 
                    250: #ifdef vax
                    251: extern u_short htons(), ntohs();
                    252: extern u_long htonl(), ntohl();
                    253: #endif
                    254: 
                    255: #define MAX_XFER_TIME         60 * 60 * 2  /* max seconds for an xfer */
                    256: #define XFER_TIME_FUDGE              10           /* MAX_XFER_TIME fudge */
                    257: 
                    258: #ifndef XFER
                    259: extern int xfer_running_cnt;             /* number of xfers running */
                    260: extern int xfer_deferred_cnt;            /* number of deferred xfers */
                    261: #define MAX_XFERS_RUNNING     4           /* max value of xfer_running_cnt */
                    262: #endif /* XFER */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.