test rrset ttl refresh.

git-svn-id: file:///svn/unbound/trunk@287 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards
2007-05-04 14:14:08 +00:00
parent 68603f6f05
commit 841d09ff08
4 changed files with 139 additions and 8 deletions
+15 -7
View File
@@ -106,6 +106,8 @@ static void matchline(const char* line, struct entry* e)
e->match_qname = true;
} else if(str_keyword(&parse, "all")) {
e->match_all = true;
} else if(str_keyword(&parse, "ttl")) {
e->match_ttl = true;
} else if(str_keyword(&parse, "UDP")) {
e->match_transport = transport_udp;
} else if(str_keyword(&parse, "TCP")) {
@@ -217,6 +219,7 @@ static struct entry* new_entry()
e->match_qtype = false;
e->match_qname = false;
e->match_all = false;
e->match_ttl = false;
e->match_serial = false;
e->ixfr_soa_serial = 0;
e->match_transport = transport_any;
@@ -555,7 +558,7 @@ static uint32_t get_serial(ldns_pkt* p)
/** match two rr lists */
static int
match_list(ldns_rr_list* q, ldns_rr_list *p)
match_list(ldns_rr_list* q, ldns_rr_list *p, bool mttl)
{
size_t i;
if(ldns_rr_list_rr_count(q) != ldns_rr_list_rr_count(p))
@@ -567,6 +570,11 @@ match_list(ldns_rr_list* q, ldns_rr_list *p)
verbose(3, "rr %d different", i);
return 0;
}
if(mttl && ldns_rr_ttl(ldns_rr_list_rr(q, i)) !=
ldns_rr_ttl(ldns_rr_list_rr(p, i))) {
verbose(3, "rr %d ttl different", i);
return 0;
}
}
return 1;
}
@@ -583,7 +591,7 @@ cmp_bool(int x, int y)
/** match all of the packet */
static int
match_all(ldns_pkt* q, ldns_pkt* p)
match_all(ldns_pkt* q, ldns_pkt* p, bool mttl)
{
if(ldns_pkt_get_opcode(q) != ldns_pkt_get_opcode(p))
{ verbose(3, "allmatch: opcode different"); return 0;}
@@ -613,13 +621,13 @@ match_all(ldns_pkt* q, ldns_pkt* p)
{ verbose(3, "allmatch: nscount different"); return 0;}
if(ldns_pkt_arcount(q) != ldns_pkt_arcount(p))
{ verbose(3, "allmatch: arcount different"); return 0;}
if(!match_list(ldns_pkt_question(q), ldns_pkt_question(p)))
if(!match_list(ldns_pkt_question(q), ldns_pkt_question(p), mttl))
{ verbose(3, "allmatch: qd section different"); return 0;}
if(!match_list(ldns_pkt_answer(q), ldns_pkt_answer(p)))
if(!match_list(ldns_pkt_answer(q), ldns_pkt_answer(p), mttl))
{ verbose(3, "allmatch: an section different"); return 0;}
if(!match_list(ldns_pkt_authority(q), ldns_pkt_authority(p)))
if(!match_list(ldns_pkt_authority(q), ldns_pkt_authority(p), mttl))
{ verbose(3, "allmatch: ar section different"); return 0;}
if(!match_list(ldns_pkt_additional(q), ldns_pkt_additional(p)))
if(!match_list(ldns_pkt_additional(q), ldns_pkt_additional(p), mttl))
{ verbose(3, "allmatch: ns section different"); return 0;}
return 1;
}
@@ -659,7 +667,7 @@ find_match(struct entry* entries, ldns_pkt* query_pkt,
verbose(3, "bad transport\n");
continue;
}
if(p->match_all && !match_all(query_pkt, reply)) {
if(p->match_all && !match_all(query_pkt, reply, p->match_ttl)) {
verbose(3, "bad allmatch\n");
continue;
}
+4 -1
View File
@@ -44,7 +44,8 @@
; 'qname' makes the query match the qname from the reply
; 'serial=1023' makes the query match if ixfr serial is 1023.
; 'all' has to match header byte for byte and all rrs in packet.
MATCH [opcode] [qtype] [qname] [serial=<value>] [all]
; 'ttl' used with all, rrs in packet must also have matching TTLs.
MATCH [opcode] [qtype] [qname] [serial=<value>] [all] [ttl]
MATCH [UDP|TCP]
MATCH ...
; Then the REPLY header is specified.
@@ -157,6 +158,8 @@ struct entry {
bool match_serial;
/** match all of the packet */
bool match_all;
/** match ttls in the packet */
bool match_ttl;
/** match query serial with this value. */
uint32_t ixfr_soa_serial;
/** match on UDP/TCP */