aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-05-18 13:04:47 +0200
committerHolger Freyther <holger@freyther.de>2016-05-31 09:32:12 +0000
commit69e9c0dfc6cc10c07d03f8800d8ff7197fe97c8b (patch)
treed54d4a96e6ed18afe30e7c9d870a5586ea758a9f
parent82dd983dd85c04b5aa013365334f2a249140902e (diff)
Make si2q scheduling optional
Previously si2quater SI messages were always scheduled. Check for neighbor configuration and only schedule si2q when necessary. Add corresponding unit test. Change-Id: Ibe997803ffb894133fd4d838410fe735791d414f Fixes: OS#1727 Reviewed-on: https://gerrit.osmocom.org/81 Tested-by: Jenkins Builder Reviewed-by: Holger Freyther <holger@freyther.de>
-rw-r--r--openbsc/src/libbsc/system_information.c10
-rw-r--r--openbsc/tests/gsm0408/gsm0408_test.c17
-rw-r--r--openbsc/tests/gsm0408/gsm0408_test.ok32
3 files changed, 40 insertions, 19 deletions
diff --git a/openbsc/src/libbsc/system_information.c b/openbsc/src/libbsc/system_information.c
index d40bbaf5..fd228e39 100644
--- a/openbsc/src/libbsc/system_information.c
+++ b/openbsc/src/libbsc/system_information.c
@@ -648,7 +648,7 @@ static int generate_si2ter(uint8_t *output, struct gsm_bts *bts)
static int generate_si2quater(uint8_t *output, struct gsm_bts *bts)
{
- int rc;
+ int rc, i = MAX_EARFCN_LIST;
struct gsm48_system_information_type_2quater *si2q =
(struct gsm48_system_information_type_2quater *) output;
@@ -667,6 +667,14 @@ static int generate_si2quater(uint8_t *output, struct gsm_bts *bts)
if (rc < 0)
return rc;
+ if (bts->si_common.si2quater_neigh_list.arfcn)
+ for (i = 0; i < MAX_EARFCN_LIST; i++)
+ if (bts->si_common.si2quater_neigh_list.arfcn[i] !=
+ OSMO_EARFCN_INVALID)
+ break;
+ if (!bts->si_common.uarfcn_length && i == MAX_EARFCN_LIST)
+ bts->si_valid &= ~(1 << SYSINFO_TYPE_2quater);
+
return sizeof(*si2q) + rc;
}
diff --git a/openbsc/tests/gsm0408/gsm0408_test.c b/openbsc/tests/gsm0408/gsm0408_test.c
index 92626670..7acc93f9 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.c
+++ b/openbsc/tests/gsm0408/gsm0408_test.c
@@ -21,7 +21,7 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
-
+#include <stdbool.h>
#include <arpa/inet.h>
#include <openbsc/gsm_04_08.h>
@@ -95,9 +95,15 @@ static inline void add_arfcn_b(struct osmo_earfcn_si2q *e, uint16_t earfcn,
static inline void gen(struct gsm_bts *bts)
{
+ bts->si_valid = 0;
+ bts->si_valid |= (1 << SYSINFO_TYPE_2quater);
+ /* should be no-op as entire buffer is filled with padding: */
+ memset(bts->si_buf[SYSINFO_TYPE_2quater], 0xAE, GSM_MACBLOCK_LEN);
int r = gsm_generate_si(bts, SYSINFO_TYPE_2quater);
+ bool v = bts->si_valid & (1 << SYSINFO_TYPE_2quater);
if (r > 0)
- printf("generated SI2quater: [%d] %s\n", r,
+ printf("generated %s SI2quater: [%d] %s\n",
+ v ? "valid" : "invalid", r,
osmo_hexdump(bts->si_buf[SYSINFO_TYPE_2quater], r));
else
printf("failed to generate SI2quater: %s\n", strerror(-r));
@@ -123,6 +129,9 @@ static inline void test_si2q_u(void)
exit(1);
bts = gsm_bts_alloc(network);
+ /* first generate invalid SI as no UARFCN added */
+ gen(bts);
+ /* subsequent calls should produce valid SI if there's enough memory */
_bts_uarfcn_add(bts, 1982, 13, 1);
_bts_uarfcn_add(bts, 1982, 44, 0);
_bts_uarfcn_add(bts, 1982, 61, 1);
@@ -155,7 +164,9 @@ static inline void test_si2q_e(void)
bts->si_common.si2quater_neigh_list.thresh_hi = 5;
osmo_earfcn_init(&bts->si_common.si2quater_neigh_list);
-
+ /* first generate invalid SI as no EARFCN added */
+ gen(bts);
+ /* subsequent calls should produce valid SI if there's enough memory */
add_arfcn_b(&bts->si_common.si2quater_neigh_list, 1917, 1);
gen(bts);
diff --git a/openbsc/tests/gsm0408/gsm0408_test.ok b/openbsc/tests/gsm0408/gsm0408_test.ok
index 7b7a2cc7..ebe94762 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.ok
+++ b/openbsc/tests/gsm0408/gsm0408_test.ok
@@ -63,24 +63,26 @@ Allocated reference: 255
Allocated reference: 0
Allocated reference: 1
Testing SYSINFO_TYPE_2quater EARFCN generation:
-added EARFCN 1917 - generated SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be c8 50 0b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
-added EARFCN 1932 - generated SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 30 14 03 2b 2b 2b 2b 2b 2b 2b 2b
-added EARFCN 1937 - generated SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 31 07 91 a0 a0 2b 2b 2b 2b 2b 2b
-added EARFCN 1945 - generated SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 31 07 91 a8 3c c8 28 0b 2b 2b 2b
-added EARFCN 1965 - generated SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 31 07 91 a8 3c ca 0f 5a 0a 03 2b
+generated invalid SI2quater: [23] 59 06 07 c0 00 04 86 59 0a 03 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
+added EARFCN 1917 - generated valid SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be c8 50 0b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
+added EARFCN 1932 - generated valid SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 30 14 03 2b 2b 2b 2b 2b 2b 2b 2b
+added EARFCN 1937 - generated valid SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 31 07 91 a0 a0 2b 2b 2b 2b 2b 2b
+added EARFCN 1945 - generated valid SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 31 07 91 a8 3c c8 28 0b 2b 2b 2b
+added EARFCN 1965 - generated valid SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 31 07 91 a8 3c ca 0f 5a 0a 03 2b
added EARFCN 1967 - failed to generate SI2quater: Cannot allocate memory
added EARFCN 1982 - failed to generate SI2quater: Cannot allocate memory
Testing SYSINFO_TYPE_2quater UARFCN generation:
-generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 0c 1a 10 99 64 00 0b 2b 2b 2b 2b 2b 2b 2b 2b
-generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 14 1a 1f 00 44 b2 00 03 2b 2b 2b 2b 2b 2b 2b
-generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 18 58 12 f0 84 86 59 00 03 2b 2b 2b 2b 2b 2b
-generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 20 58 2e f0 f2 04 86 59 00 03 2b 2b 2b 2b 2b
-generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 28 58 2e 22 f2 4e 84 86 59 00 03 2b 2b 2b 2b
-generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 34 1a 64 26 5d f2 05 04 86 59 00 03 2b 2b 2b
-generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 38 58 12 22 fd ce 8e 05 04 86 59 00 03 2b 2b
-generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 40 58 1d 22 fa ce 88 85 7b 00 44 b2 00 03 2b
-generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 4c 7a 34 0e 64 77 85 43 55 c8 10 99 64 00 0b
+generated invalid SI2quater: [23] 59 06 07 c0 00 04 86 59 00 03 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
+generated valid SI2quater: [23] 59 06 07 c0 00 25 0f 7c 0c 1a 10 99 64 00 0b 2b 2b 2b 2b 2b 2b 2b 2b
+generated valid SI2quater: [23] 59 06 07 c0 00 25 0f 7c 14 1a 1f 00 44 b2 00 03 2b 2b 2b 2b 2b 2b 2b
+generated valid SI2quater: [23] 59 06 07 c0 00 25 0f 7c 18 58 12 f0 84 86 59 00 03 2b 2b 2b 2b 2b 2b
+generated valid SI2quater: [23] 59 06 07 c0 00 25 0f 7c 20 58 2e f0 f2 04 86 59 00 03 2b 2b 2b 2b 2b
+generated valid SI2quater: [23] 59 06 07 c0 00 25 0f 7c 28 58 2e 22 f2 4e 84 86 59 00 03 2b 2b 2b 2b
+generated valid SI2quater: [23] 59 06 07 c0 00 25 0f 7c 34 1a 64 26 5d f2 05 04 86 59 00 03 2b 2b 2b
+generated valid SI2quater: [23] 59 06 07 c0 00 25 0f 7c 38 58 12 22 fd ce 8e 05 04 86 59 00 03 2b 2b
+generated valid SI2quater: [23] 59 06 07 c0 00 25 0f 7c 40 58 1d 22 fa ce 88 85 7b 00 44 b2 00 03 2b
+generated valid SI2quater: [23] 59 06 07 c0 00 25 0f 7c 4c 7a 34 0e 64 77 85 43 55 c8 10 99 64 00 0b
failed to add UARFCN to SI2quater: No space left on device
failed to add UARFCN to SI2quater: No space left on device
-generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 4c 7a 34 0e 64 77 85 43 55 c8 10 99 64 00 0b
+generated valid SI2quater: [23] 59 06 07 c0 00 25 0f 7c 4c 7a 34 0e 64 77 85 43 55 c8 10 99 64 00 0b
Done.