libosmogsm 1.13.1.1-afb4 Osmocom GSM library

Functions
gsm23003.c File Reference

Utility function implementations related to 3GPP TS 23.003. More...

`#include <ctype.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <errno.h>`
`#include <string.h>`
`#include <osmocom/gsm/gsm23003.h>`
`#include <osmocom/gsm/protocol/gsm_23_003.h>`
`#include <osmocom/core/utils.h>`

## Functions
static bool | is_n_digits (const char *str, int min_digits, int max_digits)
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...
char * | osmo_mcc_name_buf (char *buf, size_t buf_len, uint16_t mcc)
| Return MCC string as standardized 3-digit with leading zeros. More...
const char * | osmo_mcc_name (uint16_t mcc)
| Return MCC string as standardized 3-digit with leading zeros. More...
const char * | osmo_mcc_name_c (const void *ctx, uint16_t mcc)
| Return MCC string as standardized 3-digit with leading zeros, into a talloc-allocated buffer. More...
char * | osmo_mnc_name_buf (char *buf, size_t buf_len, uint16_t mnc, bool mnc_3_digits)
| Return MNC string as standardized 2- or 3-digit with leading zeros. More...
char * | osmo_mnc_name_c (const void *ctx, uint16_t mnc, bool mnc_3_digits)
| Return MNC string as standardized 2- or 3-digit with leading zeros, into a talloc-allocated buffer. 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...
char * | osmo_plmn_name_buf (char *buf, size_t buf_len, 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_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...
char * | osmo_plmn_name_c (const void *ctx, const struct osmo_plmn_id *plmn)
| Return MCC-MNC string as standardized 3-digit-dash-2/3-digit with leading zeros, into a dynamically-allocated output buffer. More...
char * | osmo_lai_name_buf (char *buf, size_t buf_len, const struct osmo_location_area_id *lai)
| Return MCC-MNC-LAC as string, in caller-provided output 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...
char * | osmo_lai_name_c (const void *ctx, const struct osmo_location_area_id *lai)
| Return MCC-MNC-LAC as string, in a talloc-allocated output buffer. More...
char * | osmo_rai_name2_buf (char *buf, size_t buf_len, const struct osmo_routing_area_id *rai)
| Return MCC-MNC-LAC-RAC as string, in caller-provided output buffer. More...
const char * | osmo_rai_name2 (const struct osmo_routing_area_id *rai)
| Return MCC-MNC-LAC-RAC as string, in a static buffer. More...
char * | osmo_rai_name2_c (const void *ctx, const struct osmo_routing_area_id *rai)
| Return MCC-MNC-LAC-RAC as string, in a talloc-allocated output buffer. More...
char * | osmo_cgi_name_buf (char *buf, size_t buf_len, const struct osmo_cell_global_id *cgi)
| Return MCC-MNC-LAC-CI as string, in caller-provided output 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...
char * | osmo_cgi_name_c (const void *ctx, const struct osmo_cell_global_id *cgi)
| Return MCC-MNC-LAC-CI as string, in a talloc-allocated output buffer. More...
char * | osmo_cgi_ps_name_buf (char *buf, size_t buf_len, const struct osmo_cell_global_id_ps *cgi_ps)
| Return MCC-MNC-LAC-RAC-CI as string, in caller-provided output buffer. More...
const char * | osmo_cgi_ps_name (const struct osmo_cell_global_id_ps *cgi_ps)
| Return MCC-MNC-LAC-RAC-CI as string, in a static buffer. More...
const char * | osmo_cgi_ps_name2 (const struct osmo_cell_global_id_ps *cgi_ps)
| Same as osmo_cgi_ps_name(), but uses a different static buffer. More...
char * | osmo_rnc_id_name_buf (char *buf, size_t buf_len, const struct osmo_rnc_id *rnc)
| Return string representation of RNC in caller-provided output buffer. More...
const char * | osmo_rnc_id_name (const struct osmo_rnc_id *rnc)
| Return string representation of RNC in static output buffer. More...
char * | osmo_rnc_id_name_c (const void *ctx, const struct osmo_rnc_id *rnc)
| Return string representation of RNC in static output buffer. More...
char * | osmo_cgi_ps_name_c (const void *ctx, const struct osmo_cell_global_id_ps *cgi_ps)
| Return MCC-MNC-LAC-RAC-CI as string, in a talloc-allocated output buffer. More...
char * | osmo_sai_name_buf (char *buf, size_t buf_len, const struct osmo_service_area_id *sai)
| Return MCC-MNC-LAC-SAC as string, in caller-provided output buffer. More...
const char * | osmo_sai_name (const struct osmo_service_area_id *sai)
| Return MCC-MNC-LAC-SAC as string, in a static buffer. More...
const char * | osmo_sai_name2 (const struct osmo_service_area_id *sai)
| Same as osmo_cgi_name(), but uses a different static buffer. More...
char * | osmo_sai_name_c (const void *ctx, const struct osmo_service_area_id *sai)
| Return MCC-MNC-LAC-SAC as string, in a talloc-allocated output buffer. More...
static void | to_bcd (uint8_t *bcd, uint16_t val)
char * | osmo_gummei_name_buf (char *buf, size_t buf_len, const struct osmo_gummei *gummei)
| Return string representation of GUMMEI in caller-provided output buffer. More...
const char * | osmo_gummei_name (const struct osmo_gummei *gummei)
| Return string representation of GUMMEI in static output buffer. More...
char * | osmo_gummei_name_c (const void *ctx, const struct osmo_gummei *gummei)
| Return string representation of GUMMEI in static output buffer. More...
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)
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_rai_cmp (const struct osmo_routing_area_id *a, const struct osmo_routing_area_id *b)
int | osmo_cgi_cmp (const struct osmo_cell_global_id *a, const struct osmo_cell_global_id *b)
int | osmo_cgi_ps_cmp (const struct osmo_cell_global_id_ps *a, const struct osmo_cell_global_id_ps *b)
int | osmo_rnc_id_cmp (const struct osmo_rnc_id *a, const struct osmo_rnc_id *b)
int | osmo_mme_id_cmp (const struct osmo_mme_id *a, const struct osmo_mme_id *b)
int | osmo_gummei_cmp (const struct osmo_gummei *a, const struct osmo_gummei *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_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...
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...

## Detailed Description

Utility function implementations related to 3GPP TS 23.003.

## Function Documentation

## ◆ is_n_digits()

static bool is_n_digits | ( | const char * | str,
|  | int | min_digits,
|  | int | max_digits
| ) |  |
| static

References len.

Referenced by osmo_imei_str_valid(), osmo_imsi_str_valid(), and osmo_msisdn_str_valid().

## ◆ osmo_cgi_cmp()

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().

## ◆ 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.

Parameters

  [in] | cgi | CGI to encode.

Returns
  Static string buffer.

References osmo_cgi_name_buf().

Referenced by gsm0808_cell_id_u_name().

## ◆ 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.

Useful for printing two distinct CGIs in the same printf format.

Parameters

  [in] | cgi | CGI to encode.

Returns
  Static string buffer.

References osmo_cgi_name_buf().

## ◆ osmo_cgi_name_buf()

char * osmo_cgi_name_buf | ( | char * | buf,
|  | size_t | buf_len,
|  | const struct osmo_cell_global_id * | cgi
| ) |  |

Return MCC-MNC-LAC-CI as string, in caller-provided output buffer.

Parameters

  [out] | buf | caller-allocated output buffer
  [in] | buf_len | size of buf in bytes
  [in] | cgi | CGI to encode.

Returns
  buf

References osmo_cell_global_id::cell_identity, osmo_cell_global_id::lai, and osmo_lai_name().

Referenced by osmo_cgi_name(), osmo_cgi_name2(), and osmo_cgi_name_c().

## ◆ osmo_cgi_name_c()

char * osmo_cgi_name_c | ( | const void * | ctx,
|  | const struct osmo_cell_global_id * | cgi
| ) |  |

Return MCC-MNC-LAC-CI as string, in a talloc-allocated output buffer.

Parameters

  [in] | ctx | talloc context from which to allocate output buffer
  [in] | cgi | CGI to encode.

Returns
  string representation of CGI in dynamically-allocated buffer.

References osmo_cgi_name_buf().

## ◆ osmo_cgi_ps_cmp()

int osmo_cgi_ps_cmp | ( | const struct osmo_cell_global_id_ps * | a,
|  | const struct osmo_cell_global_id_ps * | b
| ) |  |

References osmo_cell_global_id_ps::cell_identity, osmo_rai_cmp(), and osmo_cell_global_id_ps::rai.

## ◆ osmo_cgi_ps_name()

const char * osmo_cgi_ps_name | ( | const struct osmo_cell_global_id_ps * | cgi_ps | ) |

Return MCC-MNC-LAC-RAC-CI as string, in a static buffer.

Parameters

  [in] | cgi_ps | CGI-PS to encode.

Returns
  Static string buffer.

References osmo_cgi_ps_name_buf().

Referenced by gsm0808_cell_id_u_name().

## ◆ osmo_cgi_ps_name2()

const char * osmo_cgi_ps_name2 | ( | const struct osmo_cell_global_id_ps * | cgi_ps | ) |

Same as osmo_cgi_ps_name(), but uses a different static buffer.

Useful for printing two distinct CGI-PSs in the same printf format.

Parameters

  [in] | cgi | CGI-PS to encode.

Returns
  Static string buffer.

References osmo_cgi_ps_name_buf().

## ◆ osmo_cgi_ps_name_buf()

char * osmo_cgi_ps_name_buf | ( | char * | buf,
|  | size_t | buf_len,
|  | const struct osmo_cell_global_id_ps * | cgi_ps
| ) |  |

Return MCC-MNC-LAC-RAC-CI as string, in caller-provided output buffer.

Parameters

  [out] | buf | caller-allocated output buffer
  [in] | buf_len | size of buf in bytes
  [in] | cgi_ps | CGI-PS to encode.

Returns
  buf

References osmo_cell_global_id_ps::cell_identity, osmo_rai_name2(), and osmo_cell_global_id_ps::rai.

Referenced by osmo_cgi_ps_name(), osmo_cgi_ps_name2(), and osmo_cgi_ps_name_c().

## ◆ osmo_cgi_ps_name_c()

char * osmo_cgi_ps_name_c | ( | const void * | ctx,
|  | const struct osmo_cell_global_id_ps * | cgi_ps
| ) |  |

Return MCC-MNC-LAC-RAC-CI as string, in a talloc-allocated output buffer.

Parameters

  [in] | ctx | talloc context from which to allocate output buffer
  [in] | cgi_ps | CGI-PS to encode.

Returns
  string representation of CGI in dynamically-allocated buffer.

References osmo_cgi_ps_name_buf().

## ◆ osmo_gen_home_network_domain()

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)

