Extend dns_message_setopt to clear the opt record
Use NULL to signal that the opt record, if any, set on the message be removed.
This commit is contained in:
@@ -1114,14 +1114,14 @@ dns_message_getopt(dns_message_t *msg);
|
||||
isc_result_t
|
||||
dns_message_setopt(dns_message_t *msg, dns_rdataset_t *opt);
|
||||
/*%<
|
||||
* Set the OPT record for 'msg'.
|
||||
* Set/clear the OPT record for 'msg'.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'msg' is a valid message with rendering intent
|
||||
* and no sections have been rendered.
|
||||
*
|
||||
*\li 'opt' is a valid OPT record.
|
||||
*\li 'opt' is a valid OPT record or NULL.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
|
||||
@@ -2707,12 +2707,17 @@ dns_message_setopt(dns_message_t *msg, dns_rdataset_t *opt) {
|
||||
*/
|
||||
|
||||
REQUIRE(DNS_MESSAGE_VALID(msg));
|
||||
REQUIRE(opt->type == dns_rdatatype_opt);
|
||||
REQUIRE(opt == NULL || DNS_RDATASET_VALID(opt));
|
||||
REQUIRE(opt == NULL || opt->type == dns_rdatatype_opt);
|
||||
REQUIRE(msg->from_to_wire == DNS_MESSAGE_INTENTRENDER);
|
||||
REQUIRE(msg->state == DNS_SECTION_ANY);
|
||||
|
||||
msgresetopt(msg);
|
||||
|
||||
if (opt == NULL) {
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
result = dns_rdataset_first(opt);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
|
||||
Reference in New Issue
Block a user