]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Fix unit test to attach edns record.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 7 May 2007 13:24:30 +0000 (13:24 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 7 May 2007 13:24:30 +0000 (13:24 +0000)
git-svn-id: file:///svn/unbound/trunk@289 be551aaa-1e26-0410-a405-d3ace91eadb9

testcode/unitmsgparse.c
util/data/msgreply.c
util/data/msgreply.h

index 5e42bdf80e71738598dc2c730d5f669d738db00a..0af2c1acb073a893d20374382d89945894ca772c 100644 (file)
@@ -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));
index 4095e75670e33af075504e32e28e9f17fe2d9ece..cad215dacf64e47e32e8f8e04f7b66bbe8e7612c 100644 (file)
@@ -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;
 }
 
index 467cc96ace2745c07c8504cd2e2b827ef6f2c4fb..0abb62573549f238ba17d2fb5fa7b670b38131e7 100644 (file)
@@ -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 */