diff options
author | Harald Welte <laforge@gnumonks.org> | 2010-03-04 14:27:48 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-03-04 14:27:48 +0100 |
commit | ecf9dd0d9680882b7c9df5e9bdfdb3dd58a069ac (patch) | |
tree | 2ed02cb8cd8659c882a913c3e18fbbdd6aa8fb3d /src | |
parent | 61e2bfc5f44267a7a3b0b25ff3ab922fca2a199c (diff) |
add new rsl_dec_chan_nr() function
Diffstat (limited to 'src')
-rw-r--r-- | src/rsl.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -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 == 0x10) { + *type = RSL_CHAN_BCCH; + *subch = 0; + } else if (chan_nr == 0x11) { + *type = RSL_CHAN_RACH; + *subch = 0; + } else if (chan_nr == 0x12) { + *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", |