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));
439 REQUIRE(source != NULL);
440 REQUIRE(target != NULL);
443 return (DNS_R_FORMERR);
448 activelength = isc_buffer_activelength(source);
449 INSIST(activelength < 65536);
454 if (activelength > isc_buffer_availablelength(target))
455 result = ISC_R_NOSPACE;
457 isc_buffer_putmem(target, isc_buffer_current(source),
459 isc_buffer_forward(source, activelength);
460 result = ISC_R_SUCCESS;
465 * Reject any rdata that expands out to more than DNS_RDATA_MAXLENGTH
466 * as we cannot transmit it.
468 length = isc_buffer_usedlength(target) - isc_buffer_usedlength(&st);
469 if (result == ISC_R_SUCCESS && length > DNS_RDATA_MAXLENGTH)
470 result = DNS_R_FORMERR;
473 * We should have consumed all of our buffer.
475 if (result == ISC_R_SUCCESS && !buffer_empty(source))
476 result = DNS_R_EXTRADATA;
478 if (rdata != NULL && result == ISC_R_SUCCESS) {
479 region.base = isc_buffer_used(&st);
480 region.length = length;
481 dns_rdata_fromregion(rdata, rdclass, type, ®ion);
484 if (result != ISC_R_SUCCESS) {
492 dns_rdata_towire(dns_rdata_t *rdata, dns_compress_t *cctx,
493 isc_buffer_t *target)
495 isc_result_t result = ISC_R_NOTIMPLEMENTED;
496 isc_boolean_t use_default = ISC_FALSE;
500 REQUIRE(rdata != NULL);
501 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
504 * Some DynDNS meta-RRs have empty rdata.
506 if ((rdata->flags & DNS_RDATA_UPDATE) != 0) {
507 INSIST(rdata->length == 0);
508 return (ISC_R_SUCCESS);
516 isc_buffer_availableregion(target, &tr);
517 if (tr.length < rdata->length)
518 return (ISC_R_NOSPACE);
519 memcpy(tr.base, rdata->data, rdata->length);
520 isc_buffer_add(target, rdata->length);
521 return (ISC_R_SUCCESS);
523 if (result != ISC_R_SUCCESS) {
525 INSIST(target->used < 65536);
526 dns_compress_rollback(cctx, (isc_uint16_t)target->used);
532 * If the binary data in 'src' is valid uncompressed wire format
533 * rdata of class 'rdclass' and type 'type', return ISC_R_SUCCESS
534 * and copy the validated rdata to 'dest'. Otherwise return an error.
537 rdata_validate(isc_buffer_t *src, isc_buffer_t *dest, dns_rdataclass_t rdclass,
538 dns_rdatatype_t type)
540 dns_decompress_t dctx;
543 dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_NONE);
544 isc_buffer_setactive(src, isc_buffer_usedlength(src));
545 result = dns_rdata_fromwire(NULL, rdclass, type, src, &dctx, 0, dest);
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 if (tregion.base != sregion.base)
1171 memcpy(tregion.base, sregion.base, n);
1172 isc_buffer_forward(source, n);
1173 isc_buffer_add(target, n);
1174 return (ISC_R_SUCCESS);
1177 static isc_boolean_t
1178 name_prefix(dns_name_t *name, dns_name_t *origin, dns_name_t *target) {
1184 if (dns_name_compare(origin, dns_rootname) == 0)
1187 if (!dns_name_issubdomain(name, origin))
1190 l1 = dns_name_countlabels(name);
1191 l2 = dns_name_countlabels(origin);
1196 /* Master files should be case preserving. */
1197 dns_name_getlabelsequence(name, l1 - l2, l2, target);
1198 if (!dns_name_caseequal(origin, target))
1201 dns_name_getlabelsequence(name, 0, l1 - l2, target);
1210 str_totext(const char *source, isc_buffer_t *target) {
1212 isc_region_t region;
1214 isc_buffer_availableregion(target, ®ion);
1217 if (l > region.length)
1218 return (ISC_R_NOSPACE);
1220 memcpy(region.base, source, l);
1221 isc_buffer_add(target, l);
1222 return (ISC_R_SUCCESS);
1226 inet_totext(int af, isc_region_t *src, isc_buffer_t *target) {
1229 /* Note - inet_ntop doesn't do size checking on its input. */
1230 if (inet_ntop(af, src->base, tmpbuf, sizeof(tmpbuf)) == NULL)
1231 return (ISC_R_NOSPACE);
1232 if (strlen(tmpbuf) > isc_buffer_availablelength(target))
1233 return (ISC_R_NOSPACE);
1234 isc_buffer_putstr(target, tmpbuf);
1235 return (ISC_R_SUCCESS);
1238 static isc_boolean_t
1239 buffer_empty(isc_buffer_t *source) {
1240 return((source->current == source->active) ? ISC_TRUE : ISC_FALSE);
1244 buffer_fromregion(isc_buffer_t *buffer, isc_region_t *region) {
1245 isc_buffer_init(buffer, region->base, region->length);
1246 isc_buffer_add(buffer, region->length);
1247 isc_buffer_setactive(buffer, region->length);
1251 uint32_tobuffer(isc_uint32_t value, isc_buffer_t *target) {
1252 isc_region_t region;
1254 isc_buffer_availableregion(target, ®ion);
1255 if (region.length < 4)
1256 return (ISC_R_NOSPACE);
1257 isc_buffer_putuint32(target, value);
1258 return (ISC_R_SUCCESS);
1262 uint16_tobuffer(isc_uint32_t value, isc_buffer_t *target) {
1263 isc_region_t region;
1266 return (ISC_R_RANGE);
1267 isc_buffer_availableregion(target, ®ion);
1268 if (region.length < 2)
1269 return (ISC_R_NOSPACE);
1270 isc_buffer_putuint16(target, (isc_uint16_t)value);
1271 return (ISC_R_SUCCESS);
1275 uint8_tobuffer(isc_uint32_t value, isc_buffer_t *target) {
1276 isc_region_t region;
1279 return (ISC_R_RANGE);
1280 isc_buffer_availableregion(target, ®ion);
1281 if (region.length < 1)
1282 return (ISC_R_NOSPACE);
1283 isc_buffer_putuint8(target, (isc_uint8_t)value);
1284 return (ISC_R_SUCCESS);
1288 name_tobuffer(dns_name_t *name, isc_buffer_t *target) {
1290 dns_name_toregion(name, &r);
1291 return (isc_buffer_copyregion(target, &r));
1295 uint32_fromregion(isc_region_t *region) {
1298 REQUIRE(region->length >= 4);
1299 value = region->base[0] << 24;
1300 value |= region->base[1] << 16;
1301 value |= region->base[2] << 8;
1302 value |= region->base[3];
1307 uint16_consume_fromregion(isc_region_t *region) {
1308 isc_uint16_t r = uint16_fromregion(region);
1310 isc_region_consume(region, 2);
1315 uint16_fromregion(isc_region_t *region) {
1317 REQUIRE(region->length >= 2);
1319 return ((region->base[0] << 8) | region->base[1]);
1323 uint8_fromregion(isc_region_t *region) {
1325 REQUIRE(region->length >= 1);
1327 return (region->base[0]);
1331 uint8_consume_fromregion(isc_region_t *region) {
1332 isc_uint8_t r = uint8_fromregion(region);
1334 isc_region_consume(region, 1);
1339 mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length) {
1342 isc_buffer_availableregion(target, &tr);
1343 if (length > tr.length)
1344 return (ISC_R_NOSPACE);
1345 if (tr.base != base)
1346 memcpy(tr.base, base, length);
1347 isc_buffer_add(target, length);
1348 return (ISC_R_SUCCESS);
1352 hexvalue(char value) {
1356 c = (unsigned char)value;
1362 if ((s = strchr(hexdigits, c)) == NULL)
1364 return (s - hexdigits);
1368 decvalue(char value) {
1372 * isascii() is valid for full range of int values, no need to
1375 if (!isascii(value))
1377 if ((s = strchr(decdigits, value)) == NULL)
1379 return (s - decdigits);
1382 static const char atob_digits[86] =
1383 "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`" \
1384 "abcdefghijklmnopqrstu";
1386 * Subroutines to convert between 8 bit binary bytes and printable ASCII.
1387 * Computes the number of bytes, and three kinds of simple checksums.
1388 * Incoming bytes are collected into 32-bit words, then printed in base 85:
1389 * exp(85,5) > exp(2,32)
1390 * The ASCII characters used are between '!' and 'u';
1391 * 'z' encodes 32-bit zero; 'x' is used to mark the end of encoded data.
1393 * Originally by Paul Rutter (philabs!per) and Joe Orost (petsd!joe) for
1394 * the atob/btoa programs, released with the compress program, in mod.sources.
1395 * Modified by Mike Schwartz 8/19/86 for use in BIND.
1396 * Modified to be re-entrant 3/2/99.
1408 #define Ceor state->Ceor
1409 #define Csum state->Csum
1410 #define Crot state->Crot
1411 #define word state->word
1412 #define bcount state->bcount
1414 #define times85(x) ((((((x<<2)+x)<<2)+x)<<2)+x)
1416 static isc_result_t byte_atob(int c, isc_buffer_t *target,
1417 struct state *state);
1418 static isc_result_t putbyte(int c, isc_buffer_t *, struct state *state);
1419 static isc_result_t byte_btoa(int c, isc_buffer_t *, struct state *state);
1422 * Decode ASCII-encoded byte c into binary representation and
1423 * place into *bufp, advancing bufp.
1426 byte_atob(int c, isc_buffer_t *target, struct state *state) {
1430 return(DNS_R_SYNTAX);
1432 RETERR(putbyte(0, target, state));
1433 RETERR(putbyte(0, target, state));
1434 RETERR(putbyte(0, target, state));
1435 RETERR(putbyte(0, target, state));
1437 } else if ((s = strchr(atob_digits, c)) != NULL) {
1439 word = s - atob_digits;
1441 } else if (bcount < 4) {
1442 word = times85(word);
1443 word += s - atob_digits;
1446 word = times85(word);
1447 word += s - atob_digits;
1448 RETERR(putbyte((word >> 24) & 0xff, target, state));
1449 RETERR(putbyte((word >> 16) & 0xff, target, state));
1450 RETERR(putbyte((word >> 8) & 0xff, target, state));
1451 RETERR(putbyte(word & 0xff, target, state));
1456 return(DNS_R_SYNTAX);
1457 return(ISC_R_SUCCESS);
1461 * Compute checksum info and place c into target.
1464 putbyte(int c, isc_buffer_t *target, struct state *state) {
1470 if ((Crot & 0x80000000)) {
1477 isc_buffer_availableregion(target, &tr);
1479 return (ISC_R_NOSPACE);
1481 isc_buffer_add(target, 1);
1482 return (ISC_R_SUCCESS);
1486 * Read the ASCII-encoded data from inbuf, of length inbuflen, and convert
1487 * it into T_UNSPEC (binary data) in outbuf, not to exceed outbuflen bytes;
1488 * outbuflen must be divisible by 4. (Note: this is because outbuf is filled
1489 * in 4 bytes at a time. If the actual data doesn't end on an even 4-byte
1490 * boundary, there will be no problem...it will be padded with 0 bytes, and
1491 * numbytes will indicate the correct number of bytes. The main point is
1492 * that since the buffer is filled in 4 bytes at a time, even if there is
1493 * not a full 4 bytes of data at the end, there has to be room to 0-pad the
1494 * data, so the buffer must be of size divisible by 4). Place the number of
1495 * output bytes in numbytes, and return a failure/success status.
1499 atob_tobuffer(isc_lex_t *lexer, isc_buffer_t *target) {
1500 long oeor, osum, orot;
1501 struct state statebuf, *state= &statebuf;
1506 Ceor = Csum = Crot = word = bcount = 0;
1508 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
1510 while (token.value.as_textregion.length != 0) {
1511 if ((c = token.value.as_textregion.base[0]) == 'x') {
1514 RETERR(byte_atob(c, target, state));
1515 isc_textregion_consume(&token.value.as_textregion, 1);
1521 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
1523 if ((token.value.as_ulong % 4) != 0U)
1524 isc_buffer_subtract(target, 4 - (token.value.as_ulong % 4));
1529 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
1531 oeor = strtol(DNS_AS_STR(token), &e, 16);
1533 return (DNS_R_SYNTAX);
1538 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
1540 osum = strtol(DNS_AS_STR(token), &e, 16);
1542 return (DNS_R_SYNTAX);
1547 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
1549 orot = strtol(DNS_AS_STR(token), &e, 16);
1551 return (DNS_R_SYNTAX);
1553 if ((oeor != Ceor) || (osum != Csum) || (orot != Crot))
1554 return(DNS_R_BADCKSUM);
1555 return (ISC_R_SUCCESS);
1559 * Encode binary byte c into ASCII representation and place into *bufp,
1563 byte_btoa(int c, isc_buffer_t *target, struct state *state) {
1566 isc_buffer_availableregion(target, &tr);
1570 if ((Crot & 0x80000000)) {
1583 return (ISC_R_NOSPACE);
1585 isc_buffer_add(target, 1);
1587 register int tmp = 0;
1588 register isc_int32_t tmpword = word;
1592 * Because some don't support u_long.
1595 tmpword -= (isc_int32_t)(85 * 85 * 85 * 85 * 32);
1599 tmpword -= (isc_int32_t)(85 * 85 * 85 * 85 * 32);
1602 return (ISC_R_NOSPACE);
1603 tr.base[0] = atob_digits[(tmpword /
1604 (isc_int32_t)(85 * 85 * 85 * 85))
1606 tmpword %= (isc_int32_t)(85 * 85 * 85 * 85);
1607 tr.base[1] = atob_digits[tmpword / (85 * 85 * 85)];
1608 tmpword %= (85 * 85 * 85);
1609 tr.base[2] = atob_digits[tmpword / (85 * 85)];
1610 tmpword %= (85 * 85);
1611 tr.base[3] = atob_digits[tmpword / 85];
1613 tr.base[4] = atob_digits[tmpword];
1614 isc_buffer_add(target, 5);
1620 return (ISC_R_SUCCESS);
1625 * Encode the binary data from inbuf, of length inbuflen, into a
1626 * target. Return success/failure status
1629 btoa_totext(unsigned char *inbuf, int inbuflen, isc_buffer_t *target) {
1631 struct state statebuf, *state = &statebuf;
1632 char buf[sizeof("x 2000000000 ffffffff ffffffff ffffffff")];
1634 Ceor = Csum = Crot = word = bcount = 0;
1635 for (inc = 0; inc < inbuflen; inbuf++, inc++)
1636 RETERR(byte_btoa(*inbuf, target, state));
1639 RETERR(byte_btoa(0, target, state));
1642 * Put byte count and checksum information at end of buffer,
1645 snprintf(buf, sizeof(buf), "x %d %x %x %x", inbuflen, Ceor, Csum, Crot);
1646 return (str_totext(buf, target));
1651 default_fromtext_callback(dns_rdatacallbacks_t *callbacks, const char *fmt,
1659 vfprintf(stderr, fmt, ap);
1661 fprintf(stderr, "\n");
1665 fromtext_warneof(isc_lex_t *lexer, dns_rdatacallbacks_t *callbacks) {
1666 if (isc_lex_isfile(lexer) && callbacks != NULL) {
1667 const char *name = isc_lex_getsourcename(lexer);
1670 (*callbacks->warn)(callbacks,
1671 "%s:%lu: file does not end with newline",
1672 name, isc_lex_getsourceline(lexer));
1677 warn_badmx(isc_token_t *token, isc_lex_t *lexer,
1678 dns_rdatacallbacks_t *callbacks)
1683 if (lexer != NULL) {
1684 file = isc_lex_getsourcename(lexer);
1685 line = isc_lex_getsourceline(lexer);
1686 (*callbacks->warn)(callbacks, "%s:%u: warning: '%s': %s",
1687 file, line, DNS_AS_STR(*token),
1688 dns_result_totext(DNS_R_MXISADDRESS));
1693 warn_badname(dns_name_t *name, isc_lex_t *lexer,
1694 dns_rdatacallbacks_t *callbacks)
1698 char namebuf[DNS_NAME_FORMATSIZE];
1700 if (lexer != NULL) {
1701 file = isc_lex_getsourcename(lexer);
1702 line = isc_lex_getsourceline(lexer);
1703 dns_name_format(name, namebuf, sizeof(namebuf));
1704 (*callbacks->warn)(callbacks, "%s:%u: warning: %s: %s",
1705 file, line, namebuf,
1706 dns_result_totext(DNS_R_BADNAME));
1711 fromtext_error(void (*callback)(dns_rdatacallbacks_t *, const char *, ...),
1712 dns_rdatacallbacks_t *callbacks, const char *name,
1713 unsigned long line, isc_token_t *token, isc_result_t result)
1718 if (token != NULL) {
1719 switch (token->type) {
1720 case isc_tokentype_eol:
1721 (*callback)(callbacks, "%s: %s:%lu: near eol: %s",
1722 "dns_rdata_fromtext", name, line,
1723 dns_result_totext(result));
1725 case isc_tokentype_eof:
1726 (*callback)(callbacks, "%s: %s:%lu: near eof: %s",
1727 "dns_rdata_fromtext", name, line,
1728 dns_result_totext(result));
1730 case isc_tokentype_number:
1731 (*callback)(callbacks, "%s: %s:%lu: near %lu: %s",
1732 "dns_rdata_fromtext", name, line,
1733 token->value.as_ulong,
1734 dns_result_totext(result));
1736 case isc_tokentype_string:
1737 case isc_tokentype_qstring:
1738 (*callback)(callbacks, "%s: %s:%lu: near '%s': %s",
1739 "dns_rdata_fromtext", name, line,
1741 dns_result_totext(result));
1744 (*callback)(callbacks, "%s: %s:%lu: %s",
1745 "dns_rdata_fromtext", name, line,
1746 dns_result_totext(result));
1750 (*callback)(callbacks, "dns_rdata_fromtext: %s:%lu: %s",
1751 name, line, dns_result_totext(result));
1756 dns_rdata_covers(dns_rdata_t *rdata) {
1757 if (rdata->type == 46)
1758 return (covers_rrsig(rdata));
1759 return (covers_sig(rdata));
1763 dns_rdatatype_ismeta(dns_rdatatype_t type) {
1764 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_META) != 0)
1770 dns_rdatatype_issingleton(dns_rdatatype_t type) {
1771 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_SINGLETON)
1778 dns_rdatatype_notquestion(dns_rdatatype_t type) {
1779 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_NOTQUESTION)
1786 dns_rdatatype_questiononly(dns_rdatatype_t type) {
1787 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_QUESTIONONLY)
1794 dns_rdatatype_atparent(dns_rdatatype_t type) {
1795 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_ATPARENT) != 0)
1801 dns_rdataclass_ismeta(dns_rdataclass_t rdclass) {
1803 if (rdclass == dns_rdataclass_reserved0
1804 || rdclass == dns_rdataclass_none
1805 || rdclass == dns_rdataclass_any)
1808 return (ISC_FALSE); /* Assume it is not a meta class. */
1812 dns_rdatatype_isdnssec(dns_rdatatype_t type) {
1813 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_DNSSEC) != 0)
1819 dns_rdatatype_iszonecutauth(dns_rdatatype_t type) {
1820 if ((dns_rdatatype_attributes(type)
1821 & (DNS_RDATATYPEATTR_DNSSEC | DNS_RDATATYPEATTR_ZONECUTAUTH))
1828 dns_rdatatype_isknown(dns_rdatatype_t type) {
1829 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_UNKNOWN)
1836 dns_rdata_exists(dns_rdata_t *rdata, dns_rdatatype_t type) {
1838 REQUIRE(rdata != NULL);
1839 REQUIRE(DNS_RDATA_INITIALIZED(rdata));
1843 rdata->flags = DNS_RDATA_UPDATE;
1845 rdata->rdclass = dns_rdataclass_any;
1849 dns_rdata_notexist(dns_rdata_t *rdata, dns_rdatatype_t type) {
1851 REQUIRE(rdata != NULL);
1852 REQUIRE(DNS_RDATA_INITIALIZED(rdata));
1856 rdata->flags = DNS_RDATA_UPDATE;
1858 rdata->rdclass = dns_rdataclass_none;
1862 dns_rdata_deleterrset(dns_rdata_t *rdata, dns_rdatatype_t type) {
1864 REQUIRE(rdata != NULL);
1865 REQUIRE(DNS_RDATA_INITIALIZED(rdata));
1869 rdata->flags = DNS_RDATA_UPDATE;
1871 rdata->rdclass = dns_rdataclass_any;
1875 dns_rdata_makedelete(dns_rdata_t *rdata) {
1876 REQUIRE(rdata != NULL);
1878 rdata->rdclass = dns_rdataclass_none;
1882 dns_rdata_updateop(dns_rdata_t *rdata, dns_section_t section) {
1884 REQUIRE(rdata != NULL);
1885 REQUIRE(DNS_RDATA_INITIALIZED(rdata));
1888 case DNS_SECTION_PREREQUISITE:
1889 switch (rdata->rdclass) {
1890 case dns_rdataclass_none:
1891 switch (rdata->type) {
1892 case dns_rdatatype_any:
1893 return ("domain doesn't exist");
1895 return ("rrset doesn't exist");
1897 case dns_rdataclass_any:
1898 switch (rdata->type) {
1899 case dns_rdatatype_any:
1900 return ("domain exists");
1902 return ("rrset exists (value independent)");
1905 return ("rrset exists (value dependent)");
1907 case DNS_SECTION_UPDATE:
1908 switch (rdata->rdclass) {
1909 case dns_rdataclass_none:
1911 case dns_rdataclass_any:
1912 switch (rdata->type) {
1913 case dns_rdatatype_any:
1914 return ("delete all rrsets");
1916 return ("delete rrset");