libosmogsm
1.0.1.104-98ed3
Osmocom GSM library
|
#include <stdint.h>
#include <stdbool.h>
Go to the source code of this file.
Data Structures | |
struct | osmo_plmn_id |
struct | osmo_location_area_id |
struct | osmo_routing_area_id |
struct | osmo_cell_global_id |
struct | osmo_lac_and_ci_id |
struct | osmo_service_area_id |
struct | osmo_shared_network_area_id |
struct | osmo_gsn_address |
struct | osmo_tracking_area_id |
struct | osmo_eutran_cell_global_id |
struct | osmo_mme_id |
struct | osmo_gummei |
struct | osmo_guti |
Enumerations | |
enum | osmo_cgi_part { OSMO_CGI_PART_PLMN = 1, OSMO_CGI_PART_LAC = 2, OSMO_CGI_PART_CI = 4 } |
Bitmask of items contained in a struct osmo_cell_global_id. More... | |
enum | osmo_gsn_addr_type { GSN_ADDR_TYPE_IPV4 = 0, GSN_ADDR_TYPE_IPV6 = 1 } |
Functions | |
bool | osmo_imsi_str_valid (const char *imsi) |
Determine whether the given IMSI is valid according to 3GPP TS 23.003. More... | |
bool | osmo_msisdn_str_valid (const char *msisdn) |
Determine whether the given MSISDN is valid according to 3GPP TS 23.003. More... | |
bool | osmo_imei_str_valid (const char *imei, bool with_15th_digit) |
Determine whether the given IMEI is valid according to 3GPP TS 23.003, Section 6.2.1. More... | |
const char * | osmo_mcc_name (uint16_t mcc) |
Return MCC string as standardized 3-digit with leading zeros. More... | |
const char * | osmo_mnc_name (uint16_t mnc, bool mnc_3_digits) |
Return MNC string as standardized 2- or 3-digit with leading zeros. More... | |
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. More... | |
const char * | osmo_plmn_name2 (const struct osmo_plmn_id *plmn) |
Same as osmo_plmn_name(), but returning in a different static buffer. More... | |
const char * | osmo_lai_name (const struct osmo_location_area_id *lai) |
Return MCC-MNC-LAC as string, in a static buffer. More... | |
const char * | osmo_cgi_name (const struct osmo_cell_global_id *cgi) |
Return MCC-MNC-LAC-CI as string, in a static buffer. More... | |
const char * | osmo_cgi_name2 (const struct osmo_cell_global_id *cgi) |
Same as osmo_cgi_name(), but uses a different static buffer. More... | |
const char * | osmo_gummei_name (const struct osmo_gummei *gummei) |
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) |
static int | osmo_mcc_from_str (const char *mcc_str, uint16_t *mcc) |
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) |
int | osmo_lai_cmp (const struct osmo_location_area_id *a, const struct osmo_location_area_id *b) |
int | osmo_cgi_cmp (const struct osmo_cell_global_id *a, const struct osmo_cell_global_id *b) |
int | osmo_gen_home_network_domain (char *out, const struct osmo_plmn_id *plmn) |
Generate TS 23.003 Section 19.2 Home Network Realm/Domain (text form) More... | |
int | osmo_parse_home_network_domain (struct osmo_plmn_id *out, const char *in) |
Parse a TS 23.003 Section 19.2 Home Network Realm/Domain (text form) into a osmo_plmn_id. More... | |
int | osmo_gen_mme_domain (char *out, const struct osmo_gummei *gummei) |
Generate TS 23.003 Section 19.4.2.4 MME Domain (text form) More... | |
int | osmo_gen_mme_group_domain (char *out, uint16_t mmegi, const struct osmo_plmn_id *plmn) |
Generate TS 23.003 Section 19.4.2.4 MME Group Domain (text form) More... | |
int | osmo_parse_mme_domain (struct osmo_gummei *out, const char *in) |
Parse a TS 23.003 Section 19.4.2.4 MME Domain (text form) into a osmo_gummei. More... | |
enum osmo_cgi_part |
Bitmask of items contained in a struct osmo_cell_global_id.
See also gsm0808_cell_id_to_cgi().
Enumerator | |
---|---|
OSMO_CGI_PART_PLMN | |
OSMO_CGI_PART_LAC | |
OSMO_CGI_PART_CI |
enum osmo_gsn_addr_type |
int osmo_cgi_cmp | ( | const struct osmo_cell_global_id * | a, |
const struct osmo_cell_global_id * | b | ||
) |
References osmo_cell_global_id::cell_identity, osmo_cell_global_id::lai, and osmo_lai_cmp().
Referenced by gsm0808_cell_id_u_match(), and osmo_mcc_from_str().
const char* osmo_cgi_name | ( | const struct osmo_cell_global_id * | cgi | ) |
Return MCC-MNC-LAC-CI as string, in a static buffer.
[in] | cgi | CGI to encode. |
References _cgi_name().
Referenced by gsm0808_cell_id_u_name().
const char* osmo_cgi_name2 | ( | const struct osmo_cell_global_id * | cgi | ) |
Same as osmo_cgi_name(), but uses a different static buffer.
Useful for printing two distinct CGIs in the same printf format.
[in] | cgi | CGI to encode. |
References _cgi_name().
int osmo_gen_home_network_domain | ( | char * | out, |
const struct osmo_plmn_id * | plmn | ||
) |
Generate TS 23.003 Section 19.2 Home Network Realm/Domain (text form)
out[out] | caller-provided output buffer, at least 33 bytes long |
plmn[in] | Osmocom representation of PLMN ID (MCC + MNC) |
References osmo_plmn_id::mcc, and osmo_plmn_id::mnc.
Referenced by osmo_gen_mme_domain(), osmo_gen_mme_group_domain(), and osmo_mcc_from_str().
int osmo_gen_mme_domain | ( | char * | out, |
const struct osmo_gummei * | gummei | ||
) |
Generate TS 23.003 Section 19.4.2.4 MME Domain (text form)
out[out] | caller-provided output buffer, at least 56 bytes long |
gummei[in] | Structure representing the Globally Unique MME Identifier |
References osmo_mme_id::code, osmo_mme_id::group_id, GSM23003_HOME_NETWORK_DOMAIN_LEN, osmo_gummei::mme, osmo_gen_home_network_domain(), and osmo_gummei::plmn.
Referenced by osmo_mcc_from_str().
int osmo_gen_mme_group_domain | ( | char * | out, |
uint16_t | mmegi, | ||
const struct osmo_plmn_id * | plmn | ||
) |
Generate TS 23.003 Section 19.4.2.4 MME Group Domain (text form)
out[out] | caller-provided output buffer, at least 56 bytes long |
mmegi[in] | MME Group Identifier |
plmn[in] | Osmocom representation of PLMN ID (MCC + MNC) |
References GSM23003_HOME_NETWORK_DOMAIN_LEN, and osmo_gen_home_network_domain().
Referenced by osmo_mcc_from_str().
const char* osmo_gummei_name | ( | const struct osmo_gummei * | gummei | ) |
References osmo_mme_id::code, osmo_mme_id::group_id, osmo_gummei::mme, osmo_plmn_name(), and osmo_gummei::plmn.
bool osmo_imei_str_valid | ( | const char * | imei, |
bool | with_15th_digit | ||
) |
Determine whether the given IMEI is valid according to 3GPP TS 23.003, Section 6.2.1.
It consists of 14 digits, the 15th check digit is not intended for digital transmission.
imei | IMEI digits in ASCII string representation. |
with_15th_digit | when true, expect the 15th digit to be present and verify it. |
References is_n_digits(), and osmo_luhn().
bool osmo_imsi_str_valid | ( | const char * | imsi | ) |
Determine whether the given IMSI is valid according to 3GPP TS 23.003.
imsi | IMSI digits in ASCII string representation. |
References GSM23003_IMSI_MAX_DIGITS, GSM23003_IMSI_MIN_DIGITS, and is_n_digits().
int osmo_lai_cmp | ( | const struct osmo_location_area_id * | a, |
const struct osmo_location_area_id * | b | ||
) |
References osmo_location_area_id::lac, osmo_plmn_cmp(), and osmo_location_area_id::plmn.
Referenced by osmo_cgi_cmp(), and osmo_mcc_from_str().
const char* osmo_lai_name | ( | const struct osmo_location_area_id * | lai | ) |
Return MCC-MNC-LAC as string, in a static buffer.
[in] | lai | LAI to encode, the rac member is ignored. |
References osmo_location_area_id::lac, osmo_plmn_name(), and osmo_location_area_id::plmn.
Referenced by _cgi_name(), and gsm0808_cell_id_u_name().
|
inlinestatic |
const char* osmo_mcc_name | ( | uint16_t | mcc | ) |
Return MCC string as standardized 3-digit with leading zeros.
[in] | mcc | MCC value. |
Referenced by osmo_rai_name(), and plmn_name().
int osmo_mnc_cmp | ( | uint16_t | a_mnc, |
bool | a_mnc_3_digits, | ||
uint16_t | b_mnc, | ||
bool | b_mnc_3_digits | ||
) |
Referenced by osmo_mcc_from_str(), and osmo_plmn_cmp().
int osmo_mnc_from_str | ( | const char * | mnc_str, |
uint16_t * | mnc, | ||
bool * | mnc_3_digits | ||
) |
Referenced by osmo_mcc_from_str().
const char* osmo_mnc_name | ( | uint16_t | mnc, |
bool | mnc_3_digits | ||
) |
Return MNC string as standardized 2- or 3-digit with leading zeros.
[in] | mnc | MNC value. |
[in] | mnc_3_digits | True if an MNC should fill three digits, only has an effect if MNC < 100. |
Referenced by osmo_rai_name(), and plmn_name().
bool osmo_msisdn_str_valid | ( | const char * | msisdn | ) |
Determine whether the given MSISDN is valid according to 3GPP TS 23.003.
msisdn | MSISDN digits in ASCII string representation. |
References is_n_digits().
int osmo_parse_home_network_domain | ( | struct osmo_plmn_id * | out, |
const char * | in | ||
) |
Parse a TS 23.003 Section 19.2 Home Network Realm/Domain (text form) into a osmo_plmn_id.
out[out] | caller-allocated output structure |
in[in] | character string representation to be parsed |
References osmo_plmn_id::mcc, and osmo_plmn_id::mnc.
Referenced by osmo_mcc_from_str().
int osmo_parse_mme_domain | ( | struct osmo_gummei * | out, |
const char * | in | ||
) |
Parse a TS 23.003 Section 19.4.2.4 MME Domain (text form) into a osmo_gummei.
out[out] | caller-allocated output GUMMEI structure |
in[in] | character string representation to be parsed |
References osmo_mme_id::code, osmo_mme_id::group_id, osmo_plmn_id::mcc, osmo_gummei::mme, osmo_plmn_id::mnc, and osmo_gummei::plmn.
Referenced by osmo_mcc_from_str().
int osmo_plmn_cmp | ( | const struct osmo_plmn_id * | a, |
const struct osmo_plmn_id * | b | ||
) |
References osmo_plmn_id::mcc, osmo_plmn_id::mnc, osmo_plmn_id::mnc_3_digits, and osmo_mnc_cmp().
Referenced by osmo_lai_cmp(), and osmo_mcc_from_str().
void osmo_plmn_from_bcd | ( | const uint8_t * | bcd_src, |
struct osmo_plmn_id * | plmn | ||
) |
References osmo_plmn_id::mcc, osmo_plmn_id::mnc, and osmo_plmn_id::mnc_3_digits.
Referenced by gsm48_decode_lai2(), and gsm48_mcc_mnc_from_bcd().
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.
[in] | plmn | MCC-MNC value. |
References plmn_name().
Referenced by osmo_gummei_name(), and osmo_lai_name().
const char* osmo_plmn_name2 | ( | const struct osmo_plmn_id * | plmn | ) |
Same as osmo_plmn_name(), but returning in a different static buffer.
[in] | plmn | MCC-MNC value. |
References plmn_name().
void osmo_plmn_to_bcd | ( | uint8_t * | bcd_dst, |
const struct osmo_plmn_id * | plmn | ||
) |
References osmo_plmn_id::mcc, osmo_plmn_id::mnc, osmo_plmn_id::mnc_3_digits, and to_bcd().
Referenced by gsm48_generate_lai2(), and gsm48_mcc_mnc_to_bcd().