From e14a57cc0e63b747423c8aa390496552ecf735b9 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Mon, 29 Dec 2008 04:08:28 +0000 Subject: [PATCH] Create request channel reason to see channel requests originating from PAG --- include/openbsc/gsm_04_08.h | 1 + include/openbsc/gsm_data.h | 10 ++++++++++ src/gsm_04_08.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/include/openbsc/gsm_04_08.h b/include/openbsc/gsm_04_08.h index b9a2cc89e..081e869ef 100644 --- a/include/openbsc/gsm_04_08.h +++ b/include/openbsc/gsm_04_08.h @@ -344,6 +344,7 @@ int gsm0408_rcvmsg(struct msgb *msg); void gsm0408_generate_lai(struct gsm48_loc_area_id *lai48, u_int16_t mcc, u_int16_t mnc, u_int16_t lac); enum gsm_chan_t get_ctype_by_chreq(struct gsm_bts *bts, u_int8_t ra); +enum gsm_chreq_reason_t get_reason_by_chreq(struct gsm_bts *bts, u_int8_t ra); #endif diff --git a/include/openbsc/gsm_data.h b/include/openbsc/gsm_data.h index c0c431eda..9c0ac556a 100644 --- a/include/openbsc/gsm_data.h +++ b/include/openbsc/gsm_data.h @@ -60,6 +60,16 @@ enum gsm_chan_t { GSM_LCHAN_UNKNOWN, }; + +/* Channel Request reason */ +enum gsm_chreq_reason_t { + GSM_CHREQ_REASON_EMERG, + GSM_CHREQ_REASON_PAG, + GSM_CHREQ_REASON_CALL, + GSM_CHREQ_REASON_LOCATION_UPD, + GSM_CHREQ_REASON_OTHER, +}; + struct gsm_lchan { /* The TS that we're part of */ struct gsm_bts_trx_ts *ts; diff --git a/src/gsm_04_08.c b/src/gsm_04_08.c index a37d58332..a1a8f37e8 100644 --- a/src/gsm_04_08.c +++ b/src/gsm_04_08.c @@ -688,6 +688,21 @@ static const enum gsm_chan_t ctype_by_chreq[] = { [CHREQ_T_PAG_R_TCH_FH] = GSM_LCHAN_TCH_F, }; +static const enum gsm_chreq_reason_t reason_by_chreq[] = { + [CHREQ_T_EMERG_CALL] = GSM_CHREQ_REASON_EMERG, + [CHREQ_T_CALL_REEST_TCH_F] = GSM_CHREQ_REASON_CALL, + [CHREQ_T_CALL_REEST_TCH_H] = GSM_CHREQ_REASON_CALL, + [CHREQ_T_CALL_REEST_TCH_H_DBL] = GSM_CHREQ_REASON_CALL, + [CHREQ_T_SDCCH] = GSM_CHREQ_REASON_OTHER, + [CHREQ_T_TCH_F] = GSM_CHREQ_REASON_OTHER, + [CHREQ_T_VOICE_CALL_TCH_H] = GSM_CHREQ_REASON_OTHER, + [CHREQ_T_DATA_CALL_TCH_H] = GSM_CHREQ_REASON_OTHER, + [CHREQ_T_LOCATION_UPD] = GSM_CHREQ_REASON_LOCATION_UPD, + [CHREQ_T_PAG_R_ANY] = GSM_CHREQ_REASON_PAG, + [CHREQ_T_PAG_R_TCH_F] = GSM_CHREQ_REASON_PAG, + [CHREQ_T_PAG_R_TCH_FH] = GSM_CHREQ_REASON_PAG, +}; + enum gsm_chan_t get_ctype_by_chreq(struct gsm_bts *bts, u_int8_t ra) { int i; @@ -701,3 +716,17 @@ enum gsm_chan_t get_ctype_by_chreq(struct gsm_bts *bts, u_int8_t ra) fprintf(stderr, "Unknown CHANNEL REQUEST RQD 0x%02x\n", ra); return GSM_LCHAN_SDCCH; } + +enum gsm_chreq_reason_t get_reason_by_chreq(struct gsm_bts *bts, u_int8_t ra) +{ + int i; + /* FIXME: determine if we set NECI = 0 in the BTS SI4 */ + + for (i = 0; i < ARRAY_SIZE(chreq_type_neci0); i++) { + const struct chreq *chr = &chreq_type_neci0[i]; + if ((ra & chr->mask) == chr->val) + return reason_by_chreq[chr->type]; + } + fprintf(stderr, "Unknown CHANNEL REQUEST REASON 0x%02x\n", ra); + return GSM_CHREQ_REASON_OTHER; +}