Parameters

  out[out] | caller-provided output buffer, at least 33 bytes long
  plmn[in] | Osmocom representation of PLMN ID (MCC + MNC)

Returns
  number of characters printed (excluding NUL); negative on error

References osmo_plmn_id::mcc, and osmo_plmn_id::mnc.

Referenced by osmo_gen_mme_domain(), and osmo_gen_mme_group_domain().

## ◆ osmo_gen_mme_domain()

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)

Parameters

  out[out] | caller-provided output buffer, at least 56 bytes long
  gummei[in] | Structure representing the Globally Unique MME Identifier

Returns
  number of characters printed (excluding NUL); negative on error

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.

## ◆ osmo_gen_mme_group_domain()

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)

Parameters

  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)

Returns
  number of characters printed (excluding NUL); negative on error

References GSM23003_HOME_NETWORK_DOMAIN_LEN, and osmo_gen_home_network_domain().

## ◆ osmo_gummei_cmp()

int osmo_gummei_cmp | ( | const struct osmo_gummei * | a,
|  | const struct osmo_gummei * | b
| ) |  |

References osmo_gummei::mme, osmo_mme_id_cmp(), osmo_plmn_cmp(), and osmo_gummei::plmn.

## ◆ osmo_gummei_name()

const char * osmo_gummei_name | ( | const struct osmo_gummei * | gummei | ) |

