libosmogsm 1.13.1.1-afb4 Osmocom GSM library

Data Structures | Macros | Enumerations | Functions | Variables
gsm_utils.h File Reference

GSM utility functions, e.g. More...

`#include <stddef.h>`
`#include <stdint.h>`
`#include <osmocom/core/defs.h>`
`#include <osmocom/core/utils.h>`

Go to the source code of this file.

## Data Structures
struct | gsm_time

## Macros
#define | ADD_MODULO(sum, delta, modulo)
#define | GSM_MAX_FN (26*51*2048)
#define | GSM_FN_UNSET 0xFFFFFFFF
#define | OSMO_MAX_RAND_ID_LEN 16
#define | ARFCN_PCS 0x8000
#define | ARFCN_UPLINK 0x4000
#define | ARFCN_FLAG_MASK 0xf000 /* Reserve the upper 5 bits for flags */
#define | GSM_RFN_MODULUS 42432
#define | GSM_PCHAN_TCH_F_TCH_H_PDCH GSM_PCHAN_OSMO_DYN
#define | GSM_7BIT_LEGACY_MAX_BUFFER_SIZE 0x10000

## Enumerations
enum | gsm_band { GSM_BAND_850 = 1 , GSM_BAND_900 = 2 , GSM_BAND_1800 = 4 , GSM_BAND_1900 = 8 , GSM_BAND_450 = 0x10 , GSM_BAND_480 = 0x20 , GSM_BAND_750 = 0x40 , GSM_BAND_810 = 0x80 }
enum | gprs_tlli_type { TLLI_LOCAL , TLLI_FOREIGN , TLLI_RANDOM , TLLI_AUXILIARY , TLLI_RESERVED , TLLI_G_RNTI , TLLI_RAND_G_RNTI }
enum | gsm_phys_chan_config { GSM_PCHAN_NONE , GSM_PCHAN_CCCH , GSM_PCHAN_CCCH_SDCCH4 , GSM_PCHAN_TCH_F , GSM_PCHAN_TCH_H , GSM_PCHAN_SDCCH8_SACCH8C , GSM_PCHAN_PDCH , GSM_PCHAN_TCH_F_PDCH , GSM_PCHAN_UNKNOWN , GSM_PCHAN_CCCH_SDCCH4_CBCH , GSM_PCHAN_SDCCH8_SACCH8C_CBCH , GSM_PCHAN_OSMO_DYN , _GSM_PCHAN_MAX }
enum | gsm_chan_t { GSM_LCHAN_NONE , GSM_LCHAN_SDCCH , GSM_LCHAN_TCH_F , GSM_LCHAN_TCH_H , GSM_LCHAN_UNKNOWN , GSM_LCHAN_CCCH , GSM_LCHAN_PDTCH , GSM_LCHAN_CBCH , _GSM_LCHAN_MAX }
enum | osmo_rat_type { OSMO_RAT_UNKNOWN = 0 , OSMO_RAT_GERAN_A , OSMO_RAT_UTRAN_IU , OSMO_RAT_EUTRAN_SGS , OSMO_RAT_COUNT }

