aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-06-07 14:31:36 +0200
committerMax <msuraev@sysmocom.de>2016-06-10 14:43:55 +0200
commita6ee8245923ee907a18a062c8a36a523ddfe36b0 (patch)
treef62626141682e2b70e05948f0e1d12bfb5f45df3
parent30e7737bc25be637c4281f3a14ed64eacdf59691 (diff)
Move common TCH code into src/common/tch.c
Move gen_empty_tch_msg() into src/common/ to make adding DTXd support easier. Change-Id: Ia0d4d0f9848fc2ab54f975a3b6d1815fbcdf78a7 Related: OS#1563
-rw-r--r--src/common/Makefile.am2
-rw-r--r--src/common/tch.c67
-rw-r--r--src/osmo-bts-litecell15/tch.c40
-rw-r--r--src/osmo-bts-sysmo/tch.c40
4 files changed, 68 insertions, 81 deletions
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 8df6513..5c84ade 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -4,7 +4,7 @@ LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOTRAU_LIBS)
noinst_LIBRARIES = libbts.a libl1sched.a
libbts_a_SOURCES = gsm_data_shared.c sysinfo.c logging.c abis.c oml.c bts.c \
- rsl.c vty.c paging.c measurement.c amr.c lchan.c \
+ rsl.c vty.c paging.c measurement.c amr.c tch.c lchan.c \
load_indication.c pcu_sock.c handover.c msg_utils.c \
load_indication.c pcu_sock.c handover.c msg_utils.c \
tx_power.c bts_ctrl_commands.c bts_ctrl_lookup.c \
diff --git a/src/common/tch.c b/src/common/tch.c
new file mode 100644
index 0000000..d31b04e
--- /dev/null
+++ b/src/common/tch.c
@@ -0,0 +1,67 @@
+/* OsmoBTS common TCH code */
+
+/* (C) 2011-2012 by Harald Welte <laforge@gnumonks.org>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <osmo-bts/gsm_data.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);
+
+struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan)
+{
+ struct msgb *msg;
+ uint8_t *l1_payload;
+
+ msg = l1p_msgb_alloc();
+ if (!msg)
+ return NULL;
+
+ l1_payload = get_payload_addr(msg);
+
+ switch (lchan->tch_mode) {
+ case GSM48_CMODE_SPEECH_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);
+ set_payload_size(msg, lchan->tch.last_sid.len + 1);
+ } else {
+ /* FIXME: decide if we should send SPEECH_BAD or
+ * SID_BAD */
+#if 0
+ *payload_type = GsmL1_TchPlType_Amr_SidBad;
+ memset(l1_payload, 0xFF, 5);
+ msu_param->u8Size = 5 + 3;
+#else
+ /* send an all-zero SID */
+ set_payload_size(msg, 8);
+#endif
+ }
+ break;
+ default:
+ msgb_free(msg);
+ msg = NULL;
+ break;
+ }
+
+ return msg;
+}
diff --git a/src/osmo-bts-litecell15/tch.c b/src/osmo-bts-litecell15/tch.c
index 2c42ef5..d09264a 100644
--- a/src/osmo-bts-litecell15/tch.c
+++ b/src/osmo-bts-litecell15/tch.c
@@ -530,43 +530,3 @@ err_payload_match:
get_value_string(lc15bts_tch_pl_names, payload_type));
return -EINVAL;
}
-
-struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan)
-{
- struct msgb *msg;
- uint8_t *l1_payload;
-
- msg = l1p_msgb_alloc();
- if (!msg)
- return NULL;
-
- l1_payload = get_payload_addr(msg);
-
- switch (lchan->tch_mode) {
- case GSM48_CMODE_SPEECH_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);
- set_payload_size(msg, lchan->tch.last_sid.len + 1);
- } else {
- /* FIXME: decide if we should send SPEECH_BAD or
- * SID_BAD */
-#if 0
- *payload_type = GsmL1_TchPlType_Amr_SidBad;
- memset(l1_payload, 0xFF, 5);
- msu_param->u8Size = 5 + 3;
-#else
- /* send an all-zero SID */
- set_payload_size(msg, 8);
-#endif
- }
- break;
- default:
- msgb_free(msg);
- msg = NULL;
- break;
- }
-
- return msg;
-}
diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c
index 3b9fe36..13f9ec6 100644
--- a/src/osmo-bts-sysmo/tch.c
+++ b/src/osmo-bts-sysmo/tch.c
@@ -625,43 +625,3 @@ err_payload_match:
get_value_string(femtobts_tch_pl_names, payload_type));
return -EINVAL;
}
-
-struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan)
-{
- struct msgb *msg;
- uint8_t *l1_payload;
-
- msg = l1p_msgb_alloc();
- if (!msg)
- return NULL;
-
- l1_payload = get_payload_addr(msg);
-
- switch (lchan->tch_mode) {
- case GSM48_CMODE_SPEECH_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);
- set_payload_size(msg, lchan->tch.last_sid.len + 1);
- } else {
- /* FIXME: decide if we should send SPEECH_BAD or
- * SID_BAD */
-#if 0
- *payload_type = GsmL1_TchPlType_Amr_SidBad;
- memset(l1_payload, 0xFF, 5);
- msu_param->u8Size = 5 + 3;
-#else
- /* send an all-zero SID */
- set_payload_size(msg, 8);
-#endif
- }
- break;
- default:
- msgb_free(msg);
- msg = NULL;
- break;
- }
-
- return msg;
-}