diff mbox

openbsc[master]: Make si2q scheduling optional

Message ID 20160525093033.C83F26C49@lists.osmocom.org
State New
Headers show

Commit Message

gerrit-no-reply@lists.osmocom.org May 25, 2016, 9:30 a.m. UTC
Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/81

to look at the new patch set (#4).

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
---
M openbsc/src/libbsc/system_information.c
M openbsc/tests/gsm0408/gsm0408_test.c
M openbsc/tests/gsm0408/gsm0408_test.ok
3 files changed, 34 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/81/81/4
diff mbox

Patch

diff --git a/openbsc/src/libbsc/system_information.c b/openbsc/src/libbsc/system_information.c
index bf20394..28d5319 100644
--- a/openbsc/src/libbsc/system_information.c
+++ b/openbsc/src/libbsc/system_information.c
@@ -648,7 +648,7 @@ 
 
 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 @@ 
 	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 9262667..e7c1d7d 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,13 @@ 
 
 static inline void gen(struct gsm_bts *bts)
 {
+	bts->si_valid = 0;
+	bts->si_valid |= (1 << SYSINFO_TYPE_2quater);
 	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 +127,7 @@ 
 		exit(1);
 	bts = gsm_bts_alloc(network);
 
+	gen(bts);
 	_bts_uarfcn_add(bts, 1982, 13, 1);
 	_bts_uarfcn_add(bts, 1982, 44, 0);
 	_bts_uarfcn_add(bts, 1982, 61, 1);
@@ -155,7 +160,7 @@ 
 	bts->si_common.si2quater_neigh_list.thresh_hi = 5;
 
 	osmo_earfcn_init(&bts->si_common.si2quater_neigh_list);
-
+	gen(bts);
 	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 7b7a2cc..ebe9476 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.ok
+++ b/openbsc/tests/gsm0408/gsm0408_test.ok
@@ -63,24 +63,26 @@ 
 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.