summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-07-12 23:43:40 +0200
committerHarald Welte <laforge@gnumonks.org>2017-07-13 00:03:27 +0200
commit93713a55b93a30a01aaa99355d2d7abf4e4597a7 (patch)
tree1873b4914ef4ec76a32c2a508bcd888e4c173af2
parentb808da44ab417df0a66a9530c6aa8a45f74e74be (diff)
gsmtap_util: Add chantype_gsmtap2rsl() as inverse of chantype_rsl2gsmtap()
Change-Id: Ie1bc00670887064da0fea61c3dab036c23ceea25
-rw-r--r--include/osmocom/core/gsmtap_util.h1
-rw-r--r--src/gsmtap_util.c41
2 files changed, 41 insertions, 1 deletions
diff --git a/include/osmocom/core/gsmtap_util.h b/include/osmocom/core/gsmtap_util.h
index 59b81e55..5c5e3fdd 100644
--- a/include/osmocom/core/gsmtap_util.h
+++ b/include/osmocom/core/gsmtap_util.h
@@ -9,6 +9,7 @@
* \file gsmtap_util.h */
uint8_t chantype_rsl2gsmtap(uint8_t rsl_chantype, uint8_t rsl_link_id);
+void chantype_gsmtap2rsl(uint8_t gsmtap_chantype, uint8_t *rsl_chantype, uint8_t *link_id);
struct msgb *gsmtap_makemsg_ex(uint8_t type, uint16_t arfcn, uint8_t ts, uint8_t chan_type,
uint8_t ss, uint32_t fn, int8_t signal_dbm,
diff --git a/src/gsmtap_util.c b/src/gsmtap_util.c
index 561cdb30..26720b6c 100644
--- a/src/gsmtap_util.c
+++ b/src/gsmtap_util.c
@@ -1,7 +1,7 @@
/*! \file gsmtap_util.c
* GSMTAP support code in libosmocore. */
/*
- * (C) 2010-2011 by Harald Welte <laforge@gnumonks.org>
+ * (C) 2010-2017 by Harald Welte <laforge@gnumonks.org>
*
* All Rights Reserved
*
@@ -89,6 +89,45 @@ uint8_t chantype_rsl2gsmtap(uint8_t rsl_chantype, uint8_t link_id)
return ret;
}
+/*! convert GSMTAP channel type to RSL channel number + Link ID
+ * \param[in] gsmtap_chantype GSMTAP channel type
+ * \param[out] rsl_chantype RSL channel mumber
+ * \param[out] link_id RSL link identifier
+ */
+void chantype_gsmtap2rsl(uint8_t gsmtap_chantype, uint8_t *rsl_chantype,
+ uint8_t *link_id)
+{
+ switch (gsmtap_chantype & ~GSMTAP_CHANNEL_ACCH & 0xff) {
+ case GSMTAP_CHANNEL_TCH_F: // TCH/F, FACCH/F
+ *rsl_chantype = RSL_CHAN_Bm_ACCHs;
+ break;
+ case GSMTAP_CHANNEL_TCH_H: // TCH/H, FACCH/H
+ *rsl_chantype = RSL_CHAN_Lm_ACCHs;
+ break;
+ case GSMTAP_CHANNEL_SDCCH4: // SDCCH/4
+ *rsl_chantype = RSL_CHAN_SDCCH4_ACCH;
+ break;
+ case GSMTAP_CHANNEL_SDCCH8: // SDCCH/8
+ *rsl_chantype = RSL_CHAN_SDCCH8_ACCH;
+ break;
+ case GSMTAP_CHANNEL_BCCH: // BCCH
+ *rsl_chantype = RSL_CHAN_BCCH;
+ break;
+ case GSMTAP_CHANNEL_RACH: // RACH
+ *rsl_chantype = RSL_CHAN_RACH;
+ break;
+ case GSMTAP_CHANNEL_PCH: // PCH
+ case GSMTAP_CHANNEL_AGCH: // AGCH
+ *rsl_chantype = RSL_CHAN_PCH_AGCH;
+ break;
+ case GSMTAP_CHANNEL_PDCH:
+ *rsl_chantype = GSMTAP_CHANNEL_PDCH;
+ break;
+ }
+
+ *link_id = gsmtap_chantype & GSMTAP_CHANNEL_ACCH ? 0x40 : 0x00;
+}
+
/*! create an arbitrary type GSMTAP message
* \param[in] type The GSMTAP_TYPE_xxx constant of the message to create
* \param[in] arfcn GSM ARFCN (Channel Number)