X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=adns.git;a=blobdiff_plain;f=src%2Fsubmit.c;h=d29a14044911b27b7cdadf81606bc8acc0abed0d;hp=d0867de3b44590a3e0975408937bda7a10654bd8;hb=0ba0614a998909d8b4f51988d7a8af3ba369a5d9;hpb=b9de380c1e587b6c5828cb9de796746024946880 diff --git a/src/submit.c b/src/submit.c index d0867de..d29a140 100644 --- a/src/submit.c +++ b/src/submit.c @@ -9,17 +9,17 @@ #include "internal.h" static adns_query allocquery(adns_state ads, const char *owner, int ol, - int id, adns_rrtype type, + int id, const typeinfo *typei, adns_queryflags flags, const qcontext *ctx) { /* Query message used is the one assembled in ads->rqbuf */ adns_query qu; - + qu= malloc(sizeof(*qu)+ol+1+ads->rqbuf.used); if (!qu) return 0; qu->state= query_udp; qu->next= qu->back= qu->parent= 0; LIST_INIT(qu->children); qu->siblings.next= qu->siblings.back= 0; - qu->type= type; + qu->typei= typei; adns__vbuf_init(&qu->answer); qu->id= id; qu->flags= flags; @@ -58,21 +58,25 @@ int adns_submit(adns_state ads, int ol, id, r; qcontext ctx; struct timeval now; + const typeinfo typei; ctx.ext= context; id= ads->nextid++; r= gettimeofday(&now,0); if (r) return errno; + typei= findtype(type); + if (!typei) return failsubmit(ads,context,query_r,0,flags,id,adns_s_notimplemented); + ol= strlen(owner); if (ol<=1 || ol>MAXDNAME+1) - return failsubmit(ads,context,query_r,type,flags,id,adns_s_invaliddomain); + return failsubmit(ads,context,query_r,0,flags,id,adns_s_invaliddomain); if (owner[ol-1]=='.' && owner[ol-2]!='\\') { flags &= ~adns_qf_search; ol--; } stat= adns__mkquery(ads,owner,ol,id,type,flags); if (stat) return failsubmit(ads,context,query_r,type,flags,id,stat); - - qu= allocquery(ads,owner,ol,id,type,flags,&ctx); if (!qu) return errno; + + qu= allocquery(ads,owner,ol,id,typei,flags,&ctx); if (!qu) return errno; adns__query_udp(ads,qu,now); adns__autosys(ads,now);