summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-10-06 16:09:49 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2018-11-21 11:03:10 +0700
commitbcb903b3fcfba31340b3b921f875e3025670b0f1 (patch)
treee186fcbd8cb40ac41b612b1a8d561bb3b9b6fc07 /src
parent33afaa9c6f8360b843ac4de0567f7662cd89d5c3 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/host/layer23/include/osmocom/bb/common/l23sap.h3
-rw-r--r--src/host/layer23/src/common/l1ctl.c24
-rw-r--r--src/host/layer23/src/common/l23sap.c59
3 files changed, 66 insertions, 20 deletions
diff --git a/src/host/layer23/include/osmocom/bb/common/l23sap.h b/src/host/layer23/include/osmocom/bb/common/l23sap.h
index 814fb7de..eaa62c14 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 df12105e..d5281933 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 @@ static int rx_data_ind(struct osmocom_ms *ms, struct msgb *msg)
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 @@ static int rx_data_ind(struct osmocom_ms *ms, struct msgb *msg)
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 @@ int l1ctl_tx_data_req(struct osmocom_ms *ms, struct msgb *msg,
{
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 @@ int l1ctl_tx_data_req(struct osmocom_ms *ms, struct msgb *msg,
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 b07265ac..d034b272 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 @@ int l23sap_data_ind(struct osmocom_ms *ms, struct msgb *msg)
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);
}