From 29aca17ed0f33aa0f8ce646425425b6b57892025 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 15 Jun 2010 16:45:51 +0200 Subject: [BSC] Hopping: Add MA IE to ASS CMD, IMM ASS CMD and HO CMD Also, make sure the bit ordering in the pre-computed MA is correct, as well as the cell channel description of the target cell being present in the HO CMD. --- openbsc/src/bsc_init.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'openbsc/src/bsc_init.c') diff --git a/openbsc/src/bsc_init.c b/openbsc/src/bsc_init.c index 0066811a0..8e4aafd7d 100644 --- a/openbsc/src/bsc_init.c +++ b/openbsc/src/bsc_init.c @@ -940,32 +940,51 @@ static int generate_ma_for_ts(struct gsm_bts_trx_ts *ts) struct bitvec *cell_chan = &ts->trx->bts->si_common.cell_alloc; struct bitvec *ts_arfcn = &ts->hopping.arfcns; struct bitvec *ma = &ts->hopping.ma; + unsigned int num_cell_arfcns, bitnum, n_chan; int i; /* re-set the MA to all-zero */ ma->cur_bit = 0; + ts->hopping.ma_len = 0; memset(ma->data, 0, ma->data_len); if (!ts->hopping.enabled) return 0; + /* count the number of ARFCNs in the cell channel allocation */ + num_cell_arfcns = 0; + for (i = 1; i < 1024; i++) { + if (bitvec_get_bit_pos(cell_chan, i)) + num_cell_arfcns++; + } + + /* pad it to octet-aligned number of bits */ + ts->hopping.ma_len = num_cell_arfcns / 8; + if (num_cell_arfcns % 8) + ts->hopping.ma_len++; + + n_chan = 0; for (i = 1; i < 1024; i++) { if (!bitvec_get_bit_pos(cell_chan, i)) continue; - /* append a bit to the MA */ + n_chan++; + /* set the corresponding bit in the MA */ + bitnum = (ts->hopping.ma_len * 8) - 1 - n_chan; if (bitvec_get_bit_pos(ts_arfcn, i)) - bitvec_set_bit(ma, 1); + bitvec_set_bit_pos(ma, bitnum, 1); else - bitvec_set_bit(ma, 0); + bitvec_set_bit_pos(ma, bitnum, 0); } /* ARFCN 0 is special: It is coded last in the bitmask */ if (bitvec_get_bit_pos(cell_chan, 0)) { - /* append a bit to the MA */ + n_chan++; + /* set the corresponding bit in the MA */ + bitnum = (ts->hopping.ma_len * 8) - 1 - n_chan; if (bitvec_get_bit_pos(ts_arfcn, 0)) - bitvec_set_bit(ma, 1); + bitvec_set_bit_pos(ma, bitnum, 1); else - bitvec_set_bit(ma, 0); + bitvec_set_bit_pos(ma, bitnum, 0); } return 0; -- cgit v1.2.3