2 * Copyright (C) 2004-2012 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1998-2003 Internet Software Consortium.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
25 #include <isc/base64.h>
29 #include <isc/parseint.h>
30 #include <isc/print.h>
31 #include <isc/string.h>
32 #include <isc/stdlib.h>
35 #include <dns/callbacks.h>
37 #include <dns/compress.h>
38 #include <dns/enumtype.h>
39 #include <dns/keyflags.h>
40 #include <dns/keyvalues.h>
41 #include <dns/message.h>
42 #include <dns/rcode.h>
43 #include <dns/rdata.h>
44 #include <dns/rdataclass.h>
45 #include <dns/rdatastruct.h>
46 #include <dns/rdatatype.h>
47 #include <dns/result.h>
48 #include <dns/secalg.h>
49 #include <dns/secproto.h>
55 isc_result_t _r = (x); \
56 if (_r != ISC_R_SUCCESS) \
62 isc_result_t _r = (x); \
63 if (_r != ISC_R_SUCCESS) { \
64 isc_lex_ungettoken(lexer, &token); \
69 #define DNS_AS_STR(t) ((t).value.as_textregion.base)
71 #define ARGS_FROMTEXT int rdclass, dns_rdatatype_t type, \
72 isc_lex_t *lexer, dns_name_t *origin, \
73 unsigned int options, isc_buffer_t *target, \
74 dns_rdatacallbacks_t *callbacks
76 #define ARGS_TOTEXT dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, \
79 #define ARGS_FROMWIRE int rdclass, dns_rdatatype_t type, \
80 isc_buffer_t *source, dns_decompress_t *dctx, \
81 unsigned int options, isc_buffer_t *target
83 #define ARGS_TOWIRE dns_rdata_t *rdata, dns_compress_t *cctx, \
86 #define ARGS_COMPARE const dns_rdata_t *rdata1, const dns_rdata_t *rdata2
88 #define ARGS_FROMSTRUCT int rdclass, dns_rdatatype_t type, \
89 void *source, isc_buffer_t *target
91 #define ARGS_TOSTRUCT dns_rdata_t *rdata, void *target, isc_mem_t *mctx
93 #define ARGS_FREESTRUCT void *source
95 #define ARGS_ADDLDATA dns_rdata_t *rdata, dns_additionaldatafunc_t add, \
98 #define ARGS_DIGEST dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg
100 #define ARGS_CHECKOWNER dns_name_t *name, dns_rdataclass_t rdclass, \
101 dns_rdatatype_t type, isc_boolean_t wildcard
103 #define ARGS_CHECKNAMES dns_rdata_t *rdata, dns_name_t *owner, dns_name_t *bad
107 * Context structure for the totext_ functions.
108 * Contains formatting options for rdata-to-text
111 typedef struct dns_rdata_textctx {
112 dns_name_t *origin; /*%< Current origin, or NULL. */
113 unsigned int flags; /*%< DNS_STYLEFLAG_* */
114 unsigned int width; /*%< Width of rdata column. */
115 const char *linebreak; /*%< Line break string. */
116 } dns_rdata_textctx_t;
119 txt_totext(isc_region_t *source, isc_buffer_t *target);
122 txt_fromtext(isc_textregion_t *source, isc_buffer_t *target);
125 txt_fromwire(isc_buffer_t *source, isc_buffer_t *target);
128 name_prefix(dns_name_t *name, dns_name_t *origin, dns_name_t *target);
131 name_length(dns_name_t *name);
134 str_totext(const char *source, isc_buffer_t *target);
137 inet_totext(int af, isc_region_t *src, isc_buffer_t *target);
140 buffer_empty(isc_buffer_t *source);
143 buffer_fromregion(isc_buffer_t *buffer, isc_region_t *region);
146 uint32_tobuffer(isc_uint32_t, isc_buffer_t *target);
149 uint16_tobuffer(isc_uint32_t, isc_buffer_t *target);
152 uint8_tobuffer(isc_uint32_t, isc_buffer_t *target);
155 name_tobuffer(dns_name_t *name, isc_buffer_t *target);
158 uint32_fromregion(isc_region_t *region);
161 uint16_fromregion(isc_region_t *region);
164 uint8_fromregion(isc_region_t *region);
167 uint8_consume_fromregion(isc_region_t *region);
170 mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length);
173 hexvalue(char value);
176 decvalue(char value);
179 btoa_totext(unsigned char *inbuf, int inbuflen, isc_buffer_t *target);
182 atob_tobuffer(isc_lex_t *lexer, isc_buffer_t *target);
185 default_fromtext_callback(dns_rdatacallbacks_t *callbacks, const char *, ...)
186 ISC_FORMAT_PRINTF(2, 3);
189 fromtext_error(void (*callback)(dns_rdatacallbacks_t *, const char *, ...),
190 dns_rdatacallbacks_t *callbacks, const char *name,
191 unsigned long line, isc_token_t *token, isc_result_t result);
194 fromtext_warneof(isc_lex_t *lexer, dns_rdatacallbacks_t *callbacks);
197 rdata_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
198 isc_buffer_t *target);
201 warn_badname(dns_name_t *name, isc_lex_t *lexer,
202 dns_rdatacallbacks_t *callbacks);
205 warn_badmx(isc_token_t *token, isc_lex_t *lexer,
206 dns_rdatacallbacks_t *callbacks);
209 uint16_consume_fromregion(isc_region_t *region);
212 unknown_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
213 isc_buffer_t *target);
216 getquad(const void *src, struct in_addr *dst,
217 isc_lex_t *lexer, dns_rdatacallbacks_t *callbacks)
222 result = inet_aton(src, dst);
223 if (result == 1 && callbacks != NULL &&
224 inet_pton(AF_INET, src, &tmp) != 1) {
225 const char *name = isc_lex_getsourcename(lexer);
228 (*callbacks->warn)(callbacks, "%s:%lu: \"%s\" "
229 "is not a decimal dotted quad", name,
230 isc_lex_getsourceline(lexer), src);
235 static inline isc_result_t
236 name_duporclone(dns_name_t *source, isc_mem_t *mctx, dns_name_t *target) {
239 return (dns_name_dup(source, mctx, target));
240 dns_name_clone(source, target);
241 return (ISC_R_SUCCESS);
245 mem_maybedup(isc_mem_t *mctx, void *source, size_t length) {
250 new = isc_mem_allocate(mctx, length);
252 memcpy(new, source, length);
257 static const char hexdigits[] = "0123456789abcdef";
258 static const char decdigits[] = "0123456789";
263 #define RESERVED 0x0002
270 dns_rdata_init(dns_rdata_t *rdata) {
272 REQUIRE(rdata != NULL);
279 ISC_LINK_INIT(rdata, link);
280 /* ISC_LIST_INIT(rdata->list); */
284 dns_rdata_reset(dns_rdata_t *rdata) {
286 REQUIRE(rdata != NULL);
288 REQUIRE(!ISC_LINK_LINKED(rdata, link));
289 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
303 dns_rdata_clone(const dns_rdata_t *src, dns_rdata_t *target) {
305 REQUIRE(src != NULL);
306 REQUIRE(target != NULL);
308 REQUIRE(DNS_RDATA_INITIALIZED(target));
310 REQUIRE(DNS_RDATA_VALIDFLAGS(src));
311 REQUIRE(DNS_RDATA_VALIDFLAGS(target));
313 target->data = src->data;
314 target->length = src->length;
315 target->rdclass = src->rdclass;
316 target->type = src->type;
317 target->flags = src->flags;
326 dns_rdata_compare(const dns_rdata_t *rdata1, const dns_rdata_t *rdata2) {
328 isc_boolean_t use_default = ISC_FALSE;
330 REQUIRE(rdata1 != NULL);
331 REQUIRE(rdata2 != NULL);
332 REQUIRE(rdata1->length == 0 || rdata1->data != NULL);
333 REQUIRE(rdata2->length == 0 || rdata2->data != NULL);
334 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata1));
335 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata2));
337 if (rdata1->rdclass != rdata2->rdclass)
338 return (rdata1->rdclass < rdata2->rdclass ? -1 : 1);
340 if (rdata1->type != rdata2->type)
341 return (rdata1->type < rdata2->type ? -1 : 1);
349 dns_rdata_toregion(rdata1, &r1);
350 dns_rdata_toregion(rdata2, &r2);
351 result = isc_region_compare(&r1, &r2);
357 dns_rdata_casecompare(const dns_rdata_t *rdata1, const dns_rdata_t *rdata2) {
359 isc_boolean_t use_default = ISC_FALSE;
361 REQUIRE(rdata1 != NULL);
362 REQUIRE(rdata2 != NULL);
363 REQUIRE(rdata1->length == 0 || rdata1->data != NULL);
364 REQUIRE(rdata2->length == 0 || rdata2->data != NULL);
365 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata1));
366 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata2));
368 if (rdata1->rdclass != rdata2->rdclass)
369 return (rdata1->rdclass < rdata2->rdclass ? -1 : 1);
371 if (rdata1->type != rdata2->type)
372 return (rdata1->type < rdata2->type ? -1 : 1);
380 dns_rdata_toregion(rdata1, &r1);
381 dns_rdata_toregion(rdata2, &r2);
382 result = isc_region_compare(&r1, &r2);
392 dns_rdata_fromregion(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
393 dns_rdatatype_t type, isc_region_t *r)
396 REQUIRE(rdata != NULL);
397 REQUIRE(DNS_RDATA_INITIALIZED(rdata));
400 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
402 rdata->data = r->base;
403 rdata->length = r->length;
404 rdata->rdclass = rdclass;
410 dns_rdata_toregion(const dns_rdata_t *rdata, isc_region_t *r) {
412 REQUIRE(rdata != NULL);
414 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
416 r->base = rdata->data;
417 r->length = rdata->length;
421 dns_rdata_fromwire(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
422 dns_rdatatype_t type, isc_buffer_t *source,
423 dns_decompress_t *dctx, unsigned int options,
424 isc_buffer_t *target)
426 isc_result_t result = ISC_R_NOTIMPLEMENTED;
430 isc_boolean_t use_default = ISC_FALSE;
431 isc_uint32_t activelength;
434 REQUIRE(dctx != NULL);
436 REQUIRE(DNS_RDATA_INITIALIZED(rdata));
437 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
441 return (DNS_R_FORMERR);
446 activelength = isc_buffer_activelength(source);
447 INSIST(activelength < 65536);
452 if (activelength > isc_buffer_availablelength(target))
453 result = ISC_R_NOSPACE;
455 isc_buffer_putmem(target, isc_buffer_current(source),
457 isc_buffer_forward(source, activelength);
458 result = ISC_R_SUCCESS;
463 * Reject any rdata that expands out to more than DNS_RDATA_MAXLENGTH
464 * as we cannot transmit it.
466 length = isc_buffer_usedlength(target) - isc_buffer_usedlength(&st);
467 if (result == ISC_R_SUCCESS && length > DNS_RDATA_MAXLENGTH)
468 result = DNS_R_FORMERR;
471 * We should have consumed all of our buffer.
473 if (result == ISC_R_SUCCESS && !buffer_empty(source))
474 result = DNS_R_EXTRADATA;
476 if (rdata != NULL && result == ISC_R_SUCCESS) {
477 region.base = isc_buffer_used(&st);
478 region.length = length;
479 dns_rdata_fromregion(rdata, rdclass, type, ®ion);
482 if (result != ISC_R_SUCCESS) {
490 dns_rdata_towire(dns_rdata_t *rdata, dns_compress_t *cctx,
491 isc_buffer_t *target)
493 isc_result_t result = ISC_R_NOTIMPLEMENTED;
494 isc_boolean_t use_default = ISC_FALSE;
498 REQUIRE(rdata != NULL);
499 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
502 * Some DynDNS meta-RRs have empty rdata.
504 if ((rdata->flags & DNS_RDATA_UPDATE) != 0) {
505 INSIST(rdata->length == 0);
506 return (ISC_R_SUCCESS);
514 isc_buffer_availableregion(target, &tr);
515 if (tr.length < rdata->length)
516 return (ISC_R_NOSPACE);
517 memcpy(tr.base, rdata->data, rdata->length);
518 isc_buffer_add(target, rdata->length);
519 return (ISC_R_SUCCESS);
521 if (result != ISC_R_SUCCESS) {
523 INSIST(target->used < 65536);
524 dns_compress_rollback(cctx, (isc_uint16_t)target->used);
530 * If the binary data in 'src' is valid uncompressed wire format
531 * rdata of class 'rdclass' and type 'type', return ISC_R_SUCCESS
532 * and copy the validated rdata to 'dest'. Otherwise return an error.
535 rdata_validate(isc_buffer_t *src, isc_buffer_t *dest, dns_rdataclass_t rdclass,
536 dns_rdatatype_t type)
538 dns_decompress_t dctx;
539 dns_rdata_t rdata = DNS_RDATA_INIT;
542 dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_NONE);
543 isc_buffer_setactive(src, isc_buffer_usedlength(src));
544 result = dns_rdata_fromwire(&rdata, rdclass, type, src,
546 dns_decompress_invalidate(&dctx);
552 unknown_fromtext(dns_rdataclass_t rdclass, dns_rdatatype_t type,
553 isc_lex_t *lexer, isc_mem_t *mctx, isc_buffer_t *target)
556 isc_buffer_t *buf = NULL;
559 if (type == 0 || dns_rdatatype_ismeta(type))
560 return (DNS_R_METATYPE);
562 result = isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
564 if (result == ISC_R_SUCCESS && token.value.as_ulong > 65535U)
565 return (ISC_R_RANGE);
566 result = isc_buffer_allocate(mctx, &buf, token.value.as_ulong);
567 if (result != ISC_R_SUCCESS)
570 result = isc_hex_tobuffer(lexer, buf,
571 (unsigned int)token.value.as_ulong);
572 if (result != ISC_R_SUCCESS)
574 if (isc_buffer_usedlength(buf) != token.value.as_ulong) {
575 result = ISC_R_UNEXPECTEDEND;
579 if (dns_rdatatype_isknown(type)) {
580 result = rdata_validate(buf, target, rdclass, type);
583 isc_buffer_usedregion(buf, &r);
584 result = isc_buffer_copyregion(target, &r);
586 if (result != ISC_R_SUCCESS)
589 isc_buffer_free(&buf);
590 return (ISC_R_SUCCESS);
593 isc_buffer_free(&buf);
598 dns_rdata_fromtext(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
599 dns_rdatatype_t type, isc_lex_t *lexer,
600 dns_name_t *origin, unsigned int options, isc_mem_t *mctx,
601 isc_buffer_t *target, dns_rdatacallbacks_t *callbacks)
603 isc_result_t result = ISC_R_NOTIMPLEMENTED;
607 unsigned int lexoptions = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF |
608 ISC_LEXOPT_DNSMULTILINE | ISC_LEXOPT_ESCAPE;
611 void (*callback)(dns_rdatacallbacks_t *, const char *, ...);
612 isc_result_t tresult;
615 REQUIRE(origin == NULL || dns_name_isabsolute(origin) == ISC_TRUE);
617 REQUIRE(DNS_RDATA_INITIALIZED(rdata));
618 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
620 if (callbacks != NULL) {
621 REQUIRE(callbacks->warn != NULL);
622 REQUIRE(callbacks->error != NULL);
627 if (callbacks != NULL)
628 callback = callbacks->error;
630 callback = default_fromtext_callback;
632 result = isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring,
634 if (result != ISC_R_SUCCESS) {
635 name = isc_lex_getsourcename(lexer);
636 line = isc_lex_getsourceline(lexer);
637 fromtext_error(callback, callbacks, name, line, NULL, result);
641 if (strcmp(DNS_AS_STR(token), "\\#") == 0)
642 result = unknown_fromtext(rdclass, type, lexer, mctx, target);
644 isc_lex_ungettoken(lexer, &token);
650 * Consume to end of line / file.
651 * If not at end of line initially set error code.
652 * Call callback via fromtext_error once if there was an error.
655 name = isc_lex_getsourcename(lexer);
656 line = isc_lex_getsourceline(lexer);
657 tresult = isc_lex_gettoken(lexer, lexoptions, &token);
658 if (tresult != ISC_R_SUCCESS) {
659 if (result == ISC_R_SUCCESS)
661 if (callback != NULL)
662 fromtext_error(callback, callbacks, name,
665 } else if (token.type != isc_tokentype_eol &&
666 token.type != isc_tokentype_eof) {
667 if (result == ISC_R_SUCCESS)
668 result = DNS_R_EXTRATOKEN;
669 if (callback != NULL) {
670 fromtext_error(callback, callbacks, name,
671 line, &token, result);
674 } else if (result != ISC_R_SUCCESS && callback != NULL) {
675 fromtext_error(callback, callbacks, name, line,
679 if (token.type == isc_tokentype_eof)
680 fromtext_warneof(lexer, callbacks);
685 length = isc_buffer_usedlength(target) - isc_buffer_usedlength(&st);
686 if (result == ISC_R_SUCCESS && length > DNS_RDATA_MAXLENGTH)
687 result = ISC_R_NOSPACE;
689 if (rdata != NULL && result == ISC_R_SUCCESS) {
690 region.base = isc_buffer_used(&st);
691 region.length = length;
692 dns_rdata_fromregion(rdata, rdclass, type, ®ion);
694 if (result != ISC_R_SUCCESS) {
701 unknown_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
702 isc_buffer_t *target)
705 char buf[sizeof("65535")];
708 strlcpy(buf, "\\# ", sizeof(buf));
709 result = str_totext(buf, target);
710 if (result != ISC_R_SUCCESS)
713 dns_rdata_toregion(rdata, &sr);
714 INSIST(sr.length < 65536);
715 snprintf(buf, sizeof(buf), "%u", sr.length);
716 result = str_totext(buf, target);
717 if (result != ISC_R_SUCCESS)
720 if (sr.length != 0U) {
721 if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
722 result = str_totext(" ( ", target);
724 result = str_totext(" ", target);
726 if (result != ISC_R_SUCCESS)
729 if (tctx->width == 0) /* No splitting */
730 result = isc_hex_totext(&sr, 0, "", target);
732 result = isc_hex_totext(&sr, tctx->width - 2,
735 if (result == ISC_R_SUCCESS &&
736 (tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
737 result = str_totext(" )", target);
743 rdata_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
744 isc_buffer_t *target)
746 isc_result_t result = ISC_R_NOTIMPLEMENTED;
747 isc_boolean_t use_default = ISC_FALSE;
749 REQUIRE(rdata != NULL);
750 REQUIRE(tctx->origin == NULL ||
751 dns_name_isabsolute(tctx->origin) == ISC_TRUE);
754 * Some DynDNS meta-RRs have empty rdata.
756 if ((rdata->flags & DNS_RDATA_UPDATE) != 0) {
757 INSIST(rdata->length == 0);
758 return (ISC_R_SUCCESS);
764 result = unknown_totext(rdata, tctx, target);
770 dns_rdata_totext(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target)
772 dns_rdata_textctx_t tctx;
774 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
777 * Set up formatting options for single-line output.
779 tctx.origin = origin;
782 tctx.linebreak = " ";
783 return (rdata_totext(rdata, &tctx, target));
787 dns_rdata_tofmttext(dns_rdata_t *rdata, dns_name_t *origin,
788 unsigned int flags, unsigned int width,
789 const char *linebreak, isc_buffer_t *target)
791 dns_rdata_textctx_t tctx;
793 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
796 * Set up formatting options for formatted output.
798 tctx.origin = origin;
800 if ((flags & DNS_STYLEFLAG_MULTILINE) != 0) {
802 tctx.linebreak = linebreak;
804 tctx.width = 60; /* Used for hex word length only. */
805 tctx.linebreak = " ";
807 return (rdata_totext(rdata, &tctx, target));
811 dns_rdata_fromstruct(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
812 dns_rdatatype_t type, void *source,
813 isc_buffer_t *target)
815 isc_result_t result = ISC_R_NOTIMPLEMENTED;
818 isc_boolean_t use_default = ISC_FALSE;
821 REQUIRE(source != NULL);
823 REQUIRE(DNS_RDATA_INITIALIZED(rdata));
824 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
834 length = isc_buffer_usedlength(target) - isc_buffer_usedlength(&st);
835 if (result == ISC_R_SUCCESS && length > DNS_RDATA_MAXLENGTH)
836 result = ISC_R_NOSPACE;
838 if (rdata != NULL && result == ISC_R_SUCCESS) {
839 region.base = isc_buffer_used(&st);
840 region.length = length;
841 dns_rdata_fromregion(rdata, rdclass, type, ®ion);
843 if (result != ISC_R_SUCCESS)
849 dns_rdata_tostruct(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) {
850 isc_result_t result = ISC_R_NOTIMPLEMENTED;
851 isc_boolean_t use_default = ISC_FALSE;
853 REQUIRE(rdata != NULL);
854 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
865 dns_rdata_freestruct(void *source) {
866 dns_rdatacommon_t *common = source;
867 REQUIRE(source != NULL);
873 dns_rdata_additionaldata(dns_rdata_t *rdata, dns_additionaldatafunc_t add,
876 isc_result_t result = ISC_R_NOTIMPLEMENTED;
877 isc_boolean_t use_default = ISC_FALSE;
880 * Call 'add' for each name and type from 'rdata' which is subject to
881 * additional section processing.
884 REQUIRE(rdata != NULL);
885 REQUIRE(add != NULL);
886 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
890 /* No additional processing for unknown types */
892 result = ISC_R_SUCCESS;
898 dns_rdata_digest(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) {
899 isc_result_t result = ISC_R_NOTIMPLEMENTED;
900 isc_boolean_t use_default = ISC_FALSE;
904 * Send 'rdata' in DNSSEC canonical form to 'digest'.
907 REQUIRE(rdata != NULL);
908 REQUIRE(digest != NULL);
909 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
914 dns_rdata_toregion(rdata, &r);
915 result = (digest)(arg, &r);
922 dns_rdata_checkowner(dns_name_t *name, dns_rdataclass_t rdclass,
923 dns_rdatatype_t type, isc_boolean_t wildcard)
925 isc_boolean_t result;
932 dns_rdata_checknames(dns_rdata_t *rdata, dns_name_t *owner, dns_name_t *bad)
934 isc_boolean_t result;
941 dns_rdatatype_attributes(dns_rdatatype_t type)
943 RDATATYPE_ATTRIBUTE_SW
944 if (type >= (dns_rdatatype_t)128 && type < (dns_rdatatype_t)255)
945 return (DNS_RDATATYPEATTR_UNKNOWN | DNS_RDATATYPEATTR_META);
946 return (DNS_RDATATYPEATTR_UNKNOWN);
950 dns_rdatatype_fromtext(dns_rdatatype_t *typep, isc_textregion_t *source) {
958 return (DNS_R_UNKNOWN);
960 a = tolower((unsigned char)source->base[0]);
961 b = tolower((unsigned char)source->base[n - 1]);
963 hash = ((a + n) * b) % 256;
966 * This switch block is inlined via \#define, and will use "return"
967 * to return a result to the caller if it is a valid (known)
970 RDATATYPE_FROMTEXT_SW(hash, source->base, n, typep);
972 if (source->length > 4 && source->length < (4 + sizeof("65000")) &&
973 strncasecmp("type", source->base, 4) == 0) {
974 char buf[sizeof("65000")];
978 strncpy(buf, source->base + 4, source->length - 4);
979 buf[source->length - 4] = '\0';
980 val = strtoul(buf, &endp, 10);
981 if (*endp == '\0' && val <= 0xffff) {
982 *typep = (dns_rdatatype_t)val;
983 return (ISC_R_SUCCESS);
987 return (DNS_R_UNKNOWN);
991 dns_rdatatype_totext(dns_rdatatype_t type, isc_buffer_t *target) {
992 char buf[sizeof("TYPE65535")];
995 snprintf(buf, sizeof(buf), "TYPE%u", type);
996 return (str_totext(buf, target));
1000 dns_rdatatype_format(dns_rdatatype_t rdtype,
1001 char *array, unsigned int size)
1003 isc_result_t result;
1009 isc_buffer_init(&buf, array, size);
1010 result = dns_rdatatype_totext(rdtype, &buf);
1014 if (result == ISC_R_SUCCESS) {
1015 if (isc_buffer_availablelength(&buf) >= 1)
1016 isc_buffer_putuint8(&buf, 0);
1018 result = ISC_R_NOSPACE;
1020 if (result != ISC_R_SUCCESS)
1021 strlcpy(array, "<unknown>", size);
1029 name_length(dns_name_t *name) {
1030 return (name->length);
1034 txt_totext(isc_region_t *source, isc_buffer_t *target) {
1039 isc_region_t region;
1041 isc_buffer_availableregion(target, ®ion);
1043 tp = (char *)region.base;
1048 REQUIRE(n + 1 <= source->length);
1051 return (ISC_R_NOSPACE);
1055 if (*sp < 0x20 || *sp >= 0x7f) {
1057 return (ISC_R_NOSPACE);
1059 *tp++ = 0x30 + ((*sp / 100) % 10);
1060 *tp++ = 0x30 + ((*sp / 10) % 10);
1061 *tp++ = 0x30 + (*sp % 10);
1066 /* double quote, semi-colon, backslash */
1067 if (*sp == 0x22 || *sp == 0x3b || *sp == 0x5c) {
1069 return (ISC_R_NOSPACE);
1074 return (ISC_R_NOSPACE);
1079 return (ISC_R_NOSPACE);
1082 isc_buffer_add(target, tp - (char *)region.base);
1083 isc_region_consume(source, *source->base + 1);
1084 return (ISC_R_SUCCESS);
1088 txt_fromtext(isc_textregion_t *source, isc_buffer_t *target) {
1089 isc_region_t tregion;
1090 isc_boolean_t escape;
1091 unsigned int n, nrem;
1097 isc_buffer_availableregion(target, &tregion);
1101 nrem = tregion.length;
1104 return (ISC_R_NOSPACE);
1111 * Maximum text string length.
1117 if (escape && (d = decvalue((char)c)) != -1) {
1120 return (DNS_R_SYNTAX);
1122 if ((d = decvalue(*s++)) != -1)
1125 return (DNS_R_SYNTAX);
1127 return (DNS_R_SYNTAX);
1129 if ((d = decvalue(*s++)) != -1)
1132 return (DNS_R_SYNTAX);
1134 return (DNS_R_SYNTAX);
1135 } else if (!escape && c == '\\') {
1141 return ((tregion.length <= 256U) ?
1142 ISC_R_NOSPACE : DNS_R_SYNTAX);
1147 return (DNS_R_SYNTAX);
1148 *tregion.base = t - tregion.base - 1;
1149 isc_buffer_add(target, *tregion.base + 1);
1150 return (ISC_R_SUCCESS);
1154 txt_fromwire(isc_buffer_t *source, isc_buffer_t *target) {
1156 isc_region_t sregion;
1157 isc_region_t tregion;
1159 isc_buffer_activeregion(source, &sregion);
1160 if (sregion.length == 0)
1161 return(ISC_R_UNEXPECTEDEND);
1162 n = *sregion.base + 1;
1163 if (n > sregion.length)
1164 return (ISC_R_UNEXPECTEDEND);
1166 isc_buffer_availableregion(target, &tregion);
1167 if (n > tregion.length)
1168 return (ISC_R_NOSPACE);
1170 memcpy(tregion.base, sregion.base, n);
1171 isc_buffer_forward(source, n);
1172 isc_buffer_add(target, n);
1173 return (ISC_R_SUCCESS);
1176 static isc_boolean_t
1177 name_prefix(dns_name_t *name, dns_name_t *origin, dns_name_t *target) {
1183 if (dns_name_compare(origin, dns_rootname) == 0)
1186 if (!dns_name_issubdomain(name, origin))
1189 l1 = dns_name_countlabels(name);
1190 l2 = dns_name_countlabels(origin);
1195 /* Master files should be case preserving. */
1196 dns_name_getlabelsequence(name, l1 - l2, l2, target);
1197 if (!dns_name_caseequal(origin, target))
1200 dns_name_getlabelsequence(name, 0, l1 - l2, target);
1209 str_totext(const char *source, isc_buffer_t *target) {
1211 isc_region_t region;
1213 isc_buffer_availableregion(target, ®ion);
1216 if (l > region.length)
1217 return (ISC_R_NOSPACE);
1219 memcpy(region.base, source, l);
1220 isc_buffer_add(target, l);
1221 return (ISC_R_SUCCESS);
1225 inet_totext(int af, isc_region_t *src, isc_buffer_t *target) {
1228 /* Note - inet_ntop doesn't do size checking on its input. */
1229 if (inet_ntop(af, src->base, tmpbuf, sizeof(tmpbuf)) == NULL)
1230 return (ISC_R_NOSPACE);
1231 if (strlen(tmpbuf) > isc_buffer_availablelength(target))
1232 return (ISC_R_NOSPACE);
1233 isc_buffer_putstr(target, tmpbuf);
1234 return (ISC_R_SUCCESS);
1237 static isc_boolean_t
1238 buffer_empty(isc_buffer_t *source) {
1239 return((source->current == source->active) ? ISC_TRUE : ISC_FALSE);
1243 buffer_fromregion(isc_buffer_t *buffer, isc_region_t *region) {
1244 isc_buffer_init(buffer, region->base, region->length);
1245 isc_buffer_add(buffer, region->length);
1246 isc_buffer_setactive(buffer, region->length);
1250 uint32_tobuffer(isc_uint32_t value, isc_buffer_t *target) {
1251 isc_region_t region;
1253 isc_buffer_availableregion(target, ®ion);
1254 if (region.length < 4)
1255 return (ISC_R_NOSPACE);
1256 isc_buffer_putuint32(target, value);
1257 return (ISC_R_SUCCESS);
1261 uint16_tobuffer(isc_uint32_t value, isc_buffer_t *target) {
1262 isc_region_t region;
1265 return (ISC_R_RANGE);
1266 isc_buffer_availableregion(target, ®ion);
1267 if (region.length < 2)
1268 return (ISC_R_NOSPACE);
1269 isc_buffer_putuint16(target, (isc_uint16_t)value);
1270 return (ISC_R_SUCCESS);
1274 uint8_tobuffer(isc_uint32_t value, isc_buffer_t *target) {
1275 isc_region_t region;
1278 return (ISC_R_RANGE);
1279 isc_buffer_availableregion(target, ®ion);
1280 if (region.length < 1)
1281 return (ISC_R_NOSPACE);
1282 isc_buffer_putuint8(target, (isc_uint8_t)value);
1283 return (ISC_R_SUCCESS);
1287 name_tobuffer(dns_name_t *name, isc_buffer_t *target) {
1289 dns_name_toregion(name, &r);
1290 return (isc_buffer_copyregion(target, &r));
1294 uint32_fromregion(isc_region_t *region) {
1297 REQUIRE(region->length >= 4);
1298 value = region->base[0] << 24;
1299 value |= region->base[1] << 16;
1300 value |= region->base[2] << 8;
1301 value |= region->base[3];
1306 uint16_consume_fromregion(isc_region_t *region) {
1307 isc_uint16_t r = uint16_fromregion(region);
1309 isc_region_consume(region, 2);
1314 uint16_fromregion(isc_region_t *region) {
1316 REQUIRE(region->length >= 2);
1318 return ((region->base[0] << 8) | region->base[1]);
1322 uint8_fromregion(isc_region_t *region) {
1324 REQUIRE(region->length >= 1);
1326 return (region->base[0]);
1330 uint8_consume_fromregion(isc_region_t *region) {
1331 isc_uint8_t r = uint8_fromregion(region);
1333 isc_region_consume(region, 1);
1338 mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length) {
1341 isc_buffer_availableregion(target, &tr);
1342 if (length > tr.length)
1343 return (ISC_R_NOSPACE);
1344 memcpy(tr.base, base, length);
1345 isc_buffer_add(target, length);
1346 return (ISC_R_SUCCESS);
1350 hexvalue(char value) {
1354 c = (unsigned char)value;
1360 if ((s = strchr(hexdigits, c)) == NULL)
1362 return (s - hexdigits);
1366 decvalue(char value) {
1370 * isascii() is valid for full range of int values, no need to
1373 if (!isascii(value))
1375 if ((s = strchr(decdigits, value)) == NULL)
1377 return (s - decdigits);
1380 static const char atob_digits[86] =
1381 "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`" \
1382 "abcdefghijklmnopqrstu";
1384 * Subroutines to convert between 8 bit binary bytes and printable ASCII.
1385 * Computes the number of bytes, and three kinds of simple checksums.
1386 * Incoming bytes are collected into 32-bit words, then printed in base 85:
1387 * exp(85,5) > exp(2,32)
1388 * The ASCII characters used are between '!' and 'u';
1389 * 'z' encodes 32-bit zero; 'x' is used to mark the end of encoded data.
1391 * Originally by Paul Rutter (philabs!per) and Joe Orost (petsd!joe) for
1392 * the atob/btoa programs, released with the compress program, in mod.sources.
1393 * Modified by Mike Schwartz 8/19/86 for use in BIND.
1394 * Modified to be re-entrant 3/2/99.
1406 #define Ceor state->Ceor
1407 #define Csum state->Csum
1408 #define Crot state->Crot
1409 #define word state->word
1410 #define bcount state->bcount
1412 #define times85(x) ((((((x<<2)+x)<<2)+x)<<2)+x)
1414 static isc_result_t byte_atob(int c, isc_buffer_t *target,
1415 struct state *state);
1416 static isc_result_t putbyte(int c, isc_buffer_t *, struct state *state);
1417 static isc_result_t byte_btoa(int c, isc_buffer_t *, struct state *state);
1420 * Decode ASCII-encoded byte c into binary representation and
1421 * place into *bufp, advancing bufp.
1424 byte_atob(int c, isc_buffer_t *target, struct state *state) {
1428 return(DNS_R_SYNTAX);
1430 RETERR(putbyte(0, target, state));
1431 RETERR(putbyte(0, target, state));
1432 RETERR(putbyte(0, target, state));
1433 RETERR(putbyte(0, target, state));
1435 } else if ((s = strchr(atob_digits, c)) != NULL) {
1437 word = s - atob_digits;
1439 } else if (bcount < 4) {
1440 word = times85(word);
1441 word += s - atob_digits;
1444 word = times85(word);
1445 word += s - atob_digits;
1446 RETERR(putbyte((word >> 24) & 0xff, target, state));
1447 RETERR(putbyte((word >> 16) & 0xff, target, state));
1448 RETERR(putbyte((word >> 8) & 0xff, target, state));
1449 RETERR(putbyte(word & 0xff, target, state));
1454 return(DNS_R_SYNTAX);
1455 return(ISC_R_SUCCESS);
1459 * Compute checksum info and place c into target.
1462 putbyte(int c, isc_buffer_t *target, struct state *state) {
1468 if ((Crot & 0x80000000)) {
1475 isc_buffer_availableregion(target, &tr);
1477 return (ISC_R_NOSPACE);
1479 isc_buffer_add(target, 1);
1480 return (ISC_R_SUCCESS);
1484 * Read the ASCII-encoded data from inbuf, of length inbuflen, and convert
1485 * it into T_UNSPEC (binary data) in outbuf, not to exceed outbuflen bytes;
1486 * outbuflen must be divisible by 4. (Note: this is because outbuf is filled
1487 * in 4 bytes at a time. If the actual data doesn't end on an even 4-byte
1488 * boundary, there will be no problem...it will be padded with 0 bytes, and
1489 * numbytes will indicate the correct number of bytes. The main point is
1490 * that since the buffer is filled in 4 bytes at a time, even if there is
1491 * not a full 4 bytes of data at the end, there has to be room to 0-pad the
1492 * data, so the buffer must be of size divisible by 4). Place the number of
1493 * output bytes in numbytes, and return a failure/success status.
1497 atob_tobuffer(isc_lex_t *lexer, isc_buffer_t *target) {
1498 long oeor, osum, orot;
1499 struct state statebuf, *state= &statebuf;
1504 Ceor = Csum = Crot = word = bcount = 0;
1506 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
1508 while (token.value.as_textregion.length != 0) {
1509 if ((c = token.value.as_textregion.base[0]) == 'x') {
1512 RETERR(byte_atob(c, target, state));
1513 isc_textregion_consume(&token.value.as_textregion, 1);
1519 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
1521 if ((token.value.as_ulong % 4) != 0U)
1522 isc_buffer_subtract(target, 4 - (token.value.as_ulong % 4));
1527 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
1529 oeor = strtol(DNS_AS_STR(token), &e, 16);
1531 return (DNS_R_SYNTAX);
1536 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
1538 osum = strtol(DNS_AS_STR(token), &e, 16);
1540 return (DNS_R_SYNTAX);
1545 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
1547 orot = strtol(DNS_AS_STR(token), &e, 16);
1549 return (DNS_R_SYNTAX);
1551 if ((oeor != Ceor) || (osum != Csum) || (orot != Crot))
1552 return(DNS_R_BADCKSUM);
1553 return (ISC_R_SUCCESS);
1557 * Encode binary byte c into ASCII representation and place into *bufp,
1561 byte_btoa(int c, isc_buffer_t *target, struct state *state) {
1564 isc_buffer_availableregion(target, &tr);
1568 if ((Crot & 0x80000000)) {
1581 return (ISC_R_NOSPACE);
1583 isc_buffer_add(target, 1);
1585 register int tmp = 0;
1586 register isc_int32_t tmpword = word;
1590 * Because some don't support u_long.
1593 tmpword -= (isc_int32_t)(85 * 85 * 85 * 85 * 32);
1597 tmpword -= (isc_int32_t)(85 * 85 * 85 * 85 * 32);
1600 return (ISC_R_NOSPACE);
1601 tr.base[0] = atob_digits[(tmpword /
1602 (isc_int32_t)(85 * 85 * 85 * 85))
1604 tmpword %= (isc_int32_t)(85 * 85 * 85 * 85);
1605 tr.base[1] = atob_digits[tmpword / (85 * 85 * 85)];
1606 tmpword %= (85 * 85 * 85);
1607 tr.base[2] = atob_digits[tmpword / (85 * 85)];
1608 tmpword %= (85 * 85);
1609 tr.base[3] = atob_digits[tmpword / 85];
1611 tr.base[4] = atob_digits[tmpword];
1612 isc_buffer_add(target, 5);
1618 return (ISC_R_SUCCESS);
1623 * Encode the binary data from inbuf, of length inbuflen, into a
1624 * target. Return success/failure status
1627 btoa_totext(unsigned char *inbuf, int inbuflen, isc_buffer_t *target) {
1629 struct state statebuf, *state = &statebuf;
1630 char buf[sizeof("x 2000000000 ffffffff ffffffff ffffffff")];
1632 Ceor = Csum = Crot = word = bcount = 0;
1633 for (inc = 0; inc < inbuflen; inbuf++, inc++)
1634 RETERR(byte_btoa(*inbuf, target, state));
1637 RETERR(byte_btoa(0, target, state));
1640 * Put byte count and checksum information at end of buffer,
1643 snprintf(buf, sizeof(buf), "x %d %x %x %x", inbuflen, Ceor, Csum, Crot);
1644 return (str_totext(buf, target));
1649 default_fromtext_callback(dns_rdatacallbacks_t *callbacks, const char *fmt,
1657 vfprintf(stderr, fmt, ap);
1659 fprintf(stderr, "\n");
1663 fromtext_warneof(isc_lex_t *lexer, dns_rdatacallbacks_t *callbacks) {
1664 if (isc_lex_isfile(lexer) && callbacks != NULL) {
1665 const char *name = isc_lex_getsourcename(lexer);
1668 (*callbacks->warn)(callbacks,
1669 "%s:%lu: file does not end with newline",
1670 name, isc_lex_getsourceline(lexer));
1675 warn_badmx(isc_token_t *token, isc_lex_t *lexer,
1676 dns_rdatacallbacks_t *callbacks)
1681 if (lexer != NULL) {
1682 file = isc_lex_getsourcename(lexer);
1683 line = isc_lex_getsourceline(lexer);
1684 (*callbacks->warn)(callbacks, "%s:%u: warning: '%s': %s",
1685 file, line, DNS_AS_STR(*token),
1686 dns_result_totext(DNS_R_MXISADDRESS));
1691 warn_badname(dns_name_t *name, isc_lex_t *lexer,
1692 dns_rdatacallbacks_t *callbacks)
1696 char namebuf[DNS_NAME_FORMATSIZE];
1698 if (lexer != NULL) {
1699 file = isc_lex_getsourcename(lexer);
1700 line = isc_lex_getsourceline(lexer);
1701 dns_name_format(name, namebuf, sizeof(namebuf));
1702 (*callbacks->warn)(callbacks, "%s:%u: warning: %s: %s",
1703 file, line, namebuf,
1704 dns_result_totext(DNS_R_BADNAME));
1709 fromtext_error(void (*callback)(dns_rdatacallbacks_t *, const char *, ...),
1710 dns_rdatacallbacks_t *callbacks, const char *name,
1711 unsigned long line, isc_token_t *token, isc_result_t result)
1716 if (token != NULL) {
1717 switch (token->type) {
1718 case isc_tokentype_eol:
1719 (*callback)(callbacks, "%s: %s:%lu: near eol: %s",
1720 "dns_rdata_fromtext", name, line,
1721 dns_result_totext(result));
1723 case isc_tokentype_eof:
1724 (*callback)(callbacks, "%s: %s:%lu: near eof: %s",
1725 "dns_rdata_fromtext", name, line,
1726 dns_result_totext(result));
1728 case isc_tokentype_number:
1729 (*callback)(callbacks, "%s: %s:%lu: near %lu: %s",
1730 "dns_rdata_fromtext", name, line,
1731 token->value.as_ulong,
1732 dns_result_totext(result));
1734 case isc_tokentype_string:
1735 case isc_tokentype_qstring:
1736 (*callback)(callbacks, "%s: %s:%lu: near '%s': %s",
1737 "dns_rdata_fromtext", name, line,
1739 dns_result_totext(result));
1742 (*callback)(callbacks, "%s: %s:%lu: %s",
1743 "dns_rdata_fromtext", name, line,
1744 dns_result_totext(result));
1748 (*callback)(callbacks, "dns_rdata_fromtext: %s:%lu: %s",
1749 name, line, dns_result_totext(result));
1754 dns_rdata_covers(dns_rdata_t *rdata) {
1755 if (rdata->type == 46)
1756 return (covers_rrsig(rdata));
1757 return (covers_sig(rdata));
1761 dns_rdatatype_ismeta(dns_rdatatype_t type) {
1762 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_META) != 0)
1768 dns_rdatatype_issingleton(dns_rdatatype_t type) {
1769 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_SINGLETON)
1776 dns_rdatatype_notquestion(dns_rdatatype_t type) {
1777 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_NOTQUESTION)
1784 dns_rdatatype_questiononly(dns_rdatatype_t type) {
1785 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_QUESTIONONLY)
1792 dns_rdatatype_atparent(dns_rdatatype_t type) {
1793 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_ATPARENT) != 0)
1799 dns_rdataclass_ismeta(dns_rdataclass_t rdclass) {
1801 if (rdclass == dns_rdataclass_reserved0
1802 || rdclass == dns_rdataclass_none
1803 || rdclass == dns_rdataclass_any)
1806 return (ISC_FALSE); /* Assume it is not a meta class. */
1810 dns_rdatatype_isdnssec(dns_rdatatype_t type) {
1811 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_DNSSEC) != 0)
1817 dns_rdatatype_iszonecutauth(dns_rdatatype_t type) {
1818 if ((dns_rdatatype_attributes(type)
1819 & (DNS_RDATATYPEATTR_DNSSEC | DNS_RDATATYPEATTR_ZONECUTAUTH))
1826 dns_rdatatype_isknown(dns_rdatatype_t type) {
1827 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_UNKNOWN)
1834 dns_rdata_exists(dns_rdata_t *rdata, dns_rdatatype_t type) {
1836 REQUIRE(rdata != NULL);
1837 REQUIRE(DNS_RDATA_INITIALIZED(rdata));
1841 rdata->flags = DNS_RDATA_UPDATE;
1843 rdata->rdclass = dns_rdataclass_any;
1847 dns_rdata_notexist(dns_rdata_t *rdata, dns_rdatatype_t type) {
1849 REQUIRE(rdata != NULL);
1850 REQUIRE(DNS_RDATA_INITIALIZED(rdata));
1854 rdata->flags = DNS_RDATA_UPDATE;
1856 rdata->rdclass = dns_rdataclass_none;
1860 dns_rdata_deleterrset(dns_rdata_t *rdata, dns_rdatatype_t type) {
1862 REQUIRE(rdata != NULL);
1863 REQUIRE(DNS_RDATA_INITIALIZED(rdata));
1867 rdata->flags = DNS_RDATA_UPDATE;
1869 rdata->rdclass = dns_rdataclass_any;
1873 dns_rdata_makedelete(dns_rdata_t *rdata) {
1874 REQUIRE(rdata != NULL);
1876 rdata->rdclass = dns_rdataclass_none;
1880 dns_rdata_updateop(dns_rdata_t *rdata, dns_section_t section) {
1882 REQUIRE(rdata != NULL);
1883 REQUIRE(DNS_RDATA_INITIALIZED(rdata));
1886 case DNS_SECTION_PREREQUISITE:
1887 switch (rdata->rdclass) {
1888 case dns_rdataclass_none:
1889 switch (rdata->type) {
1890 case dns_rdatatype_any:
1891 return ("domain doesn't exist");
1893 return ("rrset doesn't exist");
1895 case dns_rdataclass_any:
1896 switch (rdata->type) {
1897 case dns_rdatatype_any:
1898 return ("domain exists");
1900 return ("rrset exists (value independent)");
1903 return ("rrset exists (value dependent)");
1905 case DNS_SECTION_UPDATE:
1906 switch (rdata->rdclass) {
1907 case dns_rdataclass_none:
1909 case dns_rdataclass_any:
1910 switch (rdata->type) {
1911 case dns_rdatatype_any:
1912 return ("delete all rrsets");
1914 return ("delete rrset");