Return string representation of GUMMEI in static output buffer.

Parameters

  [in] | gummei | GUMMEI to be stringified

Returns
  pointer to static output buffer

References osmo_gummei_name_buf().

## ◆ osmo_gummei_name_buf()

char * osmo_gummei_name_buf | ( | char * | buf,
|  | size_t | buf_len,
|  | const struct osmo_gummei * | gummei
| ) |  |

Return string representation of GUMMEI in caller-provided output buffer.

Parameters

  [out] | buf | pointer to caller-provided output buffer
  [in] | buf_len | size of buf in bytes
  [in] | gummei | GUMMEI to be stringified

Returns
  buf

References osmo_mme_id::code, osmo_mme_id::group_id, osmo_gummei::mme, osmo_plmn_name_buf(), and osmo_gummei::plmn.

Referenced by osmo_gummei_name(), and osmo_gummei_name_c().

## ◆ osmo_gummei_name_c()

char * osmo_gummei_name_c | ( | const void * | ctx,
|  | const struct osmo_gummei * | gummei
| ) |  |

Return string representation of GUMMEI in static output buffer.

Parameters

  [out] | buf | pointer to caller-provided output buffer
  [in] | buf_len | size of buf in bytes
  [in] | gummei | GUMMEI to be stringified

Returns
  pointer to static output buffer

