1 /*
2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3  *
4  * SPDX-License-Identifier: MPL-2.0
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, you can obtain one at https://mozilla.org/MPL/2.0/.
9  *
10  * See the COPYRIGHT file distributed with this work for additional
11  * information regarding copyright ownership.
12  */
13 
14 /* draft-ietf-dnsop-svcb-https-02 */
15 
16 #ifndef RDATA_IN_1_HTTPS_65_C
17 #define RDATA_IN_1_HTTPS_65_C
18 
19 #define RRTYPE_HTTPS_ATTRIBUTES 0
20 
21 /*
22  * Most of these functions refer to equivalent functions for SVCB,
23  * since wire and presentation formats are identical.
24  */
25 
26 static inline isc_result_t
fromtext_in_https(ARGS_FROMTEXT)27 fromtext_in_https(ARGS_FROMTEXT) {
28 	REQUIRE(type == dns_rdatatype_https);
29 	REQUIRE(rdclass == dns_rdataclass_in);
30 
31 	return (generic_fromtext_in_svcb(CALL_FROMTEXT));
32 }
33 
34 static inline isc_result_t
totext_in_https(ARGS_TOTEXT)35 totext_in_https(ARGS_TOTEXT) {
36 	REQUIRE(rdata->type == dns_rdatatype_https);
37 	REQUIRE(rdata->rdclass == dns_rdataclass_in);
38 	REQUIRE(rdata->length != 0);
39 
40 	return (generic_totext_in_svcb(CALL_TOTEXT));
41 }
42 
43 static inline isc_result_t
fromwire_in_https(ARGS_FROMWIRE)44 fromwire_in_https(ARGS_FROMWIRE) {
45 	REQUIRE(type == dns_rdatatype_https);
46 	REQUIRE(rdclass == dns_rdataclass_in);
47 
48 	return (generic_fromwire_in_svcb(CALL_FROMWIRE));
49 }
50 
51 static inline isc_result_t
towire_in_https(ARGS_TOWIRE)52 towire_in_https(ARGS_TOWIRE) {
53 	REQUIRE(rdata->type == dns_rdatatype_https);
54 	REQUIRE(rdata->length != 0);
55 
56 	return (generic_towire_in_svcb(CALL_TOWIRE));
57 }
58 
59 static inline int
compare_in_https(ARGS_COMPARE)60 compare_in_https(ARGS_COMPARE) {
61 	isc_region_t region1;
62 	isc_region_t region2;
63 
64 	REQUIRE(rdata1->type == rdata2->type);
65 	REQUIRE(rdata1->rdclass == rdata2->rdclass);
66 	REQUIRE(rdata1->type == dns_rdatatype_https);
67 	REQUIRE(rdata1->rdclass == dns_rdataclass_in);
68 	REQUIRE(rdata1->length != 0);
69 	REQUIRE(rdata2->length != 0);
70 
71 	dns_rdata_toregion(rdata1, &region1);
72 	dns_rdata_toregion(rdata2, &region2);
73 
74 	return (isc_region_compare(&region1, &region2));
75 }
76 
77 static inline isc_result_t
fromstruct_in_https(ARGS_FROMSTRUCT)78 fromstruct_in_https(ARGS_FROMSTRUCT) {
79 	dns_rdata_in_https_t *https = source;
80 
81 	REQUIRE(type == dns_rdatatype_https);
82 	REQUIRE(rdclass == dns_rdataclass_in);
83 	REQUIRE(https != NULL);
84 	REQUIRE(https->common.rdtype == type);
85 	REQUIRE(https->common.rdclass == rdclass);
86 
87 	return (generic_fromstruct_in_svcb(CALL_FROMSTRUCT));
88 }
89 
90 static inline isc_result_t
tostruct_in_https(ARGS_TOSTRUCT)91 tostruct_in_https(ARGS_TOSTRUCT) {
92 	dns_rdata_in_https_t *https = target;
93 
94 	REQUIRE(rdata->rdclass == dns_rdataclass_in);
95 	REQUIRE(rdata->type == dns_rdatatype_https);
96 	REQUIRE(https != NULL);
97 	REQUIRE(rdata->length != 0);
98 
99 	return (generic_tostruct_in_svcb(CALL_TOSTRUCT));
100 }
101 
102 static inline void
freestruct_in_https(ARGS_FREESTRUCT)103 freestruct_in_https(ARGS_FREESTRUCT) {
104 	dns_rdata_in_https_t *https = source;
105 
106 	REQUIRE(https != NULL);
107 	REQUIRE(https->common.rdclass == dns_rdataclass_in);
108 	REQUIRE(https->common.rdtype == dns_rdatatype_https);
109 
110 	generic_freestruct_in_svcb(CALL_FREESTRUCT);
111 }
112 
113 static inline isc_result_t
additionaldata_in_https(ARGS_ADDLDATA)114 additionaldata_in_https(ARGS_ADDLDATA) {
115 	REQUIRE(rdata->type == dns_rdatatype_https);
116 	REQUIRE(rdata->rdclass == dns_rdataclass_in);
117 
118 	return (generic_additionaldata_in_svcb(CALL_ADDLDATA));
119 }
120 
121 static inline isc_result_t
digest_in_https(ARGS_DIGEST)122 digest_in_https(ARGS_DIGEST) {
123 	isc_region_t region1;
124 
125 	REQUIRE(rdata->type == dns_rdatatype_https);
126 	REQUIRE(rdata->rdclass == dns_rdataclass_in);
127 
128 	dns_rdata_toregion(rdata, &region1);
129 	return ((digest)(arg, &region1));
130 }
131 
132 static inline bool
checkowner_in_https(ARGS_CHECKOWNER)133 checkowner_in_https(ARGS_CHECKOWNER) {
134 	REQUIRE(type == dns_rdatatype_https);
135 	REQUIRE(rdclass == dns_rdataclass_in);
136 
137 	UNUSED(name);
138 	UNUSED(type);
139 	UNUSED(rdclass);
140 	UNUSED(wildcard);
141 
142 	return (true);
143 }
144 
145 static inline bool
checknames_in_https(ARGS_CHECKNAMES)146 checknames_in_https(ARGS_CHECKNAMES) {
147 	REQUIRE(rdata->type == dns_rdatatype_https);
148 	REQUIRE(rdata->rdclass == dns_rdataclass_in);
149 
150 	return (generic_checknames_in_svcb(CALL_CHECKNAMES));
151 }
152 
153 static inline int
casecompare_in_https(ARGS_COMPARE)154 casecompare_in_https(ARGS_COMPARE) {
155 	return (compare_in_https(rdata1, rdata2));
156 }
157 
158 isc_result_t
dns_rdata_in_https_first(dns_rdata_in_https_t * https)159 dns_rdata_in_https_first(dns_rdata_in_https_t *https) {
160 	REQUIRE(https != NULL);
161 	REQUIRE(https->common.rdtype == dns_rdatatype_https);
162 	REQUIRE(https->common.rdclass == dns_rdataclass_in);
163 
164 	return (generic_rdata_in_svcb_first(https));
165 }
166 
167 isc_result_t
dns_rdata_in_https_next(dns_rdata_in_https_t * https)168 dns_rdata_in_https_next(dns_rdata_in_https_t *https) {
169 	REQUIRE(https != NULL);
170 	REQUIRE(https->common.rdtype == dns_rdatatype_https);
171 	REQUIRE(https->common.rdclass == dns_rdataclass_in);
172 
173 	return (generic_rdata_in_svcb_next(https));
174 }
175 
176 void
dns_rdata_in_https_current(dns_rdata_in_https_t * https,isc_region_t * region)177 dns_rdata_in_https_current(dns_rdata_in_https_t *https, isc_region_t *region) {
178 	REQUIRE(https != NULL);
179 	REQUIRE(https->common.rdtype == dns_rdatatype_https);
180 	REQUIRE(https->common.rdclass == dns_rdataclass_in);
181 	REQUIRE(region != NULL);
182 
183 	generic_rdata_in_svcb_current(https, region);
184 }
185 
186 #endif /* RDATA_IN_1_HTTPS_65_C */
187