Coverage Report

Created: 2026-07-30 06:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/bind9/lib/dns/rdata/generic/isdn_20.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
/* RFC1183 */
15
16
#ifndef RDATA_GENERIC_ISDN_20_C
17
#define RDATA_GENERIC_ISDN_20_C
18
19
13.9k
#define RRTYPE_ISDN_ATTRIBUTES (0)
20
21
static isc_result_t
22
2.52k
fromtext_isdn(ARGS_FROMTEXT) {
23
2.52k
  isc_token_t token;
24
25
2.52k
  REQUIRE(type == dns_rdatatype_isdn);
26
27
2.52k
  UNUSED(type);
28
2.52k
  UNUSED(rdclass);
29
2.52k
  UNUSED(origin);
30
2.52k
  UNUSED(options);
31
2.52k
  UNUSED(callbacks);
32
33
  /* ISDN-address */
34
2.52k
  RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring,
35
2.52k
              false));
36
2.52k
  RETTOK(txt_fromtext(&token.value.as_textregion, target));
37
38
  /* sa: optional */
39
2.51k
  RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring,
40
2.51k
              true));
41
2.51k
  if (token.type != isc_tokentype_string &&
42
1.28k
      token.type != isc_tokentype_qstring)
43
1.07k
  {
44
1.07k
    isc_lex_ungettoken(lexer, &token);
45
1.07k
    return ISC_R_SUCCESS;
46
1.07k
  }
47
1.43k
  RETTOK(txt_fromtext(&token.value.as_textregion, target));
48
1.43k
  return ISC_R_SUCCESS;