References osmo_gummei_name_buf().

## ◆ osmo_imei_str_valid()

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.

Parameters

  imei | IMEI digits in ASCII string representation.
  with_15th_digit | when true, expect the 15th digit to be present and verify it.

Returns
  true when the IMEI is valid, false for invalid characters or number of digits.

References is_n_digits(), and osmo_luhn().

## ◆ 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.

Parameters

  imsi | IMSI digits in ASCII string representation.

Returns
  true when the IMSI is valid, false for invalid characters or number of digits.

References GSM23003_IMSI_MAX_DIGITS, GSM23003_IMSI_MIN_DIGITS, and is_n_digits().

## ◆ osmo_lai_cmp()

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_rai_cmp().

## ◆ 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.

Parameters

  [in] | lai | LAI to encode, the rac member is ignored.

Returns
  Static string buffer.

References lai, and osmo_lai_name_buf().

Referenced by gsm0808_cell_id_u_name(), osmo_cgi_name_buf(), and osmo_sai_name_buf().

## ◆ osmo_lai_name_buf()

char * osmo_lai_name_buf | ( | char * | buf,
|  | size_t | buf_len,
|  | const struct osmo_location_area_id * | lai
| ) |  |

Return MCC-MNC-LAC as string, in caller-provided output buffer.

Parameters

  [out] | buf | caller-allocated output buffer
  [in] | buf_len | size of buf in bytes
  [in] | lai | LAI to encode, the rac member is ignored.

Returns
  buf

References gsm48_loc_area_id::lac, lai, and osmo_plmn_name_buf().

Referenced by osmo_lai_name(), and osmo_lai_name_c().

## ◆ osmo_lai_name_c()

char * osmo_lai_name_c | ( | const void * | ctx,
|  | const struct osmo_location_area_id * | lai
| ) |  |

Return MCC-MNC-LAC as string, in a talloc-allocated output buffer.

Parameters

  [in] | ctx | talloc context from which to allocate output buffer
  [in] | lai | LAI to encode, the rac member is ignored.

Returns
  string representation of lai in dynamically allocated buffer.

References lai, and osmo_lai_name_buf().

## ◆ osmo_mcc_name()

const char * osmo_mcc_name | ( | uint16_t | mcc | ) |

Return MCC string as standardized 3-digit with leading zeros.

Parameters

  [in] | mcc | MCC value.

Returns
  string in static buffer.

References osmo_mcc_name_buf().

Referenced by osmo_rai_name_buf().

## ◆ osmo_mcc_name_buf()

