[PATCH 1/3] layer23: introduce SMSCB framework

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/baseband-devel@lists.osmocom.org/.

Alex Badea vamposdecampos at gmail.com
Sun Nov 28 14:07:27 UTC 2010


Define a smscb_entity struct.  Add it to lapdm_entity.
Pass LAPDm frames with LPD=01 to SMSCB, and skip any
further LAPDm processing.

Signed-off-by: Alex Badea <vamposdecampos at gmail.com>
---
 src/host/layer23/include/osmocom/bb/common/lapdm.h |    2 +
 src/host/layer23/include/osmocom/bb/common/smscb.h |   23 ++++++++++
 src/host/layer23/src/common/Makefile.am            |    2 +-
 src/host/layer23/src/common/lapdm.c                |    7 +++
 src/host/layer23/src/common/smscb.c                |   46 ++++++++++++++++++++
 5 files changed, 79 insertions(+), 1 deletions(-)
 create mode 100644 src/host/layer23/include/osmocom/bb/common/smscb.h
 create mode 100644 src/host/layer23/src/common/smscb.c

diff --git a/src/host/layer23/include/osmocom/bb/common/lapdm.h b/src/host/layer23/include/osmocom/bb/common/lapdm.h
index de954fb..364d165 100644
--- a/src/host/layer23/include/osmocom/bb/common/lapdm.h
+++ b/src/host/layer23/include/osmocom/bb/common/lapdm.h
@@ -7,6 +7,7 @@
 #include <osmocore/msgb.h>
 
 #include <l1ctl_proto.h>
+#include <osmocom/bb/common/smscb.h>
 
 enum lapdm_state {
 	LAPDm_STATE_NULL = 0,
@@ -66,6 +67,7 @@ struct lapdm_entity {
 	struct lapdm_datalink datalink[_NR_DL_SAPI];
 	int last_tx_dequeue; /* last entity that was dequeued */
 	int tx_pending; /* currently a pending frame not confirmed by L1 */
+	struct smscb_entity smscb;
 	struct osmocom_ms *ms;
 };
 
diff --git a/src/host/layer23/include/osmocom/bb/common/smscb.h b/src/host/layer23/include/osmocom/bb/common/smscb.h
new file mode 100644
index 0000000..d689cd7
--- /dev/null
+++ b/src/host/layer23/include/osmocom/bb/common/smscb.h
@@ -0,0 +1,23 @@
+#ifndef _OSMOCOM_SMSCB_H
+#define _OSMOCOM_SMSCB_H
+
+#include <stdint.h>
+
+struct osmocom_ms;
+struct msgb;
+struct l1ctl_info_dl;
+
+struct smscb_entity {
+	struct osmocom_ms *ms;
+};
+
+/* initialize a SMSCB entity */
+void smscb_init(struct smscb_entity *se, struct osmocom_ms *ms);
+
+/* deinitialize a SMSCB entity */
+void smscb_exit(struct smscb_entity *se);
+
+/* input into SMSCB layer (from layer 1) */
+int smscb_ph_data_ind(struct smscb_entity *se, struct msgb *msg, struct l1ctl_info_dl *l1i);
+
+#endif /* _OSMOCOM_SMSCB_H */
diff --git a/src/host/layer23/src/common/Makefile.am b/src/host/layer23/src/common/Makefile.am
index 4e2686c..6f5f4f1 100644
--- a/src/host/layer23/src/common/Makefile.am
+++ b/src/host/layer23/src/common/Makefile.am
@@ -3,4 +3,4 @@ AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS)
 
 noinst_LIBRARIES = liblayer23.a
 liblayer23_a_SOURCES = l1ctl.c l1l2_interface.c sap_interface.c lapdm.c \
-	logging.c networks.c sim.c sysinfo.c gps.c
+	logging.c networks.c sim.c sysinfo.c gps.c smscb.c
diff --git a/src/host/layer23/src/common/lapdm.c b/src/host/layer23/src/common/lapdm.c
index dc9c916..9233dbb 100644
--- a/src/host/layer23/src/common/lapdm.c
+++ b/src/host/layer23/src/common/lapdm.c
@@ -79,6 +79,7 @@
 #define LAPDm_SAPI_SMS	  3
 #define LAPDm_ADDR(lpd, sapi, cr) ((((lpd) & 0x3) << 5) | (((sapi) & 0x7) << 2) | (((cr) & 0x1) << 1) | 0x1)
 
+#define LAPDm_ADDR_LPD(addr) (((addr) >> 5) & 0x03)
 #define LAPDm_ADDR_SAPI(addr) (((addr) >> 2) & 0x7)
 #define LAPDm_ADDR_CR(addr) (((addr) >> 1) & 0x1)
 #define LAPDm_ADDR_EA(addr) ((addr) & 0x1)
@@ -193,6 +194,8 @@ void lapdm_init(struct lapdm_entity *le, struct osmocom_ms *ms)
 	for (i = 0; i < ARRAY_SIZE(le->datalink); i++)
 		lapdm_dl_init(&le->datalink[i], le);
 
+	smscb_init(&le->smscb, ms);
+
 	le->ms = ms;
 }
 
@@ -227,6 +230,8 @@ void lapdm_exit(struct lapdm_entity *le)
 	unsigned int i;
 	struct lapdm_datalink *dl;
 
+	smscb_exit(&le->smscb);
+
 	for (i = 0; i < ARRAY_SIZE(le->datalink); i++) {
 		dl = &le->datalink[i];
 		lapdm_dl_flush_tx(dl);
@@ -1551,6 +1556,8 @@ int l2_ph_data_ind(struct msgb *msg, struct lapdm_entity *le, struct l1ctl_info_
 	case LAPDm_FMT_B:
 	case LAPDm_FMT_B4:
 		mctx.addr = msg->l2h[0];
+		if (LAPDm_ADDR_LPD(mctx.addr) == LAPDm_LPD_SMSCB)
+			return smscb_ph_data_ind(&le->smscb, msg, l1i);
 		if (!(mctx.addr & 0x01)) {
 			LOGP(DLAPDM, LOGL_ERROR, "we don't support "
 				"multibyte addresses (discarding)\n");
diff --git a/src/host/layer23/src/common/smscb.c b/src/host/layer23/src/common/smscb.c
new file mode 100644
index 0000000..31a5752
--- /dev/null
+++ b/src/host/layer23/src/common/smscb.c
@@ -0,0 +1,46 @@
+/* GSM SMSCB (TS 04.12) implementation */
+
+/* (C) 2010 by Alex Badea <vamposdecampos at gmail.com>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <osmocom/bb/common/smscb.h>
+#include <osmocom/bb/common/logging.h>
+#include <osmocore/msgb.h>
+
+void smscb_init(struct smscb_entity *se, struct osmocom_ms *ms)
+{
+	se->ms = ms;
+}
+
+void smscb_exit(struct smscb_entity *se)
+{
+}
+
+int smscb_ph_data_ind(struct smscb_entity *se, struct msgb *msg, struct l1ctl_info_dl *l1i)
+{
+	uint8_t addr = msg->l2h[0];
+	uint8_t seq = addr & 0x0f;
+
+	LOGP(DLAPDM, LOGL_NOTICE, "SMSCB: received message: seq=%d len=%d\n",
+		seq, msg->len);
+
+	msgb_free(msg);
+	return 0;
+}
-- 
1.7.0.4





More information about the baseband-devel mailing list