## Functions
const char * | gsm_band_name (enum gsm_band band)
| Return string name of a given GSM Band. More...
enum gsm_band | gsm_band_parse (const char *mhz)
| Parse string name of a GSM band. More...
int | osmo_get_rand_id (uint8_t *out, size_t len)
| Generate random identifier We use /dev/urandom (default when GRND_RANDOM flag is not set). More...
int | gsm_7bit_decode_n (char *decoded, size_t n, const uint8_t *user_data, uint8_t length)
| Decode a sequence of GSM 03.38 encoded 7 bit characters. More...
int | gsm_7bit_decode_n_ussd (char *decoded, size_t n, const uint8_t *user_data, uint8_t length)
| Decode a sequence of 7 bit characters (USSD encoding). More...
int | gsm_7bit_encode_n (uint8_t *result, size_t n, const char *data, int *octets_written)
| Encode a text string into GSM 03.38 encoded 7 bit characters. More...
int | gsm_7bit_encode_n_ussd (uint8_t *result, size_t n, const char *data, int *octets_written)
| Encode a text string into GSM 03.38 encoded 7 bit characters (USSD encoding). More...
int | gsm_septets2octets (uint8_t *result, const uint8_t *rdata, uint8_t septet_len, uint8_t padding) OSMO_DEPRECATED("This function is unable to handle more than 255 septets
int use | gsm_septet_pack () instead.")
int | gsm_septet_pack (uint8_t *result, const uint8_t *rdata, size_t septet_len, uint8_t padding)
| GSM Default Alphabet 7bit to octet packing. More...
int | gsm_septet_encode (uint8_t *result, const char *data)
| Encode a ASCII characterrs as 7-bit GSM alphabet (TS 03.38) More...
uint8_t | gsm_get_octet_len (const uint8_t sept_len)
| Compute number of octets from number of septets. More...
int | gsm_7bit_decode_n_hdr (char *decoded, size_t n, const uint8_t *user_data, uint8_t length, uint8_t ud_hdr_ind)
| TS 03.38 7-bit Character unpacking (6.2.1) More...
int | ms_class_gmsk_dbm (enum gsm_band band, int ms_class)
| Convert power class to dBm according to GSM TS 05.05. More...
int | ms_pwr_ctl_lvl (enum gsm_band band, unsigned int dbm)
| determine power control level for given dBm value, as indicated by the tables in chapter 4.1.1 of GSM TS 05.05 More...
int | ms_pwr_dbm (enum gsm_band band, uint8_t lvl)
| Convert TS 05.05 power level to absolute dBm value. More...
int | rxlev2dbm (uint8_t rxlev)
| Convert TS 05.08 RxLev to dBm (TS 05.08 Chapter 8.1.4) More...
uint8_t | dbm2rxlev (int dbm)
| Convert RF signal level in dBm to TS 05.08 RxLev (TS 05.08 Chapter 8.1.4) More...
static int | ms_cm2_a5n_support (uint8_t *cm2, unsigned n)
static int | ms_cm3_a5n_support (uint8_t *cm3, unsigned n)
static int | rach_max_trans_val2raw (int val)
static int | rach_max_trans_raw2val (int raw)
static uint8_t | rach_tx_integer_raw2val (uint8_t raw)
int | gsm_arfcn2band_rc (uint16_t arfcn, enum gsm_band *band)
| Resolve GSM band from ARFCN. More...
enum gsm_band | gsm_arfcn2band (uint16_t arfcn) OSMO_DEPRECATED("Use gsm_arfcn2band_rc() instead")
| Resolve GSM band from ARFCN, aborts process on invalid ARFCN. More...
uint16_t | gsm_arfcn2freq10 (uint16_t arfcn, int uplink)
| Convert an ARFCN to the frequency in MHz * 10. More...
uint16_t | gsm_freq102arfcn (uint16_t freq10, int uplink)
| Convert a Frequency in MHz * 10 to ARFCN. More...
void | gsm_fn2gsmtime (struct gsm_time *time, uint32_t fn)
| Parse GSM Frame Number into struct gsm_time. More...
char * | gsm_fn_as_gsmtime_str (uint32_t fn)
| Parse GSM Frame Number into printable string. More...
uint32_t | gsm_gsmtime2fn (const struct gsm_time *time)
| Encode decoded gsm_time to Frame Number. More...
char * | osmo_dump_gsmtime (const struct gsm_time *tm)
char * | osmo_dump_gsmtime_buf (char *buf, size_t buf_len, const struct gsm_time *tm)
char * | osmo_dump_gsmtime_c (const void *ctx, const struct gsm_time *tm)
uint32_t | gsm_rfn2fn (uint16_t rfn, uint32_t curr_fn)
static uint16_t | gsm_fn2rfn (uint32_t fn)
int | gprs_tlli_type (uint32_t tlli)
| Determine GPRS TLLI Type (TS 23.003 Chapter 2.6) More...
uint32_t | gprs_tmsi2tlli (uint32_t p_tmsi, enum gprs_tlli_type type)
| Determine TLLI from P-TMSI. More...
uint32_t | gprs_tlli2tmsi (uint32_t tlli)
| Determine P-TMSI from foreign and local TLLIs. More...
static const char * | gsm_chan_t_name (enum gsm_chan_t val)
int | gsm_7bit_decode (char *decoded, const uint8_t *user_data, uint8_t length) OSMO_DEPRECATED("Use gsm_7bit_decode_n() instead")
int | gsm_7bit_decode_ussd (char *decoded, const uint8_t *user_data, uint8_t length) OSMO_DEPRECATED("Use gsm_7bit_decode_n_ussd() instead")
int | gsm_7bit_encode (uint8_t *result, const char *data) OSMO_DEPRECATED("Use gsm_7bit_encode_n() instead")
int | gsm_7bit_encode_ussd (uint8_t *result, const char *data, int *octets_written) OSMO_DEPRECATED("Use gsm_7bit_encode_n_ussd() instead")
int | gsm_7bit_encode_oct (uint8_t *result, const char *data, int *octets_written) OSMO_DEPRECATED("Use gsm_7bit_encode_n() instead")
static const char * | osmo_rat_type_name (enum osmo_rat_type val)

## Variables
const struct value_string | gsm_chan_t_names []
const struct value_string | osmo_rat_type_names []

## Detailed Description

GSM utility functions, e.g.

coding and decoding.

## Macro Definition Documentation

## ◆ ADD_MODULO

#define ADD_MODULO | ( |  | sum,
|  |  | delta,
|  |  | modulo
| ) |  |

