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/gpos_27.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
/* RFC1712 */
15
16
#ifndef RDATA_GENERIC_GPOS_27_C
17
#define RDATA_GENERIC_GPOS_27_C
18
19
12.3k
#define RRTYPE_GPOS_ATTRIBUTES (0)
20
21
static isc_result_t
22
1.35k
fromtext_gpos(ARGS_FROMTEXT) {
23
1.35k
  isc_token_t token;
24
1.35k
  int i;
25
26
1.35k
  REQUIRE(type == dns_rdatatype_gpos);
27
28
1.35k
  UNUSED(type);
29
1.35k
  UNUSED(rdclass);
30
1.35k
  UNUSED(origin);
31
1.35k
  UNUSED(options);
32
1.35k
  UNUSED(callbacks);
33
34
5.36k
  for (i = 0; i < 3; i++) {
35
4.04k
    RETERR(isc_lex_getmastertoken(lexer, &token,
36
4.04k
                isc_tokentype_qstring, false));
37
4.02k
    RETTOK(txt_fromtext(&token.value.as_textregion, target));
38
4.02k
  }
39
1.32k
  return ISC_R_SUCCESS;
40
1.35k
}
41
42
static isc_result_t
43
1.18k
totext_gpos(ARGS_TOTEXT) {
44
1.18k
  isc_region_t region;
45
1.18k
  int i;
46
47
1.18k
  REQUIRE(rdata->type == dns_rdatatype_gpos);
48
1.18k
  REQUIRE(rdata->length != 0);
49
50
1.18k
  UNUSED(tctx);
51
52
1.18k
  dns_rdata_toregion(rdata, &region);
53
54
4.73k
  for (i = 0; i < 3; i++) {
55
3.54k
    RETERR(txt_totext(&region, true, target));
56
3.54k
    if (i != 2) {
57
2.36k
      RETERR(str_totext(" ", target));
58
2.36k
    }
59
3.54k
  }
60
61
1.18k
  return ISC_R_SUCCESS;
62
1.18k
}
63
64
static isc_result_t
65
1.92k
fromwire_gpos(ARGS_FROMWIRE) {
66
1.92k
  int i;
67
68
1.92k
  REQUIRE(type == dns_rdatatype_gpos);
69
70
1.92k
  UNUSED(type);
71
1.92k
  UNUSED(dctx);
72
1.92k
  UNUSED(rdclass);
73
74
7.10k
  for (i = 0; i < 3; i++) {
75
5.40k
    RETERR(txt_fromwire(source, target));
76
5.18k
  }
77
1.70k
  return ISC_R_SUCCESS;
78
1.92k
}
79
80
static isc_result_t
81
838
towire_gpos(ARGS_TOWIRE) {
82
838
  REQUIRE(rdata->type == dns_rdatatype_gpos);
83
838
  REQUIRE(rdata->length != 0);
84
85
838
  UNUSED(cctx);
86
87
838
  return mem_tobuffer(target, rdata->data, rdata->length);
88
838
}
89
90
static int
91
981k
compare_gpos(ARGS_COMPARE) {
92
981k
  isc_region_t r1;
93
981k
  isc_region_t r2;
94
95
981k
  REQUIRE(rdata1->type == rdata2->type);
96
981k
  REQUIRE(rdata1->rdclass == rdata2->rdclass);
97
981k
  REQUIRE(rdata1->type == dns_rdatatype_gpos);
98
981k
  REQUIRE(rdata1->length != 0);
99
981k
  REQUIRE(rdata2->length != 0);
100
101
981k
  dns_rdata_toregion(rdata1, &r1);
102
981k
  dns_rdata_toregion(rdata2, &r2);
103
981k
  return isc_region_compare(&r1, &r2);
104
981k
}
105
106
static isc_result_t
107
0
fromstruct_gpos(ARGS_FROMSTRUCT) {
108
0
  dns_rdata_gpos_t *gpos = source;
109
110
0
  REQUIRE(type == dns_rdatatype_gpos);
111
0
  REQUIRE(gpos != NULL);
112
0
  REQUIRE(gpos->common.rdtype == type);
113
0
  REQUIRE(gpos->common.rdclass == rdclass);
114
115
0
  UNUSED(type);
116
0
  UNUSED(rdclass);
117
118
0
  RETERR(uint8_tobuffer(gpos->long_len, target));
119
0
  RETERR(mem_tobuffer(target, gpos->longitude, gpos->long_len));
120
0
  RETERR(uint8_tobuffer(gpos->lat_len, target));
121
0
  RETERR(mem_tobuffer(target, gpos->latitude, gpos->lat_len));
122
0
  RETERR(uint8_tobuffer(gpos->alt_len, target));
123
0
  return mem_tobuffer(target, gpos->altitude, gpos->alt_len);
124
0
}
125
126
static isc_result_t
127
0
tostruct_gpos(ARGS_TOSTRUCT) {
128
0
  dns_rdata_gpos_t *gpos = target;
129
0
  isc_region_t region;
130
131
0
  REQUIRE(rdata->type == dns_rdatatype_gpos);
132
0
  REQUIRE(gpos != NULL);
133
0
  REQUIRE(rdata->length != 0);
134
135
0
  DNS_RDATACOMMON_INIT(gpos, rdata->type, rdata->rdclass);
136
137
0
  dns_rdata_toregion(rdata, &region);
138
0
  gpos->long_len = uint8_fromregion(&region);
139
0
  isc_region_consume(&region, 1);
140
0
  gpos->longitude = mem_maybedup(mctx, region.base, gpos->long_len);
141
0
  isc_region_consume(&region, gpos->long_len);
142
143
0
  gpos->lat_len = uint8_fromregion(&region);
144
0
  isc_region_consume(&region, 1);
145
0
  gpos->latitude = mem_maybedup(mctx, region.base, gpos->lat_len);
146
0
  isc_region_consume(&region, gpos->lat_len);
147
148
0
  gpos->alt_len = uint8_fromregion(&region);
149
0
  isc_region_consume(&region, 1);
150
0
  if (gpos->lat_len > 0) {
151
0
    gpos->altitude = mem_maybedup(mctx, region.base, gpos->alt_len);
152
0
  } else {
153
0
    gpos->altitude = NULL;
154
0
  }
155
156
0
  gpos->mctx = mctx;
157
0
  return ISC_R_SUCCESS;
158
0
}
159
160
static void
161
0
freestruct_gpos(ARGS_FREESTRUCT) {
162
0
  dns_rdata_gpos_t *gpos = source;
163
164
0
  REQUIRE(gpos != NULL);
165
0
  REQUIRE(gpos->common.rdtype == dns_rdatatype_gpos);
166
167
0
  if (gpos->mctx == NULL) {
168
0
    return;
169
0
  }
170
171
0
  if (gpos->longitude != NULL) {
172
0
    isc_mem_free(gpos->mctx, gpos->longitude);
173
0
  }
174
0
  if (gpos->latitude != NULL) {
175
0
    isc_mem_free(gpos->mctx, gpos->latitude);
176
0
  }
177
0
  if (gpos->altitude != NULL) {
178
0
    isc_mem_free(gpos->mctx, gpos->altitude);
179
0
  }
180
0
  gpos->mctx = NULL;
181
0
}
182
183
static isc_result_t
184
0
additionaldata_gpos(ARGS_ADDLDATA) {
185
0
  REQUIRE(rdata->type == dns_rdatatype_gpos);
186
187
0
  UNUSED(rdata);
188
0
  UNUSED(owner);
189
0
  UNUSED(add);
190
0
  UNUSED(arg);
191
192
0
  return ISC_R_SUCCESS;
193
0
}
194
195
static isc_result_t
196
0
digest_gpos(ARGS_DIGEST) {
197
0
  isc_region_t r;
198
199
0
  REQUIRE(rdata->type == dns_rdatatype_gpos);
200
201
0
  dns_rdata_toregion(rdata, &r);
202
203
0
  return (digest)(arg, &r);
204
0
}
205
206
static bool
207
0
checkowner_gpos(ARGS_CHECKOWNER) {
208
0
  REQUIRE(type == dns_rdatatype_gpos);
209
210
0
  UNUSED(name);
211
0
  UNUSED(type);
212
0
  UNUSED(rdclass);
213
0
  UNUSED(wildcard);
214
215
0
  return true;
216
0
}
217
218
static bool
219
0
checknames_gpos(ARGS_CHECKNAMES) {
220
0
  REQUIRE(rdata->type == dns_rdatatype_gpos);
221
222
0
  UNUSED(rdata);
223
0
  UNUSED(owner);
224
0
  UNUSED(bad);
225
226
0
  return true;
227
0
}
228
229
static int
230
0
casecompare_gpos(ARGS_COMPARE) {
231
0
  return compare_gpos(rdata1, rdata2);
232
0
}
233
234
#endif /* RDATA_GENERIC_GPOS_27_C */