49
1.43k
}
50
51
static isc_result_t
52
1.22k
totext_isdn(ARGS_TOTEXT) {
53
1.22k
  isc_region_t region;
54
55
1.22k
  REQUIRE(rdata->type == dns_rdatatype_isdn);
56
1.22k
  REQUIRE(rdata->length != 0);
57
58
1.22k
  UNUSED(tctx);
59
60
1.22k
  dns_rdata_toregion(rdata, &region);
61
1.22k
  RETERR(txt_totext(&region, true, target));
62
1.22k
  if (region.length == 0) {
63
707
    return ISC_R_SUCCESS;
64
707
  }
65
520
  RETERR(str_totext(" ", target));
66
520
  return txt_totext(&region, true, target);
67
520
}
68
69
static isc_result_t
70
1.94k
fromwire_isdn(ARGS_FROMWIRE) {
71
1.94k
  REQUIRE(type == dns_rdatatype_isdn);
72
73
1.94k
  UNUSED(type);
74
1.94k
  UNUSED(dctx);
75
1.94k
  UNUSED(rdclass);
76
77
1.94k
  RETERR(txt_fromwire(source, target));
78
1.87k
  if (buffer_empty(source)) {
79
1.08k
    return ISC_R_SUCCESS;
80
1.08k
  }
81
789
  return txt_fromwire(source, target);
82
1.87k
}
83
84
static isc_result_t
85
622
towire_isdn(ARGS_TOWIRE) {
86
622
  UNUSED(cctx);
87
88
622
  REQUIRE(rdata->type == dns_rdatatype_isdn);
89
622
  REQUIRE(rdata->length != 0);
90
91
622
  return mem_tobuffer(target, rdata->data, rdata->length);
92
622
}
93
94
static int
95
1.02M
compare_isdn(ARGS_COMPARE) {
96
1.02M
  isc_region_t r1;
97
1.02M
  isc_region_t r2;
98
99
1.02M
  REQUIRE(rdata1->type == rdata2->type);
100
1.02M
  REQUIRE(rdata1->rdclass == rdata2->rdclass);
101
1.02M
  REQUIRE(rdata1->type == dns_rdatatype_isdn);
102
1.02M
  REQUIRE(rdata1->length != 0);
103
1.02M
  REQUIRE(rdata2->length != 0);
104
105
1.02M
  dns_rdata_toregion(rdata1, &r1);
106
1.02M
  dns_rdata_toregion(rdata2, &r2);
107
1.02M
  return isc_region_compare(&r1, &r2);
108
1.02M
}
109
110
static isc_result_t
111
0
fromstruct_isdn(ARGS_FROMSTRUCT) {
112
0
  dns_rdata_isdn_t *isdn = source;
113
114
0
  REQUIRE(type == dns_rdatatype_isdn);
115
0
  REQUIRE(isdn != NULL);
116
0
  REQUIRE(isdn->common.rdtype == type);
117
0
  REQUIRE(isdn->common.rdclass == rdclass);
118
119
0
  UNUSED(type);
120
0
  UNUSED(rdclass);
121
122
0
  RETERR(uint8_tobuffer(isdn->isdn_len, target));
123
0
  RETERR(mem_tobuffer(target, isdn->isdn, isdn->isdn_len));
124
0
  if (isdn->subaddress == NULL) {
125
0
    return ISC_R_SUCCESS;
126
0
  }
127
0
  RETERR(uint8_tobuffer(isdn->subaddress_len, target));
128
0
  return mem_tobuffer(target, isdn->subaddress, isdn->subaddress_len);
129
0
}
130
131
static isc_result_t
132
0
tostruct_isdn(ARGS_TOSTRUCT) {
133
0
  dns_rdata_isdn_t *isdn = target;
134
0
  isc_region_t r;
135
136
0
  REQUIRE(rdata->type == dns_rdatatype_isdn);
137
0
  REQUIRE(isdn != NULL);
138
0
  REQUIRE(rdata->length != 0);
139
140
0
  DNS_RDATACOMMON_INIT(isdn, rdata->type, rdata->rdclass);
141
142
0
  dns_rdata_toregion(rdata, &r);
143
144
0
  isdn->isdn_len = uint8_fromregion(&r);
145
0
  isc_region_consume(&r, 1);
146
0
  isdn->isdn = mem_maybedup(mctx, r.base, isdn->isdn_len);
147
0
  isc_region_consume(&r, isdn->isdn_len);
148
149
0
  if (r.length == 0) {
150
0
    isdn->subaddress_len = 0;
151
0
    isdn->subaddress = NULL;
152
0
  } else {
153
0
    isdn->subaddress_len = uint8_fromregion(&r);
154
0
    isc_region_consume(&r, 1);
155
0
    isdn->subaddress = mem_maybedup(mctx, r.base,
156
0
            isdn->subaddress_len);
157
0
  }
158
159
0
  isdn->mctx = mctx;
160
0
  return ISC_R_SUCCESS;
161
0
}
162
163
static void
164
0
freestruct_isdn(ARGS_FREESTRUCT) {
165
0
  dns_rdata_isdn_t *isdn = source;
166
167
0
  REQUIRE(isdn != NULL);
168
169
0
  if (isdn->mctx == NULL) {
170
0
    return;
171
0
  }
172
173
0
  if (isdn->isdn != NULL) {
174
0
    isc_mem_free(isdn->mctx, isdn->isdn);
175
0
  }
176
0
  if (isdn->subaddress != NULL) {
177
0
    isc_mem_free(isdn->mctx, isdn->subaddress);
178
0
  }
179
0
  isdn->mctx = NULL;
180
0
}
181
182
static isc_result_t
183
0
additionaldata_isdn(ARGS_ADDLDATA) {
184
0
  REQUIRE(rdata->type == dns_rdatatype_isdn);
185
186
0
  UNUSED(rdata);
187
0
  UNUSED(owner);
188
0
  UNUSED(add);
189
0
  UNUSED(arg);
190
191
0
  return ISC_R_SUCCESS;
192
0
}
193
194
static isc_result_t
195
0
digest_isdn(ARGS_DIGEST) {
196
0
  isc_region_t r;
197
198
0
  REQUIRE(rdata->type == dns_rdatatype_isdn);
199
200
0
  dns_rdata_toregion(rdata, &r);
201
202
0
  return (digest)(arg, &r);
203
0
}
204
205
static bool
206
0
checkowner_isdn(ARGS_CHECKOWNER) {
207
0
  REQUIRE(type == dns_rdatatype_isdn);
208
209
0
  UNUSED(name);
210
0
  UNUSED(type);
211
0
  UNUSED(rdclass);
212
0
  UNUSED(wildcard);
213
214
0
  return true;
215
0
}
216
217
static bool
218
0
checknames_isdn(ARGS_CHECKNAMES) {
219
0
  REQUIRE(rdata->type == dns_rdatatype_isdn);
220
221
0
  UNUSED(rdata);
222
0
  UNUSED(owner);
223
0
  UNUSED(bad);
224
225
0
  return true;
226
0
}
227
228
static int
229
0
casecompare_isdn(ARGS_COMPARE) {
230
0
  return compare_isdn(rdata1, rdata2);
231
0
}
232
233
#endif /* RDATA_GENERIC_ISDN_20_C */