xref: /netbsd-src/external/mpl/bind/dist/lib/dns/rdata/generic/smimea_53.c (revision bcda20f65a8566e103791ec395f7f499ef322704)
1 /*	$NetBSD: smimea_53.c,v 1.10 2025/01/26 16:25:33 christos Exp $	*/
2 
3 /*
4  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
5  *
6  * SPDX-License-Identifier: MPL-2.0
7  *
8  * This Source Code Form is subject to the terms of the Mozilla Public
9  * License, v. 2.0. If a copy of the MPL was not distributed with this
10  * file, you can obtain one at https://mozilla.org/MPL/2.0/.
11  *
12  * See the COPYRIGHT file distributed with this work for additional
13  * information regarding copyright ownership.
14  */
15 
16 #ifndef RDATA_GENERIC_SMIMEA_53_C
17 #define RDATA_GENERIC_SMIMEA_53_C
18 
19 #define RRTYPE_SMIMEA_ATTRIBUTES 0
20 
21 static isc_result_t
22 fromtext_smimea(ARGS_FROMTEXT) {
23 	REQUIRE(type == dns_rdatatype_smimea);
24 
25 	return generic_fromtext_tlsa(CALL_FROMTEXT);
26 }
27 
28 static isc_result_t
29 totext_smimea(ARGS_TOTEXT) {
30 	REQUIRE(rdata != NULL);
31 	REQUIRE(rdata->type == dns_rdatatype_smimea);
32 
33 	return generic_totext_tlsa(CALL_TOTEXT);
34 }
35 
36 static isc_result_t
37 fromwire_smimea(ARGS_FROMWIRE) {
38 	REQUIRE(type == dns_rdatatype_smimea);
39 
40 	return generic_fromwire_tlsa(CALL_FROMWIRE);
41 }
42 
43 static isc_result_t
44 towire_smimea(ARGS_TOWIRE) {
45 	isc_region_t sr;
46 
47 	REQUIRE(rdata->type == dns_rdatatype_smimea);
48 	REQUIRE(rdata->length != 0);
49 
50 	UNUSED(cctx);
51 
52 	dns_rdata_toregion(rdata, &sr);
53 	return mem_tobuffer(target, sr.base, sr.length);
54 }
55 
56 static int
57 compare_smimea(ARGS_COMPARE) {
58 	isc_region_t r1;
59 	isc_region_t r2;
60 
61 	REQUIRE(rdata1->type == rdata2->type);
62 	REQUIRE(rdata1->rdclass == rdata2->rdclass);
63 	REQUIRE(rdata1->type == dns_rdatatype_smimea);
64 	REQUIRE(rdata1->length != 0);
65 	REQUIRE(rdata2->length != 0);
66 
67 	dns_rdata_toregion(rdata1, &r1);
68 	dns_rdata_toregion(rdata2, &r2);
69 	return isc_region_compare(&r1, &r2);
70 }
71 
72 static isc_result_t
73 fromstruct_smimea(ARGS_FROMSTRUCT) {
74 	REQUIRE(type == dns_rdatatype_smimea);
75 
76 	return generic_fromstruct_tlsa(CALL_FROMSTRUCT);
77 }
78 
79 static isc_result_t
80 tostruct_smimea(ARGS_TOSTRUCT) {
81 	dns_rdata_smimea_t *smimea = target;
82 
83 	REQUIRE(rdata != NULL);
84 	REQUIRE(rdata->type == dns_rdatatype_smimea);
85 	REQUIRE(smimea != NULL);
86 
87 	smimea->common.rdclass = rdata->rdclass;
88 	smimea->common.rdtype = rdata->type;
89 	ISC_LINK_INIT(&smimea->common, link);
90 
91 	return generic_tostruct_tlsa(CALL_TOSTRUCT);
92 }
93 
94 static void
95 freestruct_smimea(ARGS_FREESTRUCT) {
96 	dns_rdata_smimea_t *smimea = source;
97 
98 	REQUIRE(smimea != NULL);
99 	REQUIRE(smimea->common.rdtype == dns_rdatatype_smimea);
100 
101 	generic_freestruct_tlsa(source);
102 }
103 
104 static isc_result_t
105 additionaldata_smimea(ARGS_ADDLDATA) {
106 	REQUIRE(rdata->type == dns_rdatatype_smimea);
107 
108 	UNUSED(rdata);
109 	UNUSED(owner);
110 	UNUSED(add);
111 	UNUSED(arg);
112 
113 	return ISC_R_SUCCESS;
114 }
115 
116 static isc_result_t
117 digest_smimea(ARGS_DIGEST) {
118 	isc_region_t r;
119 
120 	REQUIRE(rdata->type == dns_rdatatype_smimea);
121 
122 	dns_rdata_toregion(rdata, &r);
123 
124 	return (digest)(arg, &r);
125 }
126 
127 static bool
128 checkowner_smimea(ARGS_CHECKOWNER) {
129 	REQUIRE(type == dns_rdatatype_smimea);
130 
131 	UNUSED(name);
132 	UNUSED(type);
133 	UNUSED(rdclass);
134 	UNUSED(wildcard);
135 
136 	return true;
137 }
138 
139 static bool
140 checknames_smimea(ARGS_CHECKNAMES) {
141 	REQUIRE(rdata->type == dns_rdatatype_smimea);
142 
143 	UNUSED(rdata);
144 	UNUSED(owner);
145 	UNUSED(bad);
146 
147 	return true;
148 }
149 
150 static int
151 casecompare_smimea(ARGS_COMPARE) {
152 	return compare_smimea(rdata1, rdata2);
153 }
154 
155 #endif /* RDATA_GENERIC_SMIMEA_53_C */
156