chiark / gitweb /
More reply stuff.
[adns.git] / src / submit.c
index d0867de3b44590a3e0975408937bda7a10654bd8..d29a14044911b27b7cdadf81606bc8acc0abed0d 100644 (file)
@@ -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);