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 { |
| 53 | uint8_t spare:4, |
| 54 | type:4; |
| 55 | } __attribute__ ((packed)); |
| 56 | |
| 57 | struct gad_raw_ell_point { |
| 58 | struct gad_raw_head h; /*!< type = GAD_TYPE_ELL_POINT */ |
| 59 | uint8_t lat[3]; |
| 60 | uint8_t lon[3]; |
| 61 | } __attribute__ ((packed)); |
| 62 | |
| 63 | struct gad_raw_ell_point_unc_circle { |
| 64 | struct gad_raw_head h; /*!< type = GAD_TYPE_ELL_POINT_UNC_CIRCLE */ |
| 65 | uint8_t lat[3]; |
| 66 | uint8_t lon[3]; |
| 67 | uint8_t unc:7, |
| 68 | spare2:1; |
| 69 | } __attribute__ ((packed)); |
| 70 | |
| 71 | struct gad_raw_ell_point_unc_ellipse { |
| 72 | struct gad_raw_head h; /*!< type = GAD_TYPE_ELL_POINT_UNC_ELLIPSE */ |
| 73 | uint8_t lat[3]; |
| 74 | uint8_t lon[3]; |
| 75 | uint8_t unc_semi_major:7, |
| 76 | spare1:1; |
| 77 | uint8_t unc_semi_minor:7, |
| 78 | spare2:1; |
| 79 | uint8_t major_ori; |
| 80 | uint8_t confidence:7, |
| 81 | spare3:1; |
| 82 | } __attribute__ ((packed)); |
| 83 | |
| 84 | struct gad_raw_polygon { |
| 85 | struct { |
| 86 | uint8_t num_points:4; |
| 87 | uint8_t type:4; /*!< type = GAD_TYPE_POLYGON */ |
| 88 | } h; |
| 89 | struct { |
| 90 | uint8_t lat[3]; |
| 91 | uint8_t lon[3]; |
| 92 | } point[15]; |
| 93 | } __attribute__ ((packed)); |
| 94 | |
| 95 | struct gad_raw_ell_point_alt { |
| 96 | struct gad_raw_head h; /*!< type = GAD_TYPE_ELL_POINT_ALT */ |
| 97 | uint8_t lat[3]; |
| 98 | uint8_t lon[3]; |
| 99 | uint8_t alt[2]; |
| 100 | } __attribute__ ((packed)); |
| 101 | |
| 102 | struct gad_raw_ell_point_alt_unc_ell { |
| 103 | struct gad_raw_head h; /*!< type = GAD_TYPE_ELL_POINT_ALT_UNC_ELL */ |
| 104 | uint8_t lat[3]; |
| 105 | uint8_t lon[3]; |
| 106 | uint8_t alt[2]; |
| 107 | uint8_t unc_semi_major:7, |
| 108 | spare1:1; |
| 109 | uint8_t unc_semi_minor:7, |
| 110 | spare2:1; |
| 111 | uint8_t major_ori; |
| 112 | uint8_t unc_alt:7, |
| 113 | spare3:1; |
| 114 | uint8_t confidence:7, |
| 115 | spare4:1; |
| 116 | } __attribute__ ((packed)); |
| 117 | |
| 118 | struct gad_raw_ell_arc { |
| 119 | struct gad_raw_head h; /*!< type = GAD_TYPE_ELL_ARC */ |
| 120 | uint8_t lat[3]; |
| 121 | uint8_t lon[3]; |
| 122 | uint8_t inner_r[2]; |
| 123 | uint8_t unc_r:7, |
| 124 | spare1:1; |
| 125 | uint8_t ofs_angle; |
| 126 | uint8_t incl_angle; |
| 127 | uint8_t confidence:7, |
| 128 | spare2:1; |
| 129 | } __attribute__ ((packed)); |
| 130 | |
| 131 | struct gad_raw_ha_ell_point_unc_ell { |
| 132 | struct gad_raw_head h; /*!< type = GAD_TYPE_HA_ELL_POINT_UNC_ELLIPSE */ |
| 133 | uint8_t lat[4]; |
| 134 | uint8_t lon[4]; |
| 135 | uint8_t alt[3]; |
| 136 | uint8_t unc_semi_major; |
| 137 | uint8_t unc_semi_minor; |
| 138 | uint8_t major_ori; |
| 139 | uint8_t confidence:7, |
| 140 | spare1:1; |
| 141 | } __attribute__ ((packed)); |
| 142 | |
| 143 | struct gad_raw_ha_ell_point_alt_unc_ell { |
| 144 | struct gad_raw_head h; /*!< type = GAD_TYPE_HA_ELL_POINT_ALT_UNC_ELL */ |
| 145 | uint8_t lat[4]; |
| 146 | uint8_t lon[4]; |
| 147 | uint8_t alt[3]; |
| 148 | uint8_t unc_semi_major; |
| 149 | uint8_t unc_semi_minor; |
| 150 | uint8_t major_ori; |
| 151 | uint8_t h_confidence:7, |
| 152 | spare1:1; |
| 153 | uint8_t unc_alt; |
| 154 | uint8_t v_confidence:7, |
| 155 | spare2:1; |
| 156 | } __attribute__ ((packed)); |
| 157 | |
| 158 | /*! GAD PDU in network-byte-order according to 3GPP TS 23.032 GAD: Universal Geographical Area Description. */ |
| 159 | union gad_raw { |
| 160 | struct gad_raw_head h; |
| 161 | struct gad_raw_ell_point ell_point; |
| 162 | struct gad_raw_ell_point_unc_circle ell_point_unc_circle; |
| 163 | struct gad_raw_ell_point_unc_ellipse ell_point_unc_ellipse; |
| 164 | struct gad_raw_polygon polygon; |
| 165 | struct gad_raw_ell_point_alt ell_point_alt; |
| 166 | struct gad_raw_ell_point_alt_unc_ell ell_point_alt_unc_ell; |
| 167 | struct gad_raw_ell_arc ell_arc; |
| 168 | struct gad_raw_ha_ell_point_unc_ell ha_ell_point_unc_ell; |
| 169 | struct gad_raw_ha_ell_point_alt_unc_ell ha_ell_point_alt_unc_ell; |
| 170 | } __attribute__ ((packed)); |
| 171 | |
| 172 | /*! @} */ |