Value:
do { \
if ((sum += delta) >= modulo) \
sum -= modulo; \
} while (0)

## ◆ ARFCN_FLAG_MASK

#define ARFCN_FLAG_MASK 0xf000 /* Reserve the upper 5 bits for flags */

## ◆ ARFCN_PCS

#define ARFCN_PCS 0x8000

## ◆ ARFCN_UPLINK

#define ARFCN_UPLINK 0x4000

## ◆ GSM_7BIT_LEGACY_MAX_BUFFER_SIZE

#define GSM_7BIT_LEGACY_MAX_BUFFER_SIZE 0x10000

## ◆ GSM_FN_UNSET

#define GSM_FN_UNSET 0xFFFFFFFF

## ◆ GSM_MAX_FN

#define GSM_MAX_FN (26*51*2048)

## ◆ GSM_PCHAN_TCH_F_TCH_H_PDCH

#define GSM_PCHAN_TCH_F_TCH_H_PDCH GSM_PCHAN_OSMO_DYN

## ◆ GSM_RFN_MODULUS

#define GSM_RFN_MODULUS 42432

## ◆ OSMO_MAX_RAND_ID_LEN

#define OSMO_MAX_RAND_ID_LEN 16

## Enumeration Type Documentation

## ◆ gprs_tlli_type

enum gprs_tlli_type

Enumerator
TLLI_LOCAL |
TLLI_FOREIGN |
TLLI_RANDOM |
TLLI_AUXILIARY |
TLLI_RESERVED |
TLLI_G_RNTI |
TLLI_RAND_G_RNTI |

## ◆ gsm_band

enum gsm_band

Enumerator
GSM_BAND_850 |
GSM_BAND_900 |
GSM_BAND_1800 |
GSM_BAND_1900 |
GSM_BAND_450 |
GSM_BAND_480 |
GSM_BAND_750 |
GSM_BAND_810 |

## ◆ gsm_chan_t

enum gsm_chan_t

Enumerator
GSM_LCHAN_NONE |
GSM_LCHAN_SDCCH |
GSM_LCHAN_TCH_F |
GSM_LCHAN_TCH_H |
GSM_LCHAN_UNKNOWN |
GSM_LCHAN_CCCH |
GSM_LCHAN_PDTCH |
GSM_LCHAN_CBCH |
_GSM_LCHAN_MAX |

## ◆ gsm_phys_chan_config

enum gsm_phys_chan_config

