1 /*
2  * Copyright (C) 2004, 2005, 2007, 2009, 2014, 2015  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1998-2002  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  * PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 /* $Id: spf_99.c,v 1.6 2009/12/04 22:06:37 tbox Exp $ */
19 
20 /* Reviewed: Thu Mar 16 15:40:00 PST 2000 by bwelling */
21 
22 #ifndef RDATA_GENERIC_SPF_99_C
23 #define RDATA_GENERIC_SPF_99_C
24 
25 #define RRTYPE_SPF_ATTRIBUTES (0)
26 
27 static inline isc_result_t
fromtext_spf(ARGS_FROMTEXT)28 fromtext_spf(ARGS_FROMTEXT) {
29 
30 	REQUIRE(type == dns_rdatatype_spf);
31 
32 	UNUSED(type);
33 	UNUSED(rdclass);
34 	UNUSED(origin);
35 	UNUSED(options);
36 	UNUSED(callbacks);
37 
38 	return (generic_fromtext_txt(rdclass, type, lexer, origin, options,
39 				     target, callbacks));
40 }
41 
42 static inline isc_result_t
totext_spf(ARGS_TOTEXT)43 totext_spf(ARGS_TOTEXT) {
44 
45 	UNUSED(tctx);
46 
47 	REQUIRE(rdata->type == dns_rdatatype_spf);
48 
49 	return (generic_totext_txt(rdata, tctx, target));
50 }
51 
52 static inline isc_result_t
fromwire_spf(ARGS_FROMWIRE)53 fromwire_spf(ARGS_FROMWIRE) {
54 
55 	REQUIRE(type == dns_rdatatype_spf);
56 
57 	UNUSED(type);
58 	UNUSED(dctx);
59 	UNUSED(rdclass);
60 	UNUSED(options);
61 
62 	return (generic_fromwire_txt(rdclass, type, source, dctx, options,
63 				     target));
64 }
65 
66 static inline isc_result_t
towire_spf(ARGS_TOWIRE)67 towire_spf(ARGS_TOWIRE) {
68 
69 	REQUIRE(rdata->type == dns_rdatatype_spf);
70 
71 	UNUSED(cctx);
72 
73 	return (mem_tobuffer(target, rdata->data, rdata->length));
74 }
75 
76 static inline int
compare_spf(ARGS_COMPARE)77 compare_spf(ARGS_COMPARE) {
78 	isc_region_t r1;
79 	isc_region_t r2;
80 
81 	REQUIRE(rdata1->type == rdata2->type);
82 	REQUIRE(rdata1->rdclass == rdata2->rdclass);
83 	REQUIRE(rdata1->type == dns_rdatatype_spf);
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
fromstruct_spf(ARGS_FROMSTRUCT)91 fromstruct_spf(ARGS_FROMSTRUCT) {
92 
93 	REQUIRE(type == dns_rdatatype_spf);
94 
95 	return (generic_fromstruct_txt(rdclass, type, source, target));
96 }
97 
98 static inline isc_result_t
tostruct_spf(ARGS_TOSTRUCT)99 tostruct_spf(ARGS_TOSTRUCT) {
100 	dns_rdata_spf_t *spf = target;
101 
102 	REQUIRE(rdata->type == dns_rdatatype_spf);
103 	REQUIRE(target != NULL);
104 
105 	spf->common.rdclass = rdata->rdclass;
106 	spf->common.rdtype = rdata->type;
107 	ISC_LINK_INIT(&spf->common, link);
108 
109 	return (generic_tostruct_txt(rdata, target, mctx));
110 }
111 
112 static inline void
freestruct_spf(ARGS_FREESTRUCT)113 freestruct_spf(ARGS_FREESTRUCT) {
114 	dns_rdata_spf_t *txt = source;
115 
116 	REQUIRE(source != NULL);
117 	REQUIRE(txt->common.rdtype == dns_rdatatype_spf);
118 
119 	generic_freestruct_txt(source);
120 }
121 
122 static inline isc_result_t
additionaldata_spf(ARGS_ADDLDATA)123 additionaldata_spf(ARGS_ADDLDATA) {
124 	REQUIRE(rdata->type == dns_rdatatype_spf);
125 
126 	UNUSED(rdata);
127 	UNUSED(add);
128 	UNUSED(arg);
129 
130 	return (ISC_R_SUCCESS);
131 }
132 
133 static inline isc_result_t
digest_spf(ARGS_DIGEST)134 digest_spf(ARGS_DIGEST) {
135 	isc_region_t r;
136 
137 	REQUIRE(rdata->type == dns_rdatatype_spf);
138 
139 	dns_rdata_toregion(rdata, &r);
140 
141 	return ((digest)(arg, &r));
142 }
143 
144 static inline isc_boolean_t
checkowner_spf(ARGS_CHECKOWNER)145 checkowner_spf(ARGS_CHECKOWNER) {
146 
147 	REQUIRE(type == dns_rdatatype_spf);
148 
149 	UNUSED(name);
150 	UNUSED(type);
151 	UNUSED(rdclass);
152 	UNUSED(wildcard);
153 
154 	return (ISC_TRUE);
155 }
156 
157 static inline isc_boolean_t
checknames_spf(ARGS_CHECKNAMES)158 checknames_spf(ARGS_CHECKNAMES) {
159 
160 	REQUIRE(rdata->type == dns_rdatatype_spf);
161 
162 	UNUSED(rdata);
163 	UNUSED(owner);
164 	UNUSED(bad);
165 
166 	return (ISC_TRUE);
167 }
168 
169 static inline int
casecompare_spf(ARGS_COMPARE)170 casecompare_spf(ARGS_COMPARE) {
171 	return (compare_spf(rdata1, rdata2));
172 }
173 #endif	/* RDATA_GENERIC_SPF_99_C */
174