aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-06-10 15:02:41 +0200
committerMax <msuraev@sysmocom.de>2016-06-10 15:02:41 +0200
commitf43d24598d5c8769ed94d86e57e7deec8075c93c (patch)
treefc57e0638020d81a7360aa57b62b3448273f4923
parent9966ec6459d0e8c704f7eca010ba50c3f5953f36 (diff)
Move to common/ TCH code for adding l1sap header
Move code common for both sysmoBTS and LC15 to common/tch.c to make sure fix from ef30f50d5d6d5f863fc147d05ccdceb89284934e is applied to both. Change-Id: I18124f529d3546467a266c04f394150e5466c0c0
-rw-r--r--src/common/tch.c22
-rw-r--r--src/osmo-bts-litecell15/tch.c23
-rw-r--r--src/osmo-bts-sysmo/tch.c24
3 files changed, 36 insertions, 33 deletions
diff --git a/src/common/tch.c b/src/common/tch.c
index d31b04e..03db563 100644
--- a/src/common/tch.c
+++ b/src/common/tch.c
@@ -20,12 +20,34 @@
*/
#include <osmo-bts/gsm_data.h>
+#include <osmo-bts/logging.h>
+#include <osmo-bts/l1sap.h>
extern struct msgb *l1p_msgb_alloc(void);
extern uint8_t *get_payload_addr(struct msgb *msg);
extern void set_payload_type(struct msgb *msg, struct gsm_lchan *lchan);
extern void set_payload_size(struct msgb *msg, uint8_t size);
+int add_l1sap_header(struct gsm_lchan *lchan, struct msgb *rmsg,
+ struct gsm_bts_trx *trx, uint8_t chan_nr, uint32_t fn)
+{
+ struct osmo_phsap_prim *l1sap;
+
+ LOGP(DL1C, LOGL_DEBUG, "%s Rx -> RTP: %s\n",
+ gsm_lchan_name(lchan), osmo_hexdump(rmsg->data, rmsg->len));
+
+ rmsg->l2h = rmsg->data;
+ msgb_push(rmsg, sizeof(*l1sap));
+ rmsg->l1h = rmsg->data;
+ l1sap = msgb_l1sap_prim(rmsg);
+ osmo_prim_init(&l1sap->oph, SAP_GSM_PH, PRIM_TCH, PRIM_OP_INDICATION,
+ rmsg);
+ l1sap->u.tch.chan_nr = chan_nr;
+ l1sap->u.tch.fn = fn;
+
+ return l1sap_up(trx, l1sap);
+}
+
struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan)
{
struct msgb *msg;
diff --git a/src/osmo-bts-litecell15/tch.c b/src/osmo-bts-litecell15/tch.c
index 5a76fb9..a7babf4 100644
--- a/src/osmo-bts-litecell15/tch.c
+++ b/src/osmo-bts-litecell15/tch.c
@@ -54,6 +54,10 @@
#include "lc15bts.h"
#include "l1_if.h"
+extern int add_l1sap_header(struct gsm_lchan *lchan, struct msgb *rmsg,
+ struct gsm_bts_trx *trx, uint8_t chan_nr,
+ uint32_t fn);
+
/* input octet-aligned, output not octet-aligned */
void osmo_nibble_shift_right(uint8_t *out, const uint8_t *in,
unsigned int num_nibbles)
@@ -500,22 +504,9 @@ int l1if_tch_rx(struct gsm_bts_trx *trx, uint8_t chan_nr, struct msgb *l1p_msg)
break;
}
- if (rmsg) {
- struct osmo_phsap_prim *l1sap;
-
- LOGP(DL1C, LOGL_DEBUG, "%s Rx -> RTP: %s\n",
- gsm_lchan_name(lchan), osmo_hexdump(rmsg->data, rmsg->len));
-
- /* add l1sap header */
- rmsg->l2h = rmsg->data;
- msgb_push(rmsg, sizeof(*l1sap));
- rmsg->l1h = rmsg->data;
- l1sap = msgb_l1sap_prim(rmsg);
- osmo_prim_init(&l1sap->oph, SAP_GSM_PH, PRIM_TCH, PRIM_OP_INDICATION, rmsg);
- l1sap->u.tch.chan_nr = chan_nr;
-
- return l1sap_up(trx, l1sap);
- }
+ if (rmsg)
+ return add_l1sap_header(lchan, rmsg, trx, chan_nr,
+ data_ind->u32Fn);
return 0;
diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c
index 2436c06..910c7fe 100644
--- a/src/osmo-bts-sysmo/tch.c
+++ b/src/osmo-bts-sysmo/tch.c
@@ -51,6 +51,10 @@
#include "femtobts.h"
#include "l1_if.h"
+extern int add_l1sap_header(struct gsm_lchan *lchan, struct msgb *rmsg,
+ struct gsm_bts_trx *trx, uint8_t chan_nr,
+ uint32_t fn);
+
/* input octet-aligned, output not octet-aligned */
void osmo_nibble_shift_right(uint8_t *out, const uint8_t *in,
unsigned int num_nibbles)
@@ -595,23 +599,9 @@ int l1if_tch_rx(struct gsm_bts_trx *trx, uint8_t chan_nr, struct msgb *l1p_msg)
break;
}
- if (rmsg) {
- struct osmo_phsap_prim *l1sap;
-
- LOGP(DL1C, LOGL_DEBUG, "%s Rx -> RTP: %s\n",
- gsm_lchan_name(lchan), osmo_hexdump(rmsg->data, rmsg->len));
-
- /* add l1sap header */
- rmsg->l2h = rmsg->data;
- msgb_push(rmsg, sizeof(*l1sap));
- rmsg->l1h = rmsg->data;
- l1sap = msgb_l1sap_prim(rmsg);
- osmo_prim_init(&l1sap->oph, SAP_GSM_PH, PRIM_TCH, PRIM_OP_INDICATION, rmsg);
- l1sap->u.tch.chan_nr = chan_nr;
- l1sap->u.tch.fn = data_ind->u32Fn;
-
- return l1sap_up(trx, l1sap);
- }
+ if (rmsg)
+ return add_l1sap_header(lchan, rmsg, trx, chan_nr,
+ data_ind->u32Fn);
return 0;