From 129d80382ae266cd6f0bae8bf104f8452ae4314b Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sun, 1 Jun 2014 00:48:59 +0100 Subject: [PATCH] src/: Carve out a `representation' subfield of adns_rrtype. Only the bits covered by adns_rrt_reprmask are used in translating a query type into a typeinfo structure. Arrange for adnstest to only print out the representation bits of the type; otherwise lots of the regression test files need to change for no especially good reason. Signed-off-by: Mark Wooding --- client/adnstest.c | 3 ++- src/adns.h | 1 + src/query.c | 4 +++- src/types.c | 5 +++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/client/adnstest.c b/client/adnstest.c index 550cf27..20f7c31 100644 --- a/client/adnstest.c +++ b/client/adnstest.c @@ -251,7 +251,8 @@ int main(int argc, char *const *argv) { mc->doneyet= 0; mc->fdom= fdomlist[qi]; - fprintf(stdout,"%s flags %d type %d",domain,qflags,types[ti]); + fprintf(stdout,"%s flags %d type %d", + domain,qflags,types[ti]&adns_rrt_reprmask); r= adns_submit(ads,domain,types[ti],qflags,mc,&mc->qu); if (r == ENOSYS) { fprintf(stdout," not implemented\n"); diff --git a/src/adns.h b/src/adns.h index a903934..578545c 100644 --- a/src/adns.h +++ b/src/adns.h @@ -106,6 +106,7 @@ typedef enum { /* In general, or together the desired flags: */ typedef enum { adns_rrt_typemask= 0x0ffff, + adns_rrt_reprmask= 0xffffff, adns__qtf_deref= 0x10000,/* dereference domains; perhaps get extra data */ adns__qtf_mail822= 0x20000,/* return mailboxes in RFC822 rcpt field fmt */ diff --git a/src/query.c b/src/query.c index a3ce68d..26a4df0 100644 --- a/src/query.c +++ b/src/query.c @@ -364,7 +364,9 @@ int adns_submit_reverse(adns_state ads, adns_queryflags flags, void *context, adns_query *query_r) { - if (type != adns_r_ptr && type != adns_r_ptr_raw) return EINVAL; + if (((type^adns_r_ptr) & adns_rrt_reprmask) && + ((type^adns_r_ptr_raw) & adns_rrt_reprmask)) + return EINVAL; return adns_submit_reverse_any(ads,addr,"in-addr.arpa", type,flags,context,query_r); } diff --git a/src/types.c b/src/types.c index cc9f312..83a5792 100644 --- a/src/types.c +++ b/src/types.c @@ -1222,11 +1222,11 @@ static void mf_flat(adns_query qu, void *data) { } #define TYPESZ_M(member) (sizeof(*((adns_answer*)0)->rrs.member)) #define DEEP_TYPE(code,rrt,fmt,memb,parser,comparer,/*printer*/...) \ - { adns_r_##code, rrt,fmt,TYPESZ_M(memb), mf_##memb, \ + { 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, CDR(__VA_ARGS__) } #define FLAT_TYPE(code,rrt,fmt,memb,parser,comparer,/*printer*/...) \ - { adns_r_##code, rrt,fmt,TYPESZ_M(memb), mf_flat, \ + { 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, CDR(__VA_ARGS__) } @@ -1267,6 +1267,7 @@ const typeinfo *adns__findtype(adns_rrtype type) { const typeinfo *begin, *end, *mid; if (type & adns_r_unknown) return &typeinfo_unknown; + type &= adns_rrt_reprmask; begin= typeinfos; end= typeinfos+(sizeof(typeinfos)/sizeof(typeinfo)); -- 2.30.2