Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 1 | /*! \file gsm48.h */ |
| 2 | |
Sylvain Munaut | 12ba778 | 2014-06-16 10:13:40 +0200 | [diff] [blame] | 3 | #pragma once |
Harald Welte | 4fb2075 | 2010-03-02 23:17:33 +0100 | [diff] [blame] | 4 | |
Pablo Neira Ayuso | 8341934 | 2011-03-22 16:36:13 +0100 | [diff] [blame] | 5 | #include <osmocom/gsm/tlv.h> |
| 6 | #include <osmocom/gsm/protocol/gsm_04_08.h> |
| 7 | #include <osmocom/gsm/gsm48_ie.h> |
Harald Welte | 4fb2075 | 2010-03-02 23:17:33 +0100 | [diff] [blame] | 8 | |
Harald Welte | 276ca4b | 2014-08-24 17:35:19 +0200 | [diff] [blame] | 9 | /* reserved according to GSM 03.03 ยง 2.4 */ |
| 10 | #define GSM_RESERVED_TMSI 0xFFFFFFFF |
| 11 | |
Harald Welte | a1c4f76 | 2010-05-01 11:59:42 +0200 | [diff] [blame] | 12 | /* A parsed GPRS routing area */ |
| 13 | struct gprs_ra_id { |
| 14 | uint16_t mnc; |
| 15 | uint16_t mcc; |
| 16 | uint16_t lac; |
| 17 | uint8_t rac; |
| 18 | }; |
| 19 | |
Harald Welte | 4fb2075 | 2010-03-02 23:17:33 +0100 | [diff] [blame] | 20 | extern const struct tlv_definition gsm48_att_tlvdef; |
Andreas Eversberg | 014cb87 | 2010-07-12 09:11:00 +0200 | [diff] [blame] | 21 | extern const struct tlv_definition gsm48_rr_att_tlvdef; |
| 22 | extern const struct tlv_definition gsm48_mm_att_tlvdef; |
Harald Welte | 9eb6d88 | 2010-03-25 12:00:54 +0800 | [diff] [blame] | 23 | const char *gsm48_cc_state_name(uint8_t state); |
| 24 | const char *gsm48_cc_msg_name(uint8_t msgtype); |
Philipp | 72e43f0 | 2016-10-27 13:35:20 +0200 | [diff] [blame] | 25 | const char *gsm48_rr_msg_name(uint8_t msgtype); |
Harald Welte | 4fb2075 | 2010-03-02 23:17:33 +0100 | [diff] [blame] | 26 | const char *rr_cause_name(uint8_t cause); |
| 27 | |
Harald Welte | 774a9de | 2012-07-13 21:35:13 +0200 | [diff] [blame] | 28 | int gsm48_decode_lai(struct gsm48_loc_area_id *lai, uint16_t *mcc, |
| 29 | uint16_t *mnc, uint16_t *lac); |
Harald Welte | 61e2bfc | 2010-03-04 10:53:03 +0100 | [diff] [blame] | 30 | void gsm48_generate_lai(struct gsm48_loc_area_id *lai48, uint16_t mcc, |
| 31 | uint16_t mnc, uint16_t lac); |
| 32 | int gsm48_generate_mid_from_tmsi(uint8_t *buf, uint32_t tmsi); |
| 33 | int gsm48_generate_mid_from_imsi(uint8_t *buf, const char *imsi); |
| 34 | |
Harald Welte | 9bb553e | 2010-03-28 18:14:50 +0800 | [diff] [blame] | 35 | /* Convert Mobile Identity (10.5.1.4) to string */ |
| 36 | int gsm48_mi_to_string(char *string, const int str_len, |
Harald Welte | 163d0ea | 2010-04-09 07:57:40 +0200 | [diff] [blame] | 37 | const uint8_t *mi, const int mi_len); |
Harald Welte | 1a8c4e0 | 2015-08-16 17:56:25 +0200 | [diff] [blame] | 38 | const char *gsm48_mi_type_name(uint8_t mi); |
Harald Welte | 9bb553e | 2010-03-28 18:14:50 +0800 | [diff] [blame] | 39 | |
Harald Welte | a1c4f76 | 2010-05-01 11:59:42 +0200 | [diff] [blame] | 40 | /* Parse Routeing Area Identifier */ |
| 41 | void gsm48_parse_ra(struct gprs_ra_id *raid, const uint8_t *buf); |
Max | f1ad60e | 2018-01-05 14:19:33 +0100 | [diff] [blame] | 42 | void gsm48_encode_ra(struct gsm48_ra_id *out, const struct gprs_ra_id *raid); |
Harald Welte | 35a9394 | 2010-05-01 14:25:22 +0200 | [diff] [blame] | 43 | int gsm48_construct_ra(uint8_t *buf, const struct gprs_ra_id *raid); |
Harald Welte | a1c4f76 | 2010-05-01 11:59:42 +0200 | [diff] [blame] | 44 | |
Harald Welte | 2aee7b1 | 2011-06-26 14:20:04 +0200 | [diff] [blame] | 45 | int gsm48_number_of_paging_subchannels(struct gsm48_control_channel_descr *chan_desc); |
Neels Hofmeyr | bdccc1b | 2016-03-15 13:28:10 +0100 | [diff] [blame] | 46 | |
| 47 | void gsm48_mcc_mnc_to_bcd(uint8_t *bcd_dst, uint16_t mcc, uint16_t mnc); |
| 48 | void gsm48_mcc_mnc_from_bcd(uint8_t *bcd_src, uint16_t *mcc, uint16_t *mnc); |