# 2.11BSD#431 - /usr/src/usr.sbin/named/named/ns.h

##### Macros

    ALPHA             X
    BETA              X
    FW_DUP            X
    FW_NOSERVER       X
    FW_OK             X
    FW_SERVFAIL       X
    GAMMA             X
    INIT_REFRESH      X
    MAXCNAMES         X
    MAXQUERIES        X
    MAXRETRY          X
    MAXZONES          X
    MINROOTS          X
    NSMAX             X
    PRIMING_CACHE     X
    QDATAGRAM_NULL    X
    QINFO_NULL        X
    QSTREAM_NULL      X
    Q_NEXTADDR        X
    RETRYBASE         X
    S_BADRESPONSES    X
    S_CHECKNS         X
    S_DUPQUERIES      X
    S_DUPRESP         X
    S_INPKTS          X
    S_IQUERIES        X
    S_MARTIANS        X
    S_NSTATS          X
    S_OUTPKTS         X
    S_PRIMECACHE      X
    S_QUERIES         X
    S_RESPFAIL        X
    S_RESPFORMERR     X
    S_RESPOK          X
    S_RESPONSES       X
    S_SYSQUERIES      X
    Z_CACHE           X
    Z_PRIMARY         X
    Z_SECONDARY       X

##### struct's

    fwdinfo           X
    netinfo           X
    nets              X
    qdatagram         X
    qinfo             X
    qserv             X
    qstream           X
    stats             X
    zoneinfo          X

       1: /*
       2:  * Copyright (c) 1985 Regents of the University of California.
       3:  * All rights reserved.
       4:  *
       5:  * Redistribution and use in source and binary forms are permitted
       6:  * provided that this notice is preserved and that due credit is given
       7:  * to the University of California at Berkeley. The name of the University
       8:  * may not be used to endorse or promote products derived from this
       9:  * software without specific prior written permission. This software
      10:  * is provided ``as is'' without express or implied warranty.
      11:  *
      12:  *	@(#)ns.h	4.21.1 (2.11BSD GTE) 1/1/94
      13:  */
      14:
      15: /*
      16:  * Global definitions and variables for the name server.
      17:  */
      18:
      19: #include <strings.h>
      20: #include <arpa/inet.h>
      21:
      22: /*
      23:  * Timeout time should be around 1 minute or so.  Using the
      24:  * the current simplistic backoff strategy, the sequence
      25:  * retrys after 4, 8, and 16 seconds.  With 3 servers, this
      26:  * dies out in a little more than a minute.
      27:  * (sequence RETRYBASE, 2*RETRYBASE, 4*RETRYBASE... for MAXRETRY)
      28:  */
      29: #define MAXZONES    128     /* max number of zones supported */
      30: #define MINROOTS    2       /* min number of root hints */
      31: #define NSMAX       10      /* max number of NS's to try */
      32: #define RETRYBASE   4       /* base time between retries */
      33: #define MAXRETRY    3       /* max number of retries per addr */
      34: #define MAXCNAMES   8       /* max # of CNAMES tried per addr */
      35: #define MAXQUERIES  20      /* max # of queries to be made */
      36:                     /* (prevent "recursive" loops) */
      37: #define INIT_REFRESH    600     /* retry time for initial secondary */
      38:                     /* contact (10 minutes) */
      39:
      40: #define ALPHA    0.7    /* How much to preserver of old response time */
      41: #define BETA     1.2    /* How much to penalize response time on failure */
      42: #define GAMMA    0.98   /* How much to decay unused response times */
      43:
      44: struct zoneinfo {
      45:     int z_type;         /* type of zone */
      46:     int z_auth;         /* zone is authoritative */
      47:     char    *z_origin;      /* root domain name of zone */
      48:     time_t  z_time;         /* time for next refresh */
      49:     time_t  z_lastupdate;       /* time of last refresh */
      50:     u_long  z_refresh;      /* refresh interval */
      51:     u_long  z_retry;        /* refresh retry interval */
      52:     u_long  z_expire;       /* expiration time for cached info */
      53:     u_long  z_minimum;      /* minimum TTL value */
      54:     u_long  z_serial;       /* changes if zone modified */
      55:     char    *z_source;      /* source location of data */
      56:     time_t  z_ftime;        /* modification time of source file */
      57:     int z_addrcnt;      /* address count */
      58:     struct  in_addr z_addr[NSMAX];  /* list of master servers for zone */
      59:     int z_sysloged;     /* has fail to transfer been sysloged */
      60: #ifdef ALLOW_UPDATES
      61:     int hasChanged;     /* non-zero if zone has been updated
      62: 					 * since last checkpoint
      63: 					 */
      64: #endif ALLOW_UPDATES
      65: };
      66:
      67:     /* zone types (z_type) */
      68: #define Z_PRIMARY   1
      69: #define Z_SECONDARY 2
      70: #define Z_CACHE     3
      71:
      72: /*
      73:  * Structure for recording info on forwarded queries.
      74:  */
      75: struct qinfo {
      76:     u_short q_id;           /* id of query */
      77:     u_short q_nsid;         /* id of forwarded query */
      78:     int q_dfd;          /* UDP file descriptor */
      79:     struct  sockaddr_in q_from; /* requestor's address */
      80:     char    *q_msg;         /* the message */
      81:     int q_msglen;       /* len of message */
      82:     int q_naddr;        /* number of addr's in q_addr */
      83:     int q_curaddr;      /* last addr sent to */
      84:     struct  fwdinfo *q_fwd;     /* last	forwarder used */
      85:     time_t  q_time;         /* time to retry */
      86:     struct  qinfo *q_next;      /* rexmit list (sorted by time) */
      87:     struct  qinfo *q_link;      /* storage list (random order) */
      88:     struct  qserv {
      89:         struct  sockaddr_in ns_addr;    /* addresses of NS's */
      90:         struct  databuf *ns;    /* databuf for NS record */
      91:         struct  databuf *nsdata; /* databuf for server address */
      92:         struct  timeval stime;  /* time first query started */
      93:         int nretry;     /* # of times addr retried */
      94:     } q_addr[NSMAX];        /* addresses of NS's */
      95:     struct  databuf *q_usedns[NSMAX]; /* databuf for NS that we've tried */
      96:     int q_nusedns;
      97:     int q_cname;        /* # of cnames found */
      98:     int q_nqueries;     /* # of queries required */
      99:     char    *q_cmsg;        /* the cname message */
     100:     int q_cmsglen;      /* len of cname message */
     101:     struct  qstream *q_stream;  /* TCP stream, null if UDP */
     102:     int q_system;       /* boolean, system query */
     103: };
     104:
     105: #define Q_NEXTADDR(qp,n)    \
     106:     (((qp)->q_fwd == (struct fwdinfo *)0) ? \
     107:      &(qp)->q_addr[n].ns_addr : &(qp)->q_fwd->fwdaddr)
     108:
     109: #define PRIMING_CACHE   42
     110: #define QINFO_NULL  ((struct qinfo *)0)
     111: extern struct qinfo *qfindid();
     112: extern struct qinfo *qnew();
     113: extern struct qinfo *retryqp;       /* next query to retry */
     114: /*
     115:  * Return codes from ns_forw:
     116:  */
     117: #define FW_OK       0
     118: #define FW_DUP      1
     119: #define FW_NOSERVER 2
     120: #define FW_SERVFAIL 3
     121:
     122: struct qstream {
     123:     int     s_rfd;          /* stream file descriptor */
     124:     int     s_size;         /* expected amount of data to recive */
     125:     int     s_bufsize;      /* amount of data recived in s_buf */
     126:     char    *s_buf;         /* buffer of recived data */
     127:     char    *s_bufp;        /* pointer into s_buf of recived data */
     128:     struct  qstream *s_next;    /* next stream */
     129:     struct  sockaddr_in s_from; /* address query came from */
     130:     u_long  s_time;         /* time stamp of last transaction */
     131:     int s_refcnt;       /* number of outstanding queries */
     132:     u_short s_tempsize;     /* temporary for size from net */
     133: };
     134:
     135: #define QSTREAM_NULL    ((struct qstream *)0)
     136: extern struct qstream *streamq;     /* stream queue */
     137:
     138: struct qdatagram {
     139:     int     dq_dfd;         /* datagram file descriptor */
     140:     struct  qdatagram *dq_next; /* next datagram */
     141:     struct  in_addr  dq_addr;   /* address of interface */
     142: };
     143:
     144: #define QDATAGRAM_NULL  ((struct qdatagram *)0)
     145: extern struct qdatagram *datagramq; /* datagram queue */
     146:
     147: struct netinfo {
     148:     struct netinfo *next;
     149:     u_long net;
     150:     u_long mask;
     151:     struct in_addr my_addr;
     152: };
     153:
     154: struct fwdinfo {
     155:     struct fwdinfo *next;
     156:     struct sockaddr_in fwdaddr;
     157: };
     158:
     159: struct nets {
     160:     char *name;
     161:     long net;
     162:     struct nets *next;
     163: };
     164:
     165: /*
     166:  *  Statistics Defines
     167:  */
     168: struct stats {
     169:     u_long  cnt;
     170:     char    *description;
     171: };
     172:
     173: /* gross count of UDP packets in and out */
     174: #define S_INPKTS    0
     175: #define S_OUTPKTS   1
     176: /* gross count of queries and inverse queries received */
     177: #define S_QUERIES   2
     178: #define S_IQUERIES  3
     179: #define S_DUPQUERIES    4
     180: #define S_RESPONSES 5
     181: #define S_DUPRESP   6
     182: #define S_RESPOK    7
     183: #define S_RESPFAIL  8
     184: #define S_RESPFORMERR   9
     185: #define S_SYSQUERIES    10
     186: #define S_PRIMECACHE    11
     187: #define S_CHECKNS   12
     188: #define S_BADRESPONSES  13
     189: #define S_MARTIANS  14
     190: #define S_NSTATS    15  /* Careful! */
     191: #ifdef STATS
     192: extern struct stats stats[S_NSTATS];
     193: extern u_long typestats[T_ANY+1];
     194: #endif
     195:
     196: #ifdef DEBUG
     197: extern int debug;           /* debug flag */
     198: extern FILE *ddt;           /* debug file discriptor */
     199: #endif
     200: extern int ds;              /* datagram socket */
     201: extern struct qdatagram *dqp;
     202: extern struct timeval tt;       /* place to store time */
     203:
     204: extern struct itimerval ival;       /* maintenance interval */
     205: extern struct zoneinfo zones[MAXZONES]; /* zone information */
     206: extern int nzones;          /* number of zones in use */
     207:
     208: #ifdef vax
     209: extern u_short htons(), ntohs();
     210: extern u_long htonl(), ntohl();
     211: #endif

