blob: 6eb65ca2405d48143f5b3b23cc3f79037f6ca3d2 [file] [log] [blame]
Neels Hofmeyr086bd332020-09-18 18:00:50 +02001/*! \defgroup gad 3GPP TS 23.032 GAD: Universal Geographical Area Description.
2 * @{
3 * \file gsm_23_032.h
4 */
5/*
6 * (C) 2020 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
7 *
8 * All Rights Reserved
9 *
10 * Author: Neels Hofmeyr <neels@hofmeyr.de>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Affero General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Affero General Public License for more details.
21 *
22 * You should have received a copy of the GNU Affero General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 *
25 */
26
27#pragma once
28
29#include <stdint.h>
30#include <osmocom/core/endian.h>
31
32enum gad_type {
33 /*! Ellipsoid point */
34 GAD_TYPE_ELL_POINT = 0,
35 /*! Ellipsoid point with uncertainty circle. */
36 GAD_TYPE_ELL_POINT_UNC_CIRCLE = 1,
37 /*! Ellipsoid point with uncertainty ellipse. */
38 GAD_TYPE_ELL_POINT_UNC_ELLIPSE = 3,
39 GAD_TYPE_POLYGON = 5,
40 /*! Ellipsoid point with altitude. */
41 GAD_TYPE_ELL_POINT_ALT = 8,
42 /*! Ellipsoid point with altitude and uncertainty ellipsoid. */
43 GAD_TYPE_ELL_POINT_ALT_UNC_ELL = 9,
44 /*! Ellipsoid arc */
45 GAD_TYPE_ELL_ARC = 10,
46 /*! High accuracy ellipsoid point with uncertainty ellipse. */
47 GAD_TYPE_HA_ELL_POINT_UNC_ELLIPSE = 11,
48 /*! High accuracy ellipsoid point with altitude and uncertainty ellipsoid. */
49 GAD_TYPE_HA_ELL_POINT_ALT_UNC_ELL = 12,
50};
51
52struct gad_raw_head {
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +010053#if OSMO_IS_LITTLE_ENDIAN
Neels Hofmeyr086bd332020-09-18 18:00:50 +020054 uint8_t spare:4,
55 type:4;
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +010056#elif OSMO_IS_BIG_ENDIAN
Oliver Smith0b5c09b2023-02-17 10:35:38 +010057/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +010058 uint8_t type:4, spare:4;
59#endif
Neels Hofmeyr086bd332020-09-18 18:00:50 +020060} __attribute__ ((packed));
61
62struct gad_raw_ell_point {
63 struct gad_raw_head h; /*!< type = GAD_TYPE_ELL_POINT */
64 uint8_t lat[3];
65 uint8_t lon[3];
66} __attribute__ ((packed));
67
68struct gad_raw_ell_point_unc_circle {
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +010069#if OSMO_IS_LITTLE_ENDIAN
Neels Hofmeyr086bd332020-09-18 18:00:50 +020070 struct gad_raw_head h; /*!< type = GAD_TYPE_ELL_POINT_UNC_CIRCLE */
71 uint8_t lat[3];
72 uint8_t lon[3];
73 uint8_t unc:7,
74 spare2:1;
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +010075#elif OSMO_IS_BIG_ENDIAN
Oliver Smith0b5c09b2023-02-17 10:35:38 +010076/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +010077 struct gad_raw_head h;
78 uint8_t lat[3];
79 uint8_t lon[3];
80 uint8_t spare2:1, unc:7;
81#endif
Neels Hofmeyr086bd332020-09-18 18:00:50 +020082} __attribute__ ((packed));
83
84struct gad_raw_ell_point_unc_ellipse {
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +010085#if OSMO_IS_LITTLE_ENDIAN
Neels Hofmeyr086bd332020-09-18 18:00:50 +020086 struct gad_raw_head h; /*!< type = GAD_TYPE_ELL_POINT_UNC_ELLIPSE */
87 uint8_t lat[3];
88 uint8_t lon[3];
89 uint8_t unc_semi_major:7,
90 spare1:1;
91 uint8_t unc_semi_minor:7,
92 spare2:1;
93 uint8_t major_ori;
94 uint8_t confidence:7,
95 spare3:1;
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +010096#elif OSMO_IS_BIG_ENDIAN
Oliver Smith0b5c09b2023-02-17 10:35:38 +010097/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +010098 struct gad_raw_head h;
99 uint8_t lat[3];
100 uint8_t lon[3];
101 uint8_t spare1:1, unc_semi_major:7;
102 uint8_t spare2:1, unc_semi_minor:7;
103 uint8_t major_ori;
104 uint8_t spare3:1, confidence:7;
105#endif
Neels Hofmeyr086bd332020-09-18 18:00:50 +0200106} __attribute__ ((packed));
107
108struct gad_raw_polygon {
109 struct {
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +0100110#if OSMO_IS_LITTLE_ENDIAN
Neels Hofmeyr086bd332020-09-18 18:00:50 +0200111 uint8_t num_points:4;
112 uint8_t type:4; /*!< type = GAD_TYPE_POLYGON */
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +0100113#elif OSMO_IS_BIG_ENDIAN
Oliver Smith0b5c09b2023-02-17 10:35:38 +0100114/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +0100115 uint8_t type:4, num_points:4;
116#endif
Neels Hofmeyr086bd332020-09-18 18:00:50 +0200117 } h;
118 struct {
119 uint8_t lat[3];
120 uint8_t lon[3];
121 } point[15];
122} __attribute__ ((packed));
123
124struct gad_raw_ell_point_alt {
125 struct gad_raw_head h; /*!< type = GAD_TYPE_ELL_POINT_ALT */
126 uint8_t lat[3];
127 uint8_t lon[3];
128 uint8_t alt[2];
129} __attribute__ ((packed));
130
131struct gad_raw_ell_point_alt_unc_ell {
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +0100132#if OSMO_IS_LITTLE_ENDIAN
Neels Hofmeyr086bd332020-09-18 18:00:50 +0200133 struct gad_raw_head h; /*!< type = GAD_TYPE_ELL_POINT_ALT_UNC_ELL */
134 uint8_t lat[3];
135 uint8_t lon[3];
136 uint8_t alt[2];
137 uint8_t unc_semi_major:7,
138 spare1:1;
139 uint8_t unc_semi_minor:7,
140 spare2:1;
141 uint8_t major_ori;
142 uint8_t unc_alt:7,
143 spare3:1;
144 uint8_t confidence:7,
145 spare4:1;
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +0100146#elif OSMO_IS_BIG_ENDIAN
Oliver Smith0b5c09b2023-02-17 10:35:38 +0100147/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +0100148 struct gad_raw_head h;
149 uint8_t lat[3];
150 uint8_t lon[3];
151 uint8_t alt[2];
152 uint8_t spare1:1, unc_semi_major:7;
153 uint8_t spare2:1, unc_semi_minor:7;
154 uint8_t major_ori;
155 uint8_t spare3:1, unc_alt:7;
156 uint8_t spare4:1, confidence:7;
157#endif
Neels Hofmeyr086bd332020-09-18 18:00:50 +0200158} __attribute__ ((packed));
159
160struct gad_raw_ell_arc {
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +0100161#if OSMO_IS_LITTLE_ENDIAN
Neels Hofmeyr086bd332020-09-18 18:00:50 +0200162 struct gad_raw_head h; /*!< type = GAD_TYPE_ELL_ARC */
163 uint8_t lat[3];
164 uint8_t lon[3];
165 uint8_t inner_r[2];
166 uint8_t unc_r:7,
167 spare1:1;
168 uint8_t ofs_angle;
169 uint8_t incl_angle;
170 uint8_t confidence:7,
171 spare2:1;
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +0100172#elif OSMO_IS_BIG_ENDIAN
Oliver Smith0b5c09b2023-02-17 10:35:38 +0100173/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +0100174 struct gad_raw_head h;
175 uint8_t lat[3];
176 uint8_t lon[3];
177 uint8_t inner_r[2];
178 uint8_t spare1:1, unc_r:7;
179 uint8_t ofs_angle;
180 uint8_t incl_angle;
181 uint8_t spare2:1, confidence:7;
182#endif
Neels Hofmeyr086bd332020-09-18 18:00:50 +0200183} __attribute__ ((packed));
184
185struct gad_raw_ha_ell_point_unc_ell {
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +0100186#if OSMO_IS_LITTLE_ENDIAN
Neels Hofmeyr086bd332020-09-18 18:00:50 +0200187 struct gad_raw_head h; /*!< type = GAD_TYPE_HA_ELL_POINT_UNC_ELLIPSE */
188 uint8_t lat[4];
189 uint8_t lon[4];
190 uint8_t alt[3];
191 uint8_t unc_semi_major;
192 uint8_t unc_semi_minor;
193 uint8_t major_ori;
194 uint8_t confidence:7,
195 spare1:1;
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +0100196#elif OSMO_IS_BIG_ENDIAN
Oliver Smith0b5c09b2023-02-17 10:35:38 +0100197/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +0100198 struct gad_raw_head h;
199 uint8_t lat[4];
200 uint8_t lon[4];
201 uint8_t alt[3];
202 uint8_t unc_semi_major;
203 uint8_t unc_semi_minor;
204 uint8_t major_ori;
205 uint8_t spare1:1, confidence:7;
206#endif
Neels Hofmeyr086bd332020-09-18 18:00:50 +0200207} __attribute__ ((packed));
208
209struct gad_raw_ha_ell_point_alt_unc_ell {
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +0100210#if OSMO_IS_LITTLE_ENDIAN
Neels Hofmeyr086bd332020-09-18 18:00:50 +0200211 struct gad_raw_head h; /*!< type = GAD_TYPE_HA_ELL_POINT_ALT_UNC_ELL */
212 uint8_t lat[4];
213 uint8_t lon[4];
214 uint8_t alt[3];
215 uint8_t unc_semi_major;
216 uint8_t unc_semi_minor;
217 uint8_t major_ori;
218 uint8_t h_confidence:7,
219 spare1:1;
220 uint8_t unc_alt;
221 uint8_t v_confidence:7,
222 spare2:1;
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +0100223#elif OSMO_IS_BIG_ENDIAN
Oliver Smith0b5c09b2023-02-17 10:35:38 +0100224/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
Pau Espin Pedrol15b5acb2021-02-04 12:37:25 +0100225 struct gad_raw_head h;
226 uint8_t lat[4];
227 uint8_t lon[4];
228 uint8_t alt[3];
229 uint8_t unc_semi_major;
230 uint8_t unc_semi_minor;
231 uint8_t major_ori;
232 uint8_t spare1:1, h_confidence:7;
233 uint8_t unc_alt;
234 uint8_t spare2:1, v_confidence:7;
235#endif
Neels Hofmeyr086bd332020-09-18 18:00:50 +0200236} __attribute__ ((packed));
237
238/*! GAD PDU in network-byte-order according to 3GPP TS 23.032 GAD: Universal Geographical Area Description. */
239union gad_raw {
240 struct gad_raw_head h;
241 struct gad_raw_ell_point ell_point;
242 struct gad_raw_ell_point_unc_circle ell_point_unc_circle;
243 struct gad_raw_ell_point_unc_ellipse ell_point_unc_ellipse;
244 struct gad_raw_polygon polygon;
245 struct gad_raw_ell_point_alt ell_point_alt;
246 struct gad_raw_ell_point_alt_unc_ell ell_point_alt_unc_ell;
247 struct gad_raw_ell_arc ell_arc;
248 struct gad_raw_ha_ell_point_unc_ell ha_ell_point_unc_ell;
249 struct gad_raw_ha_ell_point_alt_unc_ell ha_ell_point_alt_unc_ell;
250} __attribute__ ((packed));
251
252/*! @} */