Enumerator
GSM_PCHAN_NONE |
GSM_PCHAN_CCCH |
GSM_PCHAN_CCCH_SDCCH4 |
GSM_PCHAN_TCH_F |
GSM_PCHAN_TCH_H |
GSM_PCHAN_SDCCH8_SACCH8C |
GSM_PCHAN_PDCH |
GSM_PCHAN_TCH_F_PDCH |
GSM_PCHAN_UNKNOWN |
GSM_PCHAN_CCCH_SDCCH4_CBCH |
GSM_PCHAN_SDCCH8_SACCH8C_CBCH |
GSM_PCHAN_OSMO_DYN |
_GSM_PCHAN_MAX |

## ◆ osmo_rat_type

enum osmo_rat_type

Enumerator
OSMO_RAT_UNKNOWN |
OSMO_RAT_GERAN_A |
OSMO_RAT_UTRAN_IU |
OSMO_RAT_EUTRAN_SGS |
OSMO_RAT_COUNT |

## Function Documentation

## ◆ dbm2rxlev()

uint8_t dbm2rxlev | ( | int | dbm | ) |

Convert RF signal level in dBm to TS 05.08 RxLev (TS 05.08 Chapter 8.1.4)

Parameters

  [in] | dbm | RF signal level in dBm

Returns
  TS 05.08 RxLev value

## ◆ gprs_tlli2tmsi()

uint32_t gprs_tlli2tmsi | ( | uint32_t | tlli | ) |

Determine P-TMSI from foreign and local TLLIs.

Parameters

  [in] | tlli | P-TMSI
  [in] | type | TLLI Type we want to derive from p_tmsi

Returns
  P-TMSI or 0xffffffff on error.

References gprs_tlli_type(), tlli, TLLI_FOREIGN, and TLLI_LOCAL.

## ◆ gprs_tlli_type()

int gprs_tlli_type | ( | uint32_t | tlli | ) |

Determine GPRS TLLI Type (TS 23.003 Chapter 2.6)

References tlli, TLLI_AUXILIARY, TLLI_FOREIGN, TLLI_G_RNTI, TLLI_LOCAL, TLLI_RAND_G_RNTI, TLLI_RANDOM, and TLLI_RESERVED.

Referenced by gprs_tlli2tmsi().

## ◆ gprs_tmsi2tlli()

uint32_t gprs_tmsi2tlli | ( | uint32_t | p_tmsi,
|  | enum gprs_tlli_type | type
| ) |  |

Determine TLLI from P-TMSI.

Parameters

  [in] | p_tmsi | P-TMSI
  [in] | type | TLLI Type we want to derive from p_tmsi

Returns
  TLLI of given type

References tlli, TLLI_FOREIGN, TLLI_LOCAL, and type.

## ◆ gsm_7bit_decode()

int gsm_7bit_decode | ( | char * | decoded,
|  | const uint8_t * | user_data,
|  | uint8_t | length
| ) |  |

References gsm_7bit_decode_n(), and GSM_7BIT_LEGACY_MAX_BUFFER_SIZE.

## ◆ gsm_7bit_decode_n()

int gsm_7bit_decode_n | ( | char * | text,
|  | size_t | n,
|  | const uint8_t * | user_data,
|  | uint8_t | septet_l
| ) |  |

Decode a sequence of GSM 03.38 encoded 7 bit characters.

Parameters

  decoded | The destination buffer for the decoded characters.
  n | A maximum of n chars is written (incl. terminating \0). Requires n >= 1.
  user_data | A pointer to the start of the packed 7bit character sequence.
  length | The length of the input sequence in septets, for example pass octet_length*8/7.

Returns
  the number of (8 bit) chars written excluding the terminating \0. This is the same like strlen(decoded).

Decode a sequence of GSM 03.38 encoded 7 bit characters.

References gsm_7bit_decode_n_hdr(), and n.

Referenced by gsm_7bit_decode().

## ◆ gsm_7bit_decode_n_hdr()

int gsm_7bit_decode_n_hdr | ( | char * | text,
|  | size_t | n,
|  | const uint8_t * | user_data,
|  | uint8_t | septet_l,
|  | uint8_t | ud_hdr_ind
| ) |  |

TS 03.38 7-bit Character unpacking (6.2.1)

Parameters

  [out] | text | Caller-provided output text buffer
  [in] | n | Length of text
  [in] | user_data | Input Data (septets)
  [in] | septet_l | Number of septets in user_data
  [in] | ud_hdr_ind | User Data Header present in data

