From 435abcf2e22d777afbdccdc3048d0ad3df65240a Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Thu, 24 Feb 2000 19:37:28 +0000 Subject: [PATCH] add dns_message_renderreset() --- lib/dns/include/dns/message.h | 14 ++++++++++++++ lib/dns/message.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/lib/dns/include/dns/message.h b/lib/dns/include/dns/message.h index 0025da5997..362113b917 100644 --- a/lib/dns/include/dns/message.h +++ b/lib/dns/include/dns/message.h @@ -450,6 +450,20 @@ dns_message_renderend(dns_message_t *msg); * DNS_R_SUCCESS -- all is well. */ +void +dns_message_renderreset(dns_message_t *msg); +/* + * Reset the message so that it may be rendered again. + * + * Notes: + * + * If dns_message_renderbegin() has been called, dns_message_renderend() + * must be called before calling this function. + * + * Requires: + * + * 'msg' be a valid message with rendering intent. + */ isc_result_t dns_message_firstname(dns_message_t *msg, dns_section_t section); diff --git a/lib/dns/message.c b/lib/dns/message.c index febca5ab56..940265f152 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -1684,6 +1684,35 @@ dns_message_renderend(dns_message_t *msg) return (DNS_R_SUCCESS); } +void +dns_message_renderreset(dns_message_t *msg) +{ + unsigned int i; + dns_name_t *name; + dns_rdataset_t *rds; + + /* + * Reset the message so that it may be rendered again. + */ + + REQUIRE(DNS_MESSAGE_VALID(msg)); + REQUIRE(msg->from_to_wire == DNS_MESSAGE_INTENTRENDER); + + for (i = 0; i < DNS_SECTION_MAX; i++) { + msg->cursors[i] = NULL; + msg->counts[i] = 0; + for (name = ISC_LIST_HEAD(msg->sections[i]); + name != NULL; + name = ISC_LIST_NEXT(name, link)) { + for (rds = ISC_LIST_HEAD(name->list); + rds != NULL; + rds = ISC_LIST_NEXT(rds, link)) { + rds->attributes &= ~DNS_RDATASETATTR_RENDERED; + } + } + } +} + isc_result_t dns_message_firstname(dns_message_t *msg, dns_section_t section) {