Home | History | Annotate | Line # | Download | only in generic
      1 /*	$NetBSD: rkey_57.c,v 1.10 2026/01/29 18:37:53 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_RKEY_57_C
     17 #define RDATA_GENERIC_RKEY_57_C
     18 
     19 #define RRTYPE_RKEY_ATTRIBUTES 0
     20 
     21 static isc_result_t
     22 fromtext_rkey(ARGS_FROMTEXT) {
     23 	REQUIRE(type == dns_rdatatype_rkey);
     24 
     25 	return generic_fromtext_key(CALL_FROMTEXT);
     26 }
     27 
     28 static isc_result_t
     29 totext_rkey(ARGS_TOTEXT) {
     30 	REQUIRE(rdata != NULL);
     31 	REQUIRE(rdata->type == dns_rdatatype_rkey);
     32 
     33 	return generic_totext_key(CALL_TOTEXT);
     34 }
     35 
     36 static isc_result_t
     37 fromwire_rkey(ARGS_FROMWIRE) {
     38 	REQUIRE(type == dns_rdatatype_rkey);
     39 
     40 	return generic_fromwire_key(CALL_FROMWIRE);
     41 }
     42 
     43 static isc_result_t
     44 towire_rkey(ARGS_TOWIRE) {
     45 	isc_region_t sr;
     46 
     47 	REQUIRE(rdata != NULL);
     48 	REQUIRE(rdata->type == dns_rdatatype_rkey);
     49 	REQUIRE(rdata->length != 0);
     50 
     51 	UNUSED(cctx);
     52 
     53 	dns_rdata_toregion(rdata, &sr);
     54 	return mem_tobuffer(target, sr.base, sr.length);
     55 }
     56 
     57 static int
     58 compare_rkey(ARGS_COMPARE) {
     59 	isc_region_t r1;
     60 	isc_region_t r2;
     61 
     62 	REQUIRE(rdata1 != NULL);
     63 	REQUIRE(rdata2 != NULL);
     64 	REQUIRE(rdata1->type == rdata2->type);
     65 	REQUIRE(rdata1->rdclass == rdata2->rdclass);
     66 	REQUIRE(rdata1->type == dns_rdatatype_rkey);
     67 	REQUIRE(rdata1->length != 0);
     68 	REQUIRE(rdata2->length != 0);
     69 
     70 	dns_rdata_toregion(rdata1, &r1);
     71 	dns_rdata_toregion(rdata2, &r2);
     72 	return isc_region_compare(&r1, &r2);
     73 }
     74 
     75 static isc_result_t
     76 fromstruct_rkey(ARGS_FROMSTRUCT) {
     77 	REQUIRE(type == dns_rdatatype_rkey);
     78 
     79 	return generic_fromstruct_key(CALL_FROMSTRUCT);
     80 }
     81 
     82 static isc_result_t
     83 tostruct_rkey(ARGS_TOSTRUCT) {
     84 	dns_rdata_rkey_t *rkey = target;
     85 
     86 	REQUIRE(rkey != NULL);
     87 	REQUIRE(rdata != NULL);
     88 	REQUIRE(rdata->type == dns_rdatatype_rkey);
     89 
     90 	DNS_RDATACOMMON_INIT(rkey, rdata->type, rdata->rdclass);
     91 
     92 	return generic_tostruct_key(CALL_TOSTRUCT);
     93 }
     94 
     95 static void
     96 freestruct_rkey(ARGS_FREESTRUCT) {
     97 	dns_rdata_rkey_t *rkey = (dns_rdata_rkey_t *)source;
     98 
     99 	REQUIRE(rkey != NULL);
    100 	REQUIRE(rkey->common.rdtype == dns_rdatatype_rkey);
    101 
    102 	generic_freestruct_key(source);
    103 }
    104 
    105 static isc_result_t
    106 additionaldata_rkey(ARGS_ADDLDATA) {
    107 	REQUIRE(rdata->type == dns_rdatatype_rkey);
    108 
    109 	UNUSED(rdata);
    110 	UNUSED(owner);
    111 	UNUSED(add);
    112 	UNUSED(arg);
    113 
    114 	return ISC_R_SUCCESS;
    115 }
    116 
    117 static isc_result_t
    118 digest_rkey(ARGS_DIGEST) {
    119 	isc_region_t r;
    120 
    121 	REQUIRE(rdata != NULL);
    122 	REQUIRE(rdata->type == dns_rdatatype_rkey);
    123 
    124 	dns_rdata_toregion(rdata, &r);
    125 
    126 	return (digest)(arg, &r);
    127 }
    128 
    129 static bool
    130 checkowner_rkey(ARGS_CHECKOWNER) {
    131 	REQUIRE(type == dns_rdatatype_rkey);
    132 
    133 	UNUSED(name);
    134 	UNUSED(type);
    135 	UNUSED(rdclass);
    136 	UNUSED(wildcard);
    137 
    138 	return true;
    139 }
    140 
    141 static bool
    142 checknames_rkey(ARGS_CHECKNAMES) {
    143 	REQUIRE(rdata != NULL);
    144 	REQUIRE(rdata->type == dns_rdatatype_rkey);
    145 
    146 	UNUSED(rdata);
    147 	UNUSED(owner);
    148 	UNUSED(bad);
    149 
    150 	return true;
    151 }
    152 
    153 static int
    154 casecompare_rkey(ARGS_COMPARE) {
    155 	/*
    156 	 * Treat ALG 253 (private DNS) subtype name case sensitively.
    157 	 */
    158 	return compare_rkey(rdata1, rdata2);
    159 }
    160 
    161 #endif /* RDATA_GENERIC_RKEY_57_C */
    162