04.08 MEAS REP: Convert relative cell number to ARFCN

Since we are keeping a bitvec of the neighbor cells, we can now use
bitvec_get_nth_set_bit() to determine the ARFCN for each reported
cell in the 04.08 MEASUREMENT REPORT.
This commit is contained in:
Harald Welte 2009-12-14 22:24:28 +01:00
parent 7f73a1ac58
commit f1dae1924a
2 changed files with 12 additions and 7 deletions

View File

@ -4,8 +4,8 @@
/* extracted from a L3 measurement report IE */
struct gsm_meas_rep_cell {
u_int8_t rxlev;
u_int8_t bcch_freq; /* FIXME: translate to ARFCN */
u_int8_t bsic;
u_int16_t arfcn;
};
/* RX Level and RX Quality */

View File

@ -32,6 +32,7 @@
#include <openbsc/db.h>
#include <openbsc/msgb.h>
#include <openbsc/bitvec.h>
#include <openbsc/tlv.h>
#include <openbsc/debug.h>
#include <openbsc/gsm_data.h>
@ -171,6 +172,8 @@ int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg)
struct gsm48_hdr *gh = msgb_l3(msg);
unsigned int payload_len = msgb_l3len(msg) - sizeof(*gh);
u_int8_t *data = gh->data;
struct gsm_bts *bts = msg->lchan->ts->trx->bts;
struct bitvec *nbv = &bts->si_common.neigh_list;
if (gh->msg_type != GSM48_MT_RR_MEAS_REP)
return -EINVAL;
@ -194,37 +197,39 @@ int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg)
/* an encoding nightmare in perfection */
rep->cell[0].rxlev = data[4] & 0x3f;
rep->cell[0].bcch_freq = data[5] >> 2;
rep->cell[0].arfcn = bitvec_get_nth_set_bit(nbv, data[5] >> 2);
rep->cell[0].bsic = ((data[5] & 0x03) << 3) | (data[6] >> 5);
if (rep->num_cell < 2)
return 0;
rep->cell[1].rxlev = ((data[6] & 0x1f) << 1) | (data[7] >> 7);
rep->cell[1].bcch_freq = (data[7] >> 2) & 0x1f;
rep->cell[1].arfcn = bitvec_get_nth_set_bit(nbv, (data[7] >> 2) & 0x1f);
rep->cell[1].bsic = ((data[7] & 0x03) << 4) | (data[8] >> 4);
if (rep->num_cell < 3)
return 0;
rep->cell[2].rxlev = ((data[8] & 0x0f) << 2) | (data[9] >> 6);
rep->cell[2].bcch_freq = (data[9] >> 1) & 0x1f;
rep->cell[2].arfcn = bitvec_get_nth_set_bit(nbv, (data[9] >> 1) & 0x1f);
rep->cell[2].bsic = ((data[9] & 0x01) << 6) | (data[10] >> 3);
if (rep->num_cell < 4)
return 0;
rep->cell[3].rxlev = ((data[10] & 0x07) << 3) | (data[11] >> 5);
rep->cell[3].bcch_freq = data[11] & 0x1f;
rep->cell[3].arfcn = bitvec_get_nth_set_bit(nbv, data[11] & 0x1f);
rep->cell[3].bsic = data[12] >> 2;
if (rep->num_cell < 5)
return 0;
rep->cell[4].rxlev = ((data[12] & 0x03) << 4) | (data[13] >> 4);
rep->cell[4].bcch_freq = ((data[13] & 0xf) << 1) | (data[14] >> 7);
rep->cell[4].arfcn = bitvec_get_nth_set_bit(nbv,
((data[13] & 0xf) << 1) | (data[14] >> 7));
rep->cell[4].bsic = (data[14] >> 1) & 0x3f;
if (rep->num_cell < 6)
return 0;
rep->cell[5].rxlev = ((data[14] & 0x01) << 5) | (data[15] >> 3);
rep->cell[5].bcch_freq = ((data[15] & 0x07) << 2) | (data[16] >> 6);
rep->cell[5].arfcn = bitvec_get_nth_set_bit(nbv,
((data[15] & 0x07) << 2) | (data[16] >> 6));
rep->cell[5].bsic = data[16] & 0x3f;
return 0;