#### Defined struct's

fwdinfo defined in line 154; used 21 times

- in line 84, 155(2)
- in /usr/src/usr.sbin/named/named/db_reload.c line 96-97(4)
- in /usr/src/usr.sbin/named/named/ns_forw.c line 29(2)
- in /usr/src/usr.sbin/named/named/ns_init.c line 422-425(4), 439(4)
- in /usr/src/usr.sbin/named/named/ns_resp.c line 33(2), 140(2)

netinfo defined in line 147; used 60 times

- in line 148(2)
- in /usr/src/usr.sbin/named/named/db_load.c line 836-841(8), 865(4)
- in /usr/src/usr.sbin/named/named/ns_main.c line 111-114(8), 155-158(8), 378(4), 467-468(4)
- in /usr/src/usr.sbin/named/named/ns_req.c line 65(2), 75(2)
- in /usr/src/usr.sbin/named/named/ns_resp.c line 64-65(4)
- in /usr/src/usr.sbin/named/named/ns_sort.c line 33-38(6), 53-57(6), 79(2)

nets defined in line 159; used 2 times

- in line 162(2)

qdatagram defined in line 138; used 18 times

- in line 140-145(4), 201(2)
- in /usr/src/usr.sbin/named/named/ns_main.c line 107-108(4), 344-345(4), 440(4)

