3 #ifndef ADNS_INTERNAL_H_INCLUDED
4 #define ADNS_INTERNAL_H_INCLUDED
10 /* Configuration and constants */
13 #define MAXUDPRETRIES 15
14 #define UDPRETRYMS 2000
16 #define LOCALRESOURCEMS 20
18 /* Shared data structures */
30 /* FIXME: make sure this is all init'd properly */
31 adns_query back, next;
33 struct { adns_query head, tail; } children;
34 struct { adns_query back, next; } siblings;
37 size_t ansalloc; ansused;
38 int id, flags, udpretries; /* udpretries==-1 => _f_usevc or too big for UDP */
40 unsigned long sentudp, senttcp; /* bitmaps indexed by server */
41 struct timeval timeout;
43 unsigned char *querymsg;
47 * Queue child id answer nextserver sentudp senttcp
48 * tosend null >=0 null any any any
49 * timew null >=0 null any at least 1 bit set any
50 * childw set >=0 partial any any any
51 * output null -1 set/null any any any
61 /* FIXME: make sure this is all init'd properly */
62 adns_initflags iflags;
63 struct { adns_query head, tail; } tosend, timew, childw, output;
64 int nextid, udpsocket;
65 adns_vbuf rqbuf, tcpsend, tcprecv;
66 int nservers, tcpserver;
67 enum adns__tcpstate { server_disc, server_connecting, server_ok } tcpstate;
69 struct timeval tcptimeout;
72 } servers[MAXSERVERS];
77 void adns__debug(adns_state ads, const char *fmt, ...) PRINTFFORMAT(2,3);
78 void adns__diag(adns_state ads, const char *fmt, ...) PRINTFFORMAT(2,3);
82 void adns__query_fail(adns_state ads, adns_query qu, adns_status stat);
86 void adns__quproc_tosend(adns_state ads, adns_query qu, struct timeval now) {
88 /* Useful static inline functions: */
90 static inline void timevaladd(struct timeval *tv_io, long ms) {
94 tmp.tv_usec += (ms%1000)*1000;
95 tmp.tv_sec += ms/1000;
96 if (tmp.tv_usec >= 1000) { tmp.tv_sec++; tmp.tv_usec -= 1000; }
102 #define LIST_UNLINK_PART(list,node,part) \
104 if ((node)->back) (node)->back->part next= (node)->part next; \
105 else (list).head= (node)->part next; \
106 if ((node)->next) (node)->next->part back= (node)->part back; \
107 else (list).tail= (node)->part back; \
110 #define LIST_LINK_TAIL_PART(list,node,part) \
112 (node)->part back= 0; \
113 (node)->part next= (list).tail; \
114 if ((list).tail) (list).tail->part back= (node); else (list).part head= (node); \
115 (list).tail= (node); \
118 #define LIST_UNLINK(list,node) LIST_UNLINK_PART(list,node,)
119 #define LIST_LINK_TAIL_PART(list,node) LIST_LINK_TAIL(list,node,)