aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/bsc/gsm_data_shared.h1
-rw-r--r--src/libbsc/abis_rsl.c1
-rw-r--r--src/libbsc/chan_alloc.c4
-rw-r--r--src/libbsc/meas_rep.c5
4 files changed, 10 insertions, 1 deletions
diff --git a/include/osmocom/bsc/gsm_data_shared.h b/include/osmocom/bsc/gsm_data_shared.h
index 2d8562092..f57fae545 100644
--- a/include/osmocom/bsc/gsm_data_shared.h
+++ b/include/osmocom/bsc/gsm_data_shared.h
@@ -248,6 +248,7 @@ struct gsm_lchan {
/* cache of last measurement reports on this lchan */
struct gsm_meas_rep meas_rep[6];
int meas_rep_idx;
+ int meas_rep_cnt;
/* GSM Random Access data */
struct gsm48_req_ref *rqd_ref;
diff --git a/src/libbsc/abis_rsl.c b/src/libbsc/abis_rsl.c
index 23836c73f..1c34b9e1f 100644
--- a/src/libbsc/abis_rsl.c
+++ b/src/libbsc/abis_rsl.c
@@ -1073,6 +1073,7 @@ static int rsl_rx_meas_res(struct msgb *msg)
memset(mr, 0, sizeof(*mr));
mr->lchan = msg->lchan;
+ mr->lchan->meas_rep_cnt++;
rsl_tlv_parse(&tp, dh->data, msgb_l2len(msg)-sizeof(*dh));
diff --git a/src/libbsc/chan_alloc.c b/src/libbsc/chan_alloc.c
index 5a7b3f42e..6396ebb51 100644
--- a/src/libbsc/chan_alloc.c
+++ b/src/libbsc/chan_alloc.c
@@ -323,6 +323,10 @@ struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type,
if (lchan) {
lchan->type = type;
+ /* reset measuement report counter and index */
+ lchan->meas_rep_cnt = 0;
+ lchan->meas_rep_idx = 0;
+
/* clear sapis */
memset(lchan->sapis, 0, ARRAY_SIZE(lchan->sapis));
diff --git a/src/libbsc/meas_rep.c b/src/libbsc/meas_rep.c
index 808103d28..2a8d5ac5e 100644
--- a/src/libbsc/meas_rep.c
+++ b/src/libbsc/meas_rep.c
@@ -75,7 +75,10 @@ int get_meas_rep_avg(const struct gsm_lchan *lchan,
int avg = 0;
if (num < 1)
- return 0;
+ return -EINVAL;
+
+ if (num > lchan->meas_rep_cnt)
+ return -EINVAL;
idx = calc_initial_idx(ARRAY_SIZE(lchan->meas_rep),
lchan->meas_rep_idx, num);