chiark / gitweb /
Halfway through main implementation bit.
[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   /* FIXME: make sure this is all init'd properly */
27   adns_query back, next;
28   adns_query parent;
29   struct { adns_query head, tail; } children;
30   struct { adns_query back, next; } siblings;
31   adns_rrtype type;
32   adns_answer *answer;
33   size_t ansalloc; ansused;
34   int id, flags, udpretries; /* udpretries==-1 => _f_usevc or too big for UDP */
35   int nextudpserver;
36   unsigned long sentudp, senttcp; /* bitmaps indexed by server */
37   struct timeval timeout;
38   void *context;
39   unsigned char *querymsg;
40   int querylen;
41   char owner[1];
42   /* Possible states:
43    *  Queue   child  id   answer    nextserver  sentudp             senttcp
44    *  tosend  null   >=0  null      any         any                 any
45    *  timew   null   >=0  null      any         at least 1 bit set  any
46    *  childw  set    >=0  partial   any         any                 any
47    *  output  null   -1   set/null  any         any                 any
48    */
49 };
50
51 struct adns__vbuf {
52   size_t used, avail;
53   unsigned char *buf;
54 };
55
56 struct adns__state {
57   /* FIXME: make sure this is all init'd properly */
58   adns_initflags iflags;
59   struct { adns_query head, tail; } tosend, timew, childw, output;
60   int nextid, udpsocket;
61   adns_vbuf rqbuf, tcpsend, tcprecv;
62   int nservers, tcpserver;
63   enum adns__tcpstate { server_disc, server_connecting, server_ok } tcpstate;
64   int tcpsocket;
65   struct timeval tcptimeout;
66   struct server {
67     struct in_addr addr;
68   } servers[MAXSERVERS];
69 };
70
71 #endif