aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-01-17 12:04:17 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-01-17 19:30:05 +0100
commit9e1952a9011dbd81e28c59d4bc986d1344c1bfb0 (patch)
treeeec244268722ea623bfc794e34bd9596399c91ad
parent164ee307b20aca437d941f76fbc2f5c25a2b88ec (diff)
si: Share the ARFCN selection condition between the two statements
This makes reading the condition more easy and allows me to fix it for GSM1900 more easily and I can remove one level of indention.
-rw-r--r--openbsc/src/libbsc/system_information.c67
1 files changed, 37 insertions, 30 deletions
diff --git a/openbsc/src/libbsc/system_information.c b/openbsc/src/libbsc/system_information.c
index 702924135..dbee249e8 100644
--- a/openbsc/src/libbsc/system_information.c
+++ b/openbsc/src/libbsc/system_information.c
@@ -38,6 +38,18 @@
#include <openbsc/arfcn_range_encode.h>
+static int use_arfcn(const struct gsm_bts *bts, const int bis, const int ter,
+ const int pgsm, const int arfcn)
+{
+ if (!bis && !ter && gsm_arfcn2band(arfcn) == bts->band)
+ return 1;
+ if (bis && pgsm && gsm_arfcn2band(arfcn) == bts->band && (arfcn < 1 || arfcn > 124))
+ return 1;
+ if (ter && gsm_arfcn2band(arfcn) != bts->band)
+ return 1;
+ return 0;
+}
+
/* Frequency Lists as per TS 04.08 10.5.2.13 */
/* 10.5.2.13.2: Bit map 0 format */
@@ -138,12 +150,8 @@ static int enc_freq_lst_range(uint8_t *chan_list,
if (arfcns_used > ARRAY_SIZE(arfcns))
return -1;
/* Check if we can select it? */
- if (bitvec_get_bit_pos(bv, i)
- && ((!bis && !ter && gsm_arfcn2band(i) == bts->band)
- || (bis && pgsm && gsm_arfcn2band(i) == bts->band && (i < 1 || i > 124))
- || (ter && gsm_arfcn2band(i) != bts->band))) {
+ if (bitvec_get_bit_pos(bv, i) && use_arfcn(bts, bis, ter, pgsm, i))
arfcns[arfcns_used++] = i;
- }
}
/*
@@ -215,31 +223,30 @@ static int bitvec2freq_list(uint8_t *chan_list, struct bitvec *bv,
* in case of SI*bis, allow neighbours in same band ouside pgsm
* in case of SI*ter, allow neighbours in different bands
*/
- if (bitvec_get_bit_pos(bv, i)
- && ((!bis && !ter && gsm_arfcn2band(i) == bts->band)
- || (bis && pgsm && gsm_arfcn2band(i) == bts->band && (i < 1 || i > 124))
- || (ter && gsm_arfcn2band(i) != bts->band))) {
- /* count the arfcns we want to carry */
- arfcns += 1;
-
- /* 955..1023 < 0..885 */
- if (min < 0)
- min = i;
- if (i >= 955 && min < 955)
- min = i;
- if (i >= 955 && min >= 955 && i < min)
- min = i;
- if (i < 955 && min < 955 && i < min)
- min = i;
- if (max < 0)
- max = i;
- if (i < 955 && max >= 955)
- max = i;
- if (i >= 955 && max >= 955 && i > max)
- max = i;
- if (i < 955 && max < 955 && i > max)
- max = i;
- }
+ if (!bitvec_get_bit_pos(bv, i))
+ continue;
+ if (!use_arfcn(bts, bis, ter, pgsm, i))
+ continue;
+ /* count the arfcns we want to carry */
+ arfcns += 1;
+
+ /* 955..1023 < 0..885 */
+ if (min < 0)
+ min = i;
+ if (i >= 955 && min < 955)
+ min = i;
+ if (i >= 955 && min >= 955 && i < min)
+ min = i;
+ if (i < 955 && min < 955 && i < min)
+ min = i;
+ if (max < 0)
+ max = i;
+ if (i < 955 && max >= 955)
+ max = i;
+ if (i >= 955 && max >= 955 && i > max)
+ max = i;
+ if (i < 955 && max < 955 && i > max)
+ max = i;
}
if (max == -1) {