nonamed.c File Reference

#include <sys/types.h>
#include <stdio.h>
#include <syslog.h>
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <signal.h>
#include <assert.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/asynchio.h>
#include <net/hton.h>
#include <net/netlib.h>
#include <net/gen/in.h>
#include <net/gen/inet.h>
#include <net/gen/nameser.h>
#include <net/gen/resolv.h>
#include <net/gen/netdb.h>
#include <net/gen/socket.h>
#include <net/gen/tcp.h>
#include <net/gen/tcp_io.h>
#include <net/gen/udp.h>
#include <net/gen/udp_hdr.h>
#include <net/gen/udp_io.h>
#include <net/gen/dhcp.h>
#include <minix/paths.h>

Include dependency graph for nonamed.c:

Go to the source code of this file.

Data Structures

struct  dns
struct  query
struct  job
struct  id2id
struct  udp_dns
struct  data_cl
struct  data_rw

Defines

#define sethostent   _sethostent
#define gethostent   _gethostent
#define endhostent   _endhostent
#define nil   ((void*)0)
#define HTTL   3600L
#define SHORT_TIMEOUT   2
#define MEDIUM_TIMEOUT   4
#define LONG_TIMEOUT   300
#define N_IDS   256
#define N_DATAMAX   (4096*sizeof(char *))
#define N_NAMEDS   8
#define NO_FD   (-1)
#define T_NXD   ((u16_t) -1)
#define DO_TCP   (__minix_vmd || !__minix)
#define arraysize(a)   (sizeof(a) / sizeof((a)[0]))
#define arraylimit(a)   ((a) + arraysize(a))
#define between(a, c, z)   ((unsigned) ((c) - (a)) <= (unsigned) ((z) - (a)))
#define IMMEDIATE   ((time_t) 0)
#define NEVER   ((time_t) ((time_t) -1 < 0 ? LONG_MAX : ULONG_MAX))
#define LOCALHOST   0x7F000001
#define PC(n)   ((void) sizeof(char [sizeof(*(n)) == 1]), (char *) (n))
#define namecpy(n1, n2)   strcpy(PC(n1), PC(n2))
#define namecat(n1, n2)   strcat(PC(n1), PC(n2))
#define namechr(n, c)   ((u8_t *) strchr(PC(n), (c)))
#define namecmp(n1, n2)   strcasecmp(PC(n1), PC(n2))
#define namencmp(n1, n2, len)   strncasecmp(PC(n1), PC(n2), len)
#define dns2oct(dp)   ((u8_t *) (dp))
#define oct2dns(dp)   ((dns_t *) (dp))
#define QF_REFRESH   0x01
#define QU_SHIFT   1
#define query_allocsize(dnssize)   (offsetof(query_t, dns) + (dnssize))
#define query_size(qp)   query_allocsize((qp)->size)
#define ID_IPSELF   HTONL(0)
#define ID_PROBE   HTONS(0)
#define ID_REFRESH   HTONS(1)
#define current_named()   (+named[i_named])
#define searching()   (search_ct > 0)
#define start_searching()   ((void) (search_ct= -1))
#define stop_searching()   ((void) (search_ct= 0))
#define expecting()   (+expect)
#define start_expecting()   ((void) (expect= 1))
#define stop_expecting()   ((void) (expect= 0))
#define dlen   (offsetof(dns_t, data) + 5)
#define ulen   (offsetof(udp_dns_t, dns) + dlen)

Typedefs

typedef dns dns_t
typedef query query_t
typedef int handler_t (void *data, int expired)
typedef job job_t
typedef id2id id2id_t
typedef udp_dns udp_dns_t
typedef data_cl data_cl_t
typedef data_rw data_rw_t

Functions

static void report (const char *label)
static void fatal (const char *label)
static void * allocate (void *mem, size_t size)
static void deallocate (void *mem)
static char * timegmt (time_t t)
static char * nowgmt (void)
static void pack16 (u8_t *buf, u16_t s)
static void pack32 (u8_t *buf, u32_t l)
static u16_t upack16 (u8_t *buf)
static u32_t upack32 (u8_t *buf)
static char * itoa (char *fmt, u32_t i)
static char * classname (unsigned class)
static char * typename (unsigned type)
static int print_qrr (dns_t *dp, size_t size, u8_t *cp0, int q)
static void dns_tell (int indent, dns_t *dp, size_t size)
static u32_t dns_ttl (dns_t *dp, size_t size, u32_t delta)
static query_textract_query (query_t *qp)
static query_tget_query (u8_t *name, unsigned type)
static void insert_query (query_t *qp)
static void put_query (query_t *qp)
static void cache2file (void)
static void file2cache (void)
static void newjob (handler_t *handler, time_t timeout, void *data)
static int execjob (job_t *job, int expired)
static void force_expire (handler_t *handler)
static int nxdomain (u8_t *name)
static u16_t new_id (u16_t in_id, u16_t in_port, ipaddr_t in_ip)
static int old_id (u16_t id, u16_t *out_id, u16_t *out_port, ipaddr_t *out_ip)
static time_t filetime (const char *file)
static void init_config (ipaddr_t ifip)
static int query_hosts (u8_t *qname, unsigned type, dns_t *dp, size_t *pdlen)
static int query_chaos (u8_t *qname, unsigned type, dns_t *dp, size_t *pdlen)
static void cache_reply (dns_t *dp, size_t dlen)
static int job_save_cache (void *data, int expired)
static int compose_reply (dns_t *dp, size_t *pdlen)
static void refresh_cache (void)
static int job_read_udp (void *data, int expired)
static int job_setup_listen (void *data, int expired)
static int job_listen (void *data, int expired)
static void start_relay (int fd, int dn_fd)
static void close_relay (data_rw_t *data_rw)
static int job_setup_connect (void *data, int expired)
static int job_connect (void *data, int expired)
static void tcp_dns_tell (int fd, u8_t *buf)
static int job_read_query (void *data, int expired)
static int job_write_query (void *data, int expired)
static int job_read_reply (void *data, int expired)
static int job_write_reply (void *data, int expired)
static void named_probe (ipaddr_t ip)
static int job_find_named (void *data, int expired)
static int job_expect_named (void *data, int expired)
static void sig_handler (int sig)
static void usage (void)
int main (int argc, char **argv)

