Coverage Report

Created: 2026-01-17 06:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/bind9/lib/dns/rdata/generic/l64_106.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_L64_106_C
15
#define RDATA_GENERIC_L64_106_C
16
17
#include <string.h>
18
19
#include <isc/net.h>
20
21
7.38k
#define RRTYPE_L64_ATTRIBUTES (0)
22
23
static isc_result_t
24
102
fromtext_l64(ARGS_FROMTEXT) {
25
102
  isc_token_t token;
26
102
  unsigned char locator[NS_LOCATORSZ];
27
28
102
  REQUIRE(type == dns_rdatatype_l64);
29
30
102
  UNUSED(type);
31
102
  UNUSED(rdclass);
32
102
  UNUSED(origin);
33
102
  UNUSED(options);
34
102
  UNUSED(callbacks);
35
36
102
  RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
37
102
              false));
38
99
  if (token.value.as_ulong > 0xffffU) {
39
18
    RETTOK(ISC_R_RANGE);
40
18
  }
41
81
  RETERR(uint16_tobuffer(token.value.as_ulong, target));
42
43
81
  RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
44
81
              false));
45
46
58
  if (locator_pton(DNS_AS_STR(token), locator) != 1) {
47
33
    RETTOK(DNS_R_SYNTAX);
48
33
  }
49
25
  return mem_tobuffer(target, locator, NS_LOCATORSZ);
