chiark / gitweb /
Reentrancy: Introduce adns__cancel
[adns.git] / src / types.c
index 0658615f42d1a50d75a80e762c77ba4a776797e5..cb343beb8d4e6177042a51289147f6df35716f72 100644 (file)
@@ -261,11 +261,27 @@ static adns_status pa_inaddr(const parseinfo *pai, int cbyte,
 
 static int search_sortlist(adns_state ads, int af, const void *ad) {
   const struct sortlist *slp;
+  const struct in6_addr *a6;
+  union gen_addr a;
   int i;
-  
+  int v6mappedp= 0;
+
+  if (af == AF_INET6) {
+    a6= ad;
+    if (IN6_IS_ADDR_V4MAPPED(a6)) {
+      a.v4.s_addr= htonl(((unsigned long)a6->s6_addr[12] << 24) |
+                        ((unsigned long)a6->s6_addr[13] << 16) |
+                        ((unsigned long)a6->s6_addr[14] <<  8) |
+                        ((unsigned long)a6->s6_addr[15] <<  0));
+      v6mappedp= 1;
+    }
+  }
+
   for (i=0, slp=ads->sortlist;
        i<ads->nsortlist &&
-        !adns__addr_match_p(af,ad, slp->af,&slp->base,&slp->mask);
+        !adns__addr_match_p(af,ad, slp->af,&slp->base,&slp->mask) &&
+        !(v6mappedp &&
+          adns__addr_match_p(AF_INET,&a, slp->af,&slp->base,&slp->mask));
        i++, slp++);
   return i;
 }
@@ -572,15 +588,13 @@ static adns_status pap_hostaddr(const parseinfo *pai, int *cbyte_io,
   nflags= adns_qf_quoteok_query;
   if (!(pai->qu->flags & adns_qf_cname_loose)) nflags |= adns_qf_cname_forbid;
   
-  st= adns__internal_submit(pai->ads, &nqu, adns__findtype(adns_r_addr),
+  st= adns__internal_submit(pai->ads, &nqu, pai->qu,
+                           adns__findtype(adns_r_addr),
                            ((adns_r_addr & adns_rrt_reprmask) |
                             (pai->qu->answer->type & ~adns_rrt_reprmask)),
                            &pai->qu->vb, id, nflags, pai->now, &ctx);
   if (st) return st;
 
-  nqu->parent= pai->qu;
-  LIST_LINK_TAIL_PART(pai->qu->children,nqu,siblings.);
-
   return adns_s_ok;
 }
 
@@ -833,13 +847,12 @@ static adns_status pa_ptr(const parseinfo *pai, int dmstart,
   ctx.callback= icb_ptr;
   memset(&ctx.pinfo,0,sizeof(ctx.pinfo));
   memset(&ctx.tinfo,0,sizeof(ctx.tinfo));
-  st= adns__internal_submit(pai->ads, &nqu, adns__findtype(rrtype),
+  st= adns__internal_submit(pai->ads, &nqu, pai->qu,
+                           adns__findtype(rrtype),
                            rrtype, &pai->qu->vb, id,
                            adns_qf_quoteok_query, pai->now, &ctx);
   if (st) return st;
 
-  nqu->parent= pai->qu;
-  LIST_LINK_TAIL_PART(pai->qu->children,nqu,siblings.);
   return adns_s_ok;
 }