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));
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)
log_err("reply encode: out of memory");
return 0;
}
- attach_edns_field(pkt, edns);
+ attach_edns_record(pkt, edns);
return 1;
}
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 */