From 8a290f6a165824c1524af36218384d33909205dd Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Tue, 14 Aug 2007 15:33:07 +0000 Subject: [PATCH] Fixup parser, new test. git-svn-id: file:///svn/unbound/trunk@517 be551aaa-1e26-0410-a405-d3ace91eadb9 --- doc/Changelog | 3 +++ services/outside_network.c | 3 +++ testcode/unitmsgparse.c | 35 ++++++++++++++++++++++++----------- testdata/test_packets.6 | 13 +++++++++++++ util/data/msgparse.c | 12 +++++++++++- util/log.c | 10 +++++++++- 6 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 testdata/test_packets.6 diff --git a/doc/Changelog b/doc/Changelog index 80d913718..0e1278ade 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -7,6 +7,9 @@ - extensive debugging for memory allocations. - --enable-lock-checks can be used to enable lock checking. - protect undefs in config.h from autoheaders ministrations. + - print all received udp packets. log hex will print on multiple + lines if needed. + - fixed error in parser with backwards rrsig references. 13 August 2007: Wouter - fixup makefile, if lexer is missing give nice error and do not diff --git a/services/outside_network.c b/services/outside_network.c index f38874d78..6a4729638 100644 --- a/services/outside_network.c +++ b/services/outside_network.c @@ -259,6 +259,9 @@ outnet_udp_cb(struct comm_point* c, void* arg, int error, } verbose(VERB_ALGO, "received udp reply."); + if(verbosity >= VERB_ALGO) + log_hex("udp message", ldns_buffer_begin(c->buffer), + ldns_buffer_limit(c->buffer)); if(p->c != c) { verbose(VERB_DETAIL, "received reply id,addr on wrong port. " "dropped."); diff --git a/testcode/unitmsgparse.c b/testcode/unitmsgparse.c index 8f7aa2318..784aaefb8 100644 --- a/testcode/unitmsgparse.c +++ b/testcode/unitmsgparse.c @@ -51,6 +51,8 @@ /** verbose message parse unit test */ static int vbmp = 0; +/** if matching within a section should disregard the order of RRs. */ +static int matches_nolocation = 0; /** match two rr lists */ static int @@ -65,18 +67,25 @@ match_list(ldns_rr_list* q, ldns_rr_list *p) } for(i=0; irrsig_last->next = dataset->rr_first; else dataset->rrsig_first = dataset->rr_first; dataset->rrsig_last = dataset->rr_last; + dataset->rr_first = 0; + dataset->rr_last = 0; return dataset; } @@ -715,7 +717,7 @@ add_rr_to_rrset(struct rrset_parse* rrset, ldns_buffer* pkt, return LDNS_RCODE_FORMERR; return 0; } - + /* create rr */ if(!(rr = (struct rr_parse*)region_alloc(region, sizeof(*rr)))) return LDNS_RCODE_SERVFAIL; @@ -811,6 +813,14 @@ parse_section(ldns_buffer* pkt, struct msg_parse* msg, region_type* region, if(!rrset) return LDNS_RCODE_SERVFAIL; } + else if(0) { + printf("is part of existing: "); + dname_print(stdout, pkt, rrset->dname); + printf(" type %s(%d)\n", + ldns_rr_descript(rrset->type)? + ldns_rr_descript(rrset->type)->_name: "??", + (int)rrset->type); + } /* add to rrset. */ if((r=add_rr_to_rrset(rrset, pkt, msg, region, section, type)) != 0) diff --git a/util/log.c b/util/log.c index 9eb598d0c..8968c705a 100644 --- a/util/log.c +++ b/util/log.c @@ -179,11 +179,19 @@ log_hex(const char* msg, void* data, size_t length) uint8_t* data8 = (uint8_t*)data; const char* hexchar = "0123456789ABCDEF"; char* buf = malloc(length*2 + 1); /* alloc hex chars + \0 */ + size_t blocksize = 1024; for(i=0; i> 4 ]; buf[i*2 + 1] = hexchar[ data8[i] & 0xF ]; } buf[length*2] = 0; - log_info("%s[%u] %s", msg, (unsigned)length, buf); + if(length < blocksize/2) + log_info("%s[%u] %s", msg, (unsigned)length, buf); + else { + for(i=0; i