aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-sysmo/tch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/osmo-bts-sysmo/tch.c')
-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 e08d8a66..3b9fe36a 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;