qinfo defined in line 75; used 78 times

- in line 86-87(4), 111-113(6)
- in /usr/src/usr.sbin/named/named/ns_forw.c line 27-28(4), 53-55(4), 154(2), 278-281(4), 308-310(4), 335(2), 449(2), 477(2), 487-491(4), 508-513(8), 531-533(4)
- in /usr/src/usr.sbin/named/named/ns_main.c line 163(2)
- in /usr/src/usr.sbin/named/named/ns_req.c line 47(2), 73-74(4)
- in /usr/src/usr.sbin/named/named/ns_resp.c line 38(2), 44(2), 1016-1020(6), 1067(2), 1086(2), 1106-1113(6)

qserv defined in line 88; used 10 times

- in /usr/src/usr.sbin/named/named/ns_forw.c line 158(2), 261-266(4), 452(2)
- in /usr/src/usr.sbin/named/named/ns_resp.c line 46(2)

qstream defined in line 122; used 35 times

- in line 101, 128(2), 136(2)
- in /usr/src/usr.sbin/named/named/ns_forw.c line 51(2)
- in /usr/src/usr.sbin/named/named/ns_main.c line 106(2), 140(2), 152(2), 162(2), 1067-1072(8), 1092-1095(4), 1122(2)
- in /usr/src/usr.sbin/named/named/ns_req.c line 56(2), 1043(2), 1257(2)

stats defined in line 168; used 4 times

