2 * Copyright (C) 2006, 2007 Internet Systems Consortium, Inc. ("ISC")
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 * PERFORMANCE OF THIS SOFTWARE.
17 /* $Id: dhcid_49.c,v 1.5 2007/06/19 23:47:17 tbox Exp $ */
21 #ifndef RDATA_IN_1_DHCID_49_C
22 #define RDATA_IN_1_DHCID_49_C 1
24 #define RRTYPE_DHCID_ATTRIBUTES 0
26 static inline isc_result_t
27 fromtext_in_dhcid(ARGS_FROMTEXT
) {
30 REQUIRE(rdclass
== 1);
38 return (isc_base64_tobuffer(lexer
, target
, -1));
41 static inline isc_result_t
42 totext_in_dhcid(ARGS_TOTEXT
) {
44 char buf
[sizeof(" ; 64000 255 64000")];
47 REQUIRE(rdata
->type
== 49);
48 REQUIRE(rdata
->rdclass
== 1);
49 REQUIRE(rdata
->length
!= 0);
51 dns_rdata_toregion(rdata
, &sr
);
53 if ((tctx
->flags
& DNS_STYLEFLAG_MULTILINE
) != 0)
54 RETERR(str_totext("( " /*)*/, target
));
55 RETERR(isc_base64_totext(&sr
, tctx
->width
- 2, tctx
->linebreak
,
57 if ((tctx
->flags
& DNS_STYLEFLAG_MULTILINE
) != 0) {
58 RETERR(str_totext(/* ( */ " )", target
));
59 if (rdata
->length
> 2) {
60 n
= snprintf(buf
, sizeof(buf
), " ; %u %u %u",
61 sr
.base
[0] * 256 + sr
.base
[1],
62 sr
.base
[2], rdata
->length
- 3);
63 INSIST(n
< sizeof(buf
));
64 RETERR(str_totext(buf
, target
));
67 return (ISC_R_SUCCESS
);
70 static inline isc_result_t
71 fromwire_in_dhcid(ARGS_FROMWIRE
) {
75 REQUIRE(rdclass
== 1);
82 isc_buffer_activeregion(source
, &sr
);
84 return (ISC_R_UNEXPECTEDEND
);
86 isc_buffer_forward(source
, sr
.length
);
87 return (mem_tobuffer(target
, sr
.base
, sr
.length
));
90 static inline isc_result_t
91 towire_in_dhcid(ARGS_TOWIRE
) {
94 REQUIRE(rdata
->type
== 49);
95 REQUIRE(rdata
->rdclass
== 1);
96 REQUIRE(rdata
->length
!= 0);
100 dns_rdata_toregion(rdata
, &sr
);
101 return (mem_tobuffer(target
, sr
.base
, sr
.length
));
105 compare_in_dhcid(ARGS_COMPARE
) {
109 REQUIRE(rdata1
->type
== rdata2
->type
);
110 REQUIRE(rdata1
->rdclass
== rdata2
->rdclass
);
111 REQUIRE(rdata1
->type
== 49);
112 REQUIRE(rdata1
->rdclass
== 1);
113 REQUIRE(rdata1
->length
!= 0);
114 REQUIRE(rdata2
->length
!= 0);
116 dns_rdata_toregion(rdata1
, &r1
);
117 dns_rdata_toregion(rdata2
, &r2
);
118 return (isc_region_compare(&r1
, &r2
));
121 static inline isc_result_t
122 fromstruct_in_dhcid(ARGS_FROMSTRUCT
) {
123 dns_rdata_in_dhcid_t
*dhcid
= source
;
126 REQUIRE(rdclass
== 1);
127 REQUIRE(source
!= NULL
);
128 REQUIRE(dhcid
->common
.rdtype
== type
);
129 REQUIRE(dhcid
->common
.rdclass
== rdclass
);
130 REQUIRE(dhcid
->length
!= 0);
135 return (mem_tobuffer(target
, dhcid
->dhcid
, dhcid
->length
));
138 static inline isc_result_t
139 tostruct_in_dhcid(ARGS_TOSTRUCT
) {
140 dns_rdata_in_dhcid_t
*dhcid
= target
;
143 REQUIRE(rdata
->type
== 49);
144 REQUIRE(rdata
->rdclass
== 1);
145 REQUIRE(target
!= NULL
);
146 REQUIRE(rdata
->length
!= 0);
148 dhcid
->common
.rdclass
= rdata
->rdclass
;
149 dhcid
->common
.rdtype
= rdata
->type
;
150 ISC_LINK_INIT(&dhcid
->common
, link
);
152 dns_rdata_toregion(rdata
, ®ion
);
154 dhcid
->dhcid
= mem_maybedup(mctx
, region
.base
, region
.length
);
155 if (dhcid
->dhcid
== NULL
)
156 return (ISC_R_NOMEMORY
);
159 return (ISC_R_SUCCESS
);
163 freestruct_in_dhcid(ARGS_FREESTRUCT
) {
164 dns_rdata_in_dhcid_t
*dhcid
= source
;
166 REQUIRE(dhcid
!= NULL
);
167 REQUIRE(dhcid
->common
.rdtype
== 49);
168 REQUIRE(dhcid
->common
.rdclass
== 1);
170 if (dhcid
->mctx
== NULL
)
173 if (dhcid
->dhcid
!= NULL
)
174 isc_mem_free(dhcid
->mctx
, dhcid
->dhcid
);
178 static inline isc_result_t
179 additionaldata_in_dhcid(ARGS_ADDLDATA
) {
180 REQUIRE(rdata
->type
== 49);
181 REQUIRE(rdata
->rdclass
== 1);
187 return (ISC_R_SUCCESS
);
190 static inline isc_result_t
191 digest_in_dhcid(ARGS_DIGEST
) {
194 REQUIRE(rdata
->type
== 49);
195 REQUIRE(rdata
->rdclass
== 1);
197 dns_rdata_toregion(rdata
, &r
);
199 return ((digest
)(arg
, &r
));
202 static inline isc_boolean_t
203 checkowner_in_dhcid(ARGS_CHECKOWNER
) {
206 REQUIRE(rdclass
== 1);
216 static inline isc_boolean_t
217 checknames_in_dhcid(ARGS_CHECKNAMES
) {
219 REQUIRE(rdata
->type
== 49);
220 REQUIRE(rdata
->rdclass
== 1);
229 #endif /* RDATA_IN_1_DHCID_49_C */