Variables

static const char version [] = "2.7"
static char HOSTS [] = _PATH_HOSTS
static char PIDFILE [] = "/usr/run/nonamed.pid"
static char NNCACHE [] = "/usr/adm/nonamed.cache"
static char DHCPCACHE [] = _PATH_DHCPCACHE
static char MAGIC [4] = "NND\2"
static unsigned debug
static time_t now
static u32_t stale
static u32_t httl
static int reinit
static int done
static int single
static int localonly
static query_tmru
static query_tlru
static int q_refresh
static char * encoding []
static size_t n_datamax = N_DATAMAX
static size_t n_data
static job_tqueue
static id2id_t id2id [N_IDS]
static u16_t id_counter
static char * tcp_device
static char * udp_device
static int udp_fd
static asynchio_t asyn
static ipaddr_t my_ip
static u16_t my_port
static u16_t named_port
static ipaddr_t named [N_NAMEDS]
static unsigned n_nameds
static unsigned i_named
static int expect
static int search_ct = -1
static int dirty
static handler_t job_save_cache
static handler_t job_read_udp
static handler_t job_find_named
static handler_t job_expect_named
static handler_t job_setup_listen
static handler_t job_listen
static handler_t job_setup_connect
static handler_t job_connect
static handler_t job_read_query
static handler_t job_write_query
static handler_t job_read_reply
static handler_t job_write_reply


Define Documentation

#define arraylimit a   )     ((a) + arraysize(a))
 

Definition at line 69 of file nonamed.c.

#define arraysize a   )     (sizeof(a) / sizeof((a)[0]))
 

Definition at line 68 of file nonamed.c.

#define between a,
c,
z   )     ((unsigned) ((c) - (a)) <= (unsigned) ((z) - (a)))
 

Definition at line 70 of file nonamed.c.

 
#define current_named  )     (+named[i_named])
 

Definition at line 782 of file nonamed.c.

Referenced by job_find_named(), job_read_udp(), and job_setup_connect().

#define dlen   (offsetof(dns_t, data) + 5)
 

Referenced by compose_reply(), copy(), dump_one_seg(), file2cache(), job_read_query(), job_read_udp(), ListHosts(), main(), named_probe(), pr_rr(), and refresh_cache().

#define dns2oct dp   )     ((u8_t *) (dp))
 

Definition at line 141 of file nonamed.c.

Referenced by cache_reply(), compose_reply(), dns_ttl(), print_qrr(), query_chaos(), and query_hosts().

#define DO_TCP   (__minix_vmd || !__minix)
 

Definition at line 57 of file nonamed.c.

#define endhostent   _endhostent
 

Definition at line 10 of file nonamed.c.

Referenced by init_config(), and sethostent().

 
#define expecting  )     (+expect)
 

Definition at line 786 of file nonamed.c.

Referenced by job_expect_named().

#define gethostent   _gethostent
 

Definition at line 9 of file nonamed.c.

Referenced by init_config().

#define HTTL   3600L
 

Definition at line 46 of file nonamed.c.

Referenced by init_config().

#define ID_IPSELF   HTONL(0)
 

Definition at line 765 of file nonamed.c.

Referenced by job_read_udp(), and named_probe().

#define ID_PROBE   HTONS(0)
 

Definition at line 766 of file nonamed.c.

Referenced by job_read_udp(), and named_probe().

#define ID_REFRESH   HTONS(1)
 

Definition at line 767 of file nonamed.c.

#define IMMEDIATE   ((time_t) 0)
 

Definition at line 73 of file nonamed.c.

Referenced by force_expire(), job_listen(), and main().

#define LOCALHOST   0x7F000001
 

Definition at line 83 of file nonamed.c.

#define LONG_TIMEOUT   300
 

Definition at line 49 of file nonamed.c.

Referenced by cache_reply(), job_find_named(), job_read_query(), job_read_reply(), job_write_query(), job_write_reply(), and start_relay().

#define MEDIUM_TIMEOUT   4
 

Definition at line 48 of file nonamed.c.

#define N_DATAMAX   (4096*sizeof(char *))
 

Definition at line 51 of file nonamed.c.

#define N_IDS   256
 

Definition at line 50 of file nonamed.c.

Referenced by new_id(), and old_id().

#define N_NAMEDS   8
 

Definition at line 52 of file nonamed.c.

Referenced by init_config().

#define namecat n1,
n2   )     strcat(PC(n1), PC(n2))
 

Definition at line 130 of file nonamed.c.

Referenced by query_hosts().

#define namechr n,
c   )     ((u8_t *) strchr(PC(n), (c)))
 

