From 720de68cb064ea8a9203561756c24b48d8b5a67e Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 23 Dec 2017 01:07:45 +0100 Subject: bssmap_handle_assignm_req(): Decode channel type as first step The decision on how to further process the request depends significantly on the contents of the only mandatory IE of the ASSIGNMENT REQ. Let's decode it first. Change-Id: I030b5ad6f4fc33da9155c8a6061fd982312b20fb --- src/osmo-bsc/osmo_bsc_bssap.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/osmo-bsc/osmo_bsc_bssap.c b/src/osmo-bsc/osmo_bsc_bssap.c index 586657f41..9bd3fe9a1 100644 --- a/src/osmo-bsc/osmo_bsc_bssap.c +++ b/src/osmo-bsc/osmo_bsc_bssap.c @@ -761,6 +761,22 @@ static int bssmap_handle_assignm_req(struct osmo_bsc_sccp_con *conn, goto reject; } + /* Decode Channel Type element */ + rc = gsm0808_dec_channel_type(&ct, TLVP_VAL(&tp, GSM0808_IE_CHANNEL_TYPE), + TLVP_LEN(&tp, GSM0808_IE_CHANNEL_TYPE)); + if (rc < 0) { + LOGP(DMSC, LOGL_ERROR, "unable to decode channel type.\n"); + goto reject; + } + + /* Currently we only support a limited subset of all + * possible channel types. The limitation ends by not using + * multi-slot, limiting the channel coding to speech */ + if (ct.ch_indctr != GSM0808_CHAN_SPEECH) { + LOGP(DMSC, LOGL_ERROR, "Unsupported channel type, currently only speech is supported!\n"); + goto reject; + } + /* Detect if a CIC code is present, if so, we use the classic ip.access * method to calculate the RTP port */ if (TLVP_PRESENT(&tp, GSM0808_IE_CIRCUIT_IDENTITY_CODE)) { @@ -803,23 +819,6 @@ static int bssmap_handle_assignm_req(struct osmo_bsc_sccp_con *conn, scl_ptr = &scl; } - /* Decode Channel Type element */ - rc = gsm0808_dec_channel_type(&ct, TLVP_VAL(&tp, GSM0808_IE_CHANNEL_TYPE), - TLVP_LEN(&tp, GSM0808_IE_CHANNEL_TYPE)); - if (rc < 0) { - LOGP(DMSC, LOGL_ERROR, "unable to decode channel type.\n"); - goto reject; - } - - /* Currently we only support a limited subset of all - * possible channel types. The limitation ends by not using - * multi-slot, limiting the channel coding to speech */ - if (ct.ch_indctr != GSM0808_CHAN_SPEECH) { - LOGP(DMSC, LOGL_ERROR, - "Unsupported channel type, currently only speech is supported!\n"); - goto reject; - } - /* Match codec information from the assignment command against the * local preferences of the BSC */ rc = match_codec_pref(&full_rate, &chan_mode, &ct, scl_ptr, msc); -- cgit v1.2.3