Returns
  number of bytes written to text

References gsm_7bit_alphabet, gsm_get_octet_len(), gsm_septet_lookup(), l, n, and OSMO_ASSERT.

Referenced by gsm_7bit_decode_n(), and gsm_7bit_decode_n_ussd().

## ◆ gsm_7bit_decode_n_ussd()

int gsm_7bit_decode_n_ussd | ( | char * | text,
|  | size_t | n,
|  | const uint8_t * | user_data,
|  | uint8_t | length
| ) |  |

Decode a sequence of 7 bit characters (USSD encoding).

See also
  gsm_7bit_encode_n()

Decode a sequence of 7 bit characters (USSD encoding).

References gsm_7bit_decode_n_hdr(), gsm_get_octet_len(), length, and n.

Referenced by gsm_7bit_decode_ussd(), and parse_process_uss_req().

## ◆ gsm_7bit_decode_ussd()

int gsm_7bit_decode_ussd | ( | char * | decoded,
|  | const uint8_t * | user_data,
|  | uint8_t | length
| ) |  |

References gsm_7bit_decode_n_ussd(), GSM_7BIT_LEGACY_MAX_BUFFER_SIZE, and length.

## ◆ gsm_7bit_encode()

int gsm_7bit_encode | ( | uint8_t * | result,
|  | const char * | data
| ) |  |

References data, gsm_7bit_encode_n(), and GSM_7BIT_LEGACY_MAX_BUFFER_SIZE.

## ◆ gsm_7bit_encode_n()

int gsm_7bit_encode_n | ( | uint8_t * | result,
|  | size_t | n,
|  | const char * | data,
|  | int * | octets
| ) |  |

Encode a text string into GSM 03.38 encoded 7 bit characters.

Parameters

  result | The destination buffer for the packed 7 bit sequence.
  n | A maximum of n octets is written.
  data | A pointer to the start of the \0 terminated 8 bit character string.
  octets_written | Iff not NULL, *octets_written will be set to the number of octets written to the result buffer.

Returns
  the number of septets that have been created.

Encode a text string into GSM 03.38 encoded 7 bit characters.

Parameters

  [out] | result | Caller-provided output buffer
  [in] | n | Maximum length of result in bytes
  [in] | data | octet-aligned string
  [out] | octets | Number of octets encoded

Returns
  number of septets encoded

References data, gsm_septet_encode(), gsm_septet_pack(), and n.

Referenced by gsm340_gen_oa(), gsm_7bit_encode(), gsm_7bit_encode_n_ussd(), and gsm_7bit_encode_oct().

## ◆ gsm_7bit_encode_n_ussd()

int gsm_7bit_encode_n_ussd | ( | uint8_t * | result,
|  | size_t | n,
|  | const char * | data,
|  | int * | octets
| ) |  |

Encode a text string into GSM 03.38 encoded 7 bit characters (USSD encoding).

See also
  gsm_7bit_decode_n()

Encode a text string into GSM 03.38 encoded 7 bit characters (USSD encoding).

Parameters

  [out] | result | Caller-provided output buffer
  [in] | n | Maximum length of result in bytes
  [in] | data | octet-aligned string
  [out] | octets | Number of octets encoded

Returns
  number of septets encoded

References data, gsm_7bit_encode_n(), and n.

Referenced by gsm0480_create_notifySS(), gsm0480_create_unstructuredSS_Notify(), gsm0480_gen_ussd_resp_7bit(), and gsm_7bit_encode_ussd().

## ◆ gsm_7bit_encode_oct()

int gsm_7bit_encode_oct | ( | uint8_t * | result,
|  | const char * | data,
|  | int * | octets_written
| ) |  |

References data, gsm_7bit_encode_n(), and GSM_7BIT_LEGACY_MAX_BUFFER_SIZE.

## ◆ gsm_7bit_encode_ussd()

int gsm_7bit_encode_ussd | ( | uint8_t * | result,
|  | const char * | data,
|  | int * | octets_written
| ) |  |

References data, gsm_7bit_encode_n_ussd(), and GSM_7BIT_LEGACY_MAX_BUFFER_SIZE.

