Change in osmocom-bb[master]: layer23/common: move GSMTAP handling to L23SAP

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/gerrit-log@lists.osmocom.org/.

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Sat Oct 6 09:44:58 UTC 2018


Vadim Yanitskiy has uploaded this change for review. ( https://gerrit.osmocom.org/11248


Change subject: layer23/common: move GSMTAP handling to L23SAP
......................................................................

layer23/common: move GSMTAP handling to L23SAP

L1CTL implementation (i.e. l1ctl.c) is also not a good place for
GSMTAP handling, let's move it to L23SAP.

Change-Id: Ie143b9e839d944a7a7eebf5529798a49b8e175d7
---
M src/host/layer23/include/osmocom/bb/common/l23sap.h
M src/host/layer23/src/common/l1ctl.c
M src/host/layer23/src/common/l23sap.c
3 files changed, 66 insertions(+), 20 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/48/11248/1

diff --git a/src/host/layer23/include/osmocom/bb/common/l23sap.h b/src/host/layer23/include/osmocom/bb/common/l23sap.h
index 814fb7d..eaa62c1 100644
--- a/src/host/layer23/include/osmocom/bb/common/l23sap.h
+++ b/src/host/layer23/include/osmocom/bb/common/l23sap.h
@@ -10,6 +10,9 @@
 #define CHAN_IS_SACCH(link_id) \
 	((link_id & 0xc0) == LID_SACCH)
 
+int l23sap_gsmtap_data_ind(struct osmocom_ms *ms, struct msgb *msg);
+int l23sap_gsmtap_data_req(struct osmocom_ms *ms, struct msgb *msg);
+
 int l23sap_data_ind(struct osmocom_ms *ms, struct msgb *msg);
 int l23sap_data_conf(struct osmocom_ms *ms, struct msgb *msg);
 int l23sap_rach_conf(struct osmocom_ms *ms, struct msgb *msg);
diff --git a/src/host/layer23/src/common/l1ctl.c b/src/host/layer23/src/common/l1ctl.c
index e78f8be..60039c9 100644
--- a/src/host/layer23/src/common/l1ctl.c
+++ b/src/host/layer23/src/common/l1ctl.c
@@ -36,8 +36,6 @@
 #include <osmocom/core/msgb.h>
 #include <osmocom/gsm/tlv.h>
 #include <osmocom/gsm/gsm_utils.h>
-#include <osmocom/core/gsmtap_util.h>
-#include <osmocom/core/gsmtap.h>
 #include <osmocom/gsm/protocol/gsm_04_08.h>
 #include <osmocom/gsm/protocol/gsm_08_58.h>
 #include <osmocom/gsm/rsl.h>
@@ -48,8 +46,6 @@
 #include <osmocom/bb/common/l1l2_interface.h>
 #include <osmocom/bb/common/logging.h>
 
-extern struct gsmtap_inst *gsmtap_inst;
-
 static struct msgb *osmo_l1_alloc(uint8_t msg_type)
 {
 	struct l1ctl_hdr *l1h;
@@ -131,7 +127,6 @@
 	struct l1ctl_data_ind *ccch;
 	struct rx_meas_stat *meas = &ms->meas;
 	uint8_t chan_type, chan_ts, chan_ss;
-	uint8_t gsmtap_chan_type;
 	struct gsm_time tm;
 
 	if (msgb_l1len(msg) < sizeof(*dl)) {
@@ -216,12 +211,6 @@
 		return 0;
 	}
 
-	/* send CCCH data via GSMTAP */
-	gsmtap_chan_type = chantype_rsl2gsmtap(chan_type, dl->link_id);
-	gsmtap_send(gsmtap_inst, ntohs(dl->band_arfcn), chan_ts,
-		    gsmtap_chan_type, chan_ss, tm.fn, dl->rx_level-110,
-		    dl->snr, ccch->data, sizeof(ccch->data));
-
 	/* Send it up towards LAPDm via L23SAP */
 	return l23sap_data_ind(ms, msg);
 }
@@ -246,8 +235,6 @@
 {
 	struct l1ctl_hdr *l1h;
 	struct l1ctl_info_ul *l1i_ul;
-	uint8_t chan_type, chan_ts, chan_ss;
-	uint8_t gsmtap_chan_type;
 
 	DEBUGP(DL1C, "(%s)\n", osmo_hexdump(msg->l2h, msgb_l2len(msg)));
 
@@ -258,18 +245,15 @@
 		return -EINVAL;
 	}
 
-	/* send copy via GSMTAP */
-	rsl_dec_chan_nr(chan_nr, &chan_type, &chan_ss, &chan_ts);
-	gsmtap_chan_type = chantype_rsl2gsmtap(chan_type, link_id);
-	gsmtap_send(gsmtap_inst, 0|0x4000, chan_ts, gsmtap_chan_type,
-		    chan_ss, 0, 127, 255, msg->l2h, msgb_l2len(msg));
-
 	/* prepend uplink info header */
 	l1i_ul = (struct l1ctl_info_ul *) msgb_push(msg, sizeof(*l1i_ul));
-
+	msg->l1h = (uint8_t *) l1i_ul;
 	l1i_ul->chan_nr = chan_nr;
 	l1i_ul->link_id = link_id;
 
+	/* Send to GSMTAP */
+	l23sap_gsmtap_data_req(ms, msg);
+
 	/* prepend l1 header */
 	msg->l1h = msgb_push(msg, sizeof(*l1h));
 	l1h = (struct l1ctl_hdr *) msg->l1h;
diff --git a/src/host/layer23/src/common/l23sap.c b/src/host/layer23/src/common/l23sap.c
index b07265a..d034b27 100644
--- a/src/host/layer23/src/common/l23sap.c
+++ b/src/host/layer23/src/common/l23sap.c
@@ -26,19 +26,75 @@
 #include <errno.h>
 #include <stdint.h>
 #include <string.h>
+#include <stdbool.h>
 
 #include <arpa/inet.h>
 #include <l1ctl_proto.h>
 
 #include <osmocom/core/logging.h>
+#include <osmocom/core/gsmtap_util.h>
+#include <osmocom/core/gsmtap.h>
 #include <osmocom/core/prim.h>
 #include <osmocom/core/msgb.h>
+
 #include <osmocom/gsm/lapdm.h>
+#include <osmocom/gsm/rsl.h>
 
 #include <osmocom/bb/common/osmocom_data.h>
 #include <osmocom/bb/common/logging.h>
 #include <osmocom/bb/common/l23sap.h>
 
+extern struct gsmtap_inst *gsmtap_inst;
+
+int l23sap_gsmtap_data_ind(struct osmocom_ms *ms, struct msgb *msg)
+{
+	struct l1ctl_info_dl *dl = (struct l1ctl_info_dl *) msg->l1h;
+	uint8_t chan_type, chan_ts, chan_ss;
+	uint8_t gsmtap_chan_type;
+	uint16_t band_arfcn;
+	int8_t signal_dbm;
+	uint32_t fn;
+
+	/* FDMA / TDMA info indicated by L1 */
+	band_arfcn = ntohs(dl->band_arfcn);
+	signal_dbm = dl->rx_level - 110;
+	fn = ntohl(dl->frame_nr);
+
+	/* Logical channel info */
+	rsl_dec_chan_nr(dl->chan_nr, &chan_type, &chan_ss, &chan_ts);
+	gsmtap_chan_type = chantype_rsl2gsmtap(chan_type, dl->link_id);
+
+	/* Send to GSMTAP */
+	return gsmtap_send(gsmtap_inst, band_arfcn, chan_ts,
+		gsmtap_chan_type, chan_ss, fn, signal_dbm,
+		dl->snr, msg->l2h, msgb_l2len(msg));
+}
+
+int l23sap_gsmtap_data_req(struct osmocom_ms *ms, struct msgb *msg)
+{
+	struct l1ctl_info_ul *ul = (struct l1ctl_info_ul *) msg->l1h;
+	uint8_t chan_type, chan_ts, chan_ss;
+	uint8_t gsmtap_chan_type;
+
+	/* send copy via GSMTAP */
+	rsl_dec_chan_nr(ul->chan_nr, &chan_type, &chan_ss, &chan_ts);
+	gsmtap_chan_type = chantype_rsl2gsmtap(chan_type, ul->link_id);
+
+	/**
+	 * Send to GSMTAP
+	 *
+	 * FIXME: neither FDMA, not TDMA info is known here.
+	 * As a possible solution, we can store an UL frame
+	 * until RTS (TX confirmation) is received from PHY.
+	 * This would also require to add some reference
+	 * info to both UL/DL info headers. This is similar
+	 * to how SIM-card related messages are handled.
+	 */
+	return gsmtap_send(gsmtap_inst, 0 | 0x4000, chan_ts,
+		gsmtap_chan_type, chan_ss, 0, 127, 255,
+		msg->l2h, msgb_l2len(msg));
+}
+
 int l23sap_data_ind(struct osmocom_ms *ms, struct msgb *msg)
 {
 	struct l1ctl_info_dl *dl = (struct l1ctl_info_dl *) msg->l1h;
@@ -57,6 +113,9 @@
 	else
 		le = &ms->lapdm_channel.lapdm_dcch;
 
+	/* Send to GSMTAP */
+	l23sap_gsmtap_data_ind(ms, msg);
+
 	/* Send it up into LAPDm */
 	return lapdm_phsap_up(&pp.oph, le);
 }

-- 
To view, visit https://gerrit.osmocom.org/11248
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie143b9e839d944a7a7eebf5529798a49b8e175d7
Gerrit-Change-Number: 11248
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181006/2575453e/attachment.htm>


More information about the gerrit-log mailing list