Commit 8dec0e1a authored by Andreas Gustafsson's avatar Andreas Gustafsson

dns_message_parse now takes new argument 'preserve_order'

parent d347e7af
......@@ -264,7 +264,7 @@ got_response(isc_task_t *task, isc_event_t *ev_in)
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &msg);
CHECKRESULT(result, "dns_message_create() failed");
result = dns_message_parse(msg, &ev->buffer);
result = dns_message_parse(msg, &ev->buffer, ISC_FALSE);
CHECKRESULT(result, "dns_message_parse() failed");
result = printmessage(msg);
......@@ -304,7 +304,7 @@ got_request(isc_task_t *task, isc_event_t *ev_in)
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &msg);
CHECKRESULT(result, "dns_message_create() failed");
result = dns_message_parse(msg, &ev->buffer);
result = dns_message_parse(msg, &ev->buffer, ISC_FALSE);
CHECKRESULT(result, "dns_message_parse() failed");
result = printmessage(msg);
......
......@@ -260,7 +260,7 @@ got_response(isc_task_t *task, isc_event_t *ev_in)
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &msg);
CHECKRESULT(result, "dns_message_create() failed");
result = dns_message_parse(msg, &ev->buffer);
result = dns_message_parse(msg, &ev->buffer, ISC_FALSE);
CHECKRESULT(result, "dns_message_parse() failed");
result = printmessage(msg);
......@@ -314,7 +314,7 @@ got_request(isc_task_t *task, isc_event_t *ev_in)
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &msg);
CHECKRESULT(result, "dns_message_create() failed");
result = dns_message_parse(msg, &ev->buffer);
result = dns_message_parse(msg, &ev->buffer, ISC_FALSE);
CHECKRESULT(result, "dns_message_parse() failed");
result = printmessage(msg);
......
......@@ -144,7 +144,7 @@ recv_done(isc_task_t *task, isc_event_t *event) {
ISC_BUFFERTYPE_BINARY);
isc_buffer_add(&b, sevent->n);
dns_message_reset(message, DNS_MESSAGE_INTENTPARSE);
result = dns_message_parse(message, &b);
result = dns_message_parse(message, &b, ISC_FALSE);
if (result != ISC_R_SUCCESS)
hex_dump(&b);
check_result(result, "dns_message_parse()");
......
......@@ -134,7 +134,7 @@ main(int argc, char *argv[]) {
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &message);
CHECKRESULT(result, "dns_message_create failed");
result = dns_message_parse(message, &source);
result = dns_message_parse(message, &source, ISC_FALSE);
CHECKRESULT(result, "dns_message_parse failed");
result = printmessage(message);
......@@ -188,7 +188,7 @@ main(int argc, char *argv[]) {
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &message);
CHECKRESULT(result, "dns_message_create failed");
result = dns_message_parse(message, &source);
result = dns_message_parse(message, &source, ISC_FALSE);
CHECKRESULT(result, "dns_message_parse failed");
result = printmessage(message);
......
......@@ -202,7 +202,8 @@ dns_message_destroy(dns_message_t **msgp);
*/
dns_result_t
dns_message_parse(dns_message_t *msg, isc_buffer_t *source);
dns_message_parse(dns_message_t *msg, isc_buffer_t *source,
isc_boolean_t preserve_order);
/*
* Parse raw wire data pointed to by "buffer" and bounded by "buflen" as a
* DNS message.
......@@ -212,6 +213,18 @@ dns_message_parse(dns_message_t *msg, isc_buffer_t *source);
* time, the TSIG is verified (XXX) and the message fails if the TSIG fails
* to verify.
*
* If 'preserve_order' is true, or if the opcode of the message is UPDATE,
* a separate dns_name_t object will be created for each RR in the message.
* Each such dns_name_t will have a single rdataset containing the single RR,
* and the order of the RRs in the message is preserved.
* Otherwise, only one dns_name_t object will be created for each unique
* owner name in the section, and each such dns_name_t will have a list
* of rdatasets. To access the names and their data, use
* dns_message_firstname() and dns_message_nextname().
*
* OPT and TSIG records are always handled specially, regardless of the
* 'preserve_order' setting.
*
* If this is a multi-packet message (edns) and more data is required to
* build the full message state, DNS_R_MOREDATA is returned. In this case,
* this function should be repeated with all input buffers until DNS_R_SUCCESS
......@@ -369,12 +382,7 @@ dns_message_firstname(dns_message_t *msg, dns_section_t section);
* Set internal per-section name pointer to the beginning of the section.
*
* The functions dns_message_firstname() and dns_message_nextname() may
* be used for iterating over the owner names occuring in a section. For
* ordinary DNS messages, each unique owner name will be returned only
* once, and will be associated with a list of rdatasets. For dynamic
* update messages, the owner name of each RR in the message will be
* returned separately, it will be associated with a list containing a
* single rdataset, and that rdataset will contain a single update RR.
* be used for iterating over the owner names in a section.
*
* Requires:
*
......
......@@ -803,7 +803,7 @@ query_response(isc_task_t *task, isc_event_t *event) {
INSIST(fctx->state == fetchstate_active);
message = fctx->rmessage;
result = dns_message_parse(message, &devent->buffer);
result = dns_message_parse(message, &devent->buffer, ISC_FALSE);
if (result != DNS_R_SUCCESS) {
switch (result) {
case DNS_R_FORMERR:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment