X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=adns.git;a=blobdiff_plain;f=src%2Fadns-internal.h;h=08a29488ab6c638fe8a7b078b6404b8794dbe2c7;hp=f4fe829c7368505f37dca783c11aaa9dc310b14c;hb=c6bc229718c914227b46c18bd8511abaf9cd0135;hpb=350d37d91f274691a71c2d41854773a2f832cf07 diff --git a/src/adns-internal.h b/src/adns-internal.h index f4fe829..08a2948 100644 --- a/src/adns-internal.h +++ b/src/adns-internal.h @@ -8,16 +8,31 @@ #include "adns.h" #define MAXSERVERS 5 -#define MAXUDPRETRIES 10 +#define MAXUDPRETRIES 15 #define UDPRETRYMS 2000 -#define TCPMS 20000 +#define TCPMS 30000 +#define LOCALRESOURCEMS 20 + +union adns__align { + adns_status status; + char *cp; + adns_rrtype type; + int int; + struct in_addr ia; + unsigned long ul; +}; struct adns__query { - adns_query next, back; - adns_query parent, child; + /* FIXME: make sure this is all init'd properly */ + adns_query back, next; + adns_query parent; + struct { adns_query head, tail; } children; + struct { adns_query back, next; } siblings; adns_rrtype type; adns_answer *answer; - int id, flags, udpretries, nextserver; + size_t ansalloc; ansused; + int id, flags, udpretries; /* udpretries==-1 => _f_usevc or too big for UDP */ + int nextudpserver; unsigned long sentudp, senttcp; /* bitmaps indexed by server */ struct timeval timeout; void *context; @@ -25,27 +40,31 @@ struct adns__query { int querylen; char owner[1]; /* Possible states: - * Queue child answer nextserver sentudp senttcp - * input null null 0 all bits zero all bits zero - * timew null null any at least 1 bit set any - * childw set partial any any any - * output null set any any any + * Queue child id answer nextserver sentudp senttcp + * tosend null >=0 null any any any + * timew null >=0 null any at least 1 bit set any + * childw set >=0 partial any any any + * output null -1 set/null any any any */ }; +struct adns__vbuf { + size_t used, avail; + unsigned char *buf; +}; + struct adns__state { + /* FIXME: make sure this is all init'd properly */ adns_initflags iflags; - struct { adns_query head, tail; } input, timew, childw, output; + struct { adns_query head, tail; } tosend, timew, childw, output; int nextid, udpsocket; - int qbufavail, tcpbufavail, tcpbufused, tcpbufdone; - unsigned char *qbuf, *tcpbuf; - int nservers; + adns_vbuf rqbuf, tcpsend, tcprecv; + int nservers, tcpserver; + enum adns__tcpstate { server_disc, server_connecting, server_ok } tcpstate; + int tcpsocket; + struct timeval tcptimeout; struct server { struct in_addr addr; - enum { server_disc, server_connecting, server_ok } state; - int tcpsocket; - struct timeval timeout; - struct { adns_query head, tail; } connw; } servers[MAXSERVERS]; };