[PATCH libosmocore 1/8] gsm: add skeleton smscb module

Alex Badea vamposdecampos at gmail.com
Sat Jan 5 19:26:25 UTC 2013


Header files and skeleton functions for a SMSCB entity.

Signed-off-by: Alex Badea <vamposdecampos at gmail.com>
---
 include/Makefile.am         |    1 +
 include/osmocom/gsm/smscb.h |   28 ++++++++++++++++++
 src/gsm/Makefile.am         |    1 +
 src/gsm/libosmogsm.map      |    5 +++
 src/gsm/smscb.c             |   65 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 100 insertions(+), 0 deletions(-)
 create mode 100644 include/osmocom/gsm/smscb.h
 create mode 100644 src/gsm/smscb.c

diff --git a/include/Makefile.am b/include/Makefile.am
index 60b9ea9..560fc54 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -66,6 +66,7 @@ nobase_include_HEADERS = \
                        osmocom/gsm/protocol/ipaccess.h \
                        osmocom/gsm/rsl.h \
                        osmocom/gsm/rxlev_stat.h \
+                       osmocom/gsm/smscb.h \
                        osmocom/gsm/sysinfo.h \
                        osmocom/gsm/tlv.h
 
diff --git a/include/osmocom/gsm/smscb.h b/include/osmocom/gsm/smscb.h
new file mode 100644
index 0000000..88ba6e2
--- /dev/null
+++ b/include/osmocom/gsm/smscb.h
@@ -0,0 +1,28 @@
+#ifndef _OSMOCOM_SMSCB_H
+#define _OSMOCOM_SMSCB_H
+
+/*! \defgroup smscb SMSCB implementation according to GSM TS 03.41
+ *  @{
+ */
+
+/*! \file smscb.h */
+
+struct msgb;
+struct smscb_entity;
+
+typedef int (*smscb_cb_t)(struct msgb *msg, struct smscb_entity *se, void *ctx);
+
+/*! \brief a SMSCB Entity */
+struct smscb_entity {
+	smscb_cb_t l3_cb;	/*!< \brief callback for sending stuff to L3 */
+	void *l3_ctx;		/*!< \brief context for layer3 instance */
+};
+
+void smscb_init(struct smscb_entity *se);
+void smscb_exit(struct smscb_entity *se);
+void smscb_set_l3(struct smscb_entity *se, smscb_cb_t cb, void *ctx);
+int smscb_ph_data_ind(struct smscb_entity *se, struct msgb *msg);
+
+/*! @} */
+
+#endif /* _OSMOCOM_SMSCB_H */
diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am
index 6e2a785..3d79f7e 100644
--- a/src/gsm/Makefile.am
+++ b/src/gsm/Makefile.am
@@ -16,6 +16,7 @@ libosmogsm_la_SOURCES = a5.c rxlev_stat.c tlv_parser.c comp128.c gsm_utils.c \
 			gprs_cipher_core.c gsm0480.c abis_nm.c gsm0502.c \
 			gsm0411_utils.c gsm0411_smc.c gsm0411_smr.c \
 			lapd_core.c lapdm.c \
+			smscb.c \
 			auth_core.c auth_comp128v1.c auth_milenage.c \
 			milenage/aes-encblock.c milenage/aes-internal.c \
 			milenage/aes-internal-enc.c milenage/milenage.c gan.c
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index b2278f1..674a85f 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -223,6 +223,11 @@ rxlev_stat_get_next;
 rxlev_stat_input;
 rxlev_stat_reset;
 
+smscb_init;
+smscb_exit;
+smscb_set_l3;
+smscb_ph_data_ind;
+
 tlv_def_patch;
 tlv_dump;
 tlv_parse;
diff --git a/src/gsm/smscb.c b/src/gsm/smscb.c
new file mode 100644
index 0000000..a9f38eb
--- /dev/null
+++ b/src/gsm/smscb.c
@@ -0,0 +1,65 @@
+/* GSM SMSCB (TS 04.12) implementation */
+
+/* (C) 2010,2013 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.
+ *
+ */
+
+
+/*! \addtogroup smscb
+ *  @{
+ */
+
+/*! \file smscb.c */
+
+#include <osmocom/gsm/smscb.h>
+#include <osmocom/core/logging.h>
+#include <osmocom/core/msgb.h>
+
+/*! \brief Initialize a SMSCB entity */
+void smscb_init(struct smscb_entity *se)
+{
+}
+
+/*! \brief Deinitialize a smscb entity */
+void smscb_exit(struct smscb_entity *se)
+{
+}
+
+/*! \brief Set the L3 callback and context of a SMSCB entity */
+void smscb_set_l3(struct smscb_entity *se, smscb_cb_t cb, void *ctx)
+{
+	se->l3_cb = cb;
+	se->l3_ctx = ctx;
+}
+
+/*! \brief Input data from layer 1 */
+int smscb_ph_data_ind(struct smscb_entity *se, struct msgb *msg)
+{
+	uint8_t addr = msg->l2h[0];
+	uint8_t seq = addr & 0x0f;
+
+	LOGP(DLLAPD, 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