char * osmo_mcc_name_buf | ( | char * | buf,
|  | size_t | buf_len,
|  | uint16_t | mcc
| ) |  |

Return MCC string as standardized 3-digit with leading zeros.

Parameters

  [out] | buf | caller-allocated output buffer
  [in] | buf_len | size of buf in bytes
  [in] | mcc | MCC value.

Returns
  string in user-supplied output buffer

Referenced by osmo_mcc_name(), osmo_mcc_name_c(), and osmo_plmn_name_buf().

## ◆ osmo_mcc_name_c()

const char * osmo_mcc_name_c | ( | const void * | ctx,
|  | uint16_t | mcc
| ) |  |

Return MCC string as standardized 3-digit with leading zeros, into a talloc-allocated buffer.

Parameters

  [in] | ctx | talloc context from which to allocate output buffer
  [in] | mcc | MCC value.

Returns
  string in dynamically allocated buffer.

References osmo_mcc_name_buf().

## ◆ osmo_mme_id_cmp()

int osmo_mme_id_cmp | ( | const struct osmo_mme_id * | a,
|  | const struct osmo_mme_id * | b
| ) |  |

References osmo_mme_id::code, and osmo_mme_id::group_id.

Referenced by osmo_gummei_cmp().

## ◆ 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
| ) |  |

Referenced by osmo_plmn_cmp().

## ◆ osmo_mnc_from_str()

int osmo_mnc_from_str | ( | const char * | mnc_str,
|  | uint16_t * | mnc,
|  | bool * | mnc_3_digits
| ) |  |

References osmo_str_to_int().

Referenced by osmo_mcc_from_str().

## ◆ 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.

Parameters

  [in] | mnc | MNC value.
  [in] | mnc_3_digits | True if an MNC should fill three digits, only has an effect if MNC < 100.

Returns
  string in static buffer.

References osmo_mnc_name_buf().

Referenced by osmo_rai_name_buf().

## ◆ osmo_mnc_name_buf()

char * osmo_mnc_name_buf | ( | char * | buf,
|  | size_t | buf_len,
|  | uint16_t | mnc,
|  | bool | mnc_3_digits
| ) |  |

Return MNC string as standardized 2- or 3-digit with leading zeros.

Parameters

  [out] | buf | caller-allocated output buffer
  [in] | buf_len | size of buf in bytes
  [in] | mnc | MNC value.
  [in] | mnc_3_digits | True if an MNC should fill three digits, only has an effect if MNC < 100.

Returns
  string in static buffer.

Referenced by osmo_mnc_name(), osmo_mnc_name_c(), and osmo_plmn_name_buf().

## ◆ osmo_mnc_name_c()

char * osmo_mnc_name_c | ( | const void * | ctx,
|  | uint16_t | mnc,
|  | bool | mnc_3_digits
| ) |  |

Return MNC string as standardized 2- or 3-digit with leading zeros, into a talloc-allocated buffer.

Parameters

  [in] | ctx | talloc context from which to allocate output buffer
  [in] | mnc | MNC value.
  [in] | mnc_3_digits | True if an MNC should fill three digits, only has an effect if MNC < 100.

Returns
  string in dynamically allocated buffer.

References osmo_mnc_name_buf().

## ◆ 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.

Parameters

  msisdn | MSISDN digits in ASCII string representation.

Returns
  true when the MSISDN is valid, false for invalid characters or number of digits.

References GSM23003_MSISDN_MAX_DIGITS, GSM23003_MSISDN_MIN_DIGITS, and is_n_digits().

## ◆ osmo_parse_home_network_domain()

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.

Parameters

  out[out] | caller-allocated output structure
  in[in] | character string representation to be parsed

Returns
  0 on success; negative on error

References osmo_plmn_id::mcc, and osmo_plmn_id::mnc.

## ◆ osmo_parse_mme_domain()

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.

Parameters

  out[out] | caller-allocated output GUMMEI structure
  in[in] | character string representation to be parsed

Returns
  0 on success; negative on error

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.

## ◆ osmo_plmn_cmp()

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_gummei_cmp(), osmo_lai_cmp(), and osmo_rnc_id_cmp().

