libosmogsm  0.9.6.20170825
Osmocom GSM library
gsm0808_utils.h File Reference

Go to the source code of this file.

Functions

uint8_t gsm0808_enc_aoip_trasp_addr (struct msgb *msg, const struct sockaddr_storage *ss)
 
int gsm0808_dec_aoip_trasp_addr (struct sockaddr_storage *ss, const uint8_t *elem, uint8_t len)
 
uint8_t gsm0808_enc_speech_codec (struct msgb *msg, const struct gsm0808_speech_codec *sc)
 Encode TS 08.08 Speech Codec IE. More...
 
int gsm0808_dec_speech_codec (struct gsm0808_speech_codec *sc, const uint8_t *elem, uint8_t len)
 Decode TS 08.08 Speech Codec IE. More...
 
uint8_t gsm0808_enc_speech_codec_list (struct msgb *msg, const struct gsm0808_speech_codec_list *scl)
 Encode TS 08.08 Speech Codec list. More...
 
int gsm0808_dec_speech_codec_list (struct gsm0808_speech_codec_list *scl, const uint8_t *elem, uint8_t len)
 Decode TS 08.08 Speech Codec list IE. More...
 
uint8_t gsm0808_enc_channel_type (struct msgb *msg, const struct gsm0808_channel_type *ct)
 Encode TS 08.08 Channel Type IE. More...
 
int gsm0808_dec_channel_type (struct gsm0808_channel_type *ct, const uint8_t *elem, uint8_t len)
 Decode TS 08.08 Channel Type IE. More...
 
uint8_t gsm0808_enc_encrypt_info (struct msgb *msg, const struct gsm0808_encrypt_info *ei)
 Encode TS 08.08 Encryption Information IE. More...
 
int gsm0808_dec_encrypt_info (struct gsm0808_encrypt_info *ei, const uint8_t *elem, uint8_t len)
 Decode TS 08.08 Encryption Information IE. More...
 
uint8_t gsm0808_enc_cell_id_list (struct msgb *msg, const struct gsm0808_cell_id_list *cil)
 Encode TS 08.08 Cell Identifier List IE. More...
 
int gsm0808_dec_cell_id_list (struct gsm0808_cell_id_list *cil, const uint8_t *elem, uint8_t len)
 Decode Cell Identifier List IE. More...
 
int gsm0808_chan_type_to_speech_codec (uint8_t perm_spch)
 Convert the representation of the permitted speech codec identifier that is used in struct gsm0808_channel_type to the speech codec representation we use in struct gsm0808_speech_codec. More...
 
int gsm0808_speech_codec_from_chan_type (struct gsm0808_speech_codec *sc, uint8_t perm_spch)
 Extrapolate a speech codec field from a given permitted speech parameter (channel type). More...
 

Function Documentation

int gsm0808_chan_type_to_speech_codec ( uint8_t  perm_spch)

Convert the representation of the permitted speech codec identifier that is used in struct gsm0808_channel_type to the speech codec representation we use in struct gsm0808_speech_codec.

Parameters
[in]perm_spchto be converted (see also gsm0808_permitted_speech)
Returns
GSM speech codec type; negative on error

The speech codec type, which is used in the channel type field to signal the permitted speech versions (codecs) has a different encoding than the type field in the speech codec type element (See also 3GPP TS 48.008, 3.2.2.11 and 3.2.2.103)

References GSM0808_PERM_FR1, GSM0808_PERM_FR2, GSM0808_PERM_FR3, GSM0808_PERM_FR4, GSM0808_PERM_FR5, GSM0808_PERM_HR1, GSM0808_PERM_HR3, GSM0808_PERM_HR4, GSM0808_PERM_HR6, GSM0808_SCT_FR1, GSM0808_SCT_FR2, GSM0808_SCT_FR3, GSM0808_SCT_FR4, GSM0808_SCT_FR5, GSM0808_SCT_HR1, GSM0808_SCT_HR3, GSM0808_SCT_HR4, and GSM0808_SCT_HR6.

Referenced by gsm0808_speech_codec_from_chan_type().

int gsm0808_dec_aoip_trasp_addr ( struct sockaddr_storage *  ss,
const uint8_t *  elem,
uint8_t  len 
)
int gsm0808_dec_cell_id_list ( struct gsm0808_cell_id_list cil,
const uint8_t *  elem,
uint8_t  len 
)

Decode Cell Identifier List IE.

