X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/adns/blobdiff_plain/680d2a652d5185d75c206444e9e8db9b82b3121c..1e9efa7116ea04acfc29e7b0a7672d06db5cf00c:/src/reply.c diff --git a/src/reply.c b/src/reply.c index f98540c..5ed6581 100644 --- a/src/reply.c +++ b/src/reply.c @@ -23,12 +23,12 @@ #include "internal.h" static void cname_recurse(adns_query qu, adns_queryflags xflags) { - abort(); /* FIXME */ + assert(!"cname not implemented"); /* FIXME */ } void adns__procdgram(adns_state ads, const byte *dgram, int dglen, int serv, struct timeval now) { - int cbyte, rrstart, wantedrrs, rri, foundsoa, foundns; + int cbyte, rrstart, wantedrrs, rri, foundsoa, foundns, cname_here; int id, f1, f2, qdcount, ancount, nscount, arcount; int flg_ra, flg_rd, flg_tc, flg_qr, opcode; int rrtype, rrclass, rdlength, rdstart, ownermatched, l; @@ -36,6 +36,7 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen, adns_query qu, nqu; dns_rcode rcode; adns_status st; + vbuf tempvb; if (dglenquery_dglen; if (!qu) { - adns__debug(ads,serv,0,"reply not found (id=%02x)",id); + if (ads->iflags & adns_if_debug) { + adns__vbuf_init(&tempvb); + adns__debug(ads,serv,0,"reply not found, id %02x, query owner %s", + id, adns__diag_domain(ads,serv,0,&tempvb,adns_qf_anyquote, + dgram,dglen,DNS_HDRSIZE)); + adns__vbuf_free(&tempvb); + } return; } + anstart= qu->query_dglen; LIST_UNLINK(ads->timew,qu); /* We're definitely going to do something with this query now */ @@ -125,12 +131,13 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen, * If it has any CNAMEs we stuff them in the answer. */ wantedrrs= 0; + cbyte= anstart; for (rri= 0; rrianswer->cname= adns__alloc_interim(qu,l); if (!qu->answer->cname) return; memcpy(qu->answer->cname,qu->vb.buf,l); + cname_here= 1; /* If we find the answer section truncated after this point we restart * the query at the CNAME; if beforehand then we obviously have to use * TCP. If there is no truncation we can use the whole answer if @@ -219,7 +227,7 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen, * a CNAME in this datagram then we should probably do our own CNAME * lookup now in the hope that we won't get a referral again. */ - if (qu->cname_dgram == dgram) { cname_recurse(qu,0); return; } + if (cname_here) { cname_recurse(qu,0); return; } /* Bloody hell, I thought we asked for recursion ? */ if (flg_rd) { @@ -257,6 +265,7 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen, qu->answer->rrs.bytes+qu->answer->nrrs*qu->typei->rrsz); if (st) { adns__query_fail(qu,st); return; } if (rdstart==-1) goto x_truncated; + qu->answer->nrrs++; } /* This may have generated some child queries ... */