chiark / gitweb /
Include TTL (well, actually, expiry time) in answers.
[adns.git] / src / types.c
index 32db2841acd41837e7af93d463236077778126e3..deac6c4270498144e134e35bbea7d030b4c1a1d2 100644 (file)
@@ -3,7 +3,7 @@
  * - RR-type-specific code, and the machinery to call it
  */
 /*
- *  This file is part of adns, which is Copyright (C) 1997, 1998 Ian Jackson
+ *  This file is part of adns, which is Copyright (C) 1997-1999 Ian Jackson
  *  
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -381,11 +381,12 @@ static adns_status pap_findaddrs(const parseinfo *pai, adns_rr_hostaddr *ha,
                                 int *cbyte_io, int count, int dmstart) {
   int rri, naddrs;
   int type, class, rdlen, rdstart, ownermatched;
+  unsigned long ttl;
   adns_status st;
   
   for (rri=0, naddrs=-1; rri<count; rri++) {
     st= adns__findrr_anychk(pai->qu, pai->serv, pai->dgram, pai->dglen, cbyte_io,
-                           &type, &class, &rdlen, &rdstart,
+                           &type, &class, &ttl, &rdlen, &rdstart,
                            pai->dgram, pai->dglen, dmstart, &ownermatched);
     if (st) return st;
     if (!ownermatched || class != DNS_CLASS_IN || type != adns_r_a) {
@@ -395,6 +396,7 @@ static adns_status pap_findaddrs(const parseinfo *pai, adns_rr_hostaddr *ha,
       naddrs= 0;
     }
     if (!adns__vbuf_ensure(&pai->qu->vb, (naddrs+1)*sizeof(adns_rr_addr))) R_NOMEM;
+    adns__update_expires(pai->qu,ttl,pai->now);
     st= pa_addr(pai, rdstart,rdstart+rdlen,
                pai->qu->vb.buf + naddrs*sizeof(adns_rr_addr));
     if (st) return st;
@@ -432,6 +434,7 @@ static adns_status pap_hostaddr(const parseinfo *pai, int *cbyte_io,
   qcontext ctx;
   int id;
   adns_query nqu;
+  adns_queryflags nflags;
 
   dmstart= cbyte= *cbyte_io;
   st= pap_domain(pai, &cbyte, max, &rrp->host,
@@ -461,9 +464,12 @@ static adns_status pap_hostaddr(const parseinfo *pai, int *cbyte_io,
   ctx.ext= 0;
   ctx.callback= icb_hostaddr;
   ctx.info.hostaddr= rrp;
+  
+  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),
-                           &pai->qu->vb, id,
-                           adns_qf_quoteok_query, pai->now, 0, &ctx);
+                           &pai->qu->vb, id, nflags, pai->now, 0, &ctx);
   if (st) return st;
 
   nqu->parent= pai->qu;