50
58
}
51
52
static isc_result_t
53
719
totext_l64(ARGS_TOTEXT) {
54
719
  isc_region_t region;
55
719
  char buf[sizeof("xxxx:xxxx:xxxx:xxxx")];
56
719
  unsigned short num;
57
58
719
  REQUIRE(rdata->type == dns_rdatatype_l64);
59
719
  REQUIRE(rdata->length == 10);
60
61
719
  UNUSED(tctx);
62
63
719
  dns_rdata_toregion(rdata, &region);
64
719
  num = uint16_fromregion(&region);
65
719
  isc_region_consume(&region, 2);
66
719
  snprintf(buf, sizeof(buf), "%u", num);
67
719
  RETERR(str_totext(buf, target));
68
69
719
  RETERR(str_totext(" ", target));
70
71
719
  snprintf(buf, sizeof(buf), "%x:%x:%x:%x",
72
719
     region.base[0] << 8 | region.base[1],
73
719
     region.base[2] << 8 | region.base[3],
74
719
     region.base[4] << 8 | region.base[5],
75
719
     region.base[6] << 8 | region.base[7]);
76
719
  return str_totext(buf, target);
77
719
}
78
79
static isc_result_t
80
859
fromwire_l64(ARGS_FROMWIRE) {
81
859
  isc_region_t sregion;
82
83
859
  REQUIRE(type == dns_rdatatype_l64);
84
85
859
  UNUSED(type);
86
859
  UNUSED(rdclass);
87
859
  UNUSED(dctx);
88
89
859
  isc_buffer_activeregion(source, &sregion);
90
859
  if (sregion.length != 10) {
91
34
    return DNS_R_FORMERR;
92
34
  }
93
825
  isc_buffer_forward(source, sregion.length);
94
825
  return mem_tobuffer(target, sregion.base, sregion.length);
95
859
}
96
97
static isc_result_t
98
364
towire_l64(ARGS_TOWIRE) {
99
364
  REQUIRE(rdata->type == dns_rdatatype_l64);
100
364
  REQUIRE(rdata->length == 10);
101
102
364
  UNUSED(cctx);
103
104
364
  return mem_tobuffer(target, rdata->data, rdata->length);
105
364
}
106
107
static int
108
0
compare_l64(ARGS_COMPARE) {
109
0
  isc_region_t region1;
110
0
  isc_region_t region2;
111
112
0
  REQUIRE(rdata1->type == rdata2->type);
113
0
  REQUIRE(rdata1->rdclass == rdata2->rdclass);
114
0
  REQUIRE(rdata1->type == dns_rdatatype_l64);
115
0
  REQUIRE(rdata1->length == 10);
116
0
  REQUIRE(rdata2->length == 10);
117
118
0
  dns_rdata_toregion(rdata1, &region1);
119
0
  dns_rdata_toregion(rdata2, &region2);
120
0
  return isc_region_compare(&region1, &region2);
121
0
}
122
123
static isc_result_t
124
0
fromstruct_l64(ARGS_FROMSTRUCT) {
125
0
  dns_rdata_l64_t *l64 = source;
126
127
0
  REQUIRE(type == dns_rdatatype_l64);
128
0
  REQUIRE(l64 != NULL);
129
0
  REQUIRE(l64->common.rdtype == type);
130
0
  REQUIRE(l64->common.rdclass == rdclass);
131
132
0
  UNUSED(type);
133
0
  UNUSED(rdclass);
134
135
0
  RETERR(uint16_tobuffer(l64->pref, target));
136
0
  return mem_tobuffer(target, l64->l64, sizeof(l64->l64));
137
0
}
138
139
static isc_result_t
140
0
tostruct_l64(ARGS_TOSTRUCT) {
141
0
  isc_region_t region;
142
0
  dns_rdata_l64_t *l64 = target;
143
144
0
  REQUIRE(rdata->type == dns_rdatatype_l64);
145
0
  REQUIRE(l64 != NULL);
146
0
  REQUIRE(rdata->length == 10);
147
148
0
  UNUSED(mctx);
149
150
0
  DNS_RDATACOMMON_INIT(l64, rdata->type, rdata->rdclass);
151
152
0
  dns_rdata_toregion(rdata, &region);
153
0
  l64->pref = uint16_fromregion(&region);
154
0
  memmove(l64->l64, region.base, region.length);
155
0
  return ISC_R_SUCCESS;
156
0
}
157
158
static void
159
0
freestruct_l64(ARGS_FREESTRUCT) {
160
0
  dns_rdata_l64_t *l64 = source;
161
162
0
  REQUIRE(l64 != NULL);
163
0
  REQUIRE(l64->common.rdtype == dns_rdatatype_l64);
164
165
0
  return;
166
0
}
167
168
static isc_result_t
169
0
additionaldata_l64(ARGS_ADDLDATA) {
170
0
  REQUIRE(rdata->type == dns_rdatatype_l64);
171
0
  REQUIRE(rdata->length == 10);
172
173
0
  UNUSED(rdata);
174
0
  UNUSED(owner);
175
0
  UNUSED(add);
176
0
  UNUSED(arg);
177
178
0
  return ISC_R_SUCCESS;
179
0
}
180
181
static isc_result_t
182
0
digest_l64(ARGS_DIGEST) {
183
0
  isc_region_t r;
184
185
0
  REQUIRE(rdata->type == dns_rdatatype_l64);
186
0
  REQUIRE(rdata->length == 10);
187
188
0
  dns_rdata_toregion(rdata, &r);
189
190
0
  return (digest)(arg, &r);
191
0
}
192
193
static bool
194
0
checkowner_l64(ARGS_CHECKOWNER) {
195
0
  REQUIRE(type == dns_rdatatype_l64);
196
197
0
  UNUSED(name);
198
0
  UNUSED(type);
199
0
  UNUSED(rdclass);
200
0
  UNUSED(wildcard);
201
202
0
  return true;
203
0
}
204
205
static bool
206
0
checknames_l64(ARGS_CHECKNAMES) {
207
0
  REQUIRE(rdata->type == dns_rdatatype_l64);
208
0
  REQUIRE(rdata->length == 10);
209
210
0
  UNUSED(rdata);
211
0
  UNUSED(owner);
212
0
  UNUSED(bad);
213
214
0
  return true;
215
0
}
216
217
static int
218
0
casecompare_l64(ARGS_COMPARE) {
219
0
  return compare_l64(rdata1, rdata2);
220
0
}
221
222
#endif /* RDATA_GENERIC_L64_106_C */