xref: /netbsd-src/external/mpl/bind/dist/lib/dns/rdata/in_1/https_65.c (revision bcda20f65a8566e103791ec395f7f499ef322704)
1 /*	$NetBSD: https_65.c,v 1.4 2025/01/26 16:25:35 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 /* draft-ietf-dnsop-svcb-https-02 */
17 
18 #pragma once
19 
20 #define RRTYPE_HTTPS_ATTRIBUTES (DNS_RDATATYPEATTR_FOLLOWADDITIONAL)
21 
22 /*
23  * Most of these functions refer to equivalent functions for SVCB,
24  * since wire and presentation formats are identical.
25  */
26 
27 static isc_result_t
28 fromtext_in_https(ARGS_FROMTEXT) {
29 	REQUIRE(type == dns_rdatatype_https);
30 	REQUIRE(rdclass == dns_rdataclass_in);
31 
32 	return generic_fromtext_in_svcb(CALL_FROMTEXT);
33 }
34 
35 static isc_result_t
36 totext_in_https(ARGS_TOTEXT) {
37 	REQUIRE(rdata->type == dns_rdatatype_https);
38 	REQUIRE(rdata->rdclass == dns_rdataclass_in);
39 	REQUIRE(rdata->length != 0);
40 
41 	return generic_totext_in_svcb(CALL_TOTEXT);
42 }
43 
44 static isc_result_t
45 fromwire_in_https(ARGS_FROMWIRE) {
46 	REQUIRE(type == dns_rdatatype_https);
47 	REQUIRE(rdclass == dns_rdataclass_in);
48 
49 	return generic_fromwire_in_svcb(CALL_FROMWIRE);
50 }
51 
52 static isc_result_t
53 towire_in_https(ARGS_TOWIRE) {
54 	REQUIRE(rdata->type == dns_rdatatype_https);
55 	REQUIRE(rdata->length != 0);
56 
57 	return generic_towire_in_svcb(CALL_TOWIRE);
58 }
59 
60 static int
61 compare_in_https(ARGS_COMPARE) {
62 	isc_region_t region1;
63 	isc_region_t region2;
64 
65 	REQUIRE(rdata1->type == rdata2->type);
66 	REQUIRE(rdata1->rdclass == rdata2->rdclass);
67 	REQUIRE(rdata1->type == dns_rdatatype_https);
68 	REQUIRE(rdata1->rdclass == dns_rdataclass_in);
69 	REQUIRE(rdata1->length != 0);
70 	REQUIRE(rdata2->length != 0);
71 
72 	dns_rdata_toregion(rdata1, &region1);
73 	dns_rdata_toregion(rdata2, &region2);
74 
75 	return isc_region_compare(&region1, &region2);
76 }
77 
78 static isc_result_t
79 fromstruct_in_https(ARGS_FROMSTRUCT) {
80 	dns_rdata_in_https_t *https = source;
81 
82 	REQUIRE(type == dns_rdatatype_https);
83 	REQUIRE(rdclass == dns_rdataclass_in);
84 	REQUIRE(https != NULL);
85 	REQUIRE(https->common.rdtype == type);
86 	REQUIRE(https->common.rdclass == rdclass);
87 
88 	return generic_fromstruct_in_svcb(CALL_FROMSTRUCT);
89 }
90 
91 static isc_result_t
92 tostruct_in_https(ARGS_TOSTRUCT) {
93 	dns_rdata_in_https_t *https = target;
94 
95 	REQUIRE(rdata->rdclass == dns_rdataclass_in);
96 	REQUIRE(rdata->type == dns_rdatatype_https);
97 	REQUIRE(https != NULL);
98 	REQUIRE(rdata->length != 0);
99 
100 	return generic_tostruct_in_svcb(CALL_TOSTRUCT);
101 }
102 
103 static void
104 freestruct_in_https(ARGS_FREESTRUCT) {
105 	dns_rdata_in_https_t *https = source;
106 
107 	REQUIRE(https != NULL);
108 	REQUIRE(https->common.rdclass == dns_rdataclass_in);
109 	REQUIRE(https->common.rdtype == dns_rdatatype_https);
110 
111 	generic_freestruct_in_svcb(CALL_FREESTRUCT);
112 }
113 
114 static isc_result_t
115 additionaldata_in_https(ARGS_ADDLDATA) {
116 	REQUIRE(rdata->type == dns_rdatatype_https);
117 	REQUIRE(rdata->rdclass == dns_rdataclass_in);
118 
119 	return generic_additionaldata_in_svcb(CALL_ADDLDATA);
120 }
121 
122 static isc_result_t
123 digest_in_https(ARGS_DIGEST) {
124 	isc_region_t region1;
125 
126 	REQUIRE(rdata->type == dns_rdatatype_https);
127 	REQUIRE(rdata->rdclass == dns_rdataclass_in);
128 
129 	dns_rdata_toregion(rdata, &region1);
130 	return (digest)(arg, &region1);
131 }
132 
133 static bool
134 checkowner_in_https(ARGS_CHECKOWNER) {
135 	REQUIRE(type == dns_rdatatype_https);
136 	REQUIRE(rdclass == dns_rdataclass_in);
137 
138 	UNUSED(name);
139 	UNUSED(type);
140 	UNUSED(rdclass);
141 	UNUSED(wildcard);
142 
143 	return true;
144 }
145 
146 static bool
147 checknames_in_https(ARGS_CHECKNAMES) {
148 	REQUIRE(rdata->type == dns_rdatatype_https);
149 	REQUIRE(rdata->rdclass == dns_rdataclass_in);
150 
151 	return generic_checknames_in_svcb(CALL_CHECKNAMES);
152 }
153 
154 static int
155 casecompare_in_https(ARGS_COMPARE) {
156 	return compare_in_https(rdata1, rdata2);
157 }
158 
159 isc_result_t
160 dns_rdata_in_https_first(dns_rdata_in_https_t *https) {
161 	REQUIRE(https != NULL);
162 	REQUIRE(https->common.rdtype == dns_rdatatype_https);
163 	REQUIRE(https->common.rdclass == dns_rdataclass_in);
164 
165 	return generic_rdata_in_svcb_first(https);
166 }
167 
168 isc_result_t
169 dns_rdata_in_https_next(dns_rdata_in_https_t *https) {
170 	REQUIRE(https != NULL);
171 	REQUIRE(https->common.rdtype == dns_rdatatype_https);
172 	REQUIRE(https->common.rdclass == dns_rdataclass_in);
173 
174 	return generic_rdata_in_svcb_next(https);
175 }
176 
177 void
178 dns_rdata_in_https_current(dns_rdata_in_https_t *https, isc_region_t *region) {
179 	REQUIRE(https != NULL);
180 	REQUIRE(https->common.rdtype == dns_rdatatype_https);
181 	REQUIRE(https->common.rdclass == dns_rdataclass_in);
182 	REQUIRE(region != NULL);
183 
184 	generic_rdata_in_svcb_current(https, region);
185 }
186