gsm23003.h
Go to the documentation of this file.
#pragma once
#include <stdint.h>
#include <stdbool.h>
/* 23.003 Chapter 12.1 */
struct osmo_plmn_id {
uint16_t mcc;
uint16_t mnc;
bool mnc_3_digits; /*< ignored and implied true if mnc > 99, otherwise defines leading zeros. */
};
/* 4.1 */
struct osmo_location_area_id {
struct osmo_plmn_id plmn;
uint16_t lac;
};
/* 4.2 */
struct osmo_routing_area_id {
struct osmo_location_area_id lac;
uint8_t rac;
};
/* 4.3.1 */
struct osmo_cell_global_id {
struct osmo_location_area_id lai;
uint16_t cell_identity;
};
/* Actually defined in 3GPP TS 48.008 3.2.2.27 Cell Identifier List,
* but conceptually belongs with the above structures. */
struct osmo_lac_and_ci_id {
uint16_t lac;
uint16_t ci;
};
/* 12.5 */
struct osmo_service_area_id {
struct osmo_location_area_id lai;
uint16_t sac;
};
/* 12.6 */
struct osmo_shared_network_area_id {
struct osmo_plmn_id plmn;
uint32_t snac;
};
/* 5.1 */
enum osmo_gsn_addr_type {
GSN_ADDR_TYPE_IPV4 = 0,
GSN_ADDR_TYPE_IPV6 = 1,
};
/* 5.1 */
struct osmo_gsn_address {
enum osmo_gsn_addr_type type;
uint8_t length;
uint8_t addr[16];
};
/* 19.4.2.3 */
struct osmo_tracking_area_id {
struct osmo_plmn_id plmn;
uint16_t tac;
};
struct osmo_eutran_cell_global_id {
struct osmo_plmn_id plmn;
uint32_t eci; /* FIXME */
};
/* 2.8.1 */
struct osmo_mme_id {
uint16_t group_id;
uint8_t code;
};
/* 2.8.1 */
struct osmo_gummei {
struct osmo_plmn_id plmn;
struct osmo_mme_id mme;
};
/* 2.8.1 */
struct osmo_guti {
struct osmo_gummei gummei;
uint32_t mtmsi;
};
bool osmo_imsi_str_valid(const char *imsi);
bool osmo_msisdn_str_valid(const char *msisdn);
const char *osmo_mcc_name(uint16_t mcc);
const char *osmo_mnc_name(uint16_t mnc, bool mnc_3_digits);
const char *osmo_plmn_name(const struct osmo_plmn_id *plmn);
const char *osmo_plmn_name2(const struct osmo_plmn_id *plmn);
const char *osmo_lai_name(const struct osmo_location_area_id *lai);
const char *osmo_cgi_name(const struct osmo_cell_global_id *cgi);
const char *osmo_cgi_name2(const struct osmo_cell_global_id *cgi);
void osmo_plmn_to_bcd(uint8_t *bcd_dst, const struct osmo_plmn_id *plmn);
void osmo_plmn_from_bcd(const uint8_t *bcd_src, struct osmo_plmn_id *plmn);
int osmo_mnc_from_str(const char *mnc_str, uint16_t *mnc, bool *mnc_3_digits);
/* Convert string to MCC.
* \param mcc_str[in] String representation of an MCC, with or without leading zeros.
* \param mcc[out] MCC result buffer, or NULL.
* \returns zero on success, -EINVAL in case of surplus characters, negative errno in case of conversion
* errors. In case of error, do not modify the out-arguments.
*/
static inline int osmo_mcc_from_str(const char *mcc_str, uint16_t *mcc)
{
return osmo_mnc_from_str(mcc_str, mcc, NULL);
}
int osmo_mnc_cmp(uint16_t a_mnc, bool a_mnc_3_digits, uint16_t b_mnc, bool b_mnc_3_digits);
int osmo_plmn_cmp(const struct osmo_plmn_id *a, const struct osmo_plmn_id *b);
osmo_mme_id::code
uint8_t code
Definition: gsm23003.h:79
osmo_routing_area_id
Definition: gsm23003.h:22
osmo_location_area_id
Definition: gsm23003.h:16
osmo_tracking_area_id::tac
uint16_t tac
Definition: gsm23003.h:68
osmo_mcc_from_str
static int osmo_mcc_from_str(const char *mcc_str, uint16_t *mcc)
Definition: gsm23003.h:116
osmo_guti::mtmsi
uint32_t mtmsi
Definition: gsm23003.h:91
osmo_shared_network_area_id::plmn
struct osmo_plmn_id plmn
Definition: gsm23003.h:48
osmo_mme_id
Definition: gsm23003.h:77
osmo_cell_global_id
Definition: gsm23003.h:28
osmo_mnc_name
const char * osmo_mnc_name(uint16_t mnc, bool mnc_3_digits)
Return MNC string as standardized 2- or 3-digit with leading zeros.
Definition: gsm23003.c:90
osmo_plmn_id
Definition: gsm23003.h:9
osmo_lac_and_ci_id::lac
uint16_t lac
Definition: gsm23003.h:36
osmo_plmn_name
const char * osmo_plmn_name(const struct osmo_plmn_id *plmn)
Return MCC-MNC string as standardized 3-digit-dash-2/3-digit with leading zeros.
Definition: gsm23003.c:107
osmo_plmn_to_bcd
void osmo_plmn_to_bcd(uint8_t *bcd_dst, const struct osmo_plmn_id *plmn)
Definition: gsm23003.c:184
osmo_mnc_from_str
int osmo_mnc_from_str(const char *mnc_str, uint16_t *mnc, bool *mnc_3_digits)
Definition: gsm23003.c:238
osmo_cell_global_id::lai
struct osmo_location_area_id lai
Definition: gsm23003.h:29
osmo_routing_area_id::rac
uint8_t rac
Definition: gsm23003.h:24
osmo_msisdn_str_valid
bool osmo_msisdn_str_valid(const char *msisdn)
Determine whether the given MSISDN is valid according to 3GPP TS 23.003.
Definition: gsm23003.c:69
osmo_gsn_address::type
enum osmo_gsn_addr_type type
Definition: gsm23003.h:60
osmo_lai_name
const char * osmo_lai_name(const struct osmo_location_area_id *lai)
Return MCC-MNC-LAC as string, in a static buffer.
Definition: gsm23003.c:129
osmo_plmn_name2
const char * osmo_plmn_name2(const struct osmo_plmn_id *plmn)
Same as osmo_mcc_mnc_name(), but returning in a different static buffer.
Definition: gsm23003.c:118
osmo_gummei
Definition: gsm23003.h:83
osmo_service_area_id
Definition: gsm23003.h:41
osmo_mnc_cmp
int osmo_mnc_cmp(uint16_t a_mnc, bool a_mnc_3_digits, uint16_t b_mnc, bool b_mnc_3_digits)
Definition: gsm23003.c:274
osmo_imsi_str_valid
bool osmo_imsi_str_valid(const char *imsi)
Determine whether the given IMSI is valid according to 3GPP TS 23.003.
Definition: gsm23003.c:59
osmo_eutran_cell_global_id::eci
uint32_t eci
Definition: gsm23003.h:73
osmo_service_area_id::lai
struct osmo_location_area_id lai
Definition: gsm23003.h:42
osmo_gsn_address::length
uint8_t length
Definition: gsm23003.h:61
osmo_routing_area_id::lac
struct osmo_location_area_id lac
Definition: gsm23003.h:23
GSN_ADDR_TYPE_IPV4
@ GSN_ADDR_TYPE_IPV4
Definition: gsm23003.h:54
osmo_location_area_id::lac
uint16_t lac
Definition: gsm23003.h:18
osmo_mcc_name
const char * osmo_mcc_name(uint16_t mcc)
Return MCC string as standardized 3-digit with leading zeros.
Definition: gsm23003.c:78
osmo_guti
Definition: gsm23003.h:89
osmo_plmn_id::mnc
uint16_t mnc
Definition: gsm23003.h:11
osmo_plmn_id::mcc
uint16_t mcc
Definition: gsm23003.h:10
osmo_gummei::plmn
struct osmo_plmn_id plmn
Definition: gsm23003.h:84
osmo_eutran_cell_global_id::plmn
struct osmo_plmn_id plmn
Definition: gsm23003.h:72
osmo_gsn_address
Definition: gsm23003.h:59
osmo_cgi_name2
const char * osmo_cgi_name2(const struct osmo_cell_global_id *cgi)
Same as osmo_cgi_name(), but uses a different static buffer.
Definition: gsm23003.c:157
osmo_guti::gummei
struct osmo_gummei gummei
Definition: gsm23003.h:90
osmo_cgi_name
const char * osmo_cgi_name(const struct osmo_cell_global_id *cgi)
Return MCC-MNC-LAC-CI as string, in a static buffer.
Definition: gsm23003.c:146
osmo_shared_network_area_id::snac
uint32_t snac
Definition: gsm23003.h:49
osmo_lac_and_ci_id::ci
uint16_t ci
Definition: gsm23003.h:37
osmo_service_area_id::sac
uint16_t sac
Definition: gsm23003.h:43
GSN_ADDR_TYPE_IPV6
@ GSN_ADDR_TYPE_IPV6
Definition: gsm23003.h:55
osmo_plmn_id::mnc_3_digits
bool mnc_3_digits
Definition: gsm23003.h:12
osmo_shared_network_area_id
Definition: gsm23003.h:47
osmo_gsn_addr_type
osmo_gsn_addr_type
Definition: gsm23003.h:53
lai
struct gsm48_loc_area_id lai
Definition: gsm_04_08.h:715
osmo_plmn_cmp
int osmo_plmn_cmp(const struct osmo_plmn_id *a, const struct osmo_plmn_id *b)
Definition: gsm23003.c:290
osmo_mme_id::group_id
uint16_t group_id
Definition: gsm23003.h:78
osmo_plmn_from_bcd
void osmo_plmn_from_bcd(const uint8_t *bcd_src, struct osmo_plmn_id *plmn)
Definition: gsm23003.c:211
osmo_gummei::mme
struct osmo_mme_id mme
Definition: gsm23003.h:85
osmo_location_area_id::plmn
struct osmo_plmn_id plmn
Definition: gsm23003.h:17
osmo_gsn_address::addr
uint8_t addr[16]
Definition: gsm23003.h:62
osmo_lac_and_ci_id
Definition: gsm23003.h:35
osmo_tracking_area_id::plmn
struct osmo_plmn_id plmn
Definition: gsm23003.h:67
osmo_eutran_cell_global_id
Definition: gsm23003.h:71
osmo_cell_global_id::cell_identity
uint16_t cell_identity
Definition: gsm23003.h:30
osmo_tracking_area_id
Definition: gsm23003.h:66