Neels Hofmeyr | 086bd33 | 2020-09-18 18:00:50 +0200 | [diff] [blame] | 1 | /*! \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 | |
| 32 | enum 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 | |
| 52 | struct gad_raw_head { |
Pau Espin Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 53 | #if OSMO_IS_LITTLE_ENDIAN |
Neels Hofmeyr | 086bd33 | 2020-09-18 18:00:50 +0200 | [diff] [blame] | 54 | uint8_t spare:4, |
| 55 | type:4; |
Pau Espin Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 56 | #elif OSMO_IS_BIG_ENDIAN |
Oliver Smith | 0b5c09b | 2023-02-17 10:35:38 +0100 | [diff] [blame] | 57 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */ |
Pau Espin Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 58 | uint8_t type:4, spare:4; |
| 59 | #endif |
Neels Hofmeyr | 086bd33 | 2020-09-18 18:00:50 +0200 | [diff] [blame] | 60 | } __attribute__ ((packed)); |
| 61 | |
| 62 | struct 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 | |
| 68 | struct gad_raw_ell_point_unc_circle { |
Pau Espin Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 69 | #if OSMO_IS_LITTLE_ENDIAN |
Neels Hofmeyr | 086bd33 | 2020-09-18 18:00:50 +0200 | [diff] [blame] | 70 | 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 Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 75 | #elif OSMO_IS_BIG_ENDIAN |
Oliver Smith | 0b5c09b | 2023-02-17 10:35:38 +0100 | [diff] [blame] | 76 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */ |
Pau Espin Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 77 | 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 Hofmeyr | 086bd33 | 2020-09-18 18:00:50 +0200 | [diff] [blame] | 82 | } __attribute__ ((packed)); |
| 83 | |
| 84 | struct gad_raw_ell_point_unc_ellipse { |
Pau Espin Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 85 | #if OSMO_IS_LITTLE_ENDIAN |
Neels Hofmeyr | 086bd33 | 2020-09-18 18:00:50 +0200 | [diff] [blame] | 86 | 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 Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 96 | #elif OSMO_IS_BIG_ENDIAN |
Oliver Smith | 0b5c09b | 2023-02-17 10:35:38 +0100 | [diff] [blame] | 97 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */ |
Pau Espin Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 98 | 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 Hofmeyr | 086bd33 | 2020-09-18 18:00:50 +0200 | [diff] [blame] | 106 | } __attribute__ ((packed)); |
| 107 | |
| 108 | struct gad_raw_polygon { |
| 109 | struct { |
Pau Espin Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 110 | #if OSMO_IS_LITTLE_ENDIAN |
Neels Hofmeyr | 086bd33 | 2020-09-18 18:00:50 +0200 | [diff] [blame] | 111 | uint8_t num_points:4; |
| 112 | uint8_t type:4; /*!< type = GAD_TYPE_POLYGON */ |
Pau Espin Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 113 | #elif OSMO_IS_BIG_ENDIAN |
Oliver Smith | 0b5c09b | 2023-02-17 10:35:38 +0100 | [diff] [blame] | 114 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */ |
Pau Espin Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 115 | uint8_t type:4, num_points:4; |
| 116 | #endif |
Neels Hofmeyr | 086bd33 | 2020-09-18 18:00:50 +0200 | [diff] [blame] | 117 | } h; |
| 118 | struct { |
| 119 | uint8_t lat[3]; |
| 120 | uint8_t lon[3]; |
| 121 | } point[15]; |
| 122 | } __attribute__ ((packed)); |
| 123 | |
| 124 | struct 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 | |
| 131 | struct gad_raw_ell_point_alt_unc_ell { |
Pau Espin Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 132 | #if OSMO_IS_LITTLE_ENDIAN |
Neels Hofmeyr | 086bd33 | 2020-09-18 18:00:50 +0200 | [diff] [blame] | 133 | 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 Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 146 | #elif OSMO_IS_BIG_ENDIAN |
Oliver Smith | 0b5c09b | 2023-02-17 10:35:38 +0100 | [diff] [blame] | 147 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */ |
Pau Espin Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 148 | 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 Hofmeyr | 086bd33 | 2020-09-18 18:00:50 +0200 | [diff] [blame] | 158 | } __attribute__ ((packed)); |
| 159 | |
| 160 | struct gad_raw_ell_arc { |
Pau Espin Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 161 | #if OSMO_IS_LITTLE_ENDIAN |
Neels Hofmeyr | 086bd33 | 2020-09-18 18:00:50 +0200 | [diff] [blame] | 162 | 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 Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 172 | #elif OSMO_IS_BIG_ENDIAN |
Oliver Smith | 0b5c09b | 2023-02-17 10:35:38 +0100 | [diff] [blame] | 173 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */ |
Pau Espin Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 174 | 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 Hofmeyr | 086bd33 | 2020-09-18 18:00:50 +0200 | [diff] [blame] | 183 | } __attribute__ ((packed)); |
| 184 | |
| 185 | struct gad_raw_ha_ell_point_unc_ell { |
Pau Espin Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 186 | #if OSMO_IS_LITTLE_ENDIAN |
Neels Hofmeyr | 086bd33 | 2020-09-18 18:00:50 +0200 | [diff] [blame] | 187 | 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 Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 196 | #elif OSMO_IS_BIG_ENDIAN |
Oliver Smith | 0b5c09b | 2023-02-17 10:35:38 +0100 | [diff] [blame] | 197 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */ |
Pau Espin Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 198 | 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 Hofmeyr | 086bd33 | 2020-09-18 18:00:50 +0200 | [diff] [blame] | 207 | } __attribute__ ((packed)); |
| 208 | |
| 209 | struct gad_raw_ha_ell_point_alt_unc_ell { |
Pau Espin Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 210 | #if OSMO_IS_LITTLE_ENDIAN |
Neels Hofmeyr | 086bd33 | 2020-09-18 18:00:50 +0200 | [diff] [blame] | 211 | 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 Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 223 | #elif OSMO_IS_BIG_ENDIAN |
Oliver Smith | 0b5c09b | 2023-02-17 10:35:38 +0100 | [diff] [blame] | 224 | /* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */ |
Pau Espin Pedrol | 15b5acb | 2021-02-04 12:37:25 +0100 | [diff] [blame] | 225 | 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 Hofmeyr | 086bd33 | 2020-09-18 18:00:50 +0200 | [diff] [blame] | 236 | } __attribute__ ((packed)); |
| 237 | |
| 238 | /*! GAD PDU in network-byte-order according to 3GPP TS 23.032 GAD: Universal Geographical Area Description. */ |
| 239 | union 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 | /*! @} */ |