## ◆ osmo_plmn_from_bcd()

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().

## ◆ 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.

Parameters

  [in] | plmn | MCC-MNC value.

Returns
  string in static buffer.

References osmo_plmn_name_buf().

## ◆ osmo_plmn_name2()

const char * osmo_plmn_name2 | ( | const struct osmo_plmn_id * | plmn | ) |

Same as osmo_plmn_name(), but returning in a different static buffer.

Parameters

  [in] | plmn | MCC-MNC value.

Returns
  string in static buffer.

References osmo_plmn_name_buf().

## ◆ osmo_plmn_name_buf()

char * osmo_plmn_name_buf | ( | char * | buf,
|  | size_t | buf_len,
|  | const struct osmo_plmn_id * | plmn
| ) |  |

Return MCC-MNC string as standardized 3-digit-dash-2/3-digit with leading zeros.

Parameters

  [out] | buf | caller-allocated output buffer
  [in] | buf_len | size of buf in bytes
  [in] | plmn | MCC-MNC value.

Returns
  string in static buffer.

References osmo_plmn_id::mcc, osmo_plmn_id::mnc, osmo_plmn_id::mnc_3_digits, osmo_mcc_name_buf(), and osmo_mnc_name_buf().

Referenced by osmo_gummei_name_buf(), osmo_lai_name_buf(), osmo_plmn_name(), osmo_plmn_name2(), osmo_plmn_name_c(), osmo_rai_name2_buf(), and osmo_rnc_id_name_buf().

## ◆ osmo_plmn_name_c()

char * osmo_plmn_name_c | ( | const void * | ctx,
|  | const struct osmo_plmn_id * | plmn
| ) |  |

Return MCC-MNC string as standardized 3-digit-dash-2/3-digit with leading zeros, into a dynamically-allocated output buffer.

Parameters

  [in] | ctx | talloc context from which to allocate output buffer
  [in] | plmn | MCC-MNC value.

Returns
  string in dynamically allocated buffer.

References osmo_plmn_name_buf().

## ◆ osmo_plmn_to_bcd()

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 gsm0808_create_common_id(), gsm48_generate_lai2(), gsm48_mcc_mnc_to_bcd(), and put_old_bss_to_new_bss_information().

## ◆ osmo_rai_cmp()

int osmo_rai_cmp | ( | const struct osmo_routing_area_id * | a,
|  | const struct osmo_routing_area_id * | b
| ) |  |

References osmo_routing_area_id::lac, osmo_lai_cmp(), and osmo_routing_area_id::rac.

Referenced by osmo_cgi_ps_cmp().

## ◆ osmo_rai_name2()

const char * osmo_rai_name2 | ( | const struct osmo_routing_area_id * | rai | ) |

Return MCC-MNC-LAC-RAC as string, in a static buffer.

Parameters

  [in] | rai | RAI to encode, the rac member is ignored.

Returns
  Static string buffer.

References osmo_rai_name2_buf().

Referenced by osmo_cgi_ps_name_buf().

## ◆ osmo_rai_name2_buf()

char * osmo_rai_name2_buf | ( | char * | buf,
|  | size_t | buf_len,
|  | const struct osmo_routing_area_id * | rai
| ) |  |

Return MCC-MNC-LAC-RAC as string, in caller-provided output buffer.

Parameters

  [out] | buf | caller-allocated output buffer
  [in] | buf_len | size of buf in bytes
  [in] | rai | RAI to encode, the rac member is ignored.

Returns
  buf

References osmo_location_area_id::lac, osmo_routing_area_id::lac, osmo_plmn_name_buf(), osmo_location_area_id::plmn, and osmo_routing_area_id::rac.

Referenced by osmo_rai_name2(), and osmo_rai_name2_c().

## ◆ osmo_rai_name2_c()

char * osmo_rai_name2_c | ( | const void * | ctx,
|  | const struct osmo_routing_area_id * | rai
| ) |  |

Return MCC-MNC-LAC-RAC as string, in a talloc-allocated output buffer.

