Coverage Report

Created: 2026-09-03 06:30

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
52.0k
#define RRTYPE_HINFO_ATTRIBUTES (0)
17
18
static isc_result_t
19
5.89k
fromtext_hinfo(ARGS_FROMTEXT) {
20
5.89k
  isc_token_t token;
21
5.89k
  int i;
22
23
5.89k
  UNUSED(type);
24
5.89k
  UNUSED(rdclass);
25
5.89k
  UNUSED(origin);
26
5.89k
  UNUSED(options);
27
5.89k
  UNUSED(callbacks);
28
29
5.89k
  REQUIRE(type == dns_rdatatype_hinfo);
30
31
17.6k
  for (i = 0; i < 2; i++) {
32
11.7k
    RETERR(isc_lex_getmastertoken(lexer, &token,
33
11.7k
                isc_tokentype_qstring, false));
34
11.7k
    RETTOK(txt_fromtext(&token.value.as_textregion, target));
35
11.7k
  }
36
5.86k
  return ISC_R_SUCCESS;
37
5.89k
}
38
39
static isc_result_t
40
691
totext_hinfo(ARGS_TOTEXT) {
41
691
  isc_region_t region;
42
43
691
  UNUSED(tctx);
44
45
691
  REQUIRE(rdata->type == dns_rdatatype_hinfo);
46
691
  REQUIRE(rdata->length != 0);
47
48
691
  dns_rdata_toregion(rdata, &region);
49
691
  RETERR(txt_totext(&region, true, target));
50
691
  RETERR(str_totext(" ", target));
51
691
  return txt_totext(&region, true, target);
52
691
}
53
54
static isc_result_t
55
10.1k
fromwire_hinfo(ARGS_FROMWIRE) {
56
10.1k
  REQUIRE(type == dns_rdatatype_hinfo);
57
58
10.1k
  UNUSED(type);
59
10.1k
  UNUSED(dctx);
60
10.1k
  UNUSED(rdclass);
61
62
10.1k
  RETERR(txt_fromwire(source, target));
63
9.98k
  return txt_fromwire(source, target);
64
10.1k
}
65
66
static isc_result_t
67
348
towire_hinfo(ARGS_TOWIRE) {
68
348
  UNUSED(cctx);
69
70
348
  REQUIRE(rdata->type == dns_rdatatype_hinfo);
71
348
  REQUIRE(rdata->length != 0);
72
73
348
  return mem_tobuffer(target, rdata->data, rdata->length);
74
348
}
75
76
static int
77
11.2M
compare_hinfo(ARGS_COMPARE) {
78
11.2M
  isc_region_t r1;
79
11.2M
  isc_region_t r2;
80
81
11.2M
  REQUIRE(rdata1->type == rdata2->type);
82
11.2M
  REQUIRE(rdata1->rdclass == rdata2->rdclass);
83
11.2M
  REQUIRE(rdata1->type == dns_rdatatype_hinfo);
84
11.2M
  REQUIRE(rdata1->length != 0);
85
11.2M
  REQUIRE(rdata2->length != 0);
86
87
11.2M
  dns_rdata_toregion(rdata1, &r1);
88
11.2M
  dns_rdata_toregion(rdata2, &r2);
89
11.2M
  return isc_region_compare(&r1, &r2);
90
11.2M
}
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
}