chiark / gitweb /
Extra infra.
[adns.git] / src / adns-internal.h
index cabb271604a910dab677262291af26058361b2ad..e3a013254cbc875fb76b012ad5cc76ef76887027 100644 (file)
@@ -3,6 +3,8 @@
 #ifndef ADNS_INTERNAL_H_INCLUDED
 #define ADNS_INTERNAL_H_INCLUDED
 
+#include <sys/time.h>
+
 #include "adns.h"
 
 #define MAXSERVERS 5
@@ -14,24 +16,34 @@ struct adns__query {
   adns_query next, back;
   adns_query parent, child;
   adns_rrtype type;
-  stuct adns_answer *answer;
-  int flags, udpretries, server;
+  adns_answer *answer;
+  int id, flags, udpretries, nextserver;
+  unsigned long sentudp, senttcp; /* bitmaps indexed by server */
   struct timeval timeout;
   void *context;
   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
+   */
 };
 
 struct adns__state {
-  struct { adns_query head, tail } input, timew, childw, output;
-  int udpsocket;
+  adns_initflags iflags;
+  struct { adns_query head, tail; } input, timew, childw, output;
+  int nextid, udpsocket;
   int qbufavail, tcpbufavail, tcpbufused, tcpbufdone;
   char *qbuf, *tcpbuf;
   int nservers;
-  struct {
+  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;
+    struct { adns_query head, tail; } connw;
   } servers[MAXSERVERS];
 };