xref: /netbsd-src/external/mpl/bind/dist/lib/dns/rdata/generic/spf_99.c (revision 122b5006ee1bd67145794b4cde92f4fe4781a5ec)
1 /*	$NetBSD: spf_99.c,v 1.7 2021/08/19 11:50:17 christos Exp $	*/
2 
3 /*
4  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
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 #ifndef RDATA_GENERIC_SPF_99_C
15 #define RDATA_GENERIC_SPF_99_C
16 
17 #define RRTYPE_SPF_ATTRIBUTES (0)
18 
19 static inline isc_result_t
20 fromtext_spf(ARGS_FROMTEXT) {
21 	REQUIRE(type == dns_rdatatype_spf);
22 
23 	return (generic_fromtext_txt(CALL_FROMTEXT));
24 }
25 
26 static inline isc_result_t
27 totext_spf(ARGS_TOTEXT) {
28 	REQUIRE(rdata != NULL);
29 	REQUIRE(rdata->type == dns_rdatatype_spf);
30 
31 	return (generic_totext_txt(CALL_TOTEXT));
32 }
33 
34 static inline isc_result_t
35 fromwire_spf(ARGS_FROMWIRE) {
36 	REQUIRE(type == dns_rdatatype_spf);
37 
38 	return (generic_fromwire_txt(CALL_FROMWIRE));
39 }
40 
41 static inline isc_result_t
42 towire_spf(ARGS_TOWIRE) {
43 	REQUIRE(rdata->type == dns_rdatatype_spf);
44 
45 	UNUSED(cctx);
46 
47 	return (mem_tobuffer(target, rdata->data, rdata->length));
48 }
49 
50 static inline int
51 compare_spf(ARGS_COMPARE) {
52 	isc_region_t r1;
53 	isc_region_t r2;
54 
55 	REQUIRE(rdata1->type == rdata2->type);
56 	REQUIRE(rdata1->rdclass == rdata2->rdclass);
57 	REQUIRE(rdata1->type == dns_rdatatype_spf);
58 
59 	dns_rdata_toregion(rdata1, &r1);
60 	dns_rdata_toregion(rdata2, &r2);
61 	return (isc_region_compare(&r1, &r2));
62 }
63 
64 static inline isc_result_t
65 fromstruct_spf(ARGS_FROMSTRUCT) {
66 	REQUIRE(type == dns_rdatatype_spf);
67 
68 	return (generic_fromstruct_txt(CALL_FROMSTRUCT));
69 }
70 
71 static inline isc_result_t
72 tostruct_spf(ARGS_TOSTRUCT) {
73 	dns_rdata_spf_t *spf = target;
74 
75 	REQUIRE(spf != NULL);
76 	REQUIRE(rdata != NULL);
77 	REQUIRE(rdata->type == dns_rdatatype_spf);
78 
79 	spf->common.rdclass = rdata->rdclass;
80 	spf->common.rdtype = rdata->type;
81 	ISC_LINK_INIT(&spf->common, link);
82 
83 	return (generic_tostruct_txt(CALL_TOSTRUCT));
84 }
85 
86 static inline void
87 freestruct_spf(ARGS_FREESTRUCT) {
88 	dns_rdata_spf_t *spf = source;
89 
90 	REQUIRE(spf != NULL);
91 	REQUIRE(spf->common.rdtype == dns_rdatatype_spf);
92 
93 	generic_freestruct_txt(source);
94 }
95 
96 static inline isc_result_t
97 additionaldata_spf(ARGS_ADDLDATA) {
98 	REQUIRE(rdata->type == dns_rdatatype_spf);
99 
100 	UNUSED(rdata);
101 	UNUSED(add);
102 	UNUSED(arg);
103 
104 	return (ISC_R_SUCCESS);
105 }
106 
107 static inline isc_result_t
108 digest_spf(ARGS_DIGEST) {
109 	isc_region_t r;
110 
111 	REQUIRE(rdata->type == dns_rdatatype_spf);
112 
113 	dns_rdata_toregion(rdata, &r);
114 
115 	return ((digest)(arg, &r));
116 }
117 
118 static inline bool
119 checkowner_spf(ARGS_CHECKOWNER) {
120 	REQUIRE(type == dns_rdatatype_spf);
121 
122 	UNUSED(name);
123 	UNUSED(type);
124 	UNUSED(rdclass);
125 	UNUSED(wildcard);
126 
127 	return (true);
128 }
129 
130 static inline bool
131 checknames_spf(ARGS_CHECKNAMES) {
132 	REQUIRE(rdata->type == dns_rdatatype_spf);
133 
134 	UNUSED(rdata);
135 	UNUSED(owner);
136 	UNUSED(bad);
137 
138 	return (true);
139 }
140 
141 static inline int
142 casecompare_spf(ARGS_COMPARE) {
143 	return (compare_spf(rdata1, rdata2));
144 }
145 #endif /* RDATA_GENERIC_SPF_99_C */
146