## ◆ gsm_arfcn2band()

enum gsm_band gsm_arfcn2band | ( | uint16_t | arfcn | ) |

Resolve GSM band from ARFCN, aborts process on invalid ARFCN.

In Osmocom, we use the highest bit of the arfcn to indicate PCS. DEPRECATED: Use gsm_arfcn2band_rc instead.

Parameters

  [in] | arfcn | Osmocom ARFCN, highest bit determines PCS mode

Returns
  GSM Band if ARFCN is valid (part of any valid band), aborts otherwise

References arfcn, gsm_arfcn2band_rc(), and osmo_panic().

## ◆ gsm_arfcn2band_rc()

int gsm_arfcn2band_rc | ( | uint16_t | arfcn,
|  | enum gsm_band * | band
| ) |  |

Resolve GSM band from ARFCN.

In Osmocom, we use the highest bit of the arfcn to indicate PCS

Parameters

  [in] | arfcn | Osmocom ARFCN, highest bit determines PCS mode
  [out] | band | GSM Band containing \arfcn if arfcn is valid, undetermined otherwise

Returns
  0 if arfcn is valid and band was set, negative on error

References arfcn, ARFCN_PCS, GSM_BAND_1800, GSM_BAND_1900, GSM_BAND_450, GSM_BAND_480, GSM_BAND_750, GSM_BAND_810, GSM_BAND_850, and GSM_BAND_900.

Referenced by gsm_arfcn2band().

## ◆ gsm_arfcn2freq10()

uint16_t gsm_arfcn2freq10 | ( | uint16_t | arfcn,
|  | int | uplink
| ) |  |

Convert an ARFCN to the frequency in MHz * 10.

Parameters

  [in] | arfcn | GSM ARFCN to convert
  [in] | uplink | Uplink (1) or Downlink (0) frequency

Returns
  Frequency in units of 1/10ths of MHz (100kHz)

References arfcn, gsm_freq_range::arfcn_first, ARFCN_FLAG_MASK, gsm_freq_range::arfcn_last, gsm_freq_range::flags, gsm_freq_range::freq_dl_offset, gsm_freq_range::freq_ul_first, and gsm_ranges.

## ◆ gsm_band_name()

const char * gsm_band_name | ( | enum gsm_band | band | ) |

Return string name of a given GSM Band.

References GSM_BAND_1800, GSM_BAND_1900, GSM_BAND_450, GSM_BAND_480, GSM_BAND_750, GSM_BAND_810, GSM_BAND_850, and GSM_BAND_900.

## ◆ gsm_band_parse()

enum gsm_band gsm_band_parse | ( | const char * | mhz | ) |

Parse string name of a GSM band.

References GSM_BAND_1800, GSM_BAND_1900, GSM_BAND_450, GSM_BAND_480, GSM_BAND_750, GSM_BAND_810, GSM_BAND_850, and GSM_BAND_900.

## ◆ gsm_chan_t_name()

static const char * gsm_chan_t_name | ( | enum gsm_chan_t | val | ) |
| inline static

References get_value_string(), and gsm_chan_t_names.

## ◆ gsm_fn2gsmtime()

void gsm_fn2gsmtime | ( | struct gsm_time * | time,
|  | uint32_t | fn
| ) |  |

Parse GSM Frame Number into struct gsm_time.

Parameters

  [out] | time | Caller-provided memory for gsm_time
  [in] | fn | GSM Frame Number

References time.

Referenced by gsm_fn_as_gsmtime_str(), l2_ph_chan_conf(), and l2_ph_rach_ind().

## ◆ gsm_fn2rfn()

static uint16_t gsm_fn2rfn | ( | uint32_t | fn | ) |
| inline static

References GSM_RFN_MODULUS.

Referenced by gsm_rfn2fn().

## ◆ gsm_fn_as_gsmtime_str()

char * gsm_fn_as_gsmtime_str | ( | uint32_t | fn | ) |

Parse GSM Frame Number into printable string.

Parameters

  [in] | fn | GSM Frame Number

Returns
  pointer to printable string

References gsm_time::fn, gsm_fn2gsmtime(), osmo_dump_gsmtime(), and time.