Definition at line 131 of file nonamed.c.

Referenced by nxdomain(), and query_hosts().

#define namecmp n1,
n2   )     strcasecmp(PC(n1), PC(n2))
 

Definition at line 132 of file nonamed.c.

Referenced by init_config(), matchcmp(), query_chaos(), query_hosts(), and sort().

#define namecpy n1,
n2   )     strcpy(PC(n1), PC(n2))
 

Definition at line 129 of file nonamed.c.

Referenced by query_hosts().

#define namencmp n1,
n2,
len   )     strncasecmp(PC(n1), PC(n2), len)
 

Definition at line 133 of file nonamed.c.

Referenced by nxdomain(), and query_hosts().

#define NEVER   ((time_t) ((time_t) -1 < 0 ? LONG_MAX : ULONG_MAX))
 

Definition at line 74 of file nonamed.c.

#define nil   ((void*)0)
 

Definition at line 12 of file nonamed.c.

#define NO_FD   (-1)
 

Definition at line 53 of file nonamed.c.

Referenced by job_connect(), job_setup_connect(), and start_relay().

#define oct2dns dp   )     ((dns_t *) (dp))
 

Definition at line 142 of file nonamed.c.

Referenced by job_read_query(), and tcp_dns_tell().

#define PC n   )     ((void) sizeof(char [sizeof(*(n)) == 1]), (char *) (n))
 

Definition at line 128 of file nonamed.c.

Referenced by aohand(), disbss(), disdata(), distext(), getcap(), getlab(), imhand(), ini_terminal(), ljhand(), lookup(), mahand(), mihand(), mmhand(), mqhand(), mtrans(), objout(), sjhand(), tputs(), tqhand(), and zdump().

#define QF_REFRESH   0x01
 

Definition at line 155 of file nonamed.c.

Referenced by compose_reply(), file2cache(), and refresh_cache().

#define QU_SHIFT   1
 

Definition at line 156 of file nonamed.c.

Referenced by insert_query().

#define query_allocsize dnssize   )     (offsetof(query_t, dns) + (dnssize))
 

Definition at line 159 of file nonamed.c.

Referenced by cache_reply(), and file2cache().

#define query_size qp   )     query_allocsize((qp)->size)
 

Definition at line 160 of file nonamed.c.

Referenced by extract_query(), and insert_query().

 
#define searching  )     (search_ct > 0)
 

Definition at line 783 of file nonamed.c.

Referenced by job_connect(), job_expect_named(), and job_read_udp().

#define sethostent   _sethostent
 

Definition at line 8 of file nonamed.c.

Referenced by init_config(), and query_hosts().

#define SHORT_TIMEOUT   2
 

Definition at line 47 of file nonamed.c.

Referenced by job_find_named(), job_listen(), job_setup_connect(), and job_setup_listen().

 
#define start_expecting  )     ((void) (expect= 1))
 

Definition at line 787 of file nonamed.c.

 
#define start_searching  )     ((void) (search_ct= -1))
 

Definition at line 784 of file nonamed.c.

Referenced by job_connect(), and job_expect_named().

 
#define stop_expecting  )     ((void) (expect= 0))
 

Definition at line 788 of file nonamed.c.

 
#define stop_searching  )     ((void) (search_ct= 0))
 

Definition at line 785 of file nonamed.c.

Referenced by job_read_udp().

#define T_NXD   ((u16_t) -1)
 

Definition at line 54 of file nonamed.c.

#define ulen   (offsetof(udp_dns_t, dns) + dlen)
 

Referenced by job_read_udp(), named_probe(), and refresh_cache().


Typedef Documentation

typedef struct data_cl data_cl_t
 

typedef struct data_rw data_rw_t
 

typedef struct dns dns_t
 

typedef int handler_t(void *data, int expired)
 

Definition at line 627 of file nonamed.c.

typedef struct id2id id2id_t
 

typedef struct job job_t
 

typedef struct query query_t
 

typedef struct udp_dns udp_dns_t
 


Function Documentation

static void* allocate void *  mem,
size_t  size
[static]
 

Definition at line 97 of file nonamed.c.

References fatal(), nil, and realloc().

static void cache2file void   )  [static]
 

Definition at line 521 of file nonamed.c.

References query::age, data, debug, query::dns, dns_tell(), ENOENT, EROFS, errno, query::flags, fopen(), fp, fwrite(), if(), lru, MAGIC, query::more, nil, NNCACHE, now, printf, report(), single, query::size, stale, query::stale, strcat(), strcpy(), query::usage, and usage.

Referenced by job_save_cache().

static void cache_reply dns_t dp,
size_t  dlen
[static]
 

Definition at line 1096 of file nonamed.c.

References query::age, allocate(), C_IN, cp, dns::data, deallocate, debug, dns_hdr::dh_flag1, dns_hdr::dh_qdcount, DHF_RD, DHF_TC, dirty, dn_expand(), query::dns, dns2oct, dns_ttl(), query::flags, get_query(), dns::hdr, HTONS, insert_query(), job_save_cache, query::less, LONG_TIMEOUT, MAXDNAME, memcpy(), query::more, mru, newjob(), nil, now, printf, query_allocsize, r, query::size, query::stale, type, upack16(), query::usage, and usage.

static char* classname unsigned  class  )  [static]
 

Definition at line 232 of file nonamed.c.

References arraysize, C_IN, and itoa().

Referenced by print_qrr().

static void close_relay data_rw_t data_rw  )  [static]
 

