]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - contrib/bind9/lib/dns/rdata/generic/cdnskey_60.c
MFC r363988:
[FreeBSD/stable/9.git] / contrib / bind9 / lib / dns / rdata / generic / cdnskey_60.c
1 /*
2  * Copyright (C) 2014, 2015  Internet Systems Consortium, Inc. ("ISC")
3  *
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.
7  *
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.
15  */
16
17 /* $Id$ */
18
19 /*
20  * Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley.
21  */
22
23 /* RFC2535 */
24
25 #ifndef RDATA_GENERIC_CDNSKEY_60_C
26 #define RDATA_GENERIC_CDNSKEY_60_C
27
28 #include <dst/dst.h>
29
30 #define RRTYPE_CDNSKEY_ATTRIBUTES 0
31
32 static inline isc_result_t
33 fromtext_cdnskey(ARGS_FROMTEXT) {
34
35         REQUIRE(type == dns_rdatatype_cdnskey);
36
37         return (generic_fromtext_key(rdclass, type, lexer, origin,
38                                      options, target, callbacks));
39 }
40
41 static inline isc_result_t
42 totext_cdnskey(ARGS_TOTEXT) {
43
44         REQUIRE(rdata != NULL);
45         REQUIRE(rdata->type == dns_rdatatype_cdnskey);
46
47         return (generic_totext_key(rdata, tctx, target));
48 }
49
50 static inline isc_result_t
51 fromwire_cdnskey(ARGS_FROMWIRE) {
52
53         REQUIRE(type == dns_rdatatype_cdnskey);
54
55         return (generic_fromwire_key(rdclass, type, source, dctx,
56                                      options, target));
57 }
58
59 static inline isc_result_t
60 towire_cdnskey(ARGS_TOWIRE) {
61         isc_region_t sr;
62
63         REQUIRE(rdata->type == dns_rdatatype_cdnskey);
64         REQUIRE(rdata->length != 0);
65
66         UNUSED(cctx);
67
68         dns_rdata_toregion(rdata, &sr);
69         return (mem_tobuffer(target, sr.base, sr.length));
70 }
71
72 static inline int
73 compare_cdnskey(ARGS_COMPARE) {
74         isc_region_t r1;
75         isc_region_t r2;
76
77         REQUIRE(rdata1 != NULL);
78         REQUIRE(rdata2 != NULL);
79         REQUIRE(rdata1->type == rdata2->type);
80         REQUIRE(rdata1->rdclass == rdata2->rdclass);
81         REQUIRE(rdata1->type == dns_rdatatype_cdnskey);
82         REQUIRE(rdata1->length != 0);
83         REQUIRE(rdata2->length != 0);
84
85         dns_rdata_toregion(rdata1, &r1);
86         dns_rdata_toregion(rdata2, &r2);
87         return (isc_region_compare(&r1, &r2));
88 }
89
90 static inline isc_result_t
91 fromstruct_cdnskey(ARGS_FROMSTRUCT) {
92
93         REQUIRE(type == dns_rdatatype_cdnskey);
94
95         return (generic_fromstruct_key(rdclass, type, source, target));
96 }
97
98 static inline isc_result_t
99 tostruct_cdnskey(ARGS_TOSTRUCT) {
100         dns_rdata_cdnskey_t *dnskey = target;
101
102         REQUIRE(dnskey != NULL);
103         REQUIRE(rdata != NULL);
104         REQUIRE(rdata->type == dns_rdatatype_cdnskey);
105
106         dnskey->common.rdclass = rdata->rdclass;
107         dnskey->common.rdtype = rdata->type;
108         ISC_LINK_INIT(&dnskey->common, link);
109
110         return (generic_tostruct_key(rdata, target, mctx));
111 }
112
113 static inline void
114 freestruct_cdnskey(ARGS_FREESTRUCT) {
115         dns_rdata_cdnskey_t *dnskey = (dns_rdata_cdnskey_t *) source;
116
117         REQUIRE(dnskey != NULL);
118         REQUIRE(dnskey->common.rdtype == dns_rdatatype_cdnskey);
119
120         generic_freestruct_key(source);
121 }
122
123 static inline isc_result_t
124 additionaldata_cdnskey(ARGS_ADDLDATA) {
125         REQUIRE(rdata->type == dns_rdatatype_cdnskey);
126
127         UNUSED(rdata);
128         UNUSED(add);
129         UNUSED(arg);
130
131         return (ISC_R_SUCCESS);
132 }
133
134 static inline isc_result_t
135 digest_cdnskey(ARGS_DIGEST) {
136         isc_region_t r;
137
138         REQUIRE(rdata != NULL);
139         REQUIRE(rdata->type == dns_rdatatype_cdnskey);
140
141         dns_rdata_toregion(rdata, &r);
142
143         return ((digest)(arg, &r));
144 }
145
146 static inline isc_boolean_t
147 checkowner_cdnskey(ARGS_CHECKOWNER) {
148
149         REQUIRE(type == dns_rdatatype_cdnskey);
150
151         UNUSED(name);
152         UNUSED(type);
153         UNUSED(rdclass);
154         UNUSED(wildcard);
155
156         return (ISC_TRUE);
157 }
158
159 static inline isc_boolean_t
160 checknames_cdnskey(ARGS_CHECKNAMES) {
161
162         REQUIRE(rdata != NULL);
163         REQUIRE(rdata->type == dns_rdatatype_cdnskey);
164
165         UNUSED(rdata);
166         UNUSED(owner);
167         UNUSED(bad);
168
169         return (ISC_TRUE);
170 }
171
172 static inline int
173 casecompare_cdnskey(ARGS_COMPARE) {
174
175         /*
176          * Treat ALG 253 (private DNS) subtype name case sensistively.
177          */
178         return (compare_cdnskey(rdata1, rdata2));
179 }
180
181 #endif  /* RDATA_GENERIC_CDNSKEY_60_C */