Parameters
[out]cilCaller-provided memory to store Cell ID list
[in]elemIE value to be decoded
[in]lenLength of elem in bytes
Returns
number of bytes parsed; negative on error

References CELL_IDENT_BSS, CELL_IDENT_LAC, gsm0808_cell_id_list::id_discr, gsm0808_cell_id_list::id_list_lac, gsm0808_cell_id_list::id_list_len, and OSMO_ASSERT.

int gsm0808_dec_channel_type ( struct gsm0808_channel_type ct,
const uint8_t *  elem,
uint8_t  len 
)

Decode TS 08.08 Channel Type IE.

Parameters
[out]ctCaller-provided memory to store channel type
[in]elemIE Value to be decoded
[in]lenLength of elem in bytes
Returns
number of bytes parsed; negative on error

See also 3GPP TS 48.008 3.2.2.11 Channel Type

References ARRAY_SIZE, gsm0808_channel_type::ch_indctr, gsm0808_channel_type::ch_rate_type, OSMO_ASSERT, gsm0808_channel_type::perm_spch, and gsm0808_channel_type::perm_spch_len.

int gsm0808_dec_encrypt_info ( struct gsm0808_encrypt_info ei,
const uint8_t *  elem,
uint8_t  len 
)

Decode TS 08.08 Encryption Information IE.

Parameters
[out]eiCaller-provided memory to store encryption information
[in]elemIE value to be decoded
[in]lenLength of elem in bytes
Returns
number of bytes parsed; negative on error

References ENCRY_INFO_PERM_ALGO_MAXLEN, gsm0808_encrypt_info::key, gsm0808_encrypt_info::key_len, OSMO_ASSERT, gsm0808_encrypt_info::perm_algo, and gsm0808_encrypt_info::perm_algo_len.

int gsm0808_dec_speech_codec ( struct gsm0808_speech_codec sc,
const uint8_t *  elem,
uint8_t  len 
)

Decode TS 08.08 Speech Codec IE.

Parameters
[out]scCaller-allocated memory for Speech Codec
[in]elemIE value to be decoded
[in]lenLength of elem in bytes
Returns
number of bytes parsed; negative on error

References gsm0808_speech_codec::cfg, gsm0808_speech_codec::fi, GSM0808_SCT_CSD, GSM0808_SCT_FR1, GSM0808_SCT_FR2, GSM0808_SCT_FR3, GSM0808_SCT_FR4, GSM0808_SCT_FR5, GSM0808_SCT_HR1, GSM0808_SCT_HR3, GSM0808_SCT_HR4, GSM0808_SCT_HR6, header, OSMO_ASSERT, gsm0808_speech_codec::pi, gsm0808_speech_codec::pt, gsm0808_speech_codec::tf, and gsm0808_speech_codec::type.

Referenced by gsm0808_dec_speech_codec_list().

int gsm0808_dec_speech_codec_list ( struct gsm0808_speech_codec_list scl,
const uint8_t *  elem,
uint8_t  len 
)

Decode TS 08.08 Speech Codec list IE.

Parameters
[out]sclCaller-provided memory to store codec list
[in]elemIE value to be decoded
[in]lenLength of elem in bytes
Returns
number of bytes parsed; negative on error

See also 3GPP TS 48.008 3.2.2.103 Speech Codec List

References ARRAY_SIZE, gsm0808_speech_codec_list::codec, gsm0808_dec_speech_codec(), gsm0808_speech_codec_list::len, and OSMO_ASSERT.

uint8_t gsm0808_enc_aoip_trasp_addr ( struct msgb msg,
const struct sockaddr_storage *  ss 
)
uint8_t gsm0808_enc_cell_id_list ( struct msgb msg,
const struct gsm0808_cell_id_list cil 
)

Encode TS 08.08 Cell Identifier List IE.

Parameters
[out]msgMessage Buffer to which IE is to be appended
[in]cilCell ID List to be encoded
Returns
number of bytes appended to msg

References CELL_ID_LIST_LAC_MAXLEN, CELL_IDENT_BSS, CELL_IDENT_LAC, GSM0808_IE_CELL_IDENTIFIER_LIST, gsm0808_cell_id_list::id_discr, gsm0808_cell_id_list::id_list_lac, gsm0808_cell_id_list::id_list_len, msgb_put(), msgb_put_u16(), msgb_put_u8(), OSMO_ASSERT, and msgb::tail.

Referenced by gsm0808_create_paging().

