Coverage Report

Created: 2026-10-28 06:55

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
15.2k
#define RRTYPE_GPOS_ATTRIBUTES (0)
20
21
static isc_result_t
22
4.67k
fromtext_gpos(ARGS_FROMTEXT) {
23
4.67k
  isc_token_t token;
24
4.67k
  int i;
25
26
4.67k
  REQUIRE(type == dns_rdatatype_gpos);
27
28
4.67k
  UNUSED(type);
29
4.67k
  UNUSED(rdclass);
30
4.67k
  UNUSED(origin);
31
4.67k
  UNUSED(options);
32
4.67k
  UNUSED(callbacks);
33
34
18.6k
  for (i = 0; i < 3; i++) {
35
13.9k
    RETERR(isc_lex_getmastertoken(lexer, &token,
36
13.9k
                isc_tokentype_qstring, false));
37
13.9k
    RETTOK(txt_fromtext(&token.value.as_textregion, target));
38
13.9k
  }
39
4.63k
  return ISC_R_SUCCESS;
40
4.67k
}
41
42
static isc_result_t
43
843
totext_gpos(ARGS_TOTEXT) {
44
843
  isc_region_t region;
45
843
  int i;
46
47
843
  REQUIRE(rdata->type == dns_rdatatype_gpos);
48
843
  REQUIRE(rdata->length != 0);
49
50
843
  UNUSED(tctx);
51
52
843
  dns_rdata_toregion(rdata, &region);
53
54
3.37k
  for (i = 0; i < 3; i++) {
55
2.52k
    RETERR(txt_totext(&region, true, target));
56
2.52k
    if (i != 2) {
57
1.68k
      RETERR(str_totext(" ", target));
58
1.68k
    }
59
2.52k
  }
60
61
843
  return ISC_R_SUCCESS;
62
843
}
63
64
static isc_result_t
65
1.26k
fromwire_gpos(ARGS_FROMWIRE) {
66
1.26k
  int i;
67
68
1.26k
  REQUIRE(type == dns_rdatatype_gpos);
69
70
1.26k
  UNUSED(type);
71
1.26k
  UNUSED(dctx);
72
1.26k
  UNUSED(rdclass);
73
74
4.97k
  for (i = 0; i < 3; i++) {
75
3.76k
    RETERR(txt_fromwire(source, target));
76
3.71k
  }
77
1.21k
  return ISC_R_SUCCESS;
78
1.26k
}
79
80
static int
81
5.25M
compare_gpos(ARGS_COMPARE) {
82
5.25M
  isc_region_t r1;
83
5.25M
  isc_region_t r2;
84
85
5.25M
  REQUIRE(rdata1->type == rdata2->type);
86
5.25M
  REQUIRE(rdata1->rdclass == rdata2->rdclass);
87
5.25M
  REQUIRE(rdata1->type == dns_rdatatype_gpos);
88
5.25M
  REQUIRE(rdata1->length != 0);
89
5.25M
  REQUIRE(rdata2->length != 0);
90
91
5.25M
  dns_rdata_toregion(rdata1, &r1);
92
5.25M
  dns_rdata_toregion(rdata2, &r2);
93
5.25M
  return isc_region_compare(&r1, &r2);
94
5.25M
}
95
96
static isc_result_t
97
0
fromstruct_gpos(ARGS_FROMSTRUCT) {
98
0
  dns_rdata_gpos_t *gpos = source;
99
100
0
  REQUIRE(type == dns_rdatatype_gpos);
101
0
  REQUIRE(gpos != NULL);
102
0
  REQUIRE(gpos->common.rdtype == type);
103
0
  REQUIRE(gpos->common.rdclass == rdclass);
104
105
0
  UNUSED(type);
106
0
  UNUSED(rdclass);
107
108
0
  RETERR(uint8_tobuffer(gpos->long_len, target));
109
0
  RETERR(mem_tobuffer(target, gpos->longitude, gpos->long_len));
110
0
  RETERR(uint8_tobuffer(gpos->lat_len, target));
111
0
  RETERR(mem_tobuffer(target, gpos->latitude, gpos->lat_len));
112
0
  RETERR(uint8_tobuffer(gpos->alt_len, target));
113
0
  return mem_tobuffer(target, gpos->altitude, gpos->alt_len);
114
0
}
115
116
static isc_result_t
117
0
tostruct_gpos(ARGS_TOSTRUCT) {
118
0
  dns_rdata_gpos_t *gpos = target;
119
0
  isc_region_t region;
120
121
0
  REQUIRE(rdata->type == dns_rdatatype_gpos);
122
0
  REQUIRE(gpos != NULL);
123
0
  REQUIRE(rdata->length != 0);
124
125
0
  DNS_RDATACOMMON_INIT(gpos, rdata->type, rdata->rdclass);
126
127
0
  dns_rdata_toregion(rdata, &region);
128
0
  gpos->long_len = uint8_fromregion(&region);
129
0
  isc_region_consume(&region, 1);
130
0
  gpos->longitude = region.base;
131
0
  isc_region_consume(&region, gpos->long_len);
132
133
0
  gpos->lat_len = uint8_fromregion(&region);
134
0
  isc_region_consume(&region, 1);
135
0
  gpos->latitude = region.base;
136
0
  isc_region_consume(&region, gpos->lat_len);
137
138
0
  gpos->alt_len = uint8_fromregion(&region);
139
0
  isc_region_consume(&region, 1);
140
0
  if (gpos->lat_len > 0) {
141
0
    gpos->altitude = region.base;
142
0
  } else {
143
0
    gpos->altitude = NULL;
144
0
  }
145
146
0
  return ISC_R_SUCCESS;
147
0
}
148
149
static isc_result_t
150
0
additionaldata_gpos(ARGS_ADDLDATA) {
151
0
  REQUIRE(rdata->type == dns_rdatatype_gpos);
152
153
0
  UNUSED(rdata);
154
0
  UNUSED(owner);
155
0
  UNUSED(add);
156
0
  UNUSED(arg);
157
158
0
  return ISC_R_SUCCESS;
159
0
}
160
161
static isc_result_t
162
0
digest_gpos(ARGS_DIGEST) {
163
0
  isc_region_t r;
164
165
0
  REQUIRE(rdata->type == dns_rdatatype_gpos);
166
167
0
  dns_rdata_toregion(rdata, &r);
168
169
0
  return (digest)(arg, &r);
170
0
}
171
172
static bool
173
0
checkowner_gpos(ARGS_CHECKOWNER) {
174
0
  REQUIRE(type == dns_rdatatype_gpos);
175
176
0
  UNUSED(name);
177
0
  UNUSED(type);
178
0
  UNUSED(rdclass);
179
0
  UNUSED(wildcard);
180
181
0
  return true;
182
0
}
183
184
static bool
185
0
checknames_gpos(ARGS_CHECKNAMES) {
186
0
  REQUIRE(rdata->type == dns_rdatatype_gpos);
187
188
0
  UNUSED(rdata);
189
0
  UNUSED(owner);
190
0
  UNUSED(bad);
191
192
0
  return true;
193
0
}
194
195
static int
196
0
casecompare_gpos(ARGS_COMPARE) {
197
0
  return compare_gpos(rdata1, rdata2);
198
0
}
199
200
#endif /* RDATA_GENERIC_GPOS_27_C */