Definition at line 1562 of file nonamed.c.

References asyn, asyn_close(), data_rw::buf, close, deallocate, ioctl, nil, NWIOTCPSHUTDOWN, data_rw::r_fd, data_rw::rev, and data_rw::w_fd.

Referenced by job_read_query(), job_read_reply(), job_write_query(), and job_write_reply().

static int compose_reply dns_t dp,
size_t pdlen
[static]
 

Definition at line 1161 of file nonamed.c.

References query::age, C_CHAOS, C_IN, cp, dns::data, dns_hdr::dh_flag1, dns_hdr::dh_flag2, dns_hdr::dh_id, DHF_AA, DHF_QR, DHF_RA, DHF_RCODE, DHF_RD, DHF_TC, DHF_UNUSED, dlen, dn_expand(), query::dns, dns2oct, dns_ttl(), query::flags, FORMERR, get_query(), dns::hdr, HTONS, MAXDNAME, memcpy(), n_nameds, nil, NOERROR, now, NXDOMAIN, nxdomain(), put_query(), q_refresh, QF_REFRESH, query_chaos(), query_hosts(), r, query::size, query::stale, type, upack16(), and query::usage.

Referenced by job_read_query().

static void deallocate void *  mem  )  [static]
 

Definition at line 103 of file nonamed.c.

References free.

static void dns_tell int  indent,
dns_t dp,
size_t  size
[static]
 

Definition at line 336 of file nonamed.c.

References arraysize, count, cp, dns::data, dns_hdr::dh_ancount, dns_hdr::dh_arcount, dns_hdr::dh_flag1, dns_hdr::dh_flag2, dns_hdr::dh_nscount, dns_hdr::dh_qdcount, DHF_AA, DHF_QR, DHF_RA, DHF_RCODE, DHF_RD, DHF_TC, fputc(), dns::hdr, i, itoa(), ntohs, print_qrr(), printf, r, and stdout.

Referenced by cache2file(), file2cache(), job_read_udp(), named_probe(), and tcp_dns_tell().

static u32_t dns_ttl dns_t dp,
size_t  size,
u32_t  delta
[static]
 

Definition at line 381 of file nonamed.c.

References count, cp, dns::data, dns_hdr::dh_ancount, dns_hdr::dh_arcount, dns_hdr::dh_flag2, dns_hdr::dh_nscount, dns_hdr::dh_qdcount, DHF_RCODE, dn_expand(), dns2oct, dns::hdr, htonl, HTONS, i, L, MAXDNAME, ntohl, ntohs, NXDOMAIN, pack32(), r, T_SOA, type, upack16(), and upack32().

Referenced by cache_reply(), compose_reply(), and file2cache().

static int execjob job_t job,
int  expired
[static]
 

Definition at line 658 of file nonamed.c.

References deallocate, job(), and nil.

Referenced by main().

static query_t* extract_query query_t qp  )  [static]
 

Definition at line 445 of file nonamed.c.

References assert, query::less, lru, query::more, mru, nil, and query_size.

Referenced by get_query(), and insert_query().

static void fatal const char *  label  )  [static]
 

Definition at line 90 of file nonamed.c.

References abort(), debug, exit(), fflush(), nil, and report().

static void file2cache void   )  [static]
 

Definition at line 574 of file nonamed.c.

References query::age, allocate(), data, deallocate, debug, dlen, query::dns, dns_tell(), dns_ttl(), ENOENT, err, errno, feof, ferror, query::flags, fopen(), fp, fread(), htonl, htons, MAGIC, memcmp(), nil, NNCACHE, now, ntohs, printf, put_query(), q_refresh, QF_REFRESH, query_allocsize, report(), single, query::size, query::stale, upack16(), upack32(), and query::usage.

Referenced by main().

static time_t filetime const char *  file  )  [static]
 

Definition at line 790 of file nonamed.c.

References st, stat::st_mtime, and stat.

Referenced by init_config(), and unzRepair().

static void force_expire handler_t handler  )  [static]
 

Definition at line 673 of file nonamed.c.

References deallocate, IMMEDIATE, job(), newjob(), nil, job::prev, and queue.

Referenced by job_connect(), job_expect_named(), job_find_named(), and job_read_udp().

static query_t* get_query u8_t name,
unsigned  type
[static]
 

Definition at line 455 of file nonamed.c.

References deallocate, extract_query(), if(), query::less, MAXDNAME, mru, nil, now, r, stale, and query::stale.

Referenced by cache_reply(), and compose_reply().

static void init_config ipaddr_t  ifip  )  [static]
 

Definition at line 798 of file nonamed.c.

References close, d, data, debug, dhcp_gettag(), DHCP_TAG_DNS, DHCPCACHE, endhostent, ENOENT, errno, fatal(), filetime(), gethostent, hostent::h_name, HOSTS, HTONL, HTTL, httl, inet_ntoa(), LOCALHOST, memcpy(), N_NAMEDS, namecmp, nil, nowgmt(), ntohl, ntohs, O_RDONLY, open, printf, r, read, sethostent, single, stale, time_t, and version.

Referenced by job_read_udp(), and main().

static void insert_query query_t qp  )  [static]
 

Definition at line 480 of file nonamed.c.

References deallocate, debug, extract_query(), query::less, lru, query::more, mru, n, nil, now, printf, QU_SHIFT, query_size, sbrk, stale, query::stale, and query::usage.

Referenced by cache_reply(), and put_query().

