chiark / gitweb /
7caba2f6d9db024cbe701c3b279a6b522f4c32f7
[adns.git] / src / adns-internal.h
1 /**/
2
3 #ifndef ADNS_INTERNAL_H_INCLUDED
4 #define ADNS_INTERNAL_H_INCLUDED
5
6 #include <sys/time.h>
7
8 #include "adns.h"
9
10 #define MAXSERVERS 5
11 #define MAXUDPRETRIES 15
12 #define UDPRETRYMS 2000
13 #define TCPMS 30000
14 #define LOCALRESOURCEMS 20
15
16 union adns__align {
17   adns_status status;
18   char *cp;
19   adns_rrtype type;
20   int int;
21   struct in_addr ia;
22   unsigned long ul;
23 };
24
25 struct adns__query {
26   adns_query back, next;
27   adns_query parent;
28   struct { adns_query head, tail; } children;
29   struct { adns_query back, next; } siblings;
30   adns_rrtype type;
31   adns_answer *answer;
32   size_t ansalloc; ansused;
33   int id, flags, udpretries; /* udpretries==-1 => _f_usevc or too big for UDP */
34   int nextudpserver;
35   unsigned long sentudp, senttcp; /* bitmaps indexed by server */
36   struct timeval timeout;
37   void *context;
38   unsigned char *querymsg;
39   int querylen;
40   char owner[1];
41   /* Possible states:
42    *  Queue   child  id   answer    nextserver  sentudp             senttcp
43    *  tosend  null   >=0  null      any         any                 any
44    *  timew   null   >=0  null      any         at least 1 bit set  any
45    *  childw  set    >=0  partial   any         any                 any
46    *  output  null   -1   set/null  any         any                 any
47    */
48 };
49
50 struct adns__state {
51   adns_initflags iflags;
52   struct { adns_query head, tail; } tosend, timew, childw, output;
53   int nextid, udpsocket;
54   int qbufavail, tcpbufavail, tcpbufused, tcpbufdone;
55   unsigned char *qbuf, *tcpbuf;
56   int nservers, tcpserver;
57   enum { server_disc, server_connecting, server_ok } tcpstate;
58   int tcpsocket;
59   struct timeval tcptimeout;
60   int opbufavail, opbufused;
61   unsigned char *opbuf;
62   struct server {
63     struct in_addr addr;
64   } servers[MAXSERVERS];
65 };
66
67 #endif