[PATCH libosmocore 8/8] smscb: hook into LAPDm

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
Sat Jan 5 19:26:32 UTC 2013


Add a smscb_entity to each lapdm_entity.  Pass LAPDm messages having
LPD=01 up to SMSCB.  Pass L3 messages output by SMSCB to the L3 entity
registered with LAPDm.

Signed-off-by: Alex Badea <vamposdecampos at gmail.com>
---

This makes L3 get SMSCB decoding for free.  It worksforme, but I'm not
sure how it might interact with e.g. the BTS side.  An alternative is to
hook smscb_entity into the bb layer3 apps themselves;  suggestions are
welcome.

 include/osmocom/gsm/lapdm.h |    3 +++
 src/gsm/lapdm.c             |   13 +++++++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/include/osmocom/gsm/lapdm.h b/include/osmocom/gsm/lapdm.h
index 571fd46..e1fd4f0 100644
--- a/include/osmocom/gsm/lapdm.h
+++ b/include/osmocom/gsm/lapdm.h
@@ -2,6 +2,7 @@
 #define _OSMOCOM_LAPDM_H
 
 #include <osmocom/gsm/lapd_core.h>
+#include <osmocom/gsm/smscb.h>
 
 /*! \defgroup lapdm LAPDm implementation according to GSM TS 04.06
  *  @{
@@ -113,6 +114,8 @@ struct lapdm_entity {
 
 	/*! \brief pointer to \ref lapdm_channel of which we're part */
 	struct lapdm_channel *lapdm_ch;
+	/*! \brief SMSCB entity associated with this LAPDm entity */
+	struct smscb_entity smscb;
 
 	uint8_t ta;		/* TA used and indicated to network */
 	uint8_t tx_power;	/* MS power used and indicated to network */
diff --git a/src/gsm/lapdm.c b/src/gsm/lapdm.c
index 2bda48a..fcce526 100644
--- a/src/gsm/lapdm.c
+++ b/src/gsm/lapdm.c
@@ -114,6 +114,7 @@ enum lapdm_format {
 static int lapdm_send_ph_data_req(struct lapd_msg_ctx *lctx, struct msgb *msg);
 static int send_rslms_dlsap(struct osmo_dlsap_prim *dp,
 	struct lapd_msg_ctx *lctx);
+static int lapdm_smscb_cb(struct msgb *msg, struct smscb_entity *se, void *ctx);
 
 static void lapdm_dl_init(struct lapdm_datalink *dl,
 			  struct lapdm_entity *entity, int t200)
@@ -142,6 +143,8 @@ void lapdm_entity_init(struct lapdm_entity *le, enum lapdm_mode mode, int t200)
 		lapdm_dl_init(&le->datalink[i], le, t200);
 
 	lapdm_entity_set_mode(le, mode);
+	smscb_init(&le->smscb);
+	smscb_set_l3(&le->smscb, lapdm_smscb_cb, le);
 }
 
 /*! \brief initialize a LAPDm channel and all its channels
@@ -168,6 +171,7 @@ void lapdm_entity_exit(struct lapdm_entity *le)
 		dl = &le->datalink[i];
 		lapd_dl_exit(&dl->dl);
 	}
+	smscb_exit(&le->smscb);
 }
 
 /* \brief lfush and release all resources in LAPDm channel
@@ -229,6 +233,12 @@ static int rslms_sendmsg(struct msgb *msg, struct lapdm_entity *le)
 	return le->l3_cb(msg, le, le->l3_ctx);
 }
 
+/* input function from smscb up to L3 */
+static int lapdm_smscb_cb(struct msgb *msg, struct smscb_entity *se, void *ctx)
+{
+	return rslms_sendmsg(msg, ctx);
+}
+
 /* write a frame into the tx queue */
 static int tx_ph_data_enqueue(struct lapdm_datalink *dl, struct msgb *msg,
 				uint8_t chan_nr, uint8_t link_id, uint8_t pad)
@@ -543,6 +553,9 @@ static int l2_ph_data_ind(struct msgb *msg, struct lapdm_entity *le,
 			LOGP(DLLAPD, LOGL_INFO, "fmt=B\n");
 			n201 = N201_AB_SDCCH;
 			sapi = (msg->l2h[0] >> 2) & 7;
+
+			if (LAPDm_ADDR_LPD(msg->l2h[0]) == LAPDm_LPD_SMSCB)
+				return smscb_ph_data_ind(&le->smscb, msg);
 		}
 	}
 
-- 
1.7.0.4





More information about the baseband-devel mailing list