Coverage Report

Created: 2025-12-14 06:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/bind9/lib/dns/rdata/generic/hinfo_13.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
#pragma once
15
16
11.6k
#define RRTYPE_HINFO_ATTRIBUTES (0)
17
18
static isc_result_t
19
2.57k
fromtext_hinfo(ARGS_FROMTEXT) {
20
2.57k
  isc_token_t token;
21
2.57k
  int i;
22
23
2.57k
  UNUSED(type);
24
2.57k
  UNUSED(rdclass);
25
2.57k
  UNUSED(origin);
26
2.57k
  UNUSED(options);
27
2.57k
  UNUSED(callbacks);
28
29
2.57k
  REQUIRE(type == dns_rdatatype_hinfo);
30
31
7.69k
  for (i = 0; i < 2; i++) {
32
5.13k
    RETERR(isc_lex_getmastertoken(lexer, &token,
33
5.13k
                isc_tokentype_qstring, false));
34
5.12k
    RETTOK(txt_fromtext(&token.value.as_textregion, target));
35
5.12k
  }
36
2.55k
  return ISC_R_SUCCESS;
37
2.57k
}
38
39
static isc_result_t
40
682
totext_hinfo(ARGS_TOTEXT) {
41
682
  isc_region_t region;
42
43
682
  UNUSED(tctx);
44
45
682
  REQUIRE(rdata->type == dns_rdatatype_hinfo);
46
682
  REQUIRE(rdata->length != 0);
47
48
682
  dns_rdata_toregion(rdata, &region);
49
682
  RETERR(txt_totext(&region, true, target));
50
682
  RETERR(str_totext(" ", target));
51
682
  return txt_totext(&region, true, target);
52
682
}
53
54
static isc_result_t
55
1.27k
fromwire_hinfo(ARGS_FROMWIRE) {
56
1.27k
  REQUIRE(type == dns_rdatatype_hinfo);
57
58
1.27k
  UNUSED(type);
59
1.27k
  UNUSED(dctx);
60
1.27k
  UNUSED(rdclass);
61
62
1.27k
  RETERR(txt_fromwire(source, target));
63
1.07k
  return txt_fromwire(source, target);
64
1.27k
}
65
66
static isc_result_t
67
344
towire_hinfo(ARGS_TOWIRE) {
68
344
  UNUSED(cctx);
69
70
344
  REQUIRE(rdata->type == dns_rdatatype_hinfo);
71
344
  REQUIRE(rdata->length != 0);
72
73
344
  return mem_tobuffer(target, rdata->data, rdata->length);
74
344
}
75
76
static int
77
673k
compare_hinfo(ARGS_COMPARE) {
78
673k
  isc_region_t r1;
79
673k
  isc_region_t r2;
80
81
673k
  REQUIRE(rdata1->type == rdata2->type);
82
673k
  REQUIRE(rdata1->rdclass == rdata2->rdclass);
83
673k
  REQUIRE(rdata1->type == dns_rdatatype_hinfo);
84
673k
  REQUIRE(rdata1->length != 0);
85
673k
  REQUIRE(rdata2->length != 0);
86
87
673k
  dns_rdata_toregion(rdata1, &r1);
88
673k
  dns_rdata_toregion(rdata2, &r2);
89
673k
  return isc_region_compare(&r1, &r2);
90
673k
}
91
92
static isc_result_t
93
0
fromstruct_hinfo(ARGS_FROMSTRUCT) {
94
0
  dns_rdata_hinfo_t *hinfo = source;
95
96
0
  REQUIRE(type == dns_rdatatype_hinfo);
97
0
  REQUIRE(hinfo != NULL);
98
0
  REQUIRE(hinfo->common.rdtype == type);
99
0
  REQUIRE(hinfo->common.rdclass == rdclass);
100
101
0
  UNUSED(type);
102
0
  UNUSED(rdclass);
103
104
0
  RETERR(uint8_tobuffer(hinfo->cpu_len, target));
105
0
  RETERR(mem_tobuffer(target, hinfo->cpu, hinfo->cpu_len));
106
0
  RETERR(uint8_tobuffer(hinfo->os_len, target));
107
0
  return mem_tobuffer(target, hinfo->os, hinfo->os_len);
108
0
}
109
110
static isc_result_t
111
0
tostruct_hinfo(ARGS_TOSTRUCT) {
112
0
  dns_rdata_hinfo_t *hinfo = target;
113
0
  isc_region_t region;
114
115
0
  REQUIRE(rdata->type == dns_rdatatype_hinfo);
116
0
  REQUIRE(hinfo != NULL);
117
0
  REQUIRE(rdata->length != 0);
118
119
0
  DNS_RDATACOMMON_INIT(hinfo, rdata->type, rdata->rdclass);
120
121
0
  dns_rdata_toregion(rdata, &region);
122
0
  hinfo->cpu_len = uint8_fromregion(&region);
123
0
  isc_region_consume(&region, 1);
124
0
  hinfo->cpu = mem_maybedup(mctx, region.base, hinfo->cpu_len);
125
0
  isc_region_consume(&region, hinfo->cpu_len);
126
127
0
  hinfo->os_len = uint8_fromregion(&region);
128
0
  isc_region_consume(&region, 1);
129
0
  hinfo->os = mem_maybedup(mctx, region.base, hinfo->os_len);
130
0
  hinfo->mctx = mctx;
131
0
  return ISC_R_SUCCESS;
132
0
}
133
134
static void
135
0
freestruct_hinfo(ARGS_FREESTRUCT) {
136
0
  dns_rdata_hinfo_t *hinfo = source;
137
138
0
  REQUIRE(hinfo != NULL);
139
140
0
  if (hinfo->mctx == NULL) {
141
0
    return;
142
0
  }
143
144
0
  if (hinfo->cpu != NULL) {
145
0
    isc_mem_free(hinfo->mctx, hinfo->cpu);
146
0
  }
147
0
  if (hinfo->os != NULL) {
148
0
    isc_mem_free(hinfo->mctx, hinfo->os);
149
0
  }
150
0
  hinfo->mctx = NULL;
151
0
}
152
153
static isc_result_t
154
0
additionaldata_hinfo(ARGS_ADDLDATA) {
155
0
  REQUIRE(rdata->type == dns_rdatatype_hinfo);
156
157
0
  UNUSED(rdata);
158
0
  UNUSED(owner);
159
0
  UNUSED(add);
160
0
  UNUSED(arg);
161
162
0
  return ISC_R_SUCCESS;
163
0
}
164
165
static isc_result_t
166
0
digest_hinfo(ARGS_DIGEST) {
167
0
  isc_region_t r;
168
169
0
  REQUIRE(rdata->type == dns_rdatatype_hinfo);
170
171
0
  dns_rdata_toregion(rdata, &r);
172
173
0
  return (digest)(arg, &r);
174
0
}
175
176
static bool
177
0
checkowner_hinfo(ARGS_CHECKOWNER) {
178
0
  REQUIRE(type == dns_rdatatype_hinfo);
179
180
0
  UNUSED(name);
181
0
  UNUSED(type);
182
0
  UNUSED(rdclass);
183
0
  UNUSED(wildcard);
184
185
0
  return true;
186
0
}
187
188
static bool
189
0
checknames_hinfo(ARGS_CHECKNAMES) {
190
0
  REQUIRE(rdata->type == dns_rdatatype_hinfo);
191
192
0
  UNUSED(rdata);
193
0
  UNUSED(owner);
194
0
  UNUSED(bad);
195
196
0
  return true;
197
0
}
198
199
static int
200
0
casecompare_hinfo(ARGS_COMPARE) {
201
0
  return compare_hinfo(rdata1, rdata2);
202
0
}