diff options
author | Harald Welte <laforge@gnumonks.org> | 2018-09-17 20:45:54 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2018-09-17 21:36:59 +0200 |
commit | 3c87f5c3eaf28f7d18fccae86cc75027b67acea7 (patch) | |
tree | 1bdcdd7a420374fd283945f8e9e4631f2c1318a9 /src/common/l1sap.c | |
parent | 3941cf44795f928046968036b180e478b7725ac8 (diff) |
get_lchan_by_chan_nr(): Fix resolution of CBCH
The CBCH (as per GSM specs) always maps on sub-slot 2 of either
the SDCCH/4 or SDCCH/8 that it replaces. However, the way how we
express it as RSL-style channel number (0xC8) doesn't allow room
for any sub-slots. The top 5 bits are used for expressing CBCH, while
the bottom 3 bits are used for the timeslot number (TN).
So when transforming from channel number to lchan, we must handle the
CBCH case specially by using a hard-coded sub-slot number of 2.
Change-Id: I44e2f763d5d25311167f435f2ca7e030b2a3f009
Related: OS#1617
Diffstat (limited to 'src/common/l1sap.c')
-rw-r--r-- | src/common/l1sap.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/common/l1sap.c b/src/common/l1sap.c index 1a7a965a..ac4f0bea 100644 --- a/src/common/l1sap.c +++ b/src/common/l1sap.c @@ -58,7 +58,18 @@ struct gsm_lchan *get_lchan_by_chan_nr(struct gsm_bts_trx *trx, unsigned int chan_nr) { - return &trx->ts[L1SAP_CHAN2TS(chan_nr)].lchan[l1sap_chan2ss(chan_nr)]; + unsigned int tn, ss; + + tn = L1SAP_CHAN2TS(chan_nr); + OSMO_ASSERT(tn < ARRAY_SIZE(trx->ts)); + + if (L1SAP_IS_CHAN_CBCH(chan_nr)) + ss = 2; /* CBCH is always on sub-slot 2 */ + else + ss = l1sap_chan2ss(chan_nr); + OSMO_ASSERT(ss < ARRAY_SIZE(trx->ts[tn].lchan)); + + return &trx->ts[tn].lchan[ss]; } static struct gsm_lchan * |