- in line 192(2)
- in /usr/src/usr.sbin/named/named/ns_stats.c line 46(2)

zoneinfo defined in line 44; used 32 times

- in line 205(2)
- in /usr/src/usr.sbin/named/named/db_dump.c line 243(2)
- in /usr/src/usr.sbin/named/named/db_load.c line 107(2)
- in /usr/src/usr.sbin/named/named/db_update.c line 29(2)
- in /usr/src/usr.sbin/named/named/ns_init.c line 30(2), 46(2), 297(2), 401(2)
- in /usr/src/usr.sbin/named/named/ns_main.c line 591(2)
- in /usr/src/usr.sbin/named/named/ns_maint.c line 44(2), 113(2), 126(2), 526(2)
- in /usr/src/usr.sbin/named/named/ns_req.c line 623(2), 659(2), 1046(2)

#### Defined macros

ALPHA defined in line 40; used 3 times

- in /usr/src/usr.sbin/named/named/ns_resp.c line 196-197(2), 239

BETA defined in line 41; used 2 times

- in /usr/src/usr.sbin/named/named/ns_resp.c line 236-239(2)

FW_DUP defined in line 118; used 1 times

- in /usr/src/usr.sbin/named/named/ns_forw.c line 84

FW_NOSERVER defined in line 119; used 1 times

- in /usr/src/usr.sbin/named/named/ns_forw.c line 96

FW_OK defined in line 117; used 1 times

- in /usr/src/usr.sbin/named/named/ns_req.c line 334

FW_SERVFAIL defined in line 120; used 1 times

- in /usr/src/usr.sbin/named/named/ns_forw.c line 115

GAMMA defined in line 42; used 1 times

- in /usr/src/usr.sbin/named/named/ns_resp.c line 243

INIT_REFRESH defined in line 37; used 2 times

- in /usr/src/usr.sbin/named/named/ns_init.c line 317-318(2)

MAXCNAMES defined in line 34; used 1 times

- in /usr/src/usr.sbin/named/named/ns_resp.c line 594

MAXQUERIES defined in line 35; used 1 times

- in /usr/src/usr.sbin/named/named/ns_resp.c line 569

MAXRETRY defined in line 33; used 1 times

- in /usr/src/usr.sbin/named/named/ns_forw.c line 362

MAXZONES defined in line 29; used 4 times

- in line 205
- in /usr/src/usr.sbin/named/named/ns_init.c line 30, 125-127(2)

MINROOTS defined in line 30; used 3 times

- in /usr/src/usr.sbin/named/named/db_dump.c line 89, 161
- in /usr/src/usr.sbin/named/named/ns_resp.c line 1242

NSMAX defined in line 31; used 13 times

- in line 58, 94-95(2)
- in /usr/src/usr.sbin/named/named/ns_forw.c line 242
- in /usr/src/usr.sbin/named/named/ns_init.c line 238-239(2)
- in /usr/src/usr.sbin/named/named/ns_req.c line 72, 1141
- in /usr/src/usr.sbin/named/named/ns_resp.c line 49, 206, 384, 1116, 1416

PRIMING_CACHE defined in line 109; used 3 times

- in /usr/src/usr.sbin/named/named/ns_forw.c line 370
- in /usr/src/usr.sbin/named/named/ns_resp.c line 390, 1100

QDATAGRAM_NULL defined in line 144; used 4 times

- in /usr/src/usr.sbin/named/named/ns_main.c line 107, 532, 586, 658

QINFO_NULL defined in line 110; used 10 times

- in /usr/src/usr.sbin/named/named/ns_forw.c line 27-28(2), 70, 320, 327, 473, 497, 548
- in /usr/src/usr.sbin/named/named/ns_resp.c line 1034, 1168

QSTREAM_NULL defined in line 135; used 14 times

- in /usr/src/usr.sbin/named/named/ns_main.c line 106, 152, 687, 700-701(2), 715, 727, 755, 1079, 1124
- in /usr/src/usr.sbin/named/named/ns_req.c line 163, 558
- in /usr/src/usr.sbin/named/named/ns_resp.c line 1029, 1045

Q_NEXTADDR defined in line 105; used 12 times

- in /usr/src/usr.sbin/named/named/ns_forw.c line 124-125(2), 132, 416-417(2), 425
- in /usr/src/usr.sbin/named/named/ns_resp.c line 628-629(2), 636, 1196-1197(2), 1204

RETRYBASE defined in line 32; used 2 times

- in /usr/src/usr.sbin/named/named/ns_forw.c line 437, 459

