From: Mark Wooding Date: Sat, 7 Jun 2014 21:26:34 +0000 (+0100) Subject: src/: New type hook `query_send'. X-Git-Tag: make-bug.2014-07-26~19 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=adns.git;a=commitdiff_plain;h=66ade6021bca9f024d7bcd2b3ddeedf7a1b3a90c;ds=sidebyside src/: New type hook `query_send'. 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 --- diff --git a/src/internal.h b/src/internal.h index 552db15..5e34956 100644 --- a/src/internal.h +++ b/src/internal.h @@ -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. */ + + 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, diff --git a/src/query.c b/src/query.c index 1de9dfd..a5882f3 100644 --- a/src/query.c +++ b/src/query.c @@ -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); - - adns__query_send(qu,now); + + typei->query_send(qu,now); } adns_status adns__ckl_hostname(adns_state ads, adns_queryflags flags, diff --git a/src/types.c b/src/types.c index 7cae881..0658615 100644 --- a/src/types.c +++ b/src/types.c @@ -85,6 +85,7 @@ * 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, \ - 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, \ - 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