libosmogsm  1.10.0.56-fc03.202412192026
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 
31 #include <osmocom/core/utils.h>
32 
33 struct msgb;
34 
37  int32_t lat;
39  int32_t lon;
40 };
41 
44  int32_t lat;
46  int32_t lon;
48  uint32_t unc;
49 };
50 
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 
69  uint8_t num_points;
70  struct osmo_gad_ell_point point[15];
71 };
72 
75  int32_t lat;
77  int32_t lon;
79  int16_t alt;
80 };
81 
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 
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 
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 {
156  struct osmo_gad_polygon polygon;
159  struct osmo_gad_ell_arc ell_arc;
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 
184 uint32_t osmo_gad_enc_lat(int32_t deg_1e6);
185 int32_t osmo_gad_dec_lat(uint32_t lat);
186 uint32_t osmo_gad_enc_lon(int32_t deg_1e6);
187 int32_t osmo_gad_dec_lon(uint32_t lon);
188 uint8_t osmo_gad_enc_unc(uint32_t mm);
189 uint32_t osmo_gad_dec_unc(uint8_t unc);
uint32_t osmo_gad_enc_lat(int32_t deg_1e6)
Encode a latitude value according to 3GPP TS 23.032.
Definition: gad.c:55
int32_t osmo_gad_dec_lon(uint32_t lon)
Decode a longitude value according to 3GPP TS 23.032.
Definition: gad.c:128
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
uint32_t osmo_gad_dec_unc(uint8_t unc)
Decode an uncertainty circle value according to 3GPP TS 23.032.
Definition: gad.c:178
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
Definition: gsm_23_032.h:32
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
uint8_t osmo_gad_enc_unc(uint32_t mm)
Encode an uncertainty circle value according to 3GPP TS 23.032.
Definition: gad.c:190
uint32_t osmo_gad_enc_lon(int32_t deg_1e6)
Encode a longitude value according to 3GPP TS 23.032.
Definition: gad.c:102
int32_t osmo_gad_dec_lat(uint32_t lat)
Decode a latitude value according to 3GPP TS 23.032.
Definition: gad.c:81
static const char * osmo_gad_type_name(enum gad_type val)
Definition: gad.h:172
const struct value_string osmo_gad_type_names[]
Definition: gad.c:36
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
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
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
uint8_t data[0]
const char * get_value_string(const struct value_string *vs, uint32_t val)
uint8_t len
Definition: gsm_04_11.h:0
uint8_t msg[0]
Definition: gsm_08_08.h:8
uint8_t lon[3]
Definition: gsm_23_032.h:2
uint8_t lat[3]
Definition: gsm_23_032.h:1
Definition: gad.h:105
uint32_t unc_r
Uncertainty circle radius in millimeters, 0 .
Definition: gad.h:114
uint16_t ofs_angle
Offset angle of first arc edge in degrees from North clockwise (eastwards), 0..359.
Definition: gad.h:117
uint8_t confidence
Confidence in percent, 0 = no information, 1..100%, 101..128 = no information.
Definition: gad.h:122
int32_t lat
latitude in micro degrees (degrees * 1e6), -90'000'000 (S) .
Definition: gad.h:107
int32_t lon
longitude in micro degrees (degrees * 1e6), -180'000'000 (W) .
Definition: gad.h:109
uint32_t inner_r
inner circle radius in mm (m * 1e3)
Definition: gad.h:111
uint16_t incl_angle
Included angle defining the angular width of the arc, in degrees clockwise, 1..360.
Definition: gad.h:120
Definition: gad.h:82
uint8_t major_ori
Major axis orientation in degrees (DEG), 0 (N) .
Definition: gad.h:96
uint32_t unc_semi_major
Uncertainty ellipsoid radius of major axis in millimeters, 0 .
Definition: gad.h:91
int16_t alt
Altitude in meters, -32767 (depth) .
Definition: gad.h:88
int32_t lon
longitude in micro degrees (degrees * 1e6), -180'000'000 (W) .
Definition: gad.h:86
int32_t lat
latitude in micro degrees (degrees * 1e6), -90'000'000 (S) .
Definition: gad.h:84
uint8_t confidence
Confidence in percent, 0 = no information, 1..100%, 101..128 = no information.
Definition: gad.h:102
uint32_t unc_semi_minor
Uncertainty ellipsoid radius of minor axis in millimeters, 0 .
Definition: gad.h:94
int32_t unc_alt
Uncertainty altitude in millimeters, 0 .
Definition: gad.h:100
Definition: gad.h:73
int32_t lat
latitude in micro degrees (degrees * 1e6), -90'000'000 (S) .
Definition: gad.h:75
int16_t alt
Altitude in meters, -32767 (depth) .
Definition: gad.h:79
int32_t lon
longitude in micro degrees (degrees * 1e6), -180'000'000 (W) .
Definition: gad.h:77
Definition: gad.h:42
int32_t lon
Longitude in micro degrees (degrees * 1e6), -180'000'000 (W) .
Definition: gad.h:46
uint32_t unc
Uncertainty circle radius in millimeters (m * 1e3), 0 .
Definition: gad.h:48
int32_t lat
Latitude in micro degrees (degrees * 1e6), -90'000'000 (S) .
Definition: gad.h:44
Definition: gad.h:51
int32_t lon
Longitude in micro degrees (degrees * 1e6), -180'000'000 (W) .
Definition: gad.h:55
int32_t lat
Latitude in micro degrees (degrees * 1e6), -90'000'000 (S) .
Definition: gad.h:53
uint32_t unc_semi_minor
Uncertainty ellipsoid radius of minor axis in millimeters, 0 .
Definition: gad.h:61
uint8_t major_ori
Major axis orientation in degrees (DEG), 0 (N) .
Definition: gad.h:63
uint32_t unc_semi_major
Uncertainty ellipsoid radius of major axis in millimeters, 0 .
Definition: gad.h:58
uint8_t confidence
Confidence in percent, 0 = no information, 1..100%, 101..128 = no information.
Definition: gad.h:65
Definition: gad.h:35
int32_t lon
Longitude in micro degrees (degrees * 1e6), -180'000'000 (W) .
Definition: gad.h:39
int32_t lat
Latitude in micro degrees (degrees * 1e6), -90'000'000 (S) .
Definition: gad.h:37
Definition: gad.h:165
int rc
Definition: gad.h:166
enum gad_type type
Definition: gad.h:167
char * logmsg
Definition: gad.h:168
int32_t lat
latitude in micro degrees (degrees * 1e6), -90'000'000 (S) .
Definition: gad.h:127
uint32_t unc_semi_major
Uncertainty ellipsoid radius of major axis in millimeters, 0 .
Definition: gad.h:135
int32_t alt
Altitude in millimeters, -500'000 (depth) .
Definition: gad.h:131
uint8_t v_confidence
Vertical confidence in percent, 0 = no information, 1..100%, 101..128 = no information.
Definition: gad.h:147
uint8_t h_confidence
Horizontal confidence in percent, 0 = no information, 1..100%, 101..128 = no information.
Definition: gad.h:143
uint8_t major_ori
Major axis orientation in degrees (DEG), 0 (N) .
Definition: gad.h:141
uint32_t unc_semi_minor
Uncertainty ellipsoid radius of minor axis in millimeters, 0 .
Definition: gad.h:139
int32_t unc_alt
High-Accuracy uncertainty altitude.
Definition: gad.h:145
int32_t lon
longitude in micro degrees (degrees * 1e6), -180'000'000 (W) .
Definition: gad.h:129
Definition: gad.h:68
struct osmo_gad_ell_point point[15]
Definition: gad.h:70
uint8_t num_points
Definition: gad.h:69
Definition: gad.h:150
enum gad_type type
Definition: gad.h:151
struct osmo_gad_ell_point_unc_ellipse ell_point_unc_ellipse
Definition: gad.h:155
struct osmo_gad_ell_point ell_point
Definition: gad.h:153
struct osmo_gad_ell_point_unc_ellipse ha_ell_point_unc_ellipse
Definition: gad.h:160
struct osmo_gad_ell_point_alt_unc_ell ell_point_alt_unc_ell
Definition: gad.h:158
struct osmo_gad_ell_arc ell_arc
Definition: gad.h:159
struct osmo_gad_ha_ell_point_alt_unc_ell ha_ell_point_alt_unc_ell
Definition: gad.h:161
struct osmo_gad_polygon polygon
Definition: gad.h:156
struct osmo_gad_ell_point_unc_circle ell_point_unc_circle
Definition: gad.h:154
struct osmo_gad_ell_point_alt ell_point_alt
Definition: gad.h:157
GAD PDU in network-byte-order according to 3GPP TS 23.032 GAD: Universal Geographical Area Descriptio...
Definition: gsm_23_032.h:239