S_BADRESPONSES defined in line 188; used 1 times

- in /usr/src/usr.sbin/named/named/ns_resp.c line 110

S_CHECKNS defined in line 187; used 1 times

- in /usr/src/usr.sbin/named/named/ns_resp.c line 1286

S_DUPQUERIES defined in line 179; used 1 times

- in /usr/src/usr.sbin/named/named/ns_forw.c line 82

S_DUPRESP defined in line 181; used 1 times

- in /usr/src/usr.sbin/named/named/ns_resp.c line 79

S_INPKTS defined in line 174; used 1 times

- in /usr/src/usr.sbin/named/named/ns_main.c line 672

S_IQUERIES defined in line 178; used 1 times

- in /usr/src/usr.sbin/named/named/ns_req.c line 367

S_MARTIANS defined in line 189; used 1 times

- in /usr/src/usr.sbin/named/named/ns_resp.c line 154

S_NSTATS defined in line 190; used 3 times

- in line 192
- in /usr/src/usr.sbin/named/named/ns_stats.c line 46, 119

S_OUTPKTS defined in line 175; used 6 times

- in /usr/src/usr.sbin/named/named/ns_forw.c line 140, 434
- in /usr/src/usr.sbin/named/named/ns_req.c line 567
- in /usr/src/usr.sbin/named/named/ns_resp.c line 644, 1055, 1212

S_PRIMECACHE defined in line 186; used 1 times

- in /usr/src/usr.sbin/named/named/ns_resp.c line 1093

S_QUERIES defined in line 177; used 1 times

- in /usr/src/usr.sbin/named/named/ns_req.c line 105

S_RESPFAIL defined in line 183; used 2 times

- in /usr/src/usr.sbin/named/named/ns_req.c line 536
- in /usr/src/usr.sbin/named/named/ns_resp.c line 699

S_RESPFORMERR defined in line 184; used 2 times

- in /usr/src/usr.sbin/named/named/ns_req.c line 533
- in /usr/src/usr.sbin/named/named/ns_resp.c line 662

S_RESPOK defined in line 182; used 3 times

- in /usr/src/usr.sbin/named/named/ns_req.c line 530
- in /usr/src/usr.sbin/named/named/ns_resp.c line 668, 681

S_RESPONSES defined in line 180; used 1 times

- in /usr/src/usr.sbin/named/named/ns_resp.c line 70

S_SYSQUERIES defined in line 185; used 1 times

- in /usr/src/usr.sbin/named/named/ns_resp.c line 1126

Z_CACHE defined in line 70; used 9 times

- in /usr/src/usr.sbin/named/named/db_load.c line 142, 222, 463
- in /usr/src/usr.sbin/named/named/db_update.c line 93
- in /usr/src/usr.sbin/named/named/ns_init.c line 79, 85, 131
- in /usr/src/usr.sbin/named/named/ns_maint.c line 72
- in /usr/src/usr.sbin/named/named/ns_req.c line 673

Z_PRIMARY defined in line 68; used 3 times

- in /usr/src/usr.sbin/named/named/ns_init.c line 89
- in /usr/src/usr.sbin/named/named/ns_maint.c line 81
- in /usr/src/usr.sbin/named/named/ns_req.c line 1094

Z_SECONDARY defined in line 69; used 5 times

- in /usr/src/usr.sbin/named/named/db_load.c line 134
- in /usr/src/usr.sbin/named/named/ns_init.c line 91
- in /usr/src/usr.sbin/named/named/ns_maint.c line 74
- in /usr/src/usr.sbin/named/named/ns_req.c line 685, 1094

#### Usage of this include

ns.h used 12 times

- in /usr/src/usr.sbin/named/named/db_dump.c line 25
- in /usr/src/usr.sbin/named/named/db_load.c line 30
- in /usr/src/usr.sbin/named/named/db_reload.c line 23
- in /usr/src/usr.sbin/named/named/db_update.c line 24
- in /usr/src/usr.sbin/named/named/ns_forw.c line 24
- in /usr/src/usr.sbin/named/named/ns_init.c line 27
- in /usr/src/usr.sbin/named/named/ns_main.c line 48
- in /usr/src/usr.sbin/named/named/ns_maint.c line 29
- in /usr/src/usr.sbin/named/named/ns_req.c line 26
- in /usr/src/usr.sbin/named/named/ns_resp.c line 25
- in /usr/src/usr.sbin/named/named/ns_sort.c line 25
- in /usr/src/usr.sbin/named/named/ns_stats.c line 31

Last modified: 1994-01-11 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1774 |