static char* itoa char *  fmt,
u32_t  i
[static]
 

Definition at line 224 of file nonamed.c.

References sprintf().

static int job_connect void *  data,
int  expired
[static]
 

Definition at line 1624 of file nonamed.c.

References asyn, asyn_close(), asyn_ioctl(), close, deallocate, debug, data_cl::dn_fd, EINPROGRESS, EIO, errno, fatal(), data_cl::fd, force_expire(), job_find_named, job_setup_connect, NEVER, newjob(), NO_FD, nowgmt(), NWIOTCPCONN, printf, data_cl::retry, searching, start_relay(), start_searching, strerror(), tcp_device, and data_cl::tcpcl.

static int job_expect_named void *  data,
int  expired
[static]
 

Definition at line 1975 of file nonamed.c.

References debug, expecting, force_expire(), job_find_named, nowgmt(), printf, searching, and start_searching.

static int job_find_named void *  data,
int  expired
[static]
 

Definition at line 1944 of file nonamed.c.

References current_named, debug, force_expire(), i_named, job_find_named, job_setup_connect, LONG_TIMEOUT, n_nameds, named_probe(), NEVER, newjob(), nil, now, nowgmt(), printf, search_ct, SHORT_TIMEOUT, and stale.

static int job_listen void *  data,
int  expired
[static]
 

Definition at line 1506 of file nonamed.c.

References asyn, asyn_ioctl(), debug, EINPROGRESS, errno, data_cl::fd, IMMEDIATE, job_setup_connect, job_setup_listen, newjob(), nil, now, nowgmt(), NWIOTCPLISTEN, printf, report(), data_cl::retry, SHORT_TIMEOUT, tcp_device, and data_cl::tcpcl.

static int job_read_query void *  data,
int  expired
[static]
 

Definition at line 1672 of file nonamed.c.

References allocate(), asyn, asyn_read(), data_rw::buf, close_relay(), compose_reply(), count, debug, dlen, EINPROGRESS, EIO, errno, fatal(), htons, job_read_query, job_write_query, job_write_reply, LONG_TIMEOUT, newjob(), now, nowgmt(), ntohs, oct2dns, data_rw::offset, pack16(), PACKETSZ, printf, data_rw::r_fd, data_rw::size, strerror(), tcp_device, tcp_dns_tell(), upack16(), and data_rw::w_fd.

static int job_read_reply void *  data,
int  expired
[static]
 

Definition at line 1801 of file nonamed.c.

References allocate(), asyn, asyn_read(), data_rw::buf, close_relay(), count, debug, EINPROGRESS, EIO, errno, fatal(), job_read_reply, job_write_reply, LONG_TIMEOUT, newjob(), now, nowgmt(), ntohs, data_rw::offset, printf, data_rw::r_fd, data_rw::size, strerror(), tcp_device, tcp_dns_tell(), and upack16().

static int job_read_udp void *  data,
int  expired
[static]
 

Definition at line 1318 of file nonamed.c.

References assert, asyn, asyn_read(), current_named, debug, DHF_QR, dlen, dns_tell(), EINPROGRESS, EIO, errno, fatal(), force_expire(), i, i_named, ID_IPSELF, ID_PROBE, if(), inet_ntoa(), init_config(), job_find_named, job_read_udp, n_nameds, named, NEVER, newjob(), nil, nowgmt(), ntohs, offsetof, old_id(), printf, searching, stop_searching, strerror(), time_t, udp_device, and ulen.

static int job_save_cache void *  data,
int  expired
[static]
 

Definition at line 1153 of file nonamed.c.

References cache2file(), and dirty.

static int job_setup_connect void *  data,
int  expired
[static]
 

Definition at line 1582 of file nonamed.c.

References current_named, deallocate, debug, data_cl::dn_fd, EMFILE, errno, fatal(), data_cl::fd, ioctl, job_connect, job_setup_connect, n_nameds, named_port, NEVER, newjob(), NO_FD, now, nowgmt(), NWIOSTCPCONF, nwio_tcpconf::nwtc_flags, NWTC_LP_SEL, nwio_tcpconf::nwtc_remaddr, nwio_tcpconf::nwtc_remport, NWTC_SET_RA, NWTC_SET_RP, nwio_tcpcl::nwtcl_flags, O_RDWR, open, printf, report(), data_cl::retry, SHORT_TIMEOUT, start_relay(), tcp_device, and data_cl::tcpcl.

static int job_setup_listen void *  data,
int  expired
[static]
 

Definition at line 1471 of file nonamed.c.

References allocate(), debug, EMFILE, errno, fatal(), ioctl, job_listen, job_setup_listen, my_port, NEVER, newjob(), nil, now, nowgmt(), NWIOSTCPCONF, NWIOSTCPOPT, nwio_tcpconf::nwtc_flags, nwio_tcpconf::nwtc_locport, NWTC_LP_SET, NWTC_SHARED, NWTC_UNSET_RA, NWTC_UNSET_RP, NWTO_DEL_RST, nwio_tcpopt::nwto_flags, O_RDWR, open, printf, report(), SHORT_TIMEOUT, and tcp_device.

static int job_write_query void *  data,
int  expired
[static]
 

Definition at line 1759 of file nonamed.c.

References asyn, asyn_write(), data_rw::buf, close_relay(), count, debug, EINPROGRESS, EIO, errno, fatal(), job_read_query, job_write_query, LONG_TIMEOUT, newjob(), now, nowgmt(), data_rw::offset, printf, data_rw::size, strerror(), tcp_device, tcp_dns_tell(), and data_rw::w_fd.

