chiark / gitweb /
src/: New type hook `query_send'.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 7 Jun 2014 21:26:34 +0000 (22:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 13 Jun 2014 08:57:42 +0000 (09:57 +0100)
Puts the type code in control of how to actually send the query off.  In
particular, this allows `virtual queries' which only actually spawn
child queries for interesting records, and then collate the results.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
src/internal.h
src/query.c
src/types.c

index 552db151b7ff495da637c416324c743fd7dd2c21..5e3495610f24140c130c6a5ff45a48c8a242031c 100644 (file)
@@ -217,6 +217,12 @@ typedef struct typeinfo {
   /* Return the output resource-record element size; if this is null, then
    * the rrsz member can be used.
    */
   /* Return the output resource-record element size; if this is null, then
    * the rrsz member can be used.
    */
+
+  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__ckl_hostname(adns_state ads, adns_queryflags flags,
 } typeinfo;
 
 adns_status adns__ckl_hostname(adns_state ads, adns_queryflags flags,
index 1de9dfd181932cfdd2082c3333904782e8da21bc..a5882f3ec5f19c6b6994e7095750bd4afbe39a15 100644 (file)
@@ -104,8 +104,8 @@ static void query_submit(adns_state ads, adns_query qu,
   qu->id= id;
   qu->query_dglen= qu->vb.used;
   memcpy(qu->query_dgram,qu->vb.buf,qu->vb.used);
   qu->id= id;
   qu->query_dglen= qu->vb.used;
   memcpy(qu->query_dgram,qu->vb.buf,qu->vb.used);
-  
-  adns__query_send(qu,now);
+
+  typei->query_send(qu,now);
 }
 
 adns_status adns__ckl_hostname(adns_state ads, adns_queryflags flags,
 }
 
 adns_status adns__ckl_hostname(adns_state ads, adns_queryflags flags,
index 7cae88178dd2cf7407987a0c90d1fece8590301a..0658615f42d1a50d75a80e762c77ba4a776797e5 100644 (file)
@@ -85,6 +85,7 @@
  *    cs_*
  *    gsz_*
  *    postsort_*
  *    cs_*
  *    gsz_*
  *    postsort_*
+ *    qs_*
  */
 
 /*
  */
 
 /*
@@ -1267,11 +1268,13 @@ static void mf_flat(adns_query qu, void *data) { }
 #define DEEP_TYPE(code,rrt,fmt,memb,parser,comparer,/*printer*/...)    \
  { adns_r_##code&adns_rrt_reprmask, rrt,fmt,TYPESZ_M(memb), mf_##memb, \
      GLUE(cs_, CAR(__VA_ARGS__)),pa_##parser,di_##comparer,            \
 #define DEEP_TYPE(code,rrt,fmt,memb,parser,comparer,/*printer*/...)    \
  { adns_r_##code&adns_rrt_reprmask, rrt,fmt,TYPESZ_M(memb), mf_##memb, \
      GLUE(cs_, CAR(__VA_ARGS__)),pa_##parser,di_##comparer,            \
-     adns__ckl_hostname, 0, adns__getrrsz_default, CDR(__VA_ARGS__) }
+     adns__ckl_hostname, 0, adns__getrrsz_default, adns__query_send,   \
+     CDR(__VA_ARGS__) }
 #define FLAT_TYPE(code,rrt,fmt,memb,parser,comparer,/*printer*/...)    \
  { adns_r_##code&adns_rrt_reprmask, rrt,fmt,TYPESZ_M(memb), mf_flat,   \
      GLUE(cs_, CAR(__VA_ARGS__)),pa_##parser,di_##comparer,            \
 #define FLAT_TYPE(code,rrt,fmt,memb,parser,comparer,/*printer*/...)    \
  { adns_r_##code&adns_rrt_reprmask, rrt,fmt,TYPESZ_M(memb), mf_flat,   \
      GLUE(cs_, CAR(__VA_ARGS__)),pa_##parser,di_##comparer,            \
-     adns__ckl_hostname, 0, adns__getrrsz_default, CDR(__VA_ARGS__) }
+     adns__ckl_hostname, 0, adns__getrrsz_default, adns__query_send,   \
+     CDR(__VA_ARGS__) }
 
 #define di_0 0
 
 
 #define di_0 0