From 49a84ec6e9a8202d7bc0d6a9a5f22580d809710f Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sat, 31 Oct 2009 07:19:47 +0100 Subject: [bssmap] Assignment handling fixes and improvements - Fix the generation of the assignment failure message - Parse the permitted indicator of the assignment request message --- openbsc/src/bssap.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/openbsc/src/bssap.c b/openbsc/src/bssap.c index 4e5e2d5c6..ea27c3da9 100644 --- a/openbsc/src/bssap.c +++ b/openbsc/src/bssap.c @@ -254,6 +254,7 @@ static int bssmap_handle_assignm_req(struct sccp_connection *conn, struct bss_sccp_connection_data *msc_data; u_int8_t *data; u_int8_t multiplex; + int i, found = 0; if (!msg->lchan || !msg->lchan->msc_data) { DEBUGP(DMSC, "No lchan/msc_data in cipher mode command.\n"); @@ -280,24 +281,41 @@ static int bssmap_handle_assignm_req(struct sccp_connection *conn, * possible channel types. The limitation ends by not using * multi-slot, limiting the channel coding, speech... */ - if (TLVP_LEN(&tp, GSM0808_IE_CHANNEL_TYPE) != 3) { + if (TLVP_LEN(&tp, GSM0808_IE_CHANNEL_TYPE) < 3) { DEBUGP(DMSC, "ChannelType len !=3 not supported: %d\n", TLVP_LEN(&tp, GSM0808_IE_CHANNEL_TYPE)); goto reject; } + /* + * Try to figure out if we support the proposed speech codecs. For + * now we will always pick the full rate codecs. + */ + data = (u_int8_t *) TLVP_VAL(&tp, GSM0808_IE_CHANNEL_TYPE); if ((data[0] & 0xf) != 0x1) { DEBUGP(DMSC, "ChannelType != speech: %d\n", data[0]); goto reject; } - if (data[1] != GSM0808_SPEECH_FULL_PREF) { - DEBUGP(DMSC, "ChannelType full not preferred: %d\n", data[1]); + if (data[1] != GSM0808_SPEECH_FULL_PREF && data[1] != GSM0808_SPEECH_HALF_PREF) { + DEBUGP(DMSC, "ChannelType full not allowed: %d\n", data[1]); goto reject; } - if (data[2] != GSM0808_PERM_FR2) { + /* go through the list of permitted codecs */ + for (i = 2; i < TLVP_LEN(&tp, GSM0808_IE_CHANNEL_TYPE); ++i) { + if ((data[i] & 0x7f) == GSM0808_PERM_FR2) { + found = 1; + break; + } + + /* last octet, stop */ + if ((data[i] & 0x80) == 0x00) + break; + } + + if (!found) { DEBUGP(DMSC, "ChannelType FR2 not supported\n"); goto reject; } @@ -308,6 +326,7 @@ static int bssmap_handle_assignm_req(struct sccp_connection *conn, bsc_schedule_timer(&msc_data->T10, GSM0808_T10_VALUE); msc_data->rtp_port = rtp_calculate_port(multiplex, rtp_base_port); + DEBUGP(DMSC, "Sending ChanModify for speech on: sccp: %p\n", conn); return gsm48_lchan_modify(msg->lchan, GSM48_CMODE_SPEECH_EFR); reject: -- cgit v1.2.3