static int job_write_reply void *  data,
int  expired
[static]
 

Definition at line 1856 of file nonamed.c.

References asyn, asyn_write(), data_rw::buf, close_relay(), count, debug, EINPROGRESS, EIO, errno, fatal(), job_read_query, job_read_reply, job_write_reply, LONG_TIMEOUT, newjob(), now, nowgmt(), data_rw::offset, printf, data_rw::r_fd, data_rw::size, strerror(), tcp_device, tcp_dns_tell(), and data_rw::w_fd.

int main int  argc,
char **  argv
 

Definition at line 2007 of file nonamed.c.

References _IOLBF, assert, between, debug, done, execjob(), exit(), fatal(), fclose(), file2cache(), fopen(), fp, fprintf(), getenv(), getpid, getservbyname(), htons, i, if(), IMMEDIATE, init_config(), ioctl, job(), job_find_named, job_read_udp, job_setup_listen, localonly, LOG_DAEMON, LOG_PID, my_port, named_port, NEVER, newjob(), nil, now, nowgmt(), NWIOGUDPOPT, NWIOSUDPOPT, NWUO_DI_BROAD, NWUO_DI_IPOPT, NWUO_EN_LOC, NWUO_EXCL, nwio_udpopt::nwuo_flags, nwio_udpopt::nwuo_locaddr, nwio_udpopt::nwuo_locport, NWUO_LP_SET, NWUO_RA_ANY, NWUO_RP_ANY, NWUO_RWDATALL, O_RDWR, open, openlog(), PIDFILE, printf, queue, quit, servent::s_port, setvbuf(), sig_handler(), SIG_IGN, sigaction, sigemptyset, SIGHUP, SIGINT, SIGPIPE, SIGTERM, SIGUSR1, SIGUSR2, single, stderr, stdout, strtoul(), TCP_DEVICE, tcp_device, time, timegmt(), job::timeout, UDP_DEVICE, udp_device, and usage.

static void named_probe ipaddr_t  ip  )  [static]
 

Definition at line 1908 of file nonamed.c.

References C_IN, dns::data, debug, dns_hdr::dh_ancount, dns_hdr::dh_arcount, dns_hdr::dh_flag1, dns_hdr::dh_flag2, dns_hdr::dh_id, dns_hdr::dh_nscount, dns_hdr::dh_qdcount, dlen, udp_dns::dns, dns_tell(), fatal(), udp_dns::hdr, dns::hdr, HTONS, ID_IPSELF, ID_PROBE, inet_ntoa(), my_port, named_port, new_id(), pack16(), printf, T_NS, udp_device, udp_io_hdr::uih_data_len, udp_io_hdr::uih_dst_addr, udp_io_hdr::uih_dst_port, udp_io_hdr::uih_ip_opt_len, ulen, and write.

Referenced by job_find_named().

static u16_t new_id u16_t  in_id,
u16_t  in_port,
ipaddr_t  in_ip
[static]
 

Definition at line 724 of file nonamed.c.

References htons, id2id::id, id2id, id2id::ip, N_IDS, and id2id::port.

Referenced by insert_id_rec(), and named_probe().

static void newjob handler_t handler,
time_t  timeout,
void *  data
[static]
 

Definition at line 639 of file nonamed.c.

References allocate(), job(), job::next, nil, job::prev, and queue.

Referenced by cache_reply(), force_expire(), job(), job_connect(), job_find_named(), job_listen(), job_read_query(), job_read_reply(), job_read_udp(), job_setup_connect(), job_setup_listen(), job_write_query(), job_write_reply(), main(), and start_relay().

static char* nowgmt void   )  [static]
 

Definition at line 123 of file nonamed.c.

References now, and timegmt().

Referenced by init_config(), job_connect(), job_expect_named(), job_find_named(), job_listen(), job_read_query(), job_read_reply(), job_read_udp(), job_setup_connect(), job_setup_listen(), job_write_query(), job_write_reply(), and main().

static int nxdomain u8_t name  )  [static]
 

Definition at line 690 of file nonamed.c.

References n, namechr, namencmp, p, and top.

Referenced by compose_reply().

static int old_id u16_t  id,
u16_t out_id,
u16_t out_port,
ipaddr_t out_ip
[static]
 

Definition at line 740 of file nonamed.c.

References id2id::id, id2id, id2id::ip, N_IDS, ntohs, and id2id::port.

Referenced by job_read_udp().

static void pack16 u8_t buf,
u16_t  s
[static]
 

Definition at line 165 of file nonamed.c.

Referenced by job_read_query(), named_probe(), query_chaos(), and query_hosts().

static void pack32 u8_t buf,
u32_t  l
[static]
 

Definition at line 172 of file nonamed.c.

Referenced by dns_ttl(), query_chaos(), and query_hosts().

static int print_qrr dns_t dp,
size_t  size,
u8_t cp0,
int  q
[static]
 

Definition at line 256 of file nonamed.c.

References arraysize, classname(), cp, dn_expand(), dns2oct, encoding, ep, inet_ntoa(), MAXDNAME, ntohl, ntohs, printf, r, type, upack16(), and upack32().

Referenced by dns_tell().

static void put_query query_t qp  )  [static]
 

Definition at line 513 of file nonamed.c.

References insert_query(), query::less, query::more, mru, and nil.

