libosmogsm 1.13.1.1-afb4 Osmocom GSM library

gad.h
Go to the documentation of this file.
1
6/*
7 * (C) 2020 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
8 *
9 * All Rights Reserved
10 *
11 * Author: Neels Hofmeyr <neels@hofmeyr.de>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU Affero General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Affero General Public License for more details.
22 *
23 * You should have received a copy of the GNU Affero General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 *
26 */
27
28#pragma once
29
30#include <osmocom/gsm/protocol/gsm_23_032.h>
31#include <osmocom/core/utils.h>
32
33 struct msgb;
34
35 struct osmo_gad_ell_point {
37 int32_t lat;
39 int32_t lon;
40};
41
42 struct osmo_gad_ell_point_unc_circle {
44 int32_t lat;
46 int32_t lon;
48 uint32_t unc;
49};
50
51 struct osmo_gad_ell_point_unc_ellipse {
53 int32_t lat;
55 int32_t lon;
58 uint32_t unc_semi_major;
61 uint32_t unc_semi_minor;
63 uint8_t major_ori;
65 uint8_t confidence;
66};
67
68 struct osmo_gad_polygon {
69 uint8_t num_points;
70 struct osmo_gad_ell_point point[15];
71};
72
73 struct osmo_gad_ell_point_alt {
75 int32_t lat;
77 int32_t lon;
79 int16_t alt;
80};
81
82 struct osmo_gad_ell_point_alt_unc_ell {
84 int32_t lat;
86 int32_t lon;
88 int16_t alt;
91 uint32_t unc_semi_major;
94 uint32_t unc_semi_minor;
96 uint8_t major_ori;
100 int32_t unc_alt;
102 uint8_t confidence;
103};
104
105 struct osmo_gad_ell_arc {
107 int32_t lat;
109 int32_t lon;
111 uint32_t inner_r;
114 uint32_t unc_r;
117 uint16_t ofs_angle;
120 uint16_t incl_angle;
122 uint8_t confidence;
123};
124
125 struct osmo_gad_ha_ell_point_alt_unc_ell {
127 int32_t lat;
129 int32_t lon;
131 int32_t alt;
135 uint32_t unc_semi_major;
139 uint32_t unc_semi_minor;
141 uint8_t major_ori;
143 uint8_t h_confidence;
145 int32_t unc_alt;
147 uint8_t v_confidence;
148};
149
150 struct osmo_gad {
151 enum gad_type type;
152 union {
153 struct osmo_gad_ell_point ell_point;
154 struct osmo_gad_ell_point_unc_circle ell_point_unc_circle;
155 struct osmo_gad_ell_point_unc_ellipse ell_point_unc_ellipse;
156 struct osmo_gad_polygon polygon;
157 struct osmo_gad_ell_point_alt ell_point_alt;
158 struct osmo_gad_ell_point_alt_unc_ell ell_point_alt_unc_ell;
159 struct osmo_gad_ell_arc ell_arc;
160 struct osmo_gad_ell_point_unc_ellipse ha_ell_point_unc_ellipse;
161 struct osmo_gad_ha_ell_point_alt_unc_ell ha_ell_point_alt_unc_ell;
162 };
163};
164
165 struct osmo_gad_err {
166 int rc;
167 enum gad_type type;
168 char *logmsg;
169};
170
171 extern const struct value_string osmo_gad_type_names[];
172 static inline const char *osmo_gad_type_name(enum gad_type val)
173{ return get_value_string(osmo_gad_type_names, val); }
174
175 int osmo_gad_raw_write(struct msgb *msg, const union gad_raw *gad_raw);
176 int osmo_gad_raw_read(union gad_raw *gad_raw, struct osmo_gad_err **err, void *err_ctx, const uint8_t *data, uint8_t len);
177
178 int osmo_gad_enc(union gad_raw *gad_raw, const struct osmo_gad *gad);
179 int osmo_gad_dec(struct osmo_gad *gad, struct osmo_gad_err **err, void *err_ctx, const union gad_raw *gad_raw);
180
181 int osmo_gad_to_str_buf(char *buf, size_t buflen, const struct osmo_gad *gad);
182 char *osmo_gad_to_str_c(void *ctx, const struct osmo_gad *gad);
183
184uint32_t osmo_gad_enc_lat(int32_t deg_1e6);
185int32_t osmo_gad_dec_lat(uint32_t lat);
186uint32_t osmo_gad_enc_lon(int32_t deg_1e6);
187int32_t osmo_gad_dec_lon(uint32_t lon);
188uint8_t osmo_gad_enc_unc(uint32_t mm);
189uint32_t osmo_gad_dec_unc(uint8_t unc);
osmo_gad_enc_lat
uint32_t osmo_gad_enc_lat(int32_t deg_1e6)
Encode a latitude value according to 3GPP TS 23.032.
Definition: gad.c:55
osmo_gad_dec_lon
int32_t osmo_gad_dec_lon(uint32_t lon)
Decode a longitude value according to 3GPP TS 23.032.
Definition: gad.c:128
osmo_gad_enc
int osmo_gad_enc(union gad_raw *gad_raw, const struct osmo_gad *gad)
Write GAD values with consistent units to raw GAD PDU representation.
Definition: gad.c:376
osmo_gad_dec_unc
uint32_t osmo_gad_dec_unc(uint8_t unc)
Decode an uncertainty circle value according to 3GPP TS 23.032.
Definition: gad.c:178
osmo_gad_dec
int osmo_gad_dec(struct osmo_gad *gad, struct osmo_gad_err **err, void *err_ctx, const union gad_raw *gad_raw)
Decode GAD raw PDU to values with consistent units.
Definition: gad.c:394
gad_type
gad_type
Definition: gsm_23_032.h:32
osmo_gad_raw_read
int osmo_gad_raw_read(union gad_raw *gad_raw, struct osmo_gad_err **err, void *err_ctx, const uint8_t *data, uint8_t len)
Read a GAD PDU and validate structure.
Definition: gad.c:350
osmo_gad_enc_unc
uint8_t osmo_gad_enc_unc(uint32_t mm)
Encode an uncertainty circle value according to 3GPP TS 23.032.
Definition: gad.c:190
osmo_gad_enc_lon
uint32_t osmo_gad_enc_lon(int32_t deg_1e6)
Encode a longitude value according to 3GPP TS 23.032.
Definition: gad.c:102
osmo_gad_dec_lat
int32_t osmo_gad_dec_lat(uint32_t lat)
Decode a latitude value according to 3GPP TS 23.032.
Definition: gad.c:81
osmo_gad_type_names
const struct value_string osmo_gad_type_names[]
Definition: gad.c:36
osmo_gad_raw_write
int osmo_gad_raw_write(struct msgb *msg, const union gad_raw *gad_raw)
Append a GAD PDU to the msgb.
Definition: gad.c:327
osmo_gad_to_str_c
char * osmo_gad_to_str_c(void *ctx, const struct osmo_gad *gad)
Return a human readable representation of GAD (location estimate) values.
Definition: gad.c:486
osmo_gad_type_name
static const char * osmo_gad_type_name(enum gad_type val)
Definition: gad.h:172
osmo_gad_to_str_buf
int osmo_gad_to_str_buf(char *buf, size_t buflen, const struct osmo_gad *gad)
Return a human readable representation of GAD (location estimate) values.
Definition: gad.c:443
data
uint8_t data[0]
get_value_string
const char * get_value_string(const struct value_string *vs, uint32_t val)
len
uint8_t len
Definition: gsm_04_11.h:0
msg
uint8_t msg[0]
Definition: gsm_08_08.h:8
gsm_23_032.h
lon
uint8_t lon[3]
Definition: gsm_23_032.h:2
lat
uint8_t lat[3]
Definition: gsm_23_032.h:1
msgb
osmo_gad_ell_arc
Definition: gad.h:105
osmo_gad_ell_arc::unc_r
uint32_t unc_r
Uncertainty circle radius in millimeters, 0 .
Definition: gad.h:114
osmo_gad_ell_arc::ofs_angle
uint16_t ofs_angle
Offset angle of first arc edge in degrees from North clockwise (eastwards), 0..359.
Definition: gad.h:117
osmo_gad_ell_arc::confidence
uint8_t confidence
Confidence in percent, 0 = no information, 1..100%, 101..128 = no information.
Definition: gad.h:122
osmo_gad_ell_arc::lat
int32_t lat
latitude in micro degrees (degrees * 1e6), -90'000'000 (S) .
Definition: gad.h:107
osmo_gad_ell_arc::lon
int32_t lon
longitude in micro degrees (degrees * 1e6), -180'000'000 (W) .
Definition: gad.h:109
osmo_gad_ell_arc::inner_r
uint32_t inner_r
inner circle radius in mm (m * 1e3)
Definition: gad.h:111
osmo_gad_ell_arc::incl_angle
uint16_t incl_angle
Included angle defining the angular width of the arc, in degrees clockwise, 1..360.
Definition: gad.h:120
osmo_gad_ell_point_alt_unc_ell
Definition: gad.h:82
osmo_gad_ell_point_alt_unc_ell::major_ori
uint8_t major_ori
Major axis orientation in degrees (DEG), 0 (N) .
Definition: gad.h:96
osmo_gad_ell_point_alt_unc_ell::unc_semi_major
uint32_t unc_semi_major
Uncertainty ellipsoid radius of major axis in millimeters, 0 .
Definition: gad.h:91
osmo_gad_ell_point_alt_unc_ell::alt
int16_t alt
Altitude in meters, -32767 (depth) .
Definition: gad.h:88
osmo_gad_ell_point_alt_unc_ell::lon
int32_t lon
longitude in micro degrees (degrees * 1e6), -180'000'000 (W) .
Definition: gad.h:86
osmo_gad_ell_point_alt_unc_ell::lat
int32_t lat
latitude in micro degrees (degrees * 1e6), -90'000'000 (S) .
Definition: gad.h:84
osmo_gad_ell_point_alt_unc_ell::confidence
uint8_t confidence
Confidence in percent, 0 = no information, 1..100%, 101..128 = no information.
Definition: gad.h:102
osmo_gad_ell_point_alt_unc_ell::unc_semi_minor
uint32_t unc_semi_minor
Uncertainty ellipsoid radius of minor axis in millimeters, 0 .
Definition: gad.h:94
osmo_gad_ell_point_alt_unc_ell::unc_alt
int32_t unc_alt
Uncertainty altitude in millimeters, 0 .
Definition: gad.h:100
osmo_gad_ell_point_alt
Definition: gad.h:73
osmo_gad_ell_point_alt::lat
int32_t lat
latitude in micro degrees (degrees * 1e6), -90'000'000 (S) .
Definition: gad.h:75
osmo_gad_ell_point_alt::alt
int16_t alt
Altitude in meters, -32767 (depth) .
Definition: gad.h:79
osmo_gad_ell_point_alt::lon
int32_t lon
longitude in micro degrees (degrees * 1e6), -180'000'000 (W) .
Definition: gad.h:77
osmo_gad_ell_point_unc_circle
Definition: gad.h:42
osmo_gad_ell_point_unc_circle::lon
int32_t lon
Longitude in micro degrees (degrees * 1e6), -180'000'000 (W) .
Definition: gad.h:46
osmo_gad_ell_point_unc_circle::unc
uint32_t unc
Uncertainty circle radius in millimeters (m * 1e3), 0 .
Definition: gad.h:48
osmo_gad_ell_point_unc_circle::lat
int32_t lat
Latitude in micro degrees (degrees * 1e6), -90'000'000 (S) .
Definition: gad.h:44
osmo_gad_ell_point_unc_ellipse
Definition: gad.h:51
osmo_gad_ell_point_unc_ellipse::lon
int32_t lon
Longitude in micro degrees (degrees * 1e6), -180'000'000 (W) .
Definition: gad.h:55
osmo_gad_ell_point_unc_ellipse::lat
int32_t lat
Latitude in micro degrees (degrees * 1e6), -90'000'000 (S) .
Definition: gad.h:53
osmo_gad_ell_point_unc_ellipse::unc_semi_minor
uint32_t unc_semi_minor
Uncertainty ellipsoid radius of minor axis in millimeters, 0 .
Definition: gad.h:61
osmo_gad_ell_point_unc_ellipse::major_ori
uint8_t major_ori
Major axis orientation in degrees (DEG), 0 (N) .
Definition: gad.h:63
osmo_gad_ell_point_unc_ellipse::unc_semi_major
uint32_t unc_semi_major
Uncertainty ellipsoid radius of major axis in millimeters, 0 .
Definition: gad.h:58
osmo_gad_ell_point_unc_ellipse::confidence
uint8_t confidence
Confidence in percent, 0 = no information, 1..100%, 101..128 = no information.
Definition: gad.h:65
osmo_gad_ell_point
Definition: gad.h:35
osmo_gad_ell_point::lon
int32_t lon
Longitude in micro degrees (degrees * 1e6), -180'000'000 (W) .
Definition: gad.h:39
osmo_gad_ell_point::lat
int32_t lat
Latitude in micro degrees (degrees * 1e6), -90'000'000 (S) .
Definition: gad.h:37
osmo_gad_err
Definition: gad.h:165
osmo_gad_err::rc
int rc
Definition: gad.h:166
osmo_gad_err::type
enum gad_type type
Definition: gad.h:167
osmo_gad_err::logmsg
char * logmsg
Definition: gad.h:168
osmo_gad_ha_ell_point_alt_unc_ell
Definition: gad.h:125
osmo_gad_ha_ell_point_alt_unc_ell::lat
int32_t lat
latitude in micro degrees (degrees * 1e6), -90'000'000 (S) .
Definition: gad.h:127
osmo_gad_ha_ell_point_alt_unc_ell::unc_semi_major
uint32_t unc_semi_major
Uncertainty ellipsoid radius of major axis in millimeters, 0 .
Definition: gad.h:135
osmo_gad_ha_ell_point_alt_unc_ell::alt
int32_t alt
Altitude in millimeters, -500'000 (depth) .
Definition: gad.h:131
osmo_gad_ha_ell_point_alt_unc_ell::v_confidence
uint8_t v_confidence
Vertical confidence in percent, 0 = no information, 1..100%, 101..128 = no information.
Definition: gad.h:147
osmo_gad_ha_ell_point_alt_unc_ell::h_confidence
uint8_t h_confidence
Horizontal confidence in percent, 0 = no information, 1..100%, 101..128 = no information.
Definition: gad.h:143
osmo_gad_ha_ell_point_alt_unc_ell::major_ori
uint8_t major_ori
Major axis orientation in degrees (DEG), 0 (N) .
Definition: gad.h:141
osmo_gad_ha_ell_point_alt_unc_ell::unc_semi_minor
uint32_t unc_semi_minor
Uncertainty ellipsoid radius of minor axis in millimeters, 0 .
Definition: gad.h:139
osmo_gad_ha_ell_point_alt_unc_ell::unc_alt
int32_t unc_alt
High-Accuracy uncertainty altitude.
Definition: gad.h:145
osmo_gad_ha_ell_point_alt_unc_ell::lon
int32_t lon
longitude in micro degrees (degrees * 1e6), -180'000'000 (W) .
Definition: gad.h:129
osmo_gad_polygon
Definition: gad.h:68
osmo_gad_polygon::point
struct osmo_gad_ell_point point[15]
Definition: gad.h:70
osmo_gad_polygon::num_points
uint8_t num_points
Definition: gad.h:69
osmo_gad
Definition: gad.h:150
osmo_gad::type
enum gad_type type
Definition: gad.h:151
osmo_gad::ell_point_unc_ellipse
struct osmo_gad_ell_point_unc_ellipse ell_point_unc_ellipse
Definition: gad.h:155
osmo_gad::ell_point
struct osmo_gad_ell_point ell_point
Definition: gad.h:153
osmo_gad::ha_ell_point_unc_ellipse
struct osmo_gad_ell_point_unc_ellipse ha_ell_point_unc_ellipse
Definition: gad.h:160
osmo_gad::ell_point_alt_unc_ell
struct osmo_gad_ell_point_alt_unc_ell ell_point_alt_unc_ell
Definition: gad.h:158
osmo_gad::ell_arc
struct osmo_gad_ell_arc ell_arc
Definition: gad.h:159
osmo_gad::ha_ell_point_alt_unc_ell
struct osmo_gad_ha_ell_point_alt_unc_ell ha_ell_point_alt_unc_ell
Definition: gad.h:161
osmo_gad::polygon
struct osmo_gad_polygon polygon
Definition: gad.h:156
osmo_gad::ell_point_unc_circle
struct osmo_gad_ell_point_unc_circle ell_point_unc_circle
Definition: gad.h:154
osmo_gad::ell_point_alt
struct osmo_gad_ell_point_alt ell_point_alt
Definition: gad.h:157
value_string
gad_raw
GAD PDU in network-byte-order according to 3GPP TS 23.032 GAD: Universal Geographical Area Descriptio...
Definition: gsm_23_032.h:239
utils.h