[PATCH] osmo-bts[master]: sysmobts: Add bts-specific payload functions

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Tue Jun 7 12:40:32 UTC 2016


Review at  https://gerrit.osmocom.org/214

sysmobts: Add bts-specific payload functions

Add functions for getting payload buffer address, setting payload type
and size. Convert gen_empty_tch_msg() to use them. This is in
preparation for splitting out TCH hadling logic into common/ to make
DTXd implementation easier.

Change-Id: If213ec89762e50b4a5e79becebb589d6260e6b62
---
M src/osmo-bts-sysmo/tch.c
1 file changed, 49 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/14/214/1

diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c
index e08d8a6..3b9fe36 100644
--- a/src/osmo-bts-sysmo/tch.c
+++ b/src/osmo-bts-sysmo/tch.c
@@ -89,6 +89,51 @@
 		out[i] = (in[i] & 0xF) << 4;
 }
 
+void set_payload_size(struct msgb *msg, uint8_t size)
+{
+	GsmL1_Prim_t *l1p;
+	GsmL1_PhDataReq_t *data_req;
+	GsmL1_MsgUnitParam_t *msu_param;
+
+	l1p = msgb_l1prim(msg);
+	data_req = &l1p->u.phDataReq;
+	msu_param = &data_req->msgUnitParam;
+	msu_param->u8Size = size;
+}
+
+void set_payload_type(struct msgb *msg, struct gsm_lchan *lchan)
+{
+	GsmL1_Prim_t *l1p;
+	GsmL1_PhDataReq_t *data_req;
+	GsmL1_MsgUnitParam_t *msu_param;
+	uint8_t *payload_type;
+
+	l1p = msgb_l1prim(msg);
+	data_req = &l1p->u.phDataReq;
+	msu_param = &data_req->msgUnitParam;
+	payload_type = &msu_param->u8Buffer[0];
+
+	switch (lchan->tch_mode) {
+	case GSM48_CMODE_SPEECH_AMR:
+		*payload_type = GsmL1_TchPlType_Amr;
+		break;
+	default:
+		return;
+	}
+}
+
+uint8_t *get_payload_addr(struct msgb *msg)
+{
+	GsmL1_Prim_t *l1p;
+	GsmL1_PhDataReq_t *data_req;
+	GsmL1_MsgUnitParam_t *msu_param;
+
+	l1p = msgb_l1prim(msg);
+	data_req = &l1p->u.phDataReq;
+	msu_param = &data_req->msgUnitParam;
+
+	return &msu_param->u8Buffer[1];
+}
 
 static struct msgb *l1_to_rtppayload_fr(uint8_t *l1_payload, uint8_t payload_len)
 {
@@ -584,29 +629,21 @@
 struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan)
 {
 	struct msgb *msg;
-	GsmL1_Prim_t *l1p;
-	GsmL1_PhDataReq_t *data_req;
-	GsmL1_MsgUnitParam_t *msu_param;
-	uint8_t *payload_type;
 	uint8_t *l1_payload;
 
 	msg = l1p_msgb_alloc();
 	if (!msg)
 		return NULL;
 
-	l1p = msgb_l1prim(msg);
-	data_req = &l1p->u.phDataReq;
-	msu_param = &data_req->msgUnitParam;
-	payload_type = &msu_param->u8Buffer[0];
-	l1_payload = &msu_param->u8Buffer[1];
+	l1_payload = get_payload_addr(msg);
 
 	switch (lchan->tch_mode) {
 	case GSM48_CMODE_SPEECH_AMR:
-		*payload_type = GsmL1_TchPlType_Amr;
+		set_payload_type(msg, lchan);
 		if (lchan->tch.last_sid.len) {
 			memcpy(l1_payload, lchan->tch.last_sid.buf,
 				lchan->tch.last_sid.len);
-			msu_param->u8Size = lchan->tch.last_sid.len+1;
+			set_payload_size(msg, lchan->tch.last_sid.len + 1);
 		} else {
 			/* FIXME: decide if we should send SPEECH_BAD or
 			 * SID_BAD */
@@ -616,7 +653,7 @@
 			msu_param->u8Size = 5 + 3;
 #else
 			/* send an all-zero SID */
-			msu_param->u8Size = 8;
+			set_payload_size(msg, 8);
 #endif
 		}
 		break;

-- 
To view, visit https://gerrit.osmocom.org/214
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If213ec89762e50b4a5e79becebb589d6260e6b62
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list