4 * Copyright (C) 2006, 2007, 2009 Internet Systems Consortium, Inc. ("ISC")
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
11 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
13 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
19 /* Id: dhcid_49.c,v 1.7 2009/12/04 22:06:37 tbox Exp */
23 #ifndef RDATA_IN_1_DHCID_49_C
24 #define RDATA_IN_1_DHCID_49_C 1
26 #define RRTYPE_DHCID_ATTRIBUTES 0
28 static inline isc_result_t
29 fromtext_in_dhcid(ARGS_FROMTEXT
) {
32 REQUIRE(rdclass
== 1);
40 return (isc_base64_tobuffer(lexer
, target
, -1));
43 static inline isc_result_t
44 totext_in_dhcid(ARGS_TOTEXT
) {
46 char buf
[sizeof(" ; 64000 255 64000")];
49 REQUIRE(rdata
->type
== 49);
50 REQUIRE(rdata
->rdclass
== 1);
51 REQUIRE(rdata
->length
!= 0);
53 dns_rdata_toregion(rdata
, &sr
);
55 if ((tctx
->flags
& DNS_STYLEFLAG_MULTILINE
) != 0)
56 RETERR(str_totext("( " /*)*/, target
));
57 RETERR(isc_base64_totext(&sr
, tctx
->width
- 2, tctx
->linebreak
,
59 if ((tctx
->flags
& DNS_STYLEFLAG_MULTILINE
) != 0) {
60 RETERR(str_totext(/* ( */ " )", target
));
61 if (rdata
->length
> 2) {
62 n
= snprintf(buf
, sizeof(buf
), " ; %u %u %u",
63 sr
.base
[0] * 256 + sr
.base
[1],
64 sr
.base
[2], rdata
->length
- 3);
65 INSIST(n
< sizeof(buf
));
66 RETERR(str_totext(buf
, target
));
69 return (ISC_R_SUCCESS
);
72 static inline isc_result_t
73 fromwire_in_dhcid(ARGS_FROMWIRE
) {
77 REQUIRE(rdclass
== 1);
84 isc_buffer_activeregion(source
, &sr
);
86 return (ISC_R_UNEXPECTEDEND
);
88 isc_buffer_forward(source
, sr
.length
);
89 return (mem_tobuffer(target
, sr
.base
, sr
.length
));
92 static inline isc_result_t
93 towire_in_dhcid(ARGS_TOWIRE
) {
96 REQUIRE(rdata
->type
== 49);
97 REQUIRE(rdata
->rdclass
== 1);
98 REQUIRE(rdata
->length
!= 0);
102 dns_rdata_toregion(rdata
, &sr
);
103 return (mem_tobuffer(target
, sr
.base
, sr
.length
));
107 compare_in_dhcid(ARGS_COMPARE
) {
111 REQUIRE(rdata1
->type
== rdata2
->type
);
112 REQUIRE(rdata1
->rdclass
== rdata2
->rdclass
);
113 REQUIRE(rdata1
->type
== 49);
114 REQUIRE(rdata1
->rdclass
== 1);
115 REQUIRE(rdata1
->length
!= 0);
116 REQUIRE(rdata2
->length
!= 0);
118 dns_rdata_toregion(rdata1
, &r1
);
119 dns_rdata_toregion(rdata2
, &r2
);
120 return (isc_region_compare(&r1
, &r2
));
123 static inline isc_result_t
124 fromstruct_in_dhcid(ARGS_FROMSTRUCT
) {
125 dns_rdata_in_dhcid_t
*dhcid
= source
;
128 REQUIRE(rdclass
== 1);
129 REQUIRE(source
!= NULL
);
130 REQUIRE(dhcid
->common
.rdtype
== type
);
131 REQUIRE(dhcid
->common
.rdclass
== rdclass
);
132 REQUIRE(dhcid
->length
!= 0);
137 return (mem_tobuffer(target
, dhcid
->dhcid
, dhcid
->length
));
140 static inline isc_result_t
141 tostruct_in_dhcid(ARGS_TOSTRUCT
) {
142 dns_rdata_in_dhcid_t
*dhcid
= target
;
145 REQUIRE(rdata
->type
== 49);
146 REQUIRE(rdata
->rdclass
== 1);
147 REQUIRE(target
!= NULL
);
148 REQUIRE(rdata
->length
!= 0);
150 dhcid
->common
.rdclass
= rdata
->rdclass
;
151 dhcid
->common
.rdtype
= rdata
->type
;
152 ISC_LINK_INIT(&dhcid
->common
, link
);
154 dns_rdata_toregion(rdata
, ®ion
);
156 dhcid
->dhcid
= mem_maybedup(mctx
, region
.base
, region
.length
);
157 if (dhcid
->dhcid
== NULL
)
158 return (ISC_R_NOMEMORY
);
161 return (ISC_R_SUCCESS
);
165 freestruct_in_dhcid(ARGS_FREESTRUCT
) {
166 dns_rdata_in_dhcid_t
*dhcid
= source
;
168 REQUIRE(dhcid
!= NULL
);
169 REQUIRE(dhcid
->common
.rdtype
== 49);
170 REQUIRE(dhcid
->common
.rdclass
== 1);
172 if (dhcid
->mctx
== NULL
)
175 if (dhcid
->dhcid
!= NULL
)
176 isc_mem_free(dhcid
->mctx
, dhcid
->dhcid
);
180 static inline isc_result_t
181 additionaldata_in_dhcid(ARGS_ADDLDATA
) {
182 REQUIRE(rdata
->type
== 49);
183 REQUIRE(rdata
->rdclass
== 1);
189 return (ISC_R_SUCCESS
);
192 static inline isc_result_t
193 digest_in_dhcid(ARGS_DIGEST
) {
196 REQUIRE(rdata
->type
== 49);
197 REQUIRE(rdata
->rdclass
== 1);
199 dns_rdata_toregion(rdata
, &r
);
201 return ((digest
)(arg
, &r
));
204 static inline isc_boolean_t
205 checkowner_in_dhcid(ARGS_CHECKOWNER
) {
208 REQUIRE(rdclass
== 1);
218 static inline isc_boolean_t
219 checknames_in_dhcid(ARGS_CHECKNAMES
) {
221 REQUIRE(rdata
->type
== 49);
222 REQUIRE(rdata
->rdclass
== 1);
232 casecompare_in_dhcid(ARGS_COMPARE
) {
233 return (compare_in_dhcid(rdata1
, rdata2
));
236 #endif /* RDATA_IN_1_DHCID_49_C */