aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-06-07 14:25:48 +0200
committerMax <msuraev@sysmocom.de>2016-06-10 14:40:05 +0200
commit0e0e73bea5c4b06fed9a9ba2b6d21351b3a3a747 (patch)
tree08e38cc34ea0524b178c240b24c827eae281e652
parent51bfebec39cc0a01e30ac9c655866678a46b5c2d (diff)
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
-rw-r--r--src/osmo-bts-sysmo/tch.c61
1 files changed, 49 insertions, 12 deletions
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 @@ void osmo_nibble_shift_left_unal(uint8_t *out, const uint8_t *in,
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 @@ err_payload_match:
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 @@ struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan)
msu_param->u8Size = 5 + 3;
#else
/* send an all-zero SID */
- msu_param->u8Size = 8;
+ set_payload_size(msg, 8);
#endif
}
break;