diff --git a/bin/tests/dispatch_tcp_test.c b/bin/tests/dispatch_tcp_test.c index d4f0492d0d..7ef2b6cae7 100644 --- a/bin/tests/dispatch_tcp_test.c +++ b/bin/tests/dispatch_tcp_test.c @@ -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); diff --git a/bin/tests/dispatch_test.c b/bin/tests/dispatch_test.c index 56bdd06728..aec3e9ce27 100644 --- a/bin/tests/dispatch_test.c +++ b/bin/tests/dispatch_test.c @@ -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); diff --git a/bin/tests/sdig.c b/bin/tests/sdig.c index 9b391cbf46..5fb29df540 100644 --- a/bin/tests/sdig.c +++ b/bin/tests/sdig.c @@ -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()"); diff --git a/bin/tests/wire_test.c b/bin/tests/wire_test.c index eeabd08293..06e352db0f 100644 --- a/bin/tests/wire_test.c +++ b/bin/tests/wire_test.c @@ -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); diff --git a/lib/dns/include/dns/message.h b/lib/dns/include/dns/message.h index 5beba86c57..5654cc4d72 100644 --- a/lib/dns/include/dns/message.h +++ b/lib/dns/include/dns/message.h @@ -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: * diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 720648b855..22e0ddd0c7 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -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: