libosmogsm  1.9.2
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;
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 {
152  union {
160  struct osmo_gad_ell_point_unc_ellipse ha_ell_point_unc_ellipse;
162  };
163 };
164 
165 struct osmo_gad_err {
166  int rc;
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 unc_semi_major
Uncertainty ellipsoid radius of major axis in millimeters, 0 .
Definition: gad.h:135
int rc
Definition: gad.h:166
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
uint8_t type
Definition: gsm_08_08.h:484
struct gad_raw_ell_point_alt_unc_ell ell_point_alt_unc_ell
Definition: gsm_23_032.h:961
int32_t unc_alt
Uncertainty altitude in millimeters, 0 .
Definition: gad.h:100
const char * get_value_string(const struct value_string *vs, uint32_t val)
uint32_t unc_semi_major
Uncertainty ellipsoid radius of major axis in millimeters, 0 .
Definition: gad.h:58
int32_t lon
longitude in micro degrees (degrees * 1e6), -180&#39;000&#39;000 (W) .
Definition: gad.h:77
int16_t alt
Altitude in meters, -32767 (depth) .
Definition: gad.h:88
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
uint32_t unc_semi_minor
Uncertainty ellipsoid radius of minor axis in millimeters, 0 .
Definition: gad.h:139
GAD PDU in network-byte-order according to 3GPP TS 23.032 GAD: Universal Geographical Area Descriptio...
Definition: gsm_23_032.h:239
uint32_t unc_semi_minor
Uncertainty ellipsoid radius of minor axis in millimeters, 0 .
Definition: gad.h:94
int32_t lon
Longitude in micro degrees (degrees * 1e6), -180&#39;000&#39;000 (W) .
Definition: gad.h:39
int32_t lon
Longitude in micro degrees (degrees * 1e6), -180&#39;000&#39;000 (W) .
Definition: gad.h:46
int32_t osmo_gad_dec_lon(uint32_t lon)
Decode a longitude value according to 3GPP TS 23.032.
Definition: gad.c:128
Definition: gad.h:165
uint8_t major_ori
Major axis orientation in degrees (DEG), 0 (N) .
Definition: gad.h:63
uint32_t unc
Uncertainty circle radius in millimeters (m * 1e3), 0 .
Definition: gad.h:48
gad_type
Definition: gsm_23_032.h:32
int32_t alt
Altitude in millimeters, -500&#39;000 (depth) .
Definition: gad.h:131
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
int32_t lat
latitude in micro degrees (degrees * 1e6), -90&#39;000&#39;000 (S) .
Definition: gad.h:107
int32_t lon
longitude in micro degrees (degrees * 1e6), -180&#39;000&#39;000 (W) .
Definition: gad.h:129
uint16_t incl_angle
Included angle defining the angular width of the arc, in degrees clockwise, 1..360.
Definition: gad.h:120
uint32_t osmo_gad_enc_lat(int32_t deg_1e6)
Encode a latitude value according to 3GPP TS 23.032.
Definition: gad.c:55
struct gad_raw_ell_point_unc_ellipse ell_point_unc_ellipse
Definition: gsm_23_032.h:958
int32_t lat
latitude in micro degrees (degrees * 1e6), -90&#39;000&#39;000 (S) .
Definition: gad.h:84
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
Definition: gad.h:82
int32_t osmo_gad_dec_lat(uint32_t lat)
Decode a latitude value according to 3GPP TS 23.032.
Definition: gad.c:81
uint8_t major_ori
Major axis orientation in degrees (DEG), 0 (N) .
Definition: gad.h:96
Definition: gad.h:42
uint8_t data[0]
Definition: gad.h:73
uint8_t confidence
Confidence in percent, 0 = no information, 1..100%, 101..128 = no information.
Definition: gad.h:65
Definition: gad.h:68
uint8_t h_confidence
Horizontal confidence in percent, 0 = no information, 1..100%, 101..128 = no information.
Definition: gad.h:143
uint8_t v_confidence
Vertical confidence in percent, 0 = no information, 1..100%, 101..128 = no information.
Definition: gad.h:147
uint32_t osmo_gad_dec_unc(uint8_t unc)
Decode an uncertainty circle value according to 3GPP TS 23.032.
Definition: gad.c:178
int32_t lon
Longitude in micro degrees (degrees * 1e6), -180&#39;000&#39;000 (W) .
Definition: gad.h:55
uint32_t inner_r
inner circle radius in mm (m * 1e3)
Definition: gad.h:111
int32_t lat
Latitude in micro degrees (degrees * 1e6), -90&#39;000&#39;000 (S) .
Definition: gad.h:53
uint32_t unc_semi_major
Uncertainty ellipsoid radius of major axis in millimeters, 0 .
Definition: gad.h:91
uint8_t major_ori
Major axis orientation in degrees (DEG), 0 (N) .
Definition: gad.h:141
int32_t unc_alt
High-Accuracy uncertainty altitude.
Definition: gad.h:145
const struct value_string osmo_gad_type_names[]
Definition: gad.c:36
int32_t lon
longitude in micro degrees (degrees * 1e6), -180&#39;000&#39;000 (W) .
Definition: gad.h:86
uint16_t ofs_angle
Offset angle of first arc edge in degrees from North clockwise (eastwards), 0..359.
Definition: gad.h:117
uint32_t unc_semi_minor
Uncertainty ellipsoid radius of minor axis in millimeters, 0 .
Definition: gad.h:61
char * logmsg
Definition: gad.h:168
struct gad_raw_ell_arc ell_arc
Definition: gsm_23_032.h:962
uint8_t len
Definition: gsm_04_11.h:480
Definition: gad.h:51
static const char * osmo_gad_type_name(enum gad_type val)
Definition: gad.h:172
Definition: gad.h:150
struct @97 point[15]
int16_t alt
Altitude in meters, -32767 (depth) .
Definition: gad.h:79
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
uint8_t msg[0]
Definition: gsm_08_08.h:729
uint8_t confidence
Confidence in percent, 0 = no information, 1..100%, 101..128 = no information.
Definition: gad.h:102
int32_t lon
longitude in micro degrees (degrees * 1e6), -180&#39;000&#39;000 (W) .
Definition: gad.h:109
int32_t lat
Latitude in micro degrees (degrees * 1e6), -90&#39;000&#39;000 (S) .
Definition: gad.h:37
Definition: gad.h:35
uint8_t osmo_gad_enc_unc(uint32_t mm)
Encode an uncertainty circle value according to 3GPP TS 23.032.
Definition: gad.c:190
int32_t lat
latitude in micro degrees (degrees * 1e6), -90&#39;000&#39;000 (S) .
Definition: gad.h:75
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&#39;000&#39;000 (S) .
Definition: gad.h:44
struct gad_raw_polygon polygon
Definition: gsm_23_032.h:959
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 lat
latitude in micro degrees (degrees * 1e6), -90&#39;000&#39;000 (S) .
Definition: gad.h:127
uint8_t num_points
Definition: gad.h:69
uint32_t unc_r
Uncertainty circle radius in millimeters, 0 .
Definition: gad.h:114
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
struct gad_raw_ell_point ell_point
Definition: gsm_23_032.h:956
struct gad_raw_ell_point_unc_circle ell_point_unc_circle
Definition: gsm_23_032.h:957
Definition: gad.h:105
struct gad_raw_ell_point_alt ell_point_alt
Definition: gsm_23_032.h:960
struct gad_raw_ha_ell_point_alt_unc_ell ha_ell_point_alt_unc_ell
Definition: gsm_23_032.h:964