ASCI: Make neigh_list_get_arfcn() available to other users

The error logging message within this function is moved to the user
neigh_list_get_arfcn().

In case of an error, which results in measurement report with cell
index that does not exist in the list of neigbor cells, the measurement
report is truncated to 0 neighbor cell measurements.

Change-Id: Ia8a1dca4837536129d17e7784b892bcb75b9ca4b
This commit is contained in:
Andreas Eversberg 2023-10-02 19:09:20 +02:00
parent d561e2dcba
commit fec682b45b
2 changed files with 34 additions and 9 deletions

View File

@ -2,6 +2,7 @@
#include <stdint.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/bitvec.h>
enum handover_scope;
@ -37,6 +38,7 @@ int gsm48_send_uplink_release(struct gsm_lchan *lchan, uint8_t cause);
int gsm48_send_uplink_busy(struct gsm_lchan *lchan);
int gsm48_send_uplink_free(struct gsm_lchan *lchan, uint8_t acc_bit, uint8_t *uic);
int gsm48_rx_rr_modif_ack(struct msgb *msg);
int neigh_list_get_arfcn(struct gsm_bts *bts, const struct bitvec *nbv, unsigned int idx);
int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg);
struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value);

View File

@ -854,7 +854,7 @@ int gsm48_rx_rr_modif_ack(struct msgb *msg)
* 2) SI*ter entries (if available)
* ARFCN 0 is at the end of each sub list.
* Both sub lists are stored in one bitvec (nbv), iterate twice through it. */
static int neigh_list_get_arfcn(struct gsm_bts *bts, const struct bitvec *nbv, unsigned int idx)
int neigh_list_get_arfcn(struct gsm_bts *bts, const struct bitvec *nbv, unsigned int idx)
{
unsigned int arfcn, i = 0;
@ -893,8 +893,7 @@ static int neigh_list_get_arfcn(struct gsm_bts *bts, const struct bitvec *nbv, u
if (bitvec_get_bit_pos(nbv, 0) == ONE && !band_compatible(bts, 0) && i == idx)
return 0;
LOGP(DRR, LOGL_ERROR, "Invalid BCCH channel list index %d in measurement report\n", idx);
return 0;
return -EINVAL;
}
int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg)
@ -904,6 +903,7 @@ int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg)
struct gsm_bts *bts = msg->lchan->ts->trx->bts;
struct bitvec *nbv;
struct gsm_meas_rep_cell *mrc;
int rc;
if (gh->msg_type != GSM48_MT_RR_MEAS_REP)
return -EINVAL;
@ -938,7 +938,10 @@ int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg)
mrc = &rep->cell[0];
mrc->rxlev = data[3] & 0x3f;
mrc->neigh_idx = data[4] >> 3;
mrc->arfcn = neigh_list_get_arfcn(bts, nbv, mrc->neigh_idx);
rc = neigh_list_get_arfcn(bts, nbv, mrc->neigh_idx);
if (rc < 0)
goto error;
mrc->arfcn = rc;
mrc->bsic = ((data[4] & 0x07) << 3) | (data[5] >> 5);
if (rep->num_cell < 2)
return 0;
@ -946,7 +949,10 @@ int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg)
mrc = &rep->cell[1];
mrc->rxlev = ((data[5] & 0x1f) << 1) | (data[6] >> 7);
mrc->neigh_idx = (data[6] >> 2) & 0x1f;
mrc->arfcn = neigh_list_get_arfcn(bts, nbv, mrc->neigh_idx);
rc = neigh_list_get_arfcn(bts, nbv, mrc->neigh_idx);
if (rc < 0)
goto error;
mrc->arfcn = rc;
mrc->bsic = ((data[6] & 0x03) << 4) | (data[7] >> 4);
if (rep->num_cell < 3)
return 0;
@ -954,7 +960,10 @@ int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg)
mrc = &rep->cell[2];
mrc->rxlev = ((data[7] & 0x0f) << 2) | (data[8] >> 6);
mrc->neigh_idx = (data[8] >> 1) & 0x1f;
mrc->arfcn = neigh_list_get_arfcn(bts, nbv, mrc->neigh_idx);
rc = neigh_list_get_arfcn(bts, nbv, mrc->neigh_idx);
if (rc < 0)
goto error;
mrc->arfcn = rc;
mrc->bsic = ((data[8] & 0x01) << 5) | (data[9] >> 3);
if (rep->num_cell < 4)
return 0;
@ -962,7 +971,10 @@ int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg)
mrc = &rep->cell[3];
mrc->rxlev = ((data[9] & 0x07) << 3) | (data[10] >> 5);
mrc->neigh_idx = data[10] & 0x1f;
mrc->arfcn = neigh_list_get_arfcn(bts, nbv, mrc->neigh_idx);
rc = neigh_list_get_arfcn(bts, nbv, mrc->neigh_idx);
if (rc < 0)
goto error;
mrc->arfcn = rc;
mrc->bsic = data[11] >> 2;
if (rep->num_cell < 5)
return 0;
@ -970,7 +982,10 @@ int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg)
mrc = &rep->cell[4];
mrc->rxlev = ((data[11] & 0x03) << 4) | (data[12] >> 4);
mrc->neigh_idx = ((data[12] & 0xf) << 1) | (data[13] >> 7);
mrc->arfcn = neigh_list_get_arfcn(bts, nbv, mrc->neigh_idx);
rc = neigh_list_get_arfcn(bts, nbv, mrc->neigh_idx);
if (rc < 0)
goto error;
mrc->arfcn = rc;
mrc->bsic = (data[13] >> 1) & 0x3f;
if (rep->num_cell < 6)
return 0;
@ -978,10 +993,18 @@ int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg)
mrc = &rep->cell[5];
mrc->rxlev = ((data[13] & 0x01) << 5) | (data[14] >> 3);
mrc->neigh_idx = ((data[14] & 0x07) << 2) | (data[15] >> 6);
mrc->arfcn = neigh_list_get_arfcn(bts, nbv, mrc->neigh_idx);
rc = neigh_list_get_arfcn(bts, nbv, mrc->neigh_idx);
if (rc < 0)
goto error;
mrc->arfcn = rc;
mrc->bsic = data[15] & 0x3f;
return 0;
error:
LOGP(DRR, LOGL_ERROR, "Invalid BCCH channel list index %d in measurement report\n", mrc->neigh_idx);
rep->num_cell = 0;
return 0;
}
/* 9.1.29 RR Status */