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