Referenced by compose_reply(), and file2cache().

static int query_chaos u8_t qname,
unsigned  type,
dns_t dp,
size_t pdlen
[static]
 

Definition at line 1028 of file nonamed.c.

References arraylimit, arraysize, C_CHAOS, C_IN, cp, dns::data, dns_hdr::dh_ancount, dns_hdr::dh_arcount, dns_hdr::dh_flag1, dns_hdr::dh_flag2, dns_hdr::dh_nscount, dns_hdr::dh_qdcount, DHF_AA, DHF_QR, DHF_RA, dn_comp(), dns2oct, dns::hdr, HTONL, htons, HTONS, i, i_named, inet_ntoa(), memcpy(), my_ip, my_port, n, n_nameds, namecmp, named, nil, ntohs, pack16(), pack32(), r, sprintf(), strlen(), T_A, T_TXT, and version.

Referenced by compose_reply().

static int query_hosts u8_t qname,
unsigned  type,
dns_t dp,
size_t pdlen
[static]
 

Definition at line 880 of file nonamed.c.

References arraylimit, arraysize, C_IN, cp, dns::data, dns_hdr::dh_arcount, dns_hdr::dh_flag1, dns_hdr::dh_flag2, dns_hdr::dh_nscount, dns_hdr::dh_qdcount, DHF_AA, DHF_QR, DHF_RA, dn_comp(), dns2oct, hostent::h_addr_list, hostent::h_aliases, hostent::h_name, dns::hdr, HTONL, htons, HTONS, httl, i, if(), LOCALHOST, MAXDNAME, memcpy(), namecat, namechr, namecmp, namecpy, namencmp, nil, pack16(), pack32(), r, sethostent, single, sprintf(), T_A, T_CNAME, and T_PTR.

Referenced by compose_reply().

static void refresh_cache void   )  [static]
 

Definition at line 1254 of file nonamed.c.

References cp, dlen, query::flags, lru, MAXDNAME, query::more, nil, now, q_refresh, QF_REFRESH, r, stale, query::stale, type, and ulen.

static void report const char *  label  )  [static]
 

Definition at line 85 of file nonamed.c.

References errno, fprintf(), stderr, and strerror().

static void sig_handler int  sig  )  [static]
 

Definition at line 1989 of file nonamed.c.

References debug, done, reinit, SIGHUP, SIGINT, SIGTERM, SIGUSR1, and SIGUSR2.

static void start_relay int  fd,
int  dn_fd
[static]
 

Definition at line 1531 of file nonamed.c.

References allocate(), job_read_query, job_read_reply, LONG_TIMEOUT, newjob(), nil, NO_FD, now, query(), and reply.

Referenced by job_connect(), and job_setup_connect().

static void tcp_dns_tell int  fd,
u8_t buf
[static]
 

Definition at line 1658 of file nonamed.c.

References dns_tell(), inet_ntoa(), ioctl, ntohs, NWIOGTCPCONF, nwio_tcpconf::nwtc_remaddr, nwio_tcpconf::nwtc_remport, oct2dns, printf, and upack16().

Referenced by job_read_query(), job_read_reply(), job_write_query(), and job_write_reply().

static char* timegmt time_t  t  )  [static]
 

Definition at line 108 of file nonamed.c.

References asctime(), m, s, and sprintf().

Referenced by main(), and nowgmt().

static char* typename unsigned  type  )  [static]
 

Definition at line 241 of file nonamed.c.

static u16_t upack16 u8_t buf  )  [static]
 

Definition at line 181 of file nonamed.c.

References s.

Referenced by cache_reply(), compose_reply(), dns_ttl(), file2cache(), job_read_query(), job_read_reply(), print_qrr(), and tcp_dns_tell().

static u32_t upack32 u8_t buf  )  [static]
 

Definition at line 191 of file nonamed.c.

Referenced by dns_ttl(), file2cache(), and print_qrr().

static void usage void   )  [static]
 

Definition at line 2001 of file nonamed.c.

References exit(), fprintf(), and stderr.


Variable Documentation

asynchio_t asyn [static]
 

Definition at line 771 of file nonamed.c.

unsigned debug [static]
 

Definition at line 76 of file nonamed.c.

char DHCPCACHE[] = _PATH_DHCPCACHE [static]
 

Definition at line 63 of file nonamed.c.

int dirty [static]
 

Definition at line 780 of file nonamed.c.

int done [static]
 

Definition at line 80 of file nonamed.c.

char* encoding[] [static]
 

Initial value:

 {
        "c*",           
        "i",            
        "d",            
        "d",            
        "d",            
        "d",            
        "ddlllll",      
        "d",            
        "d",            
        "d",            
        "c*",           
        "icc*",         
        "d",            
        "ss",           
        "dd",           
        "hd",           
        "s*",           
}

Definition at line 204 of file nonamed.c.

Referenced by print_qrr().

int expect [static]
 

Definition at line 778 of file nonamed.c.

char HOSTS[] = _PATH_HOSTS [static]
 

Definition at line 60 of file nonamed.c.

Referenced by init_config().

u32_t httl [static]
 

Definition at line 79 of file nonamed.c.

Referenced by init_config(), and query_hosts().

unsigned i_named [static]
 

Definition at line 777 of file nonamed.c.

Referenced by job_find_named(), job_read_udp(), and query_chaos().

id2id_t id2id[N_IDS] [static]
 

Definition at line 721 of file nonamed.c.

Referenced by new_id(), and old_id().

