Loading...
Searching...
No Matches
gad.h
Go to the documentation of this file.
/*
* (C) 2020 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
*
* All Rights Reserved
*
* Author: Neels Hofmeyr <neels@hofmeyr.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <osmocom/gsm/protocol/gsm_23_032.h>
#include <osmocom/core/utils.h>
struct msgb;
struct osmo_gad_ell_point {
int32_t lat;
int32_t lon;
};
struct osmo_gad_ell_point_unc_circle {
int32_t lat;
int32_t lon;
uint32_t unc;
};
struct osmo_gad_ell_point_unc_ellipse {
int32_t lat;
int32_t lon;
uint32_t unc_semi_major;
uint32_t unc_semi_minor;
uint8_t major_ori;
uint8_t confidence;
};
struct osmo_gad_polygon {
uint8_t num_points;
struct osmo_gad_ell_point point[15];
};
struct osmo_gad_ell_point_alt {
int32_t lat;
int32_t lon;
int16_t alt;
};
struct osmo_gad_ell_point_alt_unc_ell {
int32_t lat;
int32_t lon;
int16_t alt;
uint32_t unc_semi_major;
uint32_t unc_semi_minor;
uint8_t major_ori;
int32_t unc_alt;
uint8_t confidence;
};
struct osmo_gad_ell_arc {
int32_t lat;
int32_t lon;
uint32_t inner_r;
uint32_t unc_r;
uint16_t ofs_angle;
uint16_t incl_angle;
uint8_t confidence;
};
struct osmo_gad_ha_ell_point_alt_unc_ell {
int32_t lat;
int32_t lon;
int32_t alt;
uint32_t unc_semi_major;
uint32_t unc_semi_minor;
uint8_t major_ori;
uint8_t h_confidence;
int32_t unc_alt;
uint8_t v_confidence;
};
struct osmo_gad {
enum gad_type type;
union {
struct osmo_gad_ell_point ell_point;
struct osmo_gad_ell_point_unc_circle ell_point_unc_circle;
struct osmo_gad_ell_point_unc_ellipse ell_point_unc_ellipse;
struct osmo_gad_polygon polygon;
struct osmo_gad_ell_point_alt ell_point_alt;
struct osmo_gad_ell_point_alt_unc_ell ell_point_alt_unc_ell;
struct osmo_gad_ell_arc ell_arc;
struct osmo_gad_ell_point_unc_ellipse ha_ell_point_unc_ellipse;
struct osmo_gad_ha_ell_point_alt_unc_ell ha_ell_point_alt_unc_ell;
};
};
struct osmo_gad_err {
int rc;
enum gad_type type;
char *logmsg;
};
extern const struct value_string osmo_gad_type_names[];
static inline const char *osmo_gad_type_name(enum gad_type val)
{ return get_value_string(osmo_gad_type_names, val); }
int osmo_gad_raw_write(struct msgb *msg, const union gad_raw *gad_raw);
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);
int osmo_gad_enc(union gad_raw *gad_raw, const struct osmo_gad *gad);
int osmo_gad_dec(struct osmo_gad *gad, struct osmo_gad_err **err, void *err_ctx, const union gad_raw *gad_raw);
int osmo_gad_to_str_buf(char *buf, size_t buflen, const struct osmo_gad *gad);
char *osmo_gad_to_str_c(void *ctx, const struct osmo_gad *gad);
uint32_t osmo_gad_enc_lat(int32_t deg_1e6);
int32_t osmo_gad_dec_lat(uint32_t lat);
uint32_t osmo_gad_enc_lon(int32_t deg_1e6);
int32_t osmo_gad_dec_lon(uint32_t lon);
uint8_t osmo_gad_enc_unc(uint32_t mm);
uint32_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]
Definition gsm_03_41.h:16
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