diff mbox

amr: Attempt to unbreak the AMR support in the BSC

Message ID 1443108097-66525-1-git-send-email-holger@freyther.de
State Accepted
Headers show

Commit Message

Holger Freyther Sept. 24, 2015, 3:21 p.m. UTC
From: Holger Hans Peter Freyther <holger@moiji-mobile.com>

The signature of mr_config and the BSC implementation didn't
match and the compiler was warning about it:

osmo_bsc_api.c:530:2: warning: initialization from incompatible pointer type
 .mr_config = bsc_mr_config,
 ^
osmo_bsc_api.c:530:2: warning: (near initialization for ‘bsc_handler.mr_config’)

Change the mr_config again and provide an implementation
that will set the ms and bts data structure. It would be
better to put the size outside of the IE but I am not going
to change it right now. It would also be nice to either move
the AMR setting into the "nitb" structure or have the msc
data be used _after_ the bts settings. This needs to be
cleaned up in the next step.

Manually verified by placing a MO call and checking that
both the channel mode modify and the mode modify request
contain the multi rate config with the rate mr config
(length two bytes, version 1, icmi==1, no start mode being
set).
---
 openbsc/include/openbsc/bsc_api.h   |  2 +-
 openbsc/src/libbsc/bsc_api.c        |  2 +-
 openbsc/src/osmo-bsc/osmo_bsc_api.c | 36 +++++++++++++++++++++++++-----------
 3 files changed, 27 insertions(+), 13 deletions(-)
diff mbox

Patch

diff --git a/openbsc/include/openbsc/bsc_api.h b/openbsc/include/openbsc/bsc_api.h
index a70d765..a3d12f2 100644
--- a/openbsc/include/openbsc/bsc_api.h
+++ b/openbsc/include/openbsc/bsc_api.h
@@ -40,7 +40,7 @@  struct bsc_api {
 	 * not implemented AMR5.9 will be used.
 	 */
 	void (*mr_config)(struct gsm_subscriber_connection *conn,
-			  uint8_t *mr_ms_lv, uint8_t *mr_bts_lv);
+				struct gsm_lchan *lchan, int full_rate);
 };
 
 int bsc_api_init(struct gsm_network *network, struct bsc_api *api);
diff --git a/openbsc/src/libbsc/bsc_api.c b/openbsc/src/libbsc/bsc_api.c
index e157eb9..504f044 100644
--- a/openbsc/src/libbsc/bsc_api.c
+++ b/openbsc/src/libbsc/bsc_api.c
@@ -163,7 +163,7 @@  static void handle_mr_config(struct gsm_subscriber_connection *conn,
 	struct gsm48_multi_rate_conf *mr_conf;
 
 	if (api->mr_config)
-		return api->mr_config(conn, lchan->mr_ms_lv, lchan->mr_bts_lv);
+		return api->mr_config(conn, lchan, full_rate);
 
 	if (full_rate)
 		mr = &lchan->ts->trx->bts->mr_full;
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_api.c b/openbsc/src/osmo-bsc/osmo_bsc_api.c
index 00a10b3..fbeed77 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_api.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_api.c
@@ -491,9 +491,10 @@  static void bsc_cm_update(struct gsm_subscriber_connection *conn,
 }
 
 static void bsc_mr_config(struct gsm_subscriber_connection *conn,
-			  struct gsm48_multi_rate_conf *conf)
+				struct gsm_lchan *lchan, int full_rate)
 {
 	struct osmo_msc_data *msc;
+	struct gsm48_multi_rate_conf *ms_conf, *bts_conf;
 
 	if (!conn->sccp_con) {
 		LOGP(DMSC, LOGL_ERROR,
@@ -504,18 +505,31 @@  static void bsc_mr_config(struct gsm_subscriber_connection *conn,
 
 	msc = conn->sccp_con->msc;
 
-	conf->ver = 1;
-	conf->icmi = 1;
+	/* initialize the data structure */
+	lchan->mr_ms_lv[0] = sizeof(*ms_conf);
+	lchan->mr_bts_lv[0] = sizeof(*bts_conf);
+	ms_conf = (struct gsm48_multi_rate_conf *) &lchan->mr_ms_lv[1];
+	bts_conf = (struct gsm48_multi_rate_conf *) &lchan->mr_bts_lv[1];
+	memset(ms_conf, 0, sizeof(*ms_conf));
+	memset(bts_conf, 0, sizeof(*bts_conf));
+
+	bts_conf->ver = ms_conf->ver = 1;
+	bts_conf->icmi = ms_conf->icmi = 1;
 
 	/* maybe gcc see's it is copy of _one_ byte */
-	conf->m4_75 = msc->amr_conf.m4_75;
-	conf->m5_15 = msc->amr_conf.m5_15;
-	conf->m5_90 = msc->amr_conf.m5_90;
-	conf->m6_70 = msc->amr_conf.m6_70;
-	conf->m7_40 = msc->amr_conf.m7_40;
-	conf->m7_95 = msc->amr_conf.m7_95;
-	conf->m10_2 = msc->amr_conf.m10_2;
-	conf->m12_2 = msc->amr_conf.m12_2;
+	bts_conf->m4_75 = ms_conf->m4_75 = msc->amr_conf.m4_75;
+	bts_conf->m5_15 = ms_conf->m5_15 = msc->amr_conf.m5_15;
+	bts_conf->m5_90 = ms_conf->m5_90 = msc->amr_conf.m5_90;
+	bts_conf->m6_70 = ms_conf->m6_70 = msc->amr_conf.m6_70;
+	bts_conf->m7_40 = ms_conf->m7_40 = msc->amr_conf.m7_40;
+	bts_conf->m7_95 = ms_conf->m7_95 = msc->amr_conf.m7_95;
+	if (full_rate) {
+		bts_conf->m10_2 = ms_conf->m10_2 = msc->amr_conf.m10_2;
+		bts_conf->m12_2 = ms_conf->m12_2 = msc->amr_conf.m12_2;
+	}
+
+	/* now copy this into the bts structure */
+	memcpy(lchan->mr_bts_lv, lchan->mr_ms_lv, sizeof(lchan->mr_ms_lv));
 }
 
 static struct bsc_api bsc_handler = {