u16_t id_counter [static]
 

Definition at line 722 of file nonamed.c.

handler_t job_connect [static]
 

Definition at line 875 of file nonamed.c.

Referenced by job_setup_connect().

handler_t job_expect_named [static]
 

Definition at line 873 of file nonamed.c.

handler_t job_find_named [static]
 

Definition at line 873 of file nonamed.c.

Referenced by job_connect(), job_expect_named(), job_find_named(), job_read_udp(), and main().

handler_t job_listen [static]
 

Definition at line 875 of file nonamed.c.

Referenced by job_setup_listen().

handler_t job_read_query [static]
 

Definition at line 876 of file nonamed.c.

Referenced by job_read_query(), job_write_query(), job_write_reply(), and start_relay().

handler_t job_read_reply [static]
 

Definition at line 877 of file nonamed.c.

Referenced by job_read_reply(), job_write_reply(), and start_relay().

handler_t job_read_udp [static]
 

Definition at line 873 of file nonamed.c.

Referenced by job_read_udp(), and main().

handler_t job_save_cache [static]
 

Definition at line 873 of file nonamed.c.

Referenced by cache_reply().

handler_t job_setup_connect [static]
 

Definition at line 875 of file nonamed.c.

Referenced by job_connect(), job_find_named(), job_listen(), and job_setup_connect().

handler_t job_setup_listen [static]
 

Definition at line 875 of file nonamed.c.

Referenced by job_listen(), job_setup_listen(), and main().

handler_t job_write_query [static]
 

Definition at line 876 of file nonamed.c.

Referenced by job_read_query(), and job_write_query().

handler_t job_write_reply [static]
 

Definition at line 877 of file nonamed.c.

Referenced by job_read_query(), job_read_reply(), and job_write_reply().

int localonly [static]
 

Definition at line 82 of file nonamed.c.

Referenced by main().

query_t * lru [static]
 

Definition at line 162 of file nonamed.c.

Referenced by cache2file(), extract_query(), insert_query(), and refresh_cache().

char MAGIC[4] = "NND\2" [static]
 

Definition at line 66 of file nonamed.c.

query_t* mru [static]
 

Definition at line 162 of file nonamed.c.

Referenced by cache_reply(), extract_query(), get_query(), insert_query(), and put_query().

ipaddr_t my_ip [static]
 

Definition at line 772 of file nonamed.c.

Referenced by query_chaos().

u16_t my_port [static]
 

Definition at line 773 of file nonamed.c.

Referenced by job_setup_listen(), main(), named_probe(), and query_chaos().

size_t n_data [static]
 

Definition at line 443 of file nonamed.c.

size_t n_datamax = N_DATAMAX [static]
 

Definition at line 442 of file nonamed.c.

unsigned n_nameds [static]
 

Definition at line 776 of file nonamed.c.

Referenced by compose_reply(), job_find_named(), job_read_udp(), job_setup_connect(), and query_chaos().

ipaddr_t named[N_NAMEDS] [static]
 

Definition at line 775 of file nonamed.c.

u16_t named_port [static]
 

Definition at line 773 of file nonamed.c.

Referenced by job_setup_connect(), main(), and named_probe().

char NNCACHE[] = "/usr/adm/nonamed.cache" [static]
 

Definition at line 62 of file nonamed.c.

Referenced by cache2file(), and file2cache().

time_t now [static]
 

Definition at line 77 of file nonamed.c.

char PIDFILE[] = "/usr/run/nonamed.pid" [static]
 

Definition at line 61 of file nonamed.c.

int q_refresh [static]
 

Definition at line 163 of file nonamed.c.

Referenced by compose_reply(), file2cache(), and refresh_cache().

job_t* queue [static]
 

Definition at line 637 of file nonamed.c.

Referenced by force_expire(), main(), newjob(), ns_interrupt(), and ns_send().

int reinit [static]
 

Definition at line 80 of file nonamed.c.

Referenced by sig_handler().

int search_ct = -1 [static]
 

Definition at line 779 of file nonamed.c.

Referenced by job_find_named().

int single [static]
 

Definition at line 81 of file nonamed.c.

Referenced by cache2file(), exstring(), file2cache(), init_config(), main(), query_hosts(), and write_map().

u32_t stale [static]
 

Definition at line 78 of file nonamed.c.

Referenced by cache2file(), get_query(), init_config(), insert_query(), job_find_named(), and refresh_cache().

char* tcp_device [static]
 

Definition at line 769 of file nonamed.c.

Referenced by connect(), daemonloop(), DataConnect(), DOdata(), DOopen(), doPASV(), job_connect(), job_listen(), job_read_query(), job_read_reply(), job_setup_connect(), job_setup_listen(), job_write_query(), job_write_reply(), listen(), main(), netfinger(), NetInit(), NETinit(), rcmd(), and tcp_connect().

char * udp_device [static]
 

Definition at line 769 of file nonamed.c.

int udp_fd [static]
 

Definition at line 770 of file nonamed.c.

Referenced by is_unused_port(), print_fd(), udp_buffree(), udp_cancel(), udp_close(), udp_get_data(), udp_init(), udp_ioctl(), udp_ip_arrived(), udp_main(), udp_read(), udp_restart_write_port(), udp_select(), and udp_write().

const char version[] = "2.7" [static]
 

Definition at line 5 of file nonamed.c.


Generated on Fri Apr 14 23:07:04 2006 for minix by  doxygen 1.4.6