summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2013-06-01 16:46:39 +0200
committerAndreas Eversberg <jolly@eversberg.eu>2013-07-29 12:44:24 +0200
commit63b8eafbd5cb91ee29e4104465229f20af517a59 (patch)
tree15f429735d1c66b2bc9d2b3f0b99a4cba4b20add
parentf6e66a1441297abbd36d2a30fd0a06fd9527b430 (diff)
HO: Count the actual meas.rep. get_meas_rep_avg fails if not reached
get_meas_rep_avg will return -EINVAL, if the required number of measurements are not reached. There will be no handover possible until the given number of measurements are available.
-rw-r--r--openbsc/include/openbsc/gsm_data_shared.h1
-rw-r--r--openbsc/src/libbsc/abis_rsl.c1
-rw-r--r--openbsc/src/libbsc/chan_alloc.c4
-rw-r--r--openbsc/src/libbsc/meas_rep.c5
4 files changed, 10 insertions, 1 deletions
diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h
index 2d8562092..f57fae545 100644
--- a/openbsc/include/openbsc/gsm_data_shared.h
+++ b/openbsc/include/openbsc/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/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c
index 23836c73f..1c34b9e1f 100644
--- a/openbsc/src/libbsc/abis_rsl.c
+++ b/openbsc/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/openbsc/src/libbsc/chan_alloc.c b/openbsc/src/libbsc/chan_alloc.c
index 5a7b3f42e..6396ebb51 100644
--- a/openbsc/src/libbsc/chan_alloc.c
+++ b/openbsc/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/openbsc/src/libbsc/meas_rep.c b/openbsc/src/libbsc/meas_rep.c
index 808103d28..2a8d5ac5e 100644
--- a/openbsc/src/libbsc/meas_rep.c
+++ b/openbsc/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);