Parameters

  [in] | ctx | talloc context from which to allocate output buffer
  [in] | rai | RAI to encode, the rac member is ignored.

Returns
  string representation of lai in dynamically allocated buffer.

References osmo_rai_name2_buf().

## ◆ osmo_rnc_id_cmp()

int osmo_rnc_id_cmp | ( | const struct osmo_rnc_id * | a,
|  | const struct osmo_rnc_id * | b
| ) |  |

References osmo_plmn_cmp(), osmo_rnc_id::plmn, and osmo_rnc_id::rnc_id.

## ◆ osmo_rnc_id_name()

const char * osmo_rnc_id_name | ( | const struct osmo_rnc_id * | rnc | ) |

Return string representation of RNC in static output buffer.

Parameters

  [in] | rnc | RNC to be stringified

Returns
  pointer to static output buffer

References osmo_rnc_id_name_buf().

## ◆ osmo_rnc_id_name_buf()

char * osmo_rnc_id_name_buf | ( | char * | buf,
|  | size_t | buf_len,
|  | const struct osmo_rnc_id * | rnc
| ) |  |

Return string representation of RNC in caller-provided output buffer.

Parameters

  [out] | buf | pointer to caller-provided output buffer
  [in] | buf_len | size of buf in bytes
  [in] | rnc | RNC to be stringified

Returns
  buf

References osmo_plmn_name_buf(), osmo_rnc_id::plmn, and osmo_rnc_id::rnc_id.

Referenced by osmo_rnc_id_name(), and osmo_rnc_id_name_c().

## ◆ osmo_rnc_id_name_c()

char * osmo_rnc_id_name_c | ( | const void * | ctx,
|  | const struct osmo_rnc_id * | rnc
| ) |  |

Return string representation of RNC in static output buffer.

Parameters

  [out] | buf | pointer to caller-provided output buffer
  [in] | buf_len | size of buf in bytes
  [in] | rnc | RNC to be stringified

Returns
  pointer to static output buffer

References osmo_rnc_id_name_buf().

## ◆ osmo_sai_name()

const char * osmo_sai_name | ( | const struct osmo_service_area_id * | sai | ) |

Return MCC-MNC-LAC-SAC as string, in a static buffer.

Parameters

  [in] | sai | SAI to encode.

Returns
  Static string buffer.

References osmo_sai_name_buf().

Referenced by gsm0808_cell_id_u_name().

## ◆ osmo_sai_name2()

const char * osmo_sai_name2 | ( | const struct osmo_service_area_id * | sai | ) |

Same as osmo_cgi_name(), but uses a different static buffer.

Useful for printing two distinct CGIs in the same printf format.

Parameters

  [in] | sai | SAI to encode.

Returns
  Static string buffer.

References osmo_sai_name_buf().

## ◆ osmo_sai_name_buf()

char * osmo_sai_name_buf | ( | char * | buf,
|  | size_t | buf_len,
|  | const struct osmo_service_area_id * | sai
| ) |  |

Return MCC-MNC-LAC-SAC as string, in caller-provided output buffer.

Parameters

  [out] | buf | caller-allocated output buffer
  [in] | buf_len | size of buf in bytes
  [in] | sai | SAI to encode.

Returns
  buf

References osmo_service_area_id::lai, osmo_lai_name(), and osmo_service_area_id::sac.

Referenced by osmo_sai_name(), osmo_sai_name2(), and osmo_sai_name_c().

## ◆ osmo_sai_name_c()

char * osmo_sai_name_c | ( | const void * | ctx,
|  | const struct osmo_service_area_id * | sai
| ) |  |

Return MCC-MNC-LAC-SAC as string, in a talloc-allocated output buffer.

Parameters

  [in] | ctx | talloc context from which to allocate output buffer
  [in] | sai | SAI to encode.

Returns
  string representation of CGI in dynamically-allocated buffer.

References osmo_sai_name_buf().

## ◆ to_bcd()

static void to_bcd | ( | uint8_t * | bcd,
|  | uint16_t | val
| ) |  |
| static

Referenced by osmo_plmn_to_bcd().