/src/bind9/lib/dns/rdata/generic/null_10.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright (C) Internet Systems Consortium, Inc. ("ISC") |
3 | | * |
4 | | * SPDX-License-Identifier: MPL-2.0 |
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_NULL_10_C |
15 | | #define RDATA_GENERIC_NULL_10_C |
16 | | |
17 | 23.8k | #define RRTYPE_NULL_ATTRIBUTES (0) |
18 | | |
19 | | static isc_result_t |
20 | 8 | fromtext_null(ARGS_FROMTEXT) { |
21 | 8 | REQUIRE(type == dns_rdatatype_null); |
22 | | |
23 | 8 | UNUSED(rdclass); |
24 | 8 | UNUSED(type); |
25 | 8 | UNUSED(lexer); |
26 | 8 | UNUSED(origin); |
27 | 8 | UNUSED(options); |
28 | 8 | UNUSED(target); |
29 | 8 | UNUSED(callbacks); |
30 | | |
31 | 8 | return DNS_R_SYNTAX; |
32 | 8 | } |
33 | | |
34 | | static isc_result_t |
35 | 3.48k | totext_null(ARGS_TOTEXT) { |
36 | 3.48k | REQUIRE(rdata->type == dns_rdatatype_null); |
37 | | |
38 | 3.48k | return unknown_totext(rdata, tctx, target); |
39 | 3.48k | } |
40 | | |
41 | | static isc_result_t |
42 | 9.25k | fromwire_null(ARGS_FROMWIRE) { |
43 | 9.25k | isc_region_t sr; |
44 | | |
45 | 9.25k | REQUIRE(type == dns_rdatatype_null); |
46 | | |
47 | 9.25k | UNUSED(type); |
48 | 9.25k | UNUSED(rdclass); |
49 | 9.25k | UNUSED(dctx); |
50 | | |
51 | 9.25k | isc_buffer_activeregion(source, &sr); |
52 | 9.25k | isc_buffer_forward(source, sr.length); |
53 | 9.25k | return mem_tobuffer(target, sr.base, sr.length); |
54 | 9.25k | } |
55 | | |
56 | | static isc_result_t |
57 | 1.77k | towire_null(ARGS_TOWIRE) { |
58 | 1.77k | REQUIRE(rdata->type == dns_rdatatype_null); |
59 | | |
60 | 1.77k | UNUSED(cctx); |
61 | | |
62 | 1.77k | return mem_tobuffer(target, rdata->data, rdata->length); |
63 | 1.77k | } |
64 | | |
65 | | static int |
66 | 5.48k | compare_null(ARGS_COMPARE) { |
67 | 5.48k | isc_region_t r1; |
68 | 5.48k | isc_region_t r2; |
69 | | |
70 | 5.48k | REQUIRE(rdata1->type == rdata2->type); |
71 | 5.48k | REQUIRE(rdata1->rdclass == rdata2->rdclass); |
72 | 5.48k | REQUIRE(rdata1->type == dns_rdatatype_null); |
73 | | |
74 | 5.48k | dns_rdata_toregion(rdata1, &r1); |
75 | 5.48k | dns_rdata_toregion(rdata2, &r2); |
76 | 5.48k | return isc_region_compare(&r1, &r2); |
77 | 5.48k | } |
78 | | |
79 | | static isc_result_t |
80 | 0 | fromstruct_null(ARGS_FROMSTRUCT) { |
81 | 0 | dns_rdata_null_t *null = source; |
82 | |
|
83 | 0 | REQUIRE(type == dns_rdatatype_null); |
84 | 0 | REQUIRE(null != NULL); |
85 | 0 | REQUIRE(null->common.rdtype == type); |
86 | 0 | REQUIRE(null->common.rdclass == rdclass); |
87 | 0 | REQUIRE(null->data != NULL || null->length == 0); |
88 | |
|
89 | 0 | UNUSED(type); |
90 | 0 | UNUSED(rdclass); |
91 | |
|
92 | 0 | return mem_tobuffer(target, null->data, null->length); |
93 | 0 | } |
94 | | |
95 | | static isc_result_t |
96 | 0 | tostruct_null(ARGS_TOSTRUCT) { |
97 | 0 | dns_rdata_null_t *null = target; |
98 | 0 | isc_region_t r; |
99 | |
|
100 | 0 | REQUIRE(rdata->type == dns_rdatatype_null); |
101 | 0 | REQUIRE(null != NULL); |
102 | |
|
103 | 0 | DNS_RDATACOMMON_INIT(null, rdata->type, rdata->rdclass); |
104 | |
|
105 | 0 | dns_rdata_toregion(rdata, &r); |
106 | 0 | null->length = r.length; |
107 | 0 | null->data = mem_maybedup(mctx, r.base, r.length); |
108 | 0 | null->mctx = mctx; |
109 | 0 | return ISC_R_SUCCESS; |
110 | 0 | } |
111 | | |
112 | | static void |
113 | 0 | freestruct_null(ARGS_FREESTRUCT) { |
114 | 0 | dns_rdata_null_t *null = source; |
115 | |
|
116 | 0 | REQUIRE(null != NULL); |
117 | 0 | REQUIRE(null->common.rdtype == dns_rdatatype_null); |
118 | |
|
119 | 0 | if (null->mctx == NULL) { |
120 | 0 | return; |
121 | 0 | } |
122 | | |
123 | 0 | if (null->data != NULL) { |
124 | 0 | isc_mem_free(null->mctx, null->data); |
125 | 0 | } |
126 | 0 | null->mctx = NULL; |
127 | 0 | } |
128 | | |
129 | | static isc_result_t |
130 | 0 | additionaldata_null(ARGS_ADDLDATA) { |
131 | 0 | REQUIRE(rdata->type == dns_rdatatype_null); |
132 | |
|
133 | 0 | UNUSED(rdata); |
134 | 0 | UNUSED(owner); |
135 | 0 | UNUSED(add); |
136 | 0 | UNUSED(arg); |
137 | |
|
138 | 0 | return ISC_R_SUCCESS; |
139 | 0 | } |
140 | | |
141 | | static isc_result_t |
142 | 0 | digest_null(ARGS_DIGEST) { |
143 | 0 | isc_region_t r; |
144 | |
|
145 | 0 | REQUIRE(rdata->type == dns_rdatatype_null); |
146 | |
|
147 | 0 | dns_rdata_toregion(rdata, &r); |
148 | |
|
149 | 0 | return (digest)(arg, &r); |
150 | 0 | } |
151 | | |
152 | | static bool |
153 | 0 | checkowner_null(ARGS_CHECKOWNER) { |
154 | 0 | REQUIRE(type == dns_rdatatype_null); |
155 | |
|
156 | 0 | UNUSED(name); |
157 | 0 | UNUSED(type); |
158 | 0 | UNUSED(rdclass); |
159 | 0 | UNUSED(wildcard); |
160 | |
|
161 | 0 | return true; |
162 | 0 | } |
163 | | |
164 | | static bool |
165 | 0 | checknames_null(ARGS_CHECKNAMES) { |
166 | 0 | REQUIRE(rdata->type == dns_rdatatype_null); |
167 | |
|
168 | 0 | UNUSED(rdata); |
169 | 0 | UNUSED(owner); |
170 | 0 | UNUSED(bad); |
171 | |
|
172 | 0 | return true; |
173 | 0 | } |
174 | | |
175 | | static int |
176 | 0 | casecompare_null(ARGS_COMPARE) { |
177 | 0 | return compare_null(rdata1, rdata2); |
178 | 0 | } |
179 | | |
180 | | #endif /* RDATA_GENERIC_NULL_10_C */ |