From: Wouter Wijngaards Date: Mon, 7 May 2007 13:24:30 +0000 (+0000) Subject: Fix unit test to attach edns record. X-Git-Tag: release-0.3~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c18d584466bb01f958343ce598a638cbd2f4b8ac;p=thirdparty%2Funbound.git Fix unit test to attach edns record. git-svn-id: file:///svn/unbound/trunk@289 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/testcode/unitmsgparse.c b/testcode/unitmsgparse.c index 5e42bdf80..0af2c1acb 100644 --- a/testcode/unitmsgparse.c +++ b/testcode/unitmsgparse.c @@ -270,6 +270,7 @@ testpkt(ldns_buffer* pkt, struct alloc_cache* alloc, ldns_buffer* out, ret = reply_info_encode(&qi, rep, id, flags, out, timenow, region, 65535); unit_assert(ret != 0); /* udp packets should fit */ + attach_edns_record(out, &edns); if(vbmp) printf("inlen %u outlen %u\n", (unsigned)ldns_buffer_limit(pkt), (unsigned)ldns_buffer_limit(out)); diff --git a/util/data/msgreply.c b/util/data/msgreply.c index 4095e7567..cad215dac 100644 --- a/util/data/msgreply.c +++ b/util/data/msgreply.c @@ -1076,9 +1076,8 @@ calc_edns_field_size(struct edns_data* edns) return 1 + 2 + 2 + 4 + 2; } -/** append EDNS field as last record in packet */ -static void -attach_edns_field(ldns_buffer* pkt, struct edns_data* edns) +void +attach_edns_record(ldns_buffer* pkt, struct edns_data* edns) { size_t len; if(!edns || !edns->edns_present) @@ -1124,7 +1123,7 @@ reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep, log_err("reply encode: out of memory"); return 0; } - attach_edns_field(pkt, edns); + attach_edns_record(pkt, edns); return 1; } diff --git a/util/data/msgreply.h b/util/data/msgreply.h index 467cc96ac..0abb62573 100644 --- a/util/data/msgreply.h +++ b/util/data/msgreply.h @@ -298,4 +298,13 @@ int reply_info_encode(struct query_info* qinfo, struct reply_info* rep, struct msgreply_entry* query_info_entrysetup(struct query_info* q, struct reply_info* r, hashvalue_t h); +/** + * Attach EDNS record to buffer. Buffer has complete packet. There must + * be enough room left for the EDNS record. + * @param pkt: packet added to. + * @param edns: if NULL or present=0, nothing is added to the packet. + */ +void attach_edns_record(ldns_buffer* pkt, struct edns_data* edns); + + #endif /* UTIL_DATA_MSGREPLY_H */