blob: 51e5ef83d95db42d373fa30e5e1cfdfb6d7aac6e [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file gsm23003.h */
2
Harald Weltebda26c02016-05-11 09:13:08 +02003#pragma once
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02004
Harald Weltebda26c02016-05-11 09:13:08 +02005#include <stdint.h>
Neels Hofmeyr9cd1e742017-10-04 03:15:47 +02006#include <stdbool.h>
Harald Weltebda26c02016-05-11 09:13:08 +02007
8/* 23.003 Chapter 12.1 */
9struct osmo_plmn_id {
10 uint16_t mcc;
11 uint16_t mnc;
Neels Hofmeyrc4fce142018-02-20 13:47:08 +010012 bool mnc_3_digits; /*< ignored and implied true if mnc > 99, otherwise defines leading zeros. */
Harald Weltebda26c02016-05-11 09:13:08 +020013};
14
15/* 4.1 */
16struct osmo_location_area_id {
17 struct osmo_plmn_id plmn;
18 uint16_t lac;
19};
20
21/* 4.2 */
22struct osmo_routing_area_id {
23 struct osmo_location_area_id lac;
24 uint8_t rac;
25};
26
27/* 4.3.1 */
28struct osmo_cell_global_id {
29 struct osmo_location_area_id lai;
30 uint16_t cell_identity;
31};
32
33/* 12.5 */
34struct osmo_service_area_id {
35 struct osmo_location_area_id lai;
36 uint16_t sac;
37};
38
39/* 12.6 */
40struct osmo_shared_network_area_id {
41 struct osmo_plmn_id plmn;
42 uint32_t snac;
43};
44
45/* 5.1 */
46enum osmo_gsn_addr_type {
47 GSN_ADDR_TYPE_IPV4 = 0,
48 GSN_ADDR_TYPE_IPV6 = 1,
49};
50
51/* 5.1 */
52struct osmo_gsn_address {
53 enum osmo_gsn_addr_type type;
54 uint8_t length;
55 uint8_t addr[16];
56};
57
58/* 19.4.2.3 */
59struct osmo_tracking_area_id {
60 struct osmo_plmn_id plmn;
61 uint16_t tac;
62};
63
64struct osmo_eutran_cell_global_id {
65 struct osmo_plmn_id plmn;
66 uint32_t eci; /* FIXME */
67};
68
69/* 2.8.1 */
70struct osmo_mme_id {
71 uint16_t group_id;
72 uint8_t code;
73};
74
75/* 2.8.1 */
76struct osmo_gummei {
77 struct osmo_plmn_id plmn;
78 struct osmo_mme_id mme;
79};
80
81/* 2.8.1 */
82struct osmo_guti {
83 struct osmo_gummei gummei;
84 uint32_t mtmsi;
85};
Neels Hofmeyr9cd1e742017-10-04 03:15:47 +020086
87bool osmo_imsi_str_valid(const char *imsi);
88bool osmo_msisdn_str_valid(const char *msisdn);
Neels Hofmeyrc4fce142018-02-20 13:47:08 +010089
90const char *osmo_mcc_name(uint16_t mcc);
91const char *osmo_mnc_name(uint16_t mnc, bool mnc_3_digits);
92const char *osmo_plmn_name(const struct osmo_plmn_id *plmn);
93const char *osmo_plmn_name2(const struct osmo_plmn_id *plmn);
94const char *osmo_lai_name(const struct osmo_location_area_id *lai);
95
96void osmo_plmn_to_bcd(uint8_t *bcd_dst, const struct osmo_plmn_id *plmn);
97void osmo_plmn_from_bcd(const uint8_t *bcd_src, struct osmo_plmn_id *plmn);