From fec682b45ba33009697d1f232460e861884b67a3 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Mon, 2 Oct 2023 19:09:20 +0200 Subject: [PATCH] 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 --- include/osmocom/bsc/gsm_04_08_rr.h | 2 ++ src/osmo-bsc/gsm_04_08_rr.c | 41 +++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/include/osmocom/bsc/gsm_04_08_rr.h b/include/osmocom/bsc/gsm_04_08_rr.h index 9a9956b95..75930baae 100644 --- a/include/osmocom/bsc/gsm_04_08_rr.h +++ b/include/osmocom/bsc/gsm_04_08_rr.h @@ -2,6 +2,7 @@ #include #include +#include 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); diff --git a/src/osmo-bsc/gsm_04_08_rr.c b/src/osmo-bsc/gsm_04_08_rr.c index 2c9f7e92a..194432125 100644 --- a/src/osmo-bsc/gsm_04_08_rr.c +++ b/src/osmo-bsc/gsm_04_08_rr.c @@ -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 */