2 * Copyright (C) 2004-2011 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.
18 /* $Id: rdata.c,v 1.209.8.2 2011-03-11 06:47:05 marka Exp $ */
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 getquad(const void *src, struct in_addr *dst,
213 isc_lex_t *lexer, dns_rdatacallbacks_t *callbacks)
218 result = inet_aton(src, dst);
219 if (result == 1 && callbacks != NULL &&
220 inet_pton(AF_INET, src, &tmp) != 1) {
221 const char *name = isc_lex_getsourcename(lexer);
224 (*callbacks->warn)(callbacks, "%s:%lu: \"%s\" "
225 "is not a decimal dotted quad", name,
226 isc_lex_getsourceline(lexer), src);
231 static inline isc_result_t
232 name_duporclone(dns_name_t *source, isc_mem_t *mctx, dns_name_t *target) {
235 return (dns_name_dup(source, mctx, target));
236 dns_name_clone(source, target);
237 return (ISC_R_SUCCESS);
241 mem_maybedup(isc_mem_t *mctx, void *source, size_t length) {
246 new = isc_mem_allocate(mctx, length);
248 memcpy(new, source, length);
253 static const char hexdigits[] = "0123456789abcdef";
254 static const char decdigits[] = "0123456789";
259 #define RESERVED 0x0002
266 dns_rdata_init(dns_rdata_t *rdata) {
268 REQUIRE(rdata != NULL);
275 ISC_LINK_INIT(rdata, link);
276 /* ISC_LIST_INIT(rdata->list); */
280 dns_rdata_reset(dns_rdata_t *rdata) {
282 REQUIRE(rdata != NULL);
284 REQUIRE(!ISC_LINK_LINKED(rdata, link));
285 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
299 dns_rdata_clone(const dns_rdata_t *src, dns_rdata_t *target) {
301 REQUIRE(src != NULL);
302 REQUIRE(target != NULL);
304 REQUIRE(DNS_RDATA_INITIALIZED(target));
306 REQUIRE(DNS_RDATA_VALIDFLAGS(src));
307 REQUIRE(DNS_RDATA_VALIDFLAGS(target));
309 target->data = src->data;
310 target->length = src->length;
311 target->rdclass = src->rdclass;
312 target->type = src->type;
313 target->flags = src->flags;
322 dns_rdata_compare(const dns_rdata_t *rdata1, const dns_rdata_t *rdata2) {
324 isc_boolean_t use_default = ISC_FALSE;
326 REQUIRE(rdata1 != NULL);
327 REQUIRE(rdata2 != NULL);
328 REQUIRE(rdata1->length == 0 || rdata1->data != NULL);
329 REQUIRE(rdata2->length == 0 || rdata2->data != NULL);
330 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata1));
331 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata2));
333 if (rdata1->rdclass != rdata2->rdclass)
334 return (rdata1->rdclass < rdata2->rdclass ? -1 : 1);
336 if (rdata1->type != rdata2->type)
337 return (rdata1->type < rdata2->type ? -1 : 1);
345 dns_rdata_toregion(rdata1, &r1);
346 dns_rdata_toregion(rdata2, &r2);
347 result = isc_region_compare(&r1, &r2);
353 dns_rdata_casecompare(const dns_rdata_t *rdata1, const dns_rdata_t *rdata2) {
355 isc_boolean_t use_default = ISC_FALSE;
357 REQUIRE(rdata1 != NULL);
358 REQUIRE(rdata2 != NULL);
359 REQUIRE(rdata1->length == 0 || rdata1->data != NULL);
360 REQUIRE(rdata2->length == 0 || rdata2->data != NULL);
361 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata1));
362 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata2));
364 if (rdata1->rdclass != rdata2->rdclass)
365 return (rdata1->rdclass < rdata2->rdclass ? -1 : 1);
367 if (rdata1->type != rdata2->type)
368 return (rdata1->type < rdata2->type ? -1 : 1);
376 dns_rdata_toregion(rdata1, &r1);
377 dns_rdata_toregion(rdata2, &r2);
378 result = isc_region_compare(&r1, &r2);
388 dns_rdata_fromregion(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
389 dns_rdatatype_t type, isc_region_t *r)
392 REQUIRE(rdata != NULL);
393 REQUIRE(DNS_RDATA_INITIALIZED(rdata));
396 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
398 rdata->data = r->base;
399 rdata->length = r->length;
400 rdata->rdclass = rdclass;
406 dns_rdata_toregion(const dns_rdata_t *rdata, isc_region_t *r) {
408 REQUIRE(rdata != NULL);
410 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
412 r->base = rdata->data;
413 r->length = rdata->length;
417 dns_rdata_fromwire(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
418 dns_rdatatype_t type, isc_buffer_t *source,
419 dns_decompress_t *dctx, unsigned int options,
420 isc_buffer_t *target)
422 isc_result_t result = ISC_R_NOTIMPLEMENTED;
426 isc_boolean_t use_default = ISC_FALSE;
427 isc_uint32_t activelength;
430 REQUIRE(dctx != NULL);
432 REQUIRE(DNS_RDATA_INITIALIZED(rdata));
433 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
437 return (DNS_R_FORMERR);
442 activelength = isc_buffer_activelength(source);
443 INSIST(activelength < 65536);
448 if (activelength > isc_buffer_availablelength(target))
449 result = ISC_R_NOSPACE;
451 isc_buffer_putmem(target, isc_buffer_current(source),
453 isc_buffer_forward(source, activelength);
454 result = ISC_R_SUCCESS;
459 * Reject any rdata that expands out to more than DNS_RDATA_MAXLENGTH
460 * as we cannot transmit it.
462 length = isc_buffer_usedlength(target) - isc_buffer_usedlength(&st);
463 if (result == ISC_R_SUCCESS && length > DNS_RDATA_MAXLENGTH)
464 result = DNS_R_FORMERR;
467 * We should have consumed all of our buffer.
469 if (result == ISC_R_SUCCESS && !buffer_empty(source))
470 result = DNS_R_EXTRADATA;
472 if (rdata != NULL && result == ISC_R_SUCCESS) {
473 region.base = isc_buffer_used(&st);
474 region.length = length;
475 dns_rdata_fromregion(rdata, rdclass, type, ®ion);
478 if (result != ISC_R_SUCCESS) {
486 dns_rdata_towire(dns_rdata_t *rdata, dns_compress_t *cctx,
487 isc_buffer_t *target)
489 isc_result_t result = ISC_R_NOTIMPLEMENTED;
490 isc_boolean_t use_default = ISC_FALSE;
494 REQUIRE(rdata != NULL);
495 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
498 * Some DynDNS meta-RRs have empty rdata.
500 if ((rdata->flags & DNS_RDATA_UPDATE) != 0) {
501 INSIST(rdata->length == 0);
502 return (ISC_R_SUCCESS);
510 isc_buffer_availableregion(target, &tr);
511 if (tr.length < rdata->length)
512 return (ISC_R_NOSPACE);
513 memcpy(tr.base, rdata->data, rdata->length);
514 isc_buffer_add(target, rdata->length);
515 return (ISC_R_SUCCESS);
517 if (result != ISC_R_SUCCESS) {
519 INSIST(target->used < 65536);
520 dns_compress_rollback(cctx, (isc_uint16_t)target->used);
526 * If the binary data in 'src' is valid uncompressed wire format
527 * rdata of class 'rdclass' and type 'type', return ISC_R_SUCCESS
528 * and copy the validated rdata to 'dest'. Otherwise return an error.
531 rdata_validate(isc_buffer_t *src, isc_buffer_t *dest, dns_rdataclass_t rdclass,
532 dns_rdatatype_t type)
534 dns_decompress_t dctx;
535 dns_rdata_t rdata = DNS_RDATA_INIT;
538 dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_NONE);
539 isc_buffer_setactive(src, isc_buffer_usedlength(src));
540 result = dns_rdata_fromwire(&rdata, rdclass, type, src,
542 dns_decompress_invalidate(&dctx);
548 unknown_fromtext(dns_rdataclass_t rdclass, dns_rdatatype_t type,
549 isc_lex_t *lexer, isc_mem_t *mctx, isc_buffer_t *target)
552 isc_buffer_t *buf = NULL;
555 if (type == 0 || dns_rdatatype_ismeta(type))
556 return (DNS_R_METATYPE);
558 result = isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
560 if (result == ISC_R_SUCCESS && token.value.as_ulong > 65535U)
561 return (ISC_R_RANGE);
562 result = isc_buffer_allocate(mctx, &buf, token.value.as_ulong);
563 if (result != ISC_R_SUCCESS)
566 result = isc_hex_tobuffer(lexer, buf,
567 (unsigned int)token.value.as_ulong);
568 if (result != ISC_R_SUCCESS)
570 if (isc_buffer_usedlength(buf) != token.value.as_ulong) {
571 result = ISC_R_UNEXPECTEDEND;
575 if (dns_rdatatype_isknown(type)) {
576 result = rdata_validate(buf, target, rdclass, type);
579 isc_buffer_usedregion(buf, &r);
580 result = isc_buffer_copyregion(target, &r);
582 if (result != ISC_R_SUCCESS)
585 isc_buffer_free(&buf);
586 return (ISC_R_SUCCESS);
589 isc_buffer_free(&buf);
594 dns_rdata_fromtext(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
595 dns_rdatatype_t type, isc_lex_t *lexer,
596 dns_name_t *origin, unsigned int options, isc_mem_t *mctx,
597 isc_buffer_t *target, dns_rdatacallbacks_t *callbacks)
599 isc_result_t result = ISC_R_NOTIMPLEMENTED;
603 unsigned int lexoptions = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF |
604 ISC_LEXOPT_DNSMULTILINE | ISC_LEXOPT_ESCAPE;
607 void (*callback)(dns_rdatacallbacks_t *, const char *, ...);
608 isc_result_t tresult;
611 REQUIRE(origin == NULL || dns_name_isabsolute(origin) == ISC_TRUE);
613 REQUIRE(DNS_RDATA_INITIALIZED(rdata));
614 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
616 if (callbacks != NULL) {
617 REQUIRE(callbacks->warn != NULL);
618 REQUIRE(callbacks->error != NULL);
623 if (callbacks != NULL)
624 callback = callbacks->error;
626 callback = default_fromtext_callback;
628 result = isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring,
630 if (result != ISC_R_SUCCESS) {
631 name = isc_lex_getsourcename(lexer);
632 line = isc_lex_getsourceline(lexer);
633 fromtext_error(callback, callbacks, name, line,
638 if (strcmp(DNS_AS_STR(token), "\\#") == 0)
639 result = unknown_fromtext(rdclass, type, lexer, mctx, target);
641 isc_lex_ungettoken(lexer, &token);
647 * Consume to end of line / file.
648 * If not at end of line initially set error code.
649 * Call callback via fromtext_error once if there was an error.
652 name = isc_lex_getsourcename(lexer);
653 line = isc_lex_getsourceline(lexer);
654 tresult = isc_lex_gettoken(lexer, lexoptions, &token);
655 if (tresult != ISC_R_SUCCESS) {
656 if (result == ISC_R_SUCCESS)
658 if (callback != NULL)
659 fromtext_error(callback, callbacks, name,
662 } else if (token.type != isc_tokentype_eol &&
663 token.type != isc_tokentype_eof) {
664 if (result == ISC_R_SUCCESS)
665 result = DNS_R_EXTRATOKEN;
666 if (callback != NULL) {
667 fromtext_error(callback, callbacks, name,
668 line, &token, result);
671 } else if (result != ISC_R_SUCCESS && callback != NULL) {
672 fromtext_error(callback, callbacks, name, line,
676 if (token.type == isc_tokentype_eof)
677 fromtext_warneof(lexer, callbacks);
682 length = isc_buffer_usedlength(target) - isc_buffer_usedlength(&st);
683 if (result == ISC_R_SUCCESS && length > DNS_RDATA_MAXLENGTH)
684 result = ISC_R_NOSPACE;
686 if (rdata != NULL && result == ISC_R_SUCCESS) {
687 region.base = isc_buffer_used(&st);
688 region.length = length;
689 dns_rdata_fromregion(rdata, rdclass, type, ®ion);
691 if (result != ISC_R_SUCCESS) {
698 rdata_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
699 isc_buffer_t *target)
701 isc_result_t result = ISC_R_NOTIMPLEMENTED;
702 isc_boolean_t use_default = ISC_FALSE;
703 char buf[sizeof("65535")];
706 REQUIRE(rdata != NULL);
707 REQUIRE(tctx->origin == NULL ||
708 dns_name_isabsolute(tctx->origin) == ISC_TRUE);
711 * Some DynDNS meta-RRs have empty rdata.
713 if ((rdata->flags & DNS_RDATA_UPDATE) != 0) {
714 INSIST(rdata->length == 0);
715 return (ISC_R_SUCCESS);
721 strlcpy(buf, "\\# ", sizeof(buf));
722 result = str_totext(buf, target);
723 INSIST(result == ISC_R_SUCCESS);
724 dns_rdata_toregion(rdata, &sr);
725 INSIST(sr.length < 65536);
726 snprintf(buf, sizeof(buf), "%u", sr.length);
727 result = str_totext(buf, target);
728 if (sr.length != 0 && result == ISC_R_SUCCESS) {
729 if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
730 result = str_totext(" ( ", target);
732 result = str_totext(" ", target);
733 if (result == ISC_R_SUCCESS)
734 result = isc_hex_totext(&sr, tctx->width - 2,
737 if (result == ISC_R_SUCCESS &&
738 (tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
739 result = str_totext(" )", target);
747 dns_rdata_totext(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target)
749 dns_rdata_textctx_t tctx;
751 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
754 * Set up formatting options for single-line output.
756 tctx.origin = origin;
759 tctx.linebreak = " ";
760 return (rdata_totext(rdata, &tctx, target));
764 dns_rdata_tofmttext(dns_rdata_t *rdata, dns_name_t *origin,
765 unsigned int flags, unsigned int width,
766 const char *linebreak, isc_buffer_t *target)
768 dns_rdata_textctx_t tctx;
770 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
773 * Set up formatting options for formatted output.
775 tctx.origin = origin;
777 if ((flags & DNS_STYLEFLAG_MULTILINE) != 0) {
779 tctx.linebreak = linebreak;
781 tctx.width = 60; /* Used for hex word length only. */
782 tctx.linebreak = " ";
784 return (rdata_totext(rdata, &tctx, target));
788 dns_rdata_fromstruct(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
789 dns_rdatatype_t type, void *source,
790 isc_buffer_t *target)
792 isc_result_t result = ISC_R_NOTIMPLEMENTED;
795 isc_boolean_t use_default = ISC_FALSE;
798 REQUIRE(source != NULL);
800 REQUIRE(DNS_RDATA_INITIALIZED(rdata));
801 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
811 length = isc_buffer_usedlength(target) - isc_buffer_usedlength(&st);
812 if (result == ISC_R_SUCCESS && length > DNS_RDATA_MAXLENGTH)
813 result = ISC_R_NOSPACE;
815 if (rdata != NULL && result == ISC_R_SUCCESS) {
816 region.base = isc_buffer_used(&st);
817 region.length = length;
818 dns_rdata_fromregion(rdata, rdclass, type, ®ion);
820 if (result != ISC_R_SUCCESS)
826 dns_rdata_tostruct(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) {
827 isc_result_t result = ISC_R_NOTIMPLEMENTED;
828 isc_boolean_t use_default = ISC_FALSE;
830 REQUIRE(rdata != NULL);
831 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
842 dns_rdata_freestruct(void *source) {
843 dns_rdatacommon_t *common = source;
844 REQUIRE(source != NULL);
850 dns_rdata_additionaldata(dns_rdata_t *rdata, dns_additionaldatafunc_t add,
853 isc_result_t result = ISC_R_NOTIMPLEMENTED;
854 isc_boolean_t use_default = ISC_FALSE;
857 * Call 'add' for each name and type from 'rdata' which is subject to
858 * additional section processing.
861 REQUIRE(rdata != NULL);
862 REQUIRE(add != NULL);
863 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
867 /* No additional processing for unknown types */
869 result = ISC_R_SUCCESS;
875 dns_rdata_digest(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) {
876 isc_result_t result = ISC_R_NOTIMPLEMENTED;
877 isc_boolean_t use_default = ISC_FALSE;
881 * Send 'rdata' in DNSSEC canonical form to 'digest'.
884 REQUIRE(rdata != NULL);
885 REQUIRE(digest != NULL);
886 REQUIRE(DNS_RDATA_VALIDFLAGS(rdata));
891 dns_rdata_toregion(rdata, &r);
892 result = (digest)(arg, &r);
899 dns_rdata_checkowner(dns_name_t *name, dns_rdataclass_t rdclass,
900 dns_rdatatype_t type, isc_boolean_t wildcard)
902 isc_boolean_t result;
909 dns_rdata_checknames(dns_rdata_t *rdata, dns_name_t *owner, dns_name_t *bad)
911 isc_boolean_t result;
918 dns_rdatatype_attributes(dns_rdatatype_t type)
920 RDATATYPE_ATTRIBUTE_SW
921 if (type >= (dns_rdatatype_t)128 && type < (dns_rdatatype_t)255)
922 return (DNS_RDATATYPEATTR_UNKNOWN | DNS_RDATATYPEATTR_META);
923 return (DNS_RDATATYPEATTR_UNKNOWN);
927 dns_rdatatype_fromtext(dns_rdatatype_t *typep, isc_textregion_t *source) {
935 return (DNS_R_UNKNOWN);
937 a = tolower((unsigned char)source->base[0]);
938 b = tolower((unsigned char)source->base[n - 1]);
940 hash = ((a + n) * b) % 256;
943 * This switch block is inlined via \#define, and will use "return"
944 * to return a result to the caller if it is a valid (known)
947 RDATATYPE_FROMTEXT_SW(hash, source->base, n, typep);
949 if (source->length > 4 && source->length < (4 + sizeof("65000")) &&
950 strncasecmp("type", source->base, 4) == 0) {
951 char buf[sizeof("65000")];
955 strncpy(buf, source->base + 4, source->length - 4);
956 buf[source->length - 4] = '\0';
957 val = strtoul(buf, &endp, 10);
958 if (*endp == '\0' && val <= 0xffff) {
959 *typep = (dns_rdatatype_t)val;
960 return (ISC_R_SUCCESS);
964 return (DNS_R_UNKNOWN);
968 dns_rdatatype_totext(dns_rdatatype_t type, isc_buffer_t *target) {
969 char buf[sizeof("TYPE65535")];
972 snprintf(buf, sizeof(buf), "TYPE%u", type);
973 return (str_totext(buf, target));
977 dns_rdatatype_format(dns_rdatatype_t rdtype,
978 char *array, unsigned int size)
986 isc_buffer_init(&buf, array, size);
987 result = dns_rdatatype_totext(rdtype, &buf);
991 if (result == ISC_R_SUCCESS) {
992 if (isc_buffer_availablelength(&buf) >= 1)
993 isc_buffer_putuint8(&buf, 0);
995 result = ISC_R_NOSPACE;
997 if (result != ISC_R_SUCCESS)
998 strlcpy(array, "<unknown>", size);
1006 name_length(dns_name_t *name) {
1007 return (name->length);
1011 txt_totext(isc_region_t *source, isc_buffer_t *target) {
1016 isc_region_t region;
1018 isc_buffer_availableregion(target, ®ion);
1020 tp = (char *)region.base;
1025 REQUIRE(n + 1 <= source->length);
1028 return (ISC_R_NOSPACE);
1032 if (*sp < 0x20 || *sp >= 0x7f) {
1034 return (ISC_R_NOSPACE);
1036 *tp++ = 0x30 + ((*sp / 100) % 10);
1037 *tp++ = 0x30 + ((*sp / 10) % 10);
1038 *tp++ = 0x30 + (*sp % 10);
1043 /* double quote, semi-colon, backslash */
1044 if (*sp == 0x22 || *sp == 0x3b || *sp == 0x5c) {
1046 return (ISC_R_NOSPACE);
1051 return (ISC_R_NOSPACE);
1056 return (ISC_R_NOSPACE);
1059 isc_buffer_add(target, tp - (char *)region.base);
1060 isc_region_consume(source, *source->base + 1);
1061 return (ISC_R_SUCCESS);
1065 txt_fromtext(isc_textregion_t *source, isc_buffer_t *target) {
1066 isc_region_t tregion;
1067 isc_boolean_t escape;
1068 unsigned int n, nrem;
1074 isc_buffer_availableregion(target, &tregion);
1078 nrem = tregion.length;
1081 return (ISC_R_NOSPACE);
1088 * Maximum text string length.
1094 if (escape && (d = decvalue((char)c)) != -1) {
1097 return (DNS_R_SYNTAX);
1099 if ((d = decvalue(*s++)) != -1)
1102 return (DNS_R_SYNTAX);
1104 return (DNS_R_SYNTAX);
1106 if ((d = decvalue(*s++)) != -1)
1109 return (DNS_R_SYNTAX);
1111 return (DNS_R_SYNTAX);
1112 } else if (!escape && c == '\\') {
1118 return (ISC_R_NOSPACE);
1123 return (DNS_R_SYNTAX);
1124 *tregion.base = t - tregion.base - 1;
1125 isc_buffer_add(target, *tregion.base + 1);
1126 return (ISC_R_SUCCESS);
1130 txt_fromwire(isc_buffer_t *source, isc_buffer_t *target) {
1132 isc_region_t sregion;
1133 isc_region_t tregion;
1135 isc_buffer_activeregion(source, &sregion);
1136 if (sregion.length == 0)
1137 return(ISC_R_UNEXPECTEDEND);
1138 n = *sregion.base + 1;
1139 if (n > sregion.length)
1140 return (ISC_R_UNEXPECTEDEND);
1142 isc_buffer_availableregion(target, &tregion);
1143 if (n > tregion.length)
1144 return (ISC_R_NOSPACE);
1146 memcpy(tregion.base, sregion.base, n);
1147 isc_buffer_forward(source, n);
1148 isc_buffer_add(target, n);
1149 return (ISC_R_SUCCESS);
1152 static isc_boolean_t
1153 name_prefix(dns_name_t *name, dns_name_t *origin, dns_name_t *target) {
1159 if (dns_name_compare(origin, dns_rootname) == 0)
1162 if (!dns_name_issubdomain(name, origin))
1165 l1 = dns_name_countlabels(name);
1166 l2 = dns_name_countlabels(origin);
1171 /* Master files should be case preserving. */
1172 dns_name_getlabelsequence(name, l1 - l2, l2, target);
1173 if (!dns_name_caseequal(origin, target))
1176 dns_name_getlabelsequence(name, 0, l1 - l2, target);
1185 str_totext(const char *source, isc_buffer_t *target) {
1187 isc_region_t region;
1189 isc_buffer_availableregion(target, ®ion);
1192 if (l > region.length)
1193 return (ISC_R_NOSPACE);
1195 memcpy(region.base, source, l);
1196 isc_buffer_add(target, l);
1197 return (ISC_R_SUCCESS);
1201 inet_totext(int af, isc_region_t *src, isc_buffer_t *target) {
1204 /* Note - inet_ntop doesn't do size checking on its input. */
1205 if (inet_ntop(af, src->base, tmpbuf, sizeof(tmpbuf)) == NULL)
1206 return (ISC_R_NOSPACE);
1207 if (strlen(tmpbuf) > isc_buffer_availablelength(target))
1208 return (ISC_R_NOSPACE);
1209 isc_buffer_putstr(target, tmpbuf);
1210 return (ISC_R_SUCCESS);
1213 static isc_boolean_t
1214 buffer_empty(isc_buffer_t *source) {
1215 return((source->current == source->active) ? ISC_TRUE : ISC_FALSE);
1219 buffer_fromregion(isc_buffer_t *buffer, isc_region_t *region) {
1220 isc_buffer_init(buffer, region->base, region->length);
1221 isc_buffer_add(buffer, region->length);
1222 isc_buffer_setactive(buffer, region->length);
1226 uint32_tobuffer(isc_uint32_t value, isc_buffer_t *target) {
1227 isc_region_t region;
1229 isc_buffer_availableregion(target, ®ion);
1230 if (region.length < 4)
1231 return (ISC_R_NOSPACE);
1232 isc_buffer_putuint32(target, value);
1233 return (ISC_R_SUCCESS);
1237 uint16_tobuffer(isc_uint32_t value, isc_buffer_t *target) {
1238 isc_region_t region;
1241 return (ISC_R_RANGE);
1242 isc_buffer_availableregion(target, ®ion);
1243 if (region.length < 2)
1244 return (ISC_R_NOSPACE);
1245 isc_buffer_putuint16(target, (isc_uint16_t)value);
1246 return (ISC_R_SUCCESS);
1250 uint8_tobuffer(isc_uint32_t value, isc_buffer_t *target) {
1251 isc_region_t region;
1254 return (ISC_R_RANGE);
1255 isc_buffer_availableregion(target, ®ion);
1256 if (region.length < 1)
1257 return (ISC_R_NOSPACE);
1258 isc_buffer_putuint8(target, (isc_uint8_t)value);
1259 return (ISC_R_SUCCESS);
1263 name_tobuffer(dns_name_t *name, isc_buffer_t *target) {
1265 dns_name_toregion(name, &r);
1266 return (isc_buffer_copyregion(target, &r));
1270 uint32_fromregion(isc_region_t *region) {
1273 REQUIRE(region->length >= 4);
1274 value = region->base[0] << 24;
1275 value |= region->base[1] << 16;
1276 value |= region->base[2] << 8;
1277 value |= region->base[3];
1282 uint16_consume_fromregion(isc_region_t *region) {
1283 isc_uint16_t r = uint16_fromregion(region);
1285 isc_region_consume(region, 2);
1290 uint16_fromregion(isc_region_t *region) {
1292 REQUIRE(region->length >= 2);
1294 return ((region->base[0] << 8) | region->base[1]);
1298 uint8_fromregion(isc_region_t *region) {
1300 REQUIRE(region->length >= 1);
1302 return (region->base[0]);
1306 uint8_consume_fromregion(isc_region_t *region) {
1307 isc_uint8_t r = uint8_fromregion(region);
1309 isc_region_consume(region, 1);
1314 mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length) {
1317 isc_buffer_availableregion(target, &tr);
1318 if (length > tr.length)
1319 return (ISC_R_NOSPACE);
1320 memcpy(tr.base, base, length);
1321 isc_buffer_add(target, length);
1322 return (ISC_R_SUCCESS);
1326 hexvalue(char value) {
1330 c = (unsigned char)value;
1336 if ((s = strchr(hexdigits, c)) == NULL)
1338 return (s - hexdigits);
1342 decvalue(char value) {
1346 * isascii() is valid for full range of int values, no need to
1349 if (!isascii(value))
1351 if ((s = strchr(decdigits, value)) == NULL)
1353 return (s - decdigits);
1356 static const char atob_digits[86] =
1357 "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`" \
1358 "abcdefghijklmnopqrstu";
1360 * Subroutines to convert between 8 bit binary bytes and printable ASCII.
1361 * Computes the number of bytes, and three kinds of simple checksums.
1362 * Incoming bytes are collected into 32-bit words, then printed in base 85:
1363 * exp(85,5) > exp(2,32)
1364 * The ASCII characters used are between '!' and 'u';
1365 * 'z' encodes 32-bit zero; 'x' is used to mark the end of encoded data.
1367 * Originally by Paul Rutter (philabs!per) and Joe Orost (petsd!joe) for
1368 * the atob/btoa programs, released with the compress program, in mod.sources.
1369 * Modified by Mike Schwartz 8/19/86 for use in BIND.
1370 * Modified to be re-entrant 3/2/99.
1382 #define Ceor state->Ceor
1383 #define Csum state->Csum
1384 #define Crot state->Crot
1385 #define word state->word
1386 #define bcount state->bcount
1388 #define times85(x) ((((((x<<2)+x)<<2)+x)<<2)+x)
1390 static isc_result_t byte_atob(int c, isc_buffer_t *target,
1391 struct state *state);
1392 static isc_result_t putbyte(int c, isc_buffer_t *, struct state *state);
1393 static isc_result_t byte_btoa(int c, isc_buffer_t *, struct state *state);
1396 * Decode ASCII-encoded byte c into binary representation and
1397 * place into *bufp, advancing bufp.
1400 byte_atob(int c, isc_buffer_t *target, struct state *state) {
1404 return(DNS_R_SYNTAX);
1406 RETERR(putbyte(0, target, state));
1407 RETERR(putbyte(0, target, state));
1408 RETERR(putbyte(0, target, state));
1409 RETERR(putbyte(0, target, state));
1411 } else if ((s = strchr(atob_digits, c)) != NULL) {
1413 word = s - atob_digits;
1415 } else if (bcount < 4) {
1416 word = times85(word);
1417 word += s - atob_digits;
1420 word = times85(word);
1421 word += s - atob_digits;
1422 RETERR(putbyte((word >> 24) & 0xff, target, state));
1423 RETERR(putbyte((word >> 16) & 0xff, target, state));
1424 RETERR(putbyte((word >> 8) & 0xff, target, state));
1425 RETERR(putbyte(word & 0xff, target, state));
1430 return(DNS_R_SYNTAX);
1431 return(ISC_R_SUCCESS);
1435 * Compute checksum info and place c into target.
1438 putbyte(int c, isc_buffer_t *target, struct state *state) {
1444 if ((Crot & 0x80000000)) {
1451 isc_buffer_availableregion(target, &tr);
1453 return (ISC_R_NOSPACE);
1455 isc_buffer_add(target, 1);
1456 return (ISC_R_SUCCESS);
1460 * Read the ASCII-encoded data from inbuf, of length inbuflen, and convert
1461 * it into T_UNSPEC (binary data) in outbuf, not to exceed outbuflen bytes;
1462 * outbuflen must be divisible by 4. (Note: this is because outbuf is filled
1463 * in 4 bytes at a time. If the actual data doesn't end on an even 4-byte
1464 * boundary, there will be no problem...it will be padded with 0 bytes, and
1465 * numbytes will indicate the correct number of bytes. The main point is
1466 * that since the buffer is filled in 4 bytes at a time, even if there is
1467 * not a full 4 bytes of data at the end, there has to be room to 0-pad the
1468 * data, so the buffer must be of size divisible by 4). Place the number of
1469 * output bytes in numbytes, and return a failure/success status.
1473 atob_tobuffer(isc_lex_t *lexer, isc_buffer_t *target) {
1474 long oeor, osum, orot;
1475 struct state statebuf, *state= &statebuf;
1480 Ceor = Csum = Crot = word = bcount = 0;
1482 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
1484 while (token.value.as_textregion.length != 0) {
1485 if ((c = token.value.as_textregion.base[0]) == 'x') {
1488 RETERR(byte_atob(c, target, state));
1489 isc_textregion_consume(&token.value.as_textregion, 1);
1495 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
1497 if ((token.value.as_ulong % 4) != 0U)
1498 isc_buffer_subtract(target, 4 - (token.value.as_ulong % 4));
1503 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
1505 oeor = strtol(DNS_AS_STR(token), &e, 16);
1507 return (DNS_R_SYNTAX);
1512 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
1514 osum = strtol(DNS_AS_STR(token), &e, 16);
1516 return (DNS_R_SYNTAX);
1521 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
1523 orot = strtol(DNS_AS_STR(token), &e, 16);
1525 return (DNS_R_SYNTAX);
1527 if ((oeor != Ceor) || (osum != Csum) || (orot != Crot))
1528 return(DNS_R_BADCKSUM);
1529 return (ISC_R_SUCCESS);
1533 * Encode binary byte c into ASCII representation and place into *bufp,
1537 byte_btoa(int c, isc_buffer_t *target, struct state *state) {
1540 isc_buffer_availableregion(target, &tr);
1544 if ((Crot & 0x80000000)) {
1557 return (ISC_R_NOSPACE);
1559 isc_buffer_add(target, 1);
1561 register int tmp = 0;
1562 register isc_int32_t tmpword = word;
1566 * Because some don't support u_long.
1569 tmpword -= (isc_int32_t)(85 * 85 * 85 * 85 * 32);
1573 tmpword -= (isc_int32_t)(85 * 85 * 85 * 85 * 32);
1576 return (ISC_R_NOSPACE);
1577 tr.base[0] = atob_digits[(tmpword /
1578 (isc_int32_t)(85 * 85 * 85 * 85))
1580 tmpword %= (isc_int32_t)(85 * 85 * 85 * 85);
1581 tr.base[1] = atob_digits[tmpword / (85 * 85 * 85)];
1582 tmpword %= (85 * 85 * 85);
1583 tr.base[2] = atob_digits[tmpword / (85 * 85)];
1584 tmpword %= (85 * 85);
1585 tr.base[3] = atob_digits[tmpword / 85];
1587 tr.base[4] = atob_digits[tmpword];
1588 isc_buffer_add(target, 5);
1594 return (ISC_R_SUCCESS);
1599 * Encode the binary data from inbuf, of length inbuflen, into a
1600 * target. Return success/failure status
1603 btoa_totext(unsigned char *inbuf, int inbuflen, isc_buffer_t *target) {
1605 struct state statebuf, *state = &statebuf;
1606 char buf[sizeof("x 2000000000 ffffffff ffffffff ffffffff")];
1608 Ceor = Csum = Crot = word = bcount = 0;
1609 for (inc = 0; inc < inbuflen; inbuf++, inc++)
1610 RETERR(byte_btoa(*inbuf, target, state));
1613 RETERR(byte_btoa(0, target, state));
1616 * Put byte count and checksum information at end of buffer,
1619 snprintf(buf, sizeof(buf), "x %d %x %x %x", inbuflen, Ceor, Csum, Crot);
1620 return (str_totext(buf, target));
1625 default_fromtext_callback(dns_rdatacallbacks_t *callbacks, const char *fmt,
1633 vfprintf(stderr, fmt, ap);
1635 fprintf(stderr, "\n");
1639 fromtext_warneof(isc_lex_t *lexer, dns_rdatacallbacks_t *callbacks) {
1640 if (isc_lex_isfile(lexer) && callbacks != NULL) {
1641 const char *name = isc_lex_getsourcename(lexer);
1644 (*callbacks->warn)(callbacks,
1645 "%s:%lu: file does not end with newline",
1646 name, isc_lex_getsourceline(lexer));
1651 warn_badmx(isc_token_t *token, isc_lex_t *lexer,
1652 dns_rdatacallbacks_t *callbacks)
1657 if (lexer != NULL) {
1658 file = isc_lex_getsourcename(lexer);
1659 line = isc_lex_getsourceline(lexer);
1660 (*callbacks->warn)(callbacks, "%s:%u: warning: '%s': %s",
1661 file, line, DNS_AS_STR(*token),
1662 dns_result_totext(DNS_R_MXISADDRESS));
1667 warn_badname(dns_name_t *name, isc_lex_t *lexer,
1668 dns_rdatacallbacks_t *callbacks)
1672 char namebuf[DNS_NAME_FORMATSIZE];
1674 if (lexer != NULL) {
1675 file = isc_lex_getsourcename(lexer);
1676 line = isc_lex_getsourceline(lexer);
1677 dns_name_format(name, namebuf, sizeof(namebuf));
1678 (*callbacks->warn)(callbacks, "%s:%u: warning: %s: %s",
1679 file, line, namebuf,
1680 dns_result_totext(DNS_R_BADNAME));
1685 fromtext_error(void (*callback)(dns_rdatacallbacks_t *, const char *, ...),
1686 dns_rdatacallbacks_t *callbacks, const char *name,
1687 unsigned long line, isc_token_t *token, isc_result_t result)
1692 if (token != NULL) {
1693 switch (token->type) {
1694 case isc_tokentype_eol:
1695 (*callback)(callbacks, "%s: %s:%lu: near eol: %s",
1696 "dns_rdata_fromtext", name, line,
1697 dns_result_totext(result));
1699 case isc_tokentype_eof:
1700 (*callback)(callbacks, "%s: %s:%lu: near eof: %s",
1701 "dns_rdata_fromtext", name, line,
1702 dns_result_totext(result));
1704 case isc_tokentype_number:
1705 (*callback)(callbacks, "%s: %s:%lu: near %lu: %s",
1706 "dns_rdata_fromtext", name, line,
1707 token->value.as_ulong,
1708 dns_result_totext(result));
1710 case isc_tokentype_string:
1711 case isc_tokentype_qstring:
1712 (*callback)(callbacks, "%s: %s:%lu: near '%s': %s",
1713 "dns_rdata_fromtext", name, line,
1715 dns_result_totext(result));
1718 (*callback)(callbacks, "%s: %s:%lu: %s",
1719 "dns_rdata_fromtext", name, line,
1720 dns_result_totext(result));
1724 (*callback)(callbacks, "dns_rdata_fromtext: %s:%lu: %s",
1725 name, line, dns_result_totext(result));
1730 dns_rdata_covers(dns_rdata_t *rdata) {
1731 if (rdata->type == 46)
1732 return (covers_rrsig(rdata));
1733 return (covers_sig(rdata));
1737 dns_rdatatype_ismeta(dns_rdatatype_t type) {
1738 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_META) != 0)
1744 dns_rdatatype_issingleton(dns_rdatatype_t type) {
1745 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_SINGLETON)
1752 dns_rdatatype_notquestion(dns_rdatatype_t type) {
1753 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_NOTQUESTION)
1760 dns_rdatatype_questiononly(dns_rdatatype_t type) {
1761 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_QUESTIONONLY)
1768 dns_rdatatype_atparent(dns_rdatatype_t type) {
1769 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_ATPARENT) != 0)
1775 dns_rdataclass_ismeta(dns_rdataclass_t rdclass) {
1777 if (rdclass == dns_rdataclass_reserved0
1778 || rdclass == dns_rdataclass_none
1779 || rdclass == dns_rdataclass_any)
1782 return (ISC_FALSE); /* Assume it is not a meta class. */
1786 dns_rdatatype_isdnssec(dns_rdatatype_t type) {
1787 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_DNSSEC) != 0)
1793 dns_rdatatype_iszonecutauth(dns_rdatatype_t type) {
1794 if ((dns_rdatatype_attributes(type)
1795 & (DNS_RDATATYPEATTR_DNSSEC | DNS_RDATATYPEATTR_ZONECUTAUTH))
1802 dns_rdatatype_isknown(dns_rdatatype_t type) {
1803 if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_UNKNOWN)
1810 dns_rdata_exists(dns_rdata_t *rdata, dns_rdatatype_t type) {
1812 REQUIRE(rdata != NULL);
1813 REQUIRE(DNS_RDATA_INITIALIZED(rdata));
1817 rdata->flags = DNS_RDATA_UPDATE;
1819 rdata->rdclass = dns_rdataclass_any;
1823 dns_rdata_notexist(dns_rdata_t *rdata, dns_rdatatype_t type) {
1825 REQUIRE(rdata != NULL);
1826 REQUIRE(DNS_RDATA_INITIALIZED(rdata));
1830 rdata->flags = DNS_RDATA_UPDATE;
1832 rdata->rdclass = dns_rdataclass_none;
1836 dns_rdata_deleterrset(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_makedelete(dns_rdata_t *rdata) {
1850 REQUIRE(rdata != NULL);
1852 rdata->rdclass = dns_rdataclass_none;
1856 dns_rdata_updateop(dns_rdata_t *rdata, dns_section_t section) {
1858 REQUIRE(rdata != NULL);
1859 REQUIRE(DNS_RDATA_INITIALIZED(rdata));
1862 case DNS_SECTION_PREREQUISITE:
1863 switch (rdata->rdclass) {
1864 case dns_rdataclass_none:
1865 switch (rdata->type) {
1866 case dns_rdatatype_any:
1867 return ("domain doesn't exist");
1869 return ("rrset doesn't exist");
1871 case dns_rdataclass_any:
1872 switch (rdata->type) {
1873 case dns_rdatatype_any:
1874 return ("domain exists");
1876 return ("rrset exists (value independent)");
1879 return ("rrset exists (value dependent)");
1881 case DNS_SECTION_UPDATE:
1882 switch (rdata->rdclass) {
1883 case dns_rdataclass_none:
1885 case dns_rdataclass_any:
1886 switch (rdata->type) {
1887 case dns_rdatatype_any:
1888 return ("delete all rrsets");
1890 return ("delete rrset");