/* last 4 bytes are minimum ttl in network format */
if(d->count == 0) return 0;
if(d->rr_len[0] < 2+4) return 0;
- minimum = sldns_read_uint32(d->rr_data[0]+(d->rr_len[0]-2-4));
+ minimum = sldns_read_uint32(d->rr_data[0]+(d->rr_len[0]-4));
d->ttl = (time_t)minimum;
d->rr_ttl[0] = (time_t)minimum;
msg->rep->ttl = get_rrset_ttl(msg->rep->rrsets[0]);
* to generate answers from that is above the query */
node_exists = az_find_ce(z, qinfo, node, node_exact, &ce, &rrset);
+ if(verbosity >= VERB_ALGO) {
+ char zname[256], qname[256], nname[256], cename[256],
+ tpstr[32], rrstr[32];
+ sldns_wire2str_dname_buf(qinfo->qname, qinfo->qname_len, qname,
+ sizeof(qname));
+ sldns_wire2str_type_buf(qinfo->qtype, tpstr, sizeof(tpstr));
+ sldns_wire2str_dname_buf(z->name, z->namelen, zname,
+ sizeof(zname));
+ if(node)
+ sldns_wire2str_dname_buf(node->name, node->namelen,
+ nname, sizeof(nname));
+ else snprintf(nname, sizeof(nname), "NULL");
+ if(ce)
+ sldns_wire2str_dname_buf(ce->name, ce->namelen,
+ cename, sizeof(cename));
+ else snprintf(cename, sizeof(cename), "NULL");
+ if(rrset) sldns_wire2str_type_buf(az_rrset_type(rrset),
+ rrstr, sizeof(rrstr));
+ else snprintf(rrstr, sizeof(rrstr), "NULL");
+ log_info("auth_zone %s query %s %s, domain %s %s %s, "
+ "ce %s, rrset %s", zname, qname, tpstr, nname,
+ (node_exact?"exact":"notexact"),
+ (node_exists?"exist":"notexist"), cename, rrstr);
+ }
+
if(node_exists) {
/* the node is fine, generate answer from node */
return az_generate_answer_with_node(z, qinfo, region, *msg,
z = auth_zone_find(az, dp_nm, dp_nmlen, qinfo->qclass);
if(!z) {
lock_rw_unlock(&az->lock);
+ verbose(VERB_ALGO, "no auth zone for query, fallback");
/* no auth zone, fallback to internet */
*fallback = 1;
return 0;
/** queries for example.com: zone, query, flags, answer. end with NULL */
static struct q_ans example_com_queries[] = {
- {"example.com", "www.example.com A", "",
+ {"example.com", "www.example.com. A", "",
";flags QR AA rcode NOERROR\n"
";answer section\n"
"www.example.com. 3600 IN A 10.0.0.2\n"
if(!*qinfo) fatal_exit("out of memory");
(*qinfo)->qname = regional_alloc_init(region, buf, dname_len);
if(!(*qinfo)->qname) fatal_exit("out of memory");
+ (*qinfo)->qname_len = dname_len;
(*qinfo)->qtype = sldns_wirerr_get_type(buf, len, dname_len);
(*qinfo)->qclass = sldns_wirerr_get_class(buf, len, dname_len);
}
int ret, fallback = 0;
struct dns_msg* msg = NULL;
char* ans_str;
+ int oldv = verbosity;
+ /* increase verbosity to printout logic in authzone */
+ if(vbmp) verbosity = 4;
ret = auth_zones_lookup(az, qinfo, region, &msg, &fallback, dp_nm,
dp_nmlen);
+ if(vbmp) verbosity = oldv;
/* check the answer */
ans_str = msgtostr(msg);
static void
authzone_read_test(void)
{
- if(vbmp) log_info("Testing read auth zone");
+ if(vbmp) printf("Testing read auth zone\n");
check_read_exact("example.com", zone_example_com);
}
static void
authzone_query_test(void)
{
- if(vbmp) log_info("Testing query auth zone");
+ if(vbmp) printf("Testing query auth zone\n");
check_queries("example.com", zone_example_com, example_com_queries);
}
atexit(tmpfilecleanup);
authzone_read_test();
authzone_query_test();
- /* exit(0);*/ /* DEBUG */
+ /*exit(0);*/ /* DEBUG */
}