uint8_t gsm0808_enc_channel_type ( struct msgb msg,
const struct gsm0808_channel_type ct 
)

Encode TS 08.08 Channel Type IE.

Parameters
[out]msgMessage Buffer to which IE is to be appended
[in]ctChannel Type to be encoded
Returns
number of bytes added to msg

See also 3GPP TS 48.008 3.2.2.11 Channel Type

References gsm0808_channel_type::ch_indctr, gsm0808_channel_type::ch_rate_type, CHANNEL_TYPE_ELEMENT_MAXLEN, GSM0808_CHAN_SIGN, GSM0808_CHAN_SPEECH, GSM0808_IE_CHANNEL_TYPE, msgb_put(), msgb_put_u8(), OSMO_ASSERT, gsm0808_channel_type::perm_spch, gsm0808_channel_type::perm_spch_len, and msgb::tail.

Referenced by gsm0808_create_ass().

uint8_t gsm0808_enc_encrypt_info ( struct msgb msg,
const struct gsm0808_encrypt_info ei 
)

Encode TS 08.08 Encryption Information IE.

Parameters
[out]msgMessage Buffer to which IE is to be appended
[in]eiEncryption Information to be encoded
Returns
number of bytes appended to msg

References ARRAY_SIZE, ENCRY_INFO_PERM_ALGO_MAXLEN, GSM0808_IE_ENCRYPTION_INFORMATION, gsm0808_encrypt_info::key, gsm0808_encrypt_info::key_len, msgb_put(), msgb_put_u8(), OSMO_ASSERT, gsm0808_encrypt_info::perm_algo, gsm0808_encrypt_info::perm_algo_len, and msgb::tail.

Referenced by gsm0808_create_cipher().

uint8_t gsm0808_enc_speech_codec ( struct msgb msg,
const struct gsm0808_speech_codec sc 
)

Encode TS 08.08 Speech Codec IE.

Parameters
[out]msgMessage Buffer to which IE will be appended
[in]scSpeech Codec to be encoded into IE
Returns
number of bytes appended to msg

See also 3GPP TS 48.008 3.2.2.103 Speech Codec List

References enc_speech_codec(), GSM0808_IE_SPEECH_CODEC, msgb_put(), msgb_put_u8(), OSMO_ASSERT, and msgb::tail.

Referenced by gsm0808_create_ass_compl().

uint8_t gsm0808_enc_speech_codec_list ( struct msgb msg,
const struct gsm0808_speech_codec_list scl 
)

Encode TS 08.08 Speech Codec list.

Parameters
[out]msgMessage Buffer to which IE is to be appended
[in]sclSpeech Codec List to be encoded into IE
Returns
number of bytes added to msg

See also 3GPP TS 48.008 3.2.2.103 Speech Codec List

References gsm0808_speech_codec_list::codec, enc_speech_codec(), GSM0808_IE_SPEECH_CODEC_LIST, gsm0808_speech_codec_list::len, msgb_put(), msgb_put_u8(), OSMO_ASSERT, and msgb::tail.

Referenced by gsm0808_create_ass(), gsm0808_create_ass_compl(), gsm0808_create_ass_fail(), and gsm0808_create_layer3_aoip().

int gsm0808_speech_codec_from_chan_type ( struct gsm0808_speech_codec sc,
uint8_t  perm_spch 
)

Extrapolate a speech codec field from a given permitted speech parameter (channel type).

Parameters
[out]scCaller provided memory to store the resulting speech codec
[in]perm_spchvalue that is used to derive the speech codec info (see also: enum gsm0808_speech_codec_type in gsm0808_utils.h)
Returns
zero when successful; negative on error

References gsm0808_speech_codec::cfg, gsm0808_speech_codec::fi, gsm0808_chan_type_to_speech_codec(), GSM0808_SC_CFG_DEFAULT_FR_AMR, GSM0808_SC_CFG_DEFAULT_FR_AMR_WB, GSM0808_SC_CFG_DEFAULT_HR_AMR, GSM0808_SC_CFG_DEFAULT_OFR_AMR_WB, GSM0808_SC_CFG_DEFAULT_OHR_AMR, GSM0808_SC_CFG_DEFAULT_OHR_AMR_WB, GSM0808_SCT_FR3, GSM0808_SCT_FR4, GSM0808_SCT_FR5, GSM0808_SCT_HR3, GSM0808_SCT_HR4, GSM0808_SCT_HR6, and gsm0808_speech_codec::type.