## ◆ gsm_freq102arfcn()

uint16_t gsm_freq102arfcn | ( | uint16_t | freq10,
|  | int | uplink
| ) |  |

Convert a Frequency in MHz * 10 to ARFCN.

Parameters

  [in] | freq10 | Frequency in units of 1/10ths of MHz (100kHz)
  [in] | uplink | Frequency is Uplink (1) or Downlink (0)

Returns
  ARFCN in case of success; 0xffff on error

References arfcn, gsm_freq_range::arfcn_first, gsm_freq_range::arfcn_last, ARFCN_UPLINK, gsm_freq_range::flags, gsm_freq_range::freq_dl_offset, gsm_freq_range::freq_ul_first, and gsm_ranges.

## ◆ gsm_get_octet_len()

uint8_t gsm_get_octet_len | ( | const uint8_t | sept_len | ) |

Compute number of octets from number of septets.

For instance: 47 septets need 41,125 = 42 octets.

Parameters

  [in] | sept_len | Number of septets

Returns
  Number of octets required

Referenced by gsm_7bit_decode_n_hdr(), and gsm_7bit_decode_n_ussd().

## ◆ gsm_gsmtime2fn()

uint32_t gsm_gsmtime2fn | ( | const struct gsm_time * | time | ) |

Encode decoded gsm_time to Frame Number.

Parameters

  [in] | time | GSM Time in decoded structure

Returns
  GSM Frame Number

References gsm_time::fn, GSM_MAX_FN, OSMO_MOD_FLR, and time.

## ◆ gsm_rfn2fn()

uint32_t gsm_rfn2fn | ( | uint16_t | rfn,
|  | uint32_t | curr_fn
| ) |  |

References gsm_fn2rfn(), GSM_MAX_FN, GSM_RFN_MODULUS, GSM_RFN_THRESHOLD, GSM_TDMA_FN_DIFF, GSM_TDMA_FN_SUB, GSM_TDMA_FN_SUM, and OSMO_ASSERT.

## ◆ gsm_septet_encode()

int gsm_septet_encode | ( | uint8_t * | result,
|  | const char * | data
| ) |  |

Encode a ASCII characterrs as 7-bit GSM alphabet (TS 03.38)

This function converts a zero-terminated input string data from ASCII into octet-aligned 7-bit GSM characters. No packing is performed.

Parameters

  [out] | result | caller-allocated output buffer
  [in] | data | input data, ASCII

Returns
  number of octets used in result

References data, and gsm_7bit_alphabet.

Referenced by gsm_7bit_encode_n().

## ◆ gsm_septet_pack() [1/2]

int use gsm_septet_pack | ( |  | ) |

## ◆ gsm_septet_pack() [2/2]

int gsm_septet_pack | ( | uint8_t * | result,
|  | const uint8_t * | rdata,
|  | size_t | septet_len,
|  | uint8_t | padding
| ) |  |

GSM Default Alphabet 7bit to octet packing.

Parameters

  [out] | result | Caller-provided output buffer
  [in] | rdata | Input data septets
  [in] | septet_len | Length of rdata
  [in] | padding | padding bits at start

Returns
  number of bytes used in result

References data.

Referenced by gsm_7bit_encode_n(), and gsm_septets2octets().

## ◆ gsm_septets2octets()

int gsm_septets2octets | ( | uint8_t * | result,
|  | const uint8_t * | rdata,
|  | uint8_t | septet_len,
|  | uint8_t | padding
| ) |  |

References OSMO_DEPRECATED.

## ◆ ms_class_gmsk_dbm()

int ms_class_gmsk_dbm | ( | enum gsm_band | band,
|  | int | class
| ) |  |

Convert power class to dBm according to GSM TS 05.05.

Parameters

  [in] | band | GSM frequency band
  [in] | class | GSM power class

Returns
  maximum transmit power of power class in dBm, negative on error

References GSM_BAND_1800, GSM_BAND_1900, GSM_BAND_450, GSM_BAND_480, GSM_BAND_750, GSM_BAND_810, GSM_BAND_850, and GSM_BAND_900.

## ◆ ms_cm2_a5n_support()

