chiark / gitweb /
Finished CNAME handling. Except that there's no testing, and it
[adns] / src / internal.h
index 2c5a073a7ea124ca4bfe02127f951be432807785..40da52d5bda5ffd05343b8e24a6780969d6cda3c 100644 (file)
@@ -42,6 +42,7 @@ typedef unsigned char byte;
 
 #include <sys/time.h>
 
+#define ADNS_FEATURE_MANYAF
 #include "adns.h"
 #include "dlist.h"
 
@@ -91,6 +92,13 @@ typedef enum {
   rcode_refused
 } dns_rcode;
 
+enum {
+  adns__qf_senddirect = 0x00100000,/* don't call the `query_send' type hook */
+  adns__qf_nosend     = 0x00200000,/* don't send the query when submitting */
+  adns__qf_addr_answer= 0x01000000,/* addr query received an answer */
+  adns__qf_addr_cname = 0x02000000 /* addr subquery performed on cname */
+};
+
 /* Shared data structures */
 
 typedef union {
@@ -128,7 +136,7 @@ typedef struct {
   int nrevcomp;
   int revcompwd;
   adns_rrtype rrtype;
-  void *(*sockaddr_to_inaddr)(struct sockaddr *sa);
+  const void *(*sockaddr_to_inaddr)(const struct sockaddr *sa);
   int (*sockaddr_equalp)(const struct sockaddr *sa,
                         const struct sockaddr *sb);
   void (*prefix_mask)(int len, union gen_addr *a);
@@ -194,6 +202,12 @@ typedef struct typeinfo {
    * them.  (This is really for the benefit of SRV's bizarre weighting
    * stuff.)  May be 0 to mean nothing needs to be done.
    */
+
+  void (*query_send)(adns_query qu, struct timeval now);
+  /* Send the query to nameservers, and hook it into the appropriate queue.
+   * Normal behaviour is to call adns__query_send, but this can be overridden
+   * for special effects.
+   */
 } typeinfo;
 
 adns_status adns__qdpl_normal(adns_state ads,
@@ -206,6 +220,7 @@ adns_status adns__qdpl_normal(adns_state ads,
 
 typedef struct allocnode {
   struct allocnode *next, *back;
+  size_t sz;
 } allocnode;
 
 union maxalign {
@@ -473,8 +488,8 @@ void adns__query_send(adns_query qu, struct timeval now);
 /* From query.c: */
 
 adns_status adns__internal_submit(adns_state ads, adns_query *query_r,
-                                 const typeinfo *typei, vbuf *qumsg_vb,
-                                 int id,
+                                 const typeinfo *typei, adns_rrtype,
+                                 vbuf *qumsg_vb, int id,
                                  adns_queryflags flags, struct timeval now,
                                  const qcontext *ctx);
 /* Submits a query (for internal use, called during external submits).
@@ -485,6 +500,10 @@ adns_status adns__internal_submit(adns_state ads, adns_query *query_r,
  * the memory for it is _taken over_ by this routine whether it
  * succeeds or fails (if it succeeds, the vbuf is reused for qu->vb).
  *
+ * If adns__qf_nosend is set in flags, then the query is not sent: doing
+ * whatever is necessary to send the query and link it onto the appropriate
+ * queue is left as the caller's responsibility.
+ *
  * *ctx is copied byte-for-byte into the query.
  *
  * When the child query is done, ctx->callback will be called.  The
@@ -535,8 +554,7 @@ void *adns__alloc_preserved(adns_query qu, size_t sz);
  *  answer->cname and answer->owner are _preserved.
  */
 
-void adns__transfer_interim(adns_query from, adns_query to,
-                           void *block, size_t sz);
+void adns__transfer_interim(adns_query from, adns_query to, void *block);
 /* Transfers an interim allocation from one query to another, so that
  * the `to' query will have room for the data when we get to makefinal
  * and so that the free will happen when the `to' query is freed
@@ -550,6 +568,10 @@ void adns__transfer_interim(adns_query from, adns_query to,
  * TTLs get inherited by their parents.
  */
 
+void adns__free_interim(adns_query qu, void *p);
+/* Forget about a block allocated by adns__alloc_interim.
+ */
+
 void *adns__alloc_mine(adns_query qu, size_t sz);
 /* Like _interim, but does not record the length for later
  * copying into the answer.  This just ensures that the memory
@@ -573,6 +595,7 @@ void adns__reset_preserved(adns_query qu);
 
 void adns__query_done(adns_query qu);
 void adns__query_fail(adns_query qu, adns_status stat);
+void adns__cancel_children(adns_query qu);
 
 /* From reply.c: */