2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1999-2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and 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: unspec_103.c,v 1.28.2.2 2004/03/09 06:11:34 marka Exp $ */
20 #ifndef RDATA_GENERIC_UNSPEC_103_C
21 #define RDATA_GENERIC_UNSPEC_103_C
23 #define RRTYPE_UNSPEC_ATTRIBUTES (0)
25 static inline isc_result_t
26 fromtext_unspec(ARGS_FROMTEXT
) {
36 return (atob_tobuffer(lexer
, target
));
39 static inline isc_result_t
40 totext_unspec(ARGS_TOTEXT
) {
42 REQUIRE(rdata
->type
== 103);
46 return (btoa_totext(rdata
->data
, rdata
->length
, target
));
49 static inline isc_result_t
50 fromwire_unspec(ARGS_FROMWIRE
) {
60 isc_buffer_activeregion(source
, &sr
);
61 isc_buffer_forward(source
, sr
.length
);
62 return (mem_tobuffer(target
, sr
.base
, sr
.length
));
65 static inline isc_result_t
66 towire_unspec(ARGS_TOWIRE
) {
68 REQUIRE(rdata
->type
== 103);
72 return (mem_tobuffer(target
, rdata
->data
, rdata
->length
));
76 compare_unspec(ARGS_COMPARE
) {
80 REQUIRE(rdata1
->type
== rdata2
->type
);
81 REQUIRE(rdata1
->rdclass
== rdata2
->rdclass
);
82 REQUIRE(rdata1
->type
== 103);
84 dns_rdata_toregion(rdata1
, &r1
);
85 dns_rdata_toregion(rdata2
, &r2
);
86 return (compare_region(&r1
, &r2
));
89 static inline isc_result_t
90 fromstruct_unspec(ARGS_FROMSTRUCT
) {
91 dns_rdata_unspec_t
*unspec
= source
;
94 REQUIRE(source
!= NULL
);
95 REQUIRE(unspec
->common
.rdtype
== type
);
96 REQUIRE(unspec
->common
.rdclass
== rdclass
);
97 REQUIRE(unspec
->data
!= NULL
|| unspec
->datalen
== 0);
102 return (mem_tobuffer(target
, unspec
->data
, unspec
->datalen
));
105 static inline isc_result_t
106 tostruct_unspec(ARGS_TOSTRUCT
) {
107 dns_rdata_unspec_t
*unspec
= target
;
110 REQUIRE(rdata
->type
== 103);
111 REQUIRE(target
!= NULL
);
113 unspec
->common
.rdclass
= rdata
->rdclass
;
114 unspec
->common
.rdtype
= rdata
->type
;
115 ISC_LINK_INIT(&unspec
->common
, link
);
117 dns_rdata_toregion(rdata
, &r
);
118 unspec
->datalen
= r
.length
;
119 unspec
->data
= mem_maybedup(mctx
, r
.base
, r
.length
);
120 if (unspec
->data
== NULL
)
121 return (ISC_R_NOMEMORY
);
124 return (ISC_R_SUCCESS
);
128 freestruct_unspec(ARGS_FREESTRUCT
) {
129 dns_rdata_unspec_t
*unspec
= source
;
131 REQUIRE(source
!= NULL
);
132 REQUIRE(unspec
->common
.rdtype
== 103);
134 if (unspec
->mctx
== NULL
)
137 if (unspec
->data
!= NULL
)
138 isc_mem_free(unspec
->mctx
, unspec
->data
);
142 static inline isc_result_t
143 additionaldata_unspec(ARGS_ADDLDATA
) {
144 REQUIRE(rdata
->type
== 103);
150 return (ISC_R_SUCCESS
);
153 static inline isc_result_t
154 digest_unspec(ARGS_DIGEST
) {
157 REQUIRE(rdata
->type
== 103);
159 dns_rdata_toregion(rdata
, &r
);
161 return ((digest
)(arg
, &r
));
164 #endif /* RDATA_GENERIC_UNSPEC_103_C */