jolly has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/34625?usp=email )

Change subject: ASCI: Make neigh_list_get_arfcn() available to other users
......................................................................

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
---
M include/osmocom/bsc/gsm_04_08_rr.h
M src/osmo-bsc/gsm_04_08_rr.c
2 files changed, 50 insertions(+), 9 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  fixeria: Looks good to me, approved




diff --git a/include/osmocom/bsc/gsm_04_08_rr.h 
b/include/osmocom/bsc/gsm_04_08_rr.h
index 9a9956b..75930ba 100644
--- a/include/osmocom/bsc/gsm_04_08_rr.h
+++ b/include/osmocom/bsc/gsm_04_08_rr.h
@@ -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_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 2c9f7e9..1944321 100644
--- a/src/osmo-bsc/gsm_04_08_rr.c
+++ b/src/osmo-bsc/gsm_04_08_rr.c
@@ -854,7 +854,7 @@
  *   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 @@
        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 @@
        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 @@
        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 @@
        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 @@
        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 @@
        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 @@
        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 @@
        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 */

--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/34625?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Ia8a1dca4837536129d17e7784b892bcb75b9ca4b
Gerrit-Change-Number: 34625
Gerrit-PatchSet: 4
Gerrit-Owner: jolly <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: jolly <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to