Use NULL to signal that the opt record, if any, set on the
message be removed.
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:
*
*/
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;