static int ms_cm2_a5n_support | ( | uint8_t * | cm2,
|  | unsigned | n
| ) |  |
| inline static

References cm2, and n.

## ◆ ms_cm3_a5n_support()

static int ms_cm3_a5n_support | ( | uint8_t * | cm3,
|  | unsigned | n
| ) |  |
| inline static

References n.

## ◆ ms_pwr_ctl_lvl()

int ms_pwr_ctl_lvl | ( | enum gsm_band | band,
|  | unsigned int | dbm
| ) |  |

determine power control level for given dBm value, as indicated by the tables in chapter 4.1.1 of GSM TS 05.05

Parameters

  [in] | GSM | frequency band
  [in] | dbm | RF power value in dBm

Returns
  TS 05.05 power control level

References GSM_BAND_1800, GSM_BAND_1900, GSM_BAND_450, GSM_BAND_480, GSM_BAND_750, GSM_BAND_810, GSM_BAND_850, and GSM_BAND_900.

## ◆ ms_pwr_dbm()

int ms_pwr_dbm | ( | enum gsm_band | band,
|  | uint8_t | lvl
| ) |  |

Convert TS 05.05 power level to absolute dBm value.

Parameters

  [in] | band | GSM frequency band
  [in] | lvl | TS 05.05 power control level

Returns
  RF power level in dBm

References GSM_BAND_1800, GSM_BAND_1900, GSM_BAND_450, GSM_BAND_480, GSM_BAND_750, GSM_BAND_810, GSM_BAND_850, and GSM_BAND_900.

## ◆ osmo_dump_gsmtime()

char * osmo_dump_gsmtime | ( | const struct gsm_time * | tm | ) |

References osmo_dump_gsmtime_buf().

Referenced by gsm_fn_as_gsmtime_str().

## ◆ osmo_dump_gsmtime_buf()

char * osmo_dump_gsmtime_buf | ( | char * | buf,
|  | size_t | buf_len,
|  | const struct gsm_time * | tm
| ) |  |

References gsm_time::fn, gsm_time::t1, gsm_time::t2, and gsm_time::t3.

Referenced by osmo_dump_gsmtime(), and osmo_dump_gsmtime_c().

## ◆ osmo_dump_gsmtime_c()

char * osmo_dump_gsmtime_c | ( | const void * | ctx,
|  | const struct gsm_time * | tm
| ) |  |

References osmo_dump_gsmtime_buf().

## ◆ osmo_get_rand_id()

int osmo_get_rand_id | ( | uint8_t * | out,
|  | size_t | len
| ) |  |

Generate random identifier We use /dev/urandom (default when GRND_RANDOM flag is not set).

Both /dev/(u)random numbers are coming from the same CSPRNG anyway (at least on GNU/Linux >= 4.8). See also RFC4086.

Parameters

  [out] | out | Buffer to be filled with random data
  [in] | len | Number of random bytes required

Returns
  0 on success, or a negative error code on error.

References ENOTSUP, len, and OSMO_MAX_RAND_ID_LEN.

## ◆ osmo_rat_type_name()

static const char * osmo_rat_type_name | ( | enum osmo_rat_type | val | ) |
| inline static

References get_value_string(), and osmo_rat_type_names.

Referenced by osmo_gsup_encode().

## ◆ rach_max_trans_raw2val()

static int rach_max_trans_raw2val | ( | int | raw | ) |
| inline static

## ◆ rach_max_trans_val2raw()

static int rach_max_trans_val2raw | ( | int | val | ) |
| inline static

## ◆ rach_tx_integer_raw2val()

static uint8_t rach_tx_integer_raw2val | ( | uint8_t | raw | ) |
| inline static

## ◆ rxlev2dbm()

int rxlev2dbm | ( | uint8_t | rxlev | ) |

Convert TS 05.08 RxLev to dBm (TS 05.08 Chapter 8.1.4)

Parameters

  [in] | rxlev | TS 05.08 RxLev value

Returns
  Received RF power in dBm

## Variable Documentation

## ◆ osmo_rat_type_names

const struct value_string osmo_rat_type_names[]
| extern

Referenced by osmo_rat_type_name().