gsm48.h
Go to the documentation of this file.
#pragma once
#include <stdbool.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/gsm/protocol/gsm_04_08.h>
#include <osmocom/gsm/gsm48_ie.h>
#include <osmocom/gsm/gsm23003.h>
/* reserved according to GSM 03.03 § 2.4 */
#define GSM_RESERVED_TMSI 0xFFFFFFFF
/* Valid MCC and MNC range from 0 to 999.
* To mark an invalid / unset MNC, this value shall be used. */
#define GSM_MCC_MNC_INVALID 0xFFFF
/* A parsed GPRS routing area */
struct gprs_ra_id {
uint16_t mcc;
uint16_t mnc;
bool mnc_3_digits;
uint16_t lac;
uint8_t rac;
};
extern const struct tlv_definition gsm48_att_tlvdef;
extern const struct tlv_definition gsm48_rr_att_tlvdef;
extern const struct tlv_definition gsm48_mm_att_tlvdef;
const char *gsm48_cc_state_name(uint8_t state);
const char *gsm48_cc_msg_name(uint8_t msgtype);
const char *gsm48_rr_msg_name(uint8_t msgtype);
const char *rr_cause_name(uint8_t cause);
const char *osmo_rai_name(const struct gprs_ra_id *rai);
int gsm48_decode_lai(struct gsm48_loc_area_id *lai, uint16_t *mcc,
uint16_t *mnc, uint16_t *lac)
OSMO_DEPRECATED("Use gsm48_decode_lai2() instead, to not lose leading zeros in the MNC");
void gsm48_decode_lai2(const struct gsm48_loc_area_id *lai, struct osmo_location_area_id *decoded);
void gsm48_generate_lai(struct gsm48_loc_area_id *lai48, uint16_t mcc,
uint16_t mnc, uint16_t lac)
OSMO_DEPRECATED("Use gsm48_generate_lai2() instead, to not lose leading zeros in the MNC");
void gsm48_generate_lai2(struct gsm48_loc_area_id *lai48, const struct osmo_location_area_id *lai);
int gsm48_generate_mid_from_tmsi(uint8_t *buf, uint32_t tmsi);
int gsm48_generate_mid_from_imsi(uint8_t *buf, const char *imsi);
uint8_t gsm48_generate_mid(uint8_t *buf, const char *id, uint8_t mi_type);
/* Convert Mobile Identity (10.5.1.4) to string */
int gsm48_mi_to_string(char *string, const int str_len,
const uint8_t *mi, const int mi_len);
const char *gsm48_mi_type_name(uint8_t mi);
/* Parse Routeing Area Identifier */
void gsm48_parse_ra(struct gprs_ra_id *raid, const uint8_t *buf);
void gsm48_encode_ra(struct gsm48_ra_id *out, const struct gprs_ra_id *raid);
int gsm48_construct_ra(uint8_t *buf, const struct gprs_ra_id *raid) OSMO_DEPRECATED("Use gsm48_encode_ra() instead");
int gsm48_number_of_paging_subchannels(struct gsm48_control_channel_descr *chan_desc);
void gsm48_mcc_mnc_to_bcd(uint8_t *bcd_dst, uint16_t mcc, uint16_t mnc)
OSMO_DEPRECATED("Use osmo_plmn_to_bcd() instead, to not lose leading zeros in the MNC");
void gsm48_mcc_mnc_from_bcd(uint8_t *bcd_src, uint16_t *mcc, uint16_t *mnc)
OSMO_DEPRECATED("Use osmo_plmn_from_bcd() instead, to not lose leading zeros in the MNC");
gprs_ra_id::rac
uint8_t rac
Definition: gsm48.h:25
osmo_rai_name
const char * osmo_rai_name(const struct gprs_ra_id *rai)
Return MCC-MNC-LAC-RAC as string, in a static buffer.
Definition: gsm48.c:189
gsm48_generate_lai2
void gsm48_generate_lai2(struct gsm48_loc_area_id *lai48, const struct osmo_location_area_id *lai)
Encode TS 04.08 Location Area Identifier.
Definition: gsm48.c:507
gprs_ra_id::mnc
uint16_t mnc
Definition: gsm48.h:22
osmo_location_area_id
Definition: gsm23003.h:16
cause
uint8_t cause
Definition: gsm_04_08.h:710
gprs_ra_id::mnc_3_digits
bool mnc_3_digits
Definition: gsm48.h:23
gsm48_generate_mid
uint8_t gsm48_generate_mid(uint8_t *buf, const char *id, uint8_t mi_type)
Generate TS 24.008 §10.5.1.4 Mobile ID.
Definition: gsm48.c:608
osmo_plmn_to_bcd
void osmo_plmn_to_bcd(uint8_t *bcd_dst, const struct osmo_plmn_id *plmn)
Definition: gsm23003.c:184
gsm48_parse_ra
void gsm48_parse_ra(struct gprs_ra_id *raid, const uint8_t *buf)
Parse TS 04.08 Routing Area Identifier.
Definition: gsm48.c:691
gprs_ra_id
Definition: gsm48.h:20
gsm48_mi_to_string
int gsm48_mi_to_string(char *string, const int str_len, const uint8_t *mi, const int mi_len)
Convert TS 04.08 Mobile Identity (10.5.1.4) to string.
Definition: gsm48.c:646
gsm48_generate_mid_from_tmsi
int gsm48_generate_mid_from_tmsi(uint8_t *buf, uint32_t tmsi)
Generate TS 04.08 Mobile ID from TMSI.
Definition: gsm48.c:592
gsm48_generate_mid_from_imsi
int gsm48_generate_mid_from_imsi(uint8_t *buf, const char *imsi)
Generate TS 04.08 Mobile ID from IMSI.
Definition: gsm48.c:635
gsm48_mm_att_tlvdef
const struct tlv_definition gsm48_mm_att_tlvdef
TLV parser definitions for TS 04.08 MM.
Definition: gsm48.c:141
gsm48_encode_ra
void gsm48_encode_ra(struct gsm48_ra_id *out, const struct gprs_ra_id *raid)
Encode a 3GPP TS 24.008 § 10.5.5.15 Routing area identification.
Definition: gsm48.c:718
gsm48_construct_ra
int gsm48_construct_ra(uint8_t *buf, const struct gprs_ra_id *raid) OSMO_DEPRECATED("Use gsm48_encode_ra() instead")
Encode a TS 04.08 Routing Area Identifier.
Definition: gsm48.c:739
tlv_definition
Definition of All 256 IE / TLV.
Definition: tlv.h:419
gprs_ra_id::mcc
uint16_t mcc
Definition: gsm48.h:21
gsm48_mi_type_name
const char * gsm48_mi_type_name(uint8_t mi)
return string representation of Mobile Identity Type
Definition: gsm48.c:431
gsm48_decode_lai2
void gsm48_decode_lai2(const struct gsm48_loc_area_id *lai, struct osmo_location_area_id *decoded)
Decode TS 04.08 Location Area Identifier.
Definition: gsm48.c:538
gsm_04_08.h
gsm48_mcc_mnc_from_bcd
void gsm48_mcc_mnc_from_bcd(uint8_t *bcd_src, uint16_t *mcc, uint16_t *mnc) OSMO_DEPRECATED("Use osmo_plmn_from_bcd() instead
mi_len
uint8_t mi_len
Definition: gsm_04_08.h:716
gsm48_number_of_paging_subchannels
int gsm48_number_of_paging_subchannels(struct gsm48_control_channel_descr *chan_desc)
Determine number of paging sub-channels.
Definition: gsm48.c:753
gsm48_control_channel_descr
Definition: gsm_04_08.h:860
gsm48_rr_att_tlvdef
const struct tlv_definition gsm48_rr_att_tlvdef
TLV parser definitions for TS 04.08 RR.
Definition: gsm48.c:96
gsm23003.h
gsm48_generate_lai
void gsm48_generate_lai(struct gsm48_loc_area_id *lai48, uint16_t mcc, uint16_t mnc, uint16_t lac) OSMO_DEPRECATED("Use gsm48_generate_lai2() instead
gsm48_att_tlvdef
const struct tlv_definition gsm48_att_tlvdef
TLV parser definitions for TS 04.08 CC.
Definition: gsm48.c:54
lac
uint16_t lac
Definition: gsm_04_08.h:709
gsm48_ie.h
gsm48_cc_msg_name
const char * gsm48_cc_msg_name(uint8_t msgtype)
return string representation of CC Message Type
Definition: gsm48.c:283
lai
struct gsm48_loc_area_id lai
Definition: gsm_04_08.h:715
gsm48_mcc_mnc_to_bcd
void gsm48_mcc_mnc_to_bcd(uint8_t *bcd_dst, uint16_t mcc, uint16_t mnc) OSMO_DEPRECATED("Use osmo_plmn_to_bcd() instead
MNC
int to not lose leading zeros in the MNC
Definition: gsm48.h:39
osmo_plmn_from_bcd
void osmo_plmn_from_bcd(const uint8_t *bcd_src, struct osmo_plmn_id *plmn)
Definition: gsm23003.c:211
gprs_ra_id::lac
uint16_t lac
Definition: gsm48.h:24
gsm48_loc_area_id
Definition: gsm_04_08.h:785
tlv.h
rr_cause_name
const char * rr_cause_name(uint8_t cause)
return string representation of RR Cause value
Definition: gsm48.c:180
gsm48_decode_lai
int gsm48_decode_lai(struct gsm48_loc_area_id *lai, uint16_t *mcc, uint16_t *mnc, uint16_t *lac) OSMO_DEPRECATED("Use gsm48_decode_lai2() instead
chan_desc
struct gsm48_chan_desc chan_desc
Definition: gsm_04_08.h:632
mi
uint8_t mi[0]
Definition: gsm_04_08.h:717
gsm48_rr_msg_name
const char * gsm48_rr_msg_name(uint8_t msgtype)
return string representation of RR Message Type
Definition: gsm48.c:391
gsm48_cc_state_name
const char * gsm48_cc_state_name(uint8_t state)
return string representation of CC State
Definition: gsm48.c:235
gsm48_ra_id
Definition: gsm_04_08.h:1988