summaryrefslogtreecommitdiffstats
path: root/src/shared/libosmocore
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-03-04 14:58:44 +0100
committerHarald Welte <laforge@gnumonks.org>2010-03-04 14:58:44 +0100
commitdec5ab7c7beaa1ce86fcc895fdb1838e4b9493e3 (patch)
tree8743177763182dc3c099219dc5564b23b90245c6 /src/shared/libosmocore
parenta5cdce1503cfbd0b4afdc16ae8fa27181009c9a1 (diff)
parent6fec514d7bcf8e6fe469d31ccc13d5cd473058a4 (diff)
Merge commit '6fec514d7bcf8e6fe469d31ccc13d5cd473058a4'
Diffstat (limited to 'src/shared/libosmocore')
-rw-r--r--src/shared/libosmocore/include/osmocore/rsl.h2
-rw-r--r--src/shared/libosmocore/src/rsl.c34
2 files changed, 36 insertions, 0 deletions
diff --git a/src/shared/libosmocore/include/osmocore/rsl.h b/src/shared/libosmocore/include/osmocore/rsl.h
index 0da05206..4c5f75b8 100644
--- a/src/shared/libosmocore/include/osmocore/rsl.h
+++ b/src/shared/libosmocore/include/osmocore/rsl.h
@@ -13,6 +13,8 @@ extern const struct tlv_definition rsl_att_tlvdef;
/* encode channel number as per Section 9.3.1 */
uint8_t rsl_enc_chan_nr(uint8_t type, uint8_t subch, uint8_t timeslot);
+/* decode channel number as per Section 9.3.1 */
+int rsl_dec_chan_nr(uint8_t chan_nr, uint8_t *type, uint8_t *subch, uint8_t *timeslot);
const struct value_string rsl_rlm_cause_strs[];
diff --git a/src/shared/libosmocore/src/rsl.c b/src/shared/libosmocore/src/rsl.c
index 58afc9de..c864b12f 100644
--- a/src/shared/libosmocore/src/rsl.c
+++ b/src/shared/libosmocore/src/rsl.c
@@ -21,6 +21,9 @@
*
*/
+#include <stdint.h>
+#include <errno.h>
+
#include <osmocore/tlv.h>
#include <osmocore/rsl.h>
@@ -142,6 +145,37 @@ uint8_t rsl_enc_chan_nr(uint8_t type, uint8_t subch, uint8_t timeslot)
return ret;
}
+int rsl_dec_chan_nr(uint8_t chan_nr, uint8_t *type, uint8_t *subch, uint8_t *timeslot)
+{
+ *timeslot = chan_nr & 0x7;
+
+ if ((chan_nr & 0xf8) == RSL_CHAN_Bm_ACCHs) {
+ *type = RSL_CHAN_Bm_ACCHs;
+ *subch = 0;
+ } else if ((chan_nr & 0xf0) == RSL_CHAN_Lm_ACCHs) {
+ *type = RSL_CHAN_Lm_ACCHs;
+ *subch = (chan_nr >> 3) & 0x1;
+ } else if ((chan_nr & 0xe0) == RSL_CHAN_SDCCH4_ACCH) {
+ *type = RSL_CHAN_SDCCH4_ACCH;
+ *subch = (chan_nr >> 3) & 0x3;
+ } else if ((chan_nr & 0xc0) == RSL_CHAN_SDCCH8_ACCH) {
+ *type = RSL_CHAN_SDCCH8_ACCH;
+ *subch = (chan_nr >> 3) & 0x7;
+ } else if ((chan_nr & 0xf8) == RSL_CHAN_BCCH) {
+ *type = RSL_CHAN_BCCH;
+ *subch = 0;
+ } else if ((chan_nr & 0xf8) == RSL_CHAN_RACH) {
+ *type = RSL_CHAN_RACH;
+ *subch = 0;
+ } else if ((chan_nr & 0xf8) == RSL_CHAN_PCH_AGCH) {
+ *type = RSL_CHAN_PCH_AGCH;
+ *subch = 0;
+ } else
+ return -EINVAL;
+
+ return 0;
+}
+
/* FIXME: convert to value_string */
static const char *rsl_err_vals[0xff] = {
[RSL_ERR_RADIO_IF_FAIL] = "Radio Interface Failure",