2 * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1998-2001 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: mb_7.c,v 1.45 2007/06/19 23:47:17 tbox Exp $ */
20 /* Reviewed: Wed Mar 15 17:31:26 PST 2000 by bwelling */
22 #ifndef RDATA_GENERIC_MB_7_C
23 #define RDATA_GENERIC_MB_7_C
25 #define RRTYPE_MB_ATTRIBUTES (0)
27 static inline isc_result_t
28 fromtext_mb(ARGS_FROMTEXT
) {
39 RETERR(isc_lex_getmastertoken(lexer
, &token
, isc_tokentype_string
,
42 dns_name_init(&name
, NULL
);
43 buffer_fromregion(&buffer
, &token
.value
.as_region
);
44 origin
= (origin
!= NULL
) ? origin
: dns_rootname
;
45 RETTOK(dns_name_fromtext(&name
, &buffer
, origin
, options
, target
));
46 return (ISC_R_SUCCESS
);
49 static inline isc_result_t
50 totext_mb(ARGS_TOTEXT
) {
56 REQUIRE(rdata
->type
== 7);
57 REQUIRE(rdata
->length
!= 0);
59 dns_name_init(&name
, NULL
);
60 dns_name_init(&prefix
, NULL
);
62 dns_rdata_toregion(rdata
, ®ion
);
63 dns_name_fromregion(&name
, ®ion
);
65 sub
= name_prefix(&name
, tctx
->origin
, &prefix
);
67 return (dns_name_totext(&prefix
, sub
, target
));
70 static inline isc_result_t
71 fromwire_mb(ARGS_FROMWIRE
) {
79 dns_decompress_setmethods(dctx
, DNS_COMPRESS_GLOBAL14
);
81 dns_name_init(&name
, NULL
);
82 return (dns_name_fromwire(&name
, source
, dctx
, options
, target
));
85 static inline isc_result_t
86 towire_mb(ARGS_TOWIRE
) {
88 dns_offsets_t offsets
;
91 REQUIRE(rdata
->type
== 7);
92 REQUIRE(rdata
->length
!= 0);
94 dns_compress_setmethods(cctx
, DNS_COMPRESS_GLOBAL14
);
96 dns_name_init(&name
, offsets
);
97 dns_rdata_toregion(rdata
, ®ion
);
98 dns_name_fromregion(&name
, ®ion
);
100 return (dns_name_towire(&name
, cctx
, target
));
104 compare_mb(ARGS_COMPARE
) {
107 isc_region_t region1
;
108 isc_region_t region2
;
110 REQUIRE(rdata1
->type
== rdata2
->type
);
111 REQUIRE(rdata1
->rdclass
== rdata2
->rdclass
);
112 REQUIRE(rdata1
->type
== 7);
113 REQUIRE(rdata1
->length
!= 0);
114 REQUIRE(rdata2
->length
!= 0);
116 dns_name_init(&name1
, NULL
);
117 dns_name_init(&name2
, NULL
);
119 dns_rdata_toregion(rdata1
, ®ion1
);
120 dns_rdata_toregion(rdata2
, ®ion2
);
122 dns_name_fromregion(&name1
, ®ion1
);
123 dns_name_fromregion(&name2
, ®ion2
);
125 return (dns_name_rdatacompare(&name1
, &name2
));
128 static inline isc_result_t
129 fromstruct_mb(ARGS_FROMSTRUCT
) {
130 dns_rdata_mb_t
*mb
= source
;
134 REQUIRE(source
!= NULL
);
135 REQUIRE(mb
->common
.rdtype
== type
);
136 REQUIRE(mb
->common
.rdclass
== rdclass
);
141 dns_name_toregion(&mb
->mb
, ®ion
);
142 return (isc_buffer_copyregion(target
, ®ion
));
145 static inline isc_result_t
146 tostruct_mb(ARGS_TOSTRUCT
) {
148 dns_rdata_mb_t
*mb
= target
;
151 REQUIRE(rdata
->type
== 7);
152 REQUIRE(target
!= NULL
);
153 REQUIRE(rdata
->length
!= 0);
155 mb
->common
.rdclass
= rdata
->rdclass
;
156 mb
->common
.rdtype
= rdata
->type
;
157 ISC_LINK_INIT(&mb
->common
, link
);
159 dns_name_init(&name
, NULL
);
160 dns_rdata_toregion(rdata
, ®ion
);
161 dns_name_fromregion(&name
, ®ion
);
162 dns_name_init(&mb
->mb
, NULL
);
163 RETERR(name_duporclone(&name
, mctx
, &mb
->mb
));
165 return (ISC_R_SUCCESS
);
169 freestruct_mb(ARGS_FREESTRUCT
) {
170 dns_rdata_mb_t
*mb
= source
;
172 REQUIRE(source
!= NULL
);
174 if (mb
->mctx
== NULL
)
177 dns_name_free(&mb
->mb
, mb
->mctx
);
181 static inline isc_result_t
182 additionaldata_mb(ARGS_ADDLDATA
) {
184 dns_offsets_t offsets
;
187 REQUIRE(rdata
->type
== 7);
189 dns_name_init(&name
, offsets
);
190 dns_rdata_toregion(rdata
, ®ion
);
191 dns_name_fromregion(&name
, ®ion
);
193 return ((add
)(arg
, &name
, dns_rdatatype_a
));
196 static inline isc_result_t
197 digest_mb(ARGS_DIGEST
) {
201 REQUIRE(rdata
->type
== 7);
203 dns_rdata_toregion(rdata
, &r
);
204 dns_name_init(&name
, NULL
);
205 dns_name_fromregion(&name
, &r
);
207 return (dns_name_digest(&name
, digest
, arg
));
210 static inline isc_boolean_t
211 checkowner_mb(ARGS_CHECKOWNER
) {
219 return (dns_name_ismailbox(name
));
222 static inline isc_boolean_t
223 checknames_mb(ARGS_CHECKNAMES
) {
225 REQUIRE(rdata
->type
== 7);
234 #endif /* RDATA_GENERIC_MB_7_C */