[PATCH] openbsc[master]: Prepare for extended SI2quater support

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Wed Apr 12 13:58:28 UTC 2017


Hello Jenkins Builder,

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

    https://gerrit.osmocom.org/2312

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

Prepare for extended SI2quater support

Supporting SI2quater support as per 3GPP TS 44.018 will require chnages
to the way System Information is stored because it uses 1:n instead of
1:1 mapping between SI type and generated SI content. This should not
affect other SI types though. To facilitate this transition:

* convert the code to always use GSM_BTS_SI helper instead of accessing
  buffer directly
* make helper more robust by adding extra parenthesis
* add similar helper for gsm_lchan

Change-Id: I74e4e3cb86364cec869a1472a41b4a95af0d50dd
Related: RT#8792
---
M openbsc/include/openbsc/gsm_data_shared.h
M openbsc/src/libbsc/bsc_vty.c
M openbsc/src/libbsc/system_information.c
M openbsc/tests/gsm0408/gsm0408_test.c
4 files changed, 11 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/12/2312/3

diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h
index 242889a..d9d508b 100644
--- a/openbsc/include/openbsc/gsm_data_shared.h
+++ b/openbsc/include/openbsc/gsm_data_shared.h
@@ -483,7 +483,8 @@
 	struct gsm_bts_trx_ts ts[TRX_NR_TS];
 };
 
-#define GSM_BTS_SI(bts, i)	(void *)(bts->si_buf[i])
+#define GSM_BTS_SI(bts, i)	(void *)((bts)->si_buf[i])
+#define GSM_LCHAN_SI(lchan, i)	(void *)((lchan)->si.buf[i])
 
 enum gsm_bts_type {
 	GSM_BTS_TYPE_UNKNOWN,
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index c1882fc..a2f0264 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -644,7 +644,7 @@
 				get_value_string(osmo_sitype_strs, i), VTY_NEWLINE);
 			vty_out(vty, "  system-information %s static %s%s",
 				get_value_string(osmo_sitype_strs, i),
-				osmo_hexdump_nospc(bts->si_buf[i], sizeof(bts->si_buf[i])),
+				osmo_hexdump_nospc(GSM_BTS_SI(bts, i), GSM_MACBLOCK_LEN),
 				VTY_NEWLINE);
 		}
 	}
@@ -2688,11 +2688,11 @@
 	}
 
 	/* Fill buffer with padding pattern */
-	memset(bts->si_buf[type], 0x2b, sizeof(bts->si_buf[type]));
+	memset(GSM_BTS_SI(bts, type), 0x2b, GSM_MACBLOCK_LEN);
 
 	/* Parse the user-specified SI in hex format, [partially] overwriting padding */
-	rc = osmo_hexparse(argv[1], bts->si_buf[type], sizeof(bts->si_buf[0]));
-	if (rc < 0 || rc > sizeof(bts->si_buf[0])) {
+	rc = osmo_hexparse(argv[1], GSM_BTS_SI(bts, type), GSM_MACBLOCK_LEN);
+	if (rc < 0 || rc > GSM_MACBLOCK_LEN) {
 		vty_out(vty, "Error parsing HEXSTRING%s", VTY_NEWLINE);
 		return CMD_WARNING;
 	}
diff --git a/openbsc/src/libbsc/system_information.c b/openbsc/src/libbsc/system_information.c
index 2610331..71916e3 100644
--- a/openbsc/src/libbsc/system_information.c
+++ b/openbsc/src/libbsc/system_information.c
@@ -633,8 +633,7 @@
 	if (n) {
 		/* indicate in SI2 and SI2bis: there is an extension */
 		struct gsm48_system_information_type_2 *si2 =
-			(struct gsm48_system_information_type_2 *)
-				bts->si_buf[SYSINFO_TYPE_2];
+			(struct gsm48_system_information_type_2 *) GSM_BTS_SI(bts, SYSINFO_TYPE_2);
 		si2->bcch_frequency_list[0] |= 0x20;
 		si2b->bcch_frequency_list[0] |= 0x20;
 	} else
@@ -887,8 +886,7 @@
 	if (n) {
 		/* indicate in SI5 and SI5bis: there is an extension */
 		struct gsm48_system_information_type_5 *si5 =
-			(struct gsm48_system_information_type_5 *)
-				bts->si_buf[SYSINFO_TYPE_5];
+			(struct gsm48_system_information_type_5 *) GSM_BTS_SI(bts, SYSINFO_TYPE_5);
 		si5->bcch_frequency_list[0] |= 0x20;
 		si5b->bcch_frequency_list[0] |= 0x20;
 	} else
@@ -1090,5 +1088,5 @@
 	if (!gen_si)
 		return -EINVAL;
 
-	return gen_si(bts->si_buf[si_type], bts);
+	return gen_si(GSM_BTS_SI(bts, si_type), bts);
 }
diff --git a/openbsc/tests/gsm0408/gsm0408_test.c b/openbsc/tests/gsm0408/gsm0408_test.c
index 08cf43f..81dc177 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.c
+++ b/openbsc/tests/gsm0408/gsm0408_test.c
@@ -99,13 +99,12 @@
 	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);
+	memset(GSM_BTS_SI(bts, 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 %s SI2quater: [%d] %s\n",
-		       v ? "valid" : "invalid", r,
-		       osmo_hexdump(bts->si_buf[SYSINFO_TYPE_2quater], r));
+		       v ? "valid" : "invalid", r, osmo_hexdump(GSM_BTS_SI(bts, SYSINFO_TYPE_2quater), r));
 	else
 		printf("failed to generate SI2quater: %s\n", strerror(-r));
 }

-- 
To view, visit https://gerrit.osmocom.org/2312
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I74e4e3cb86364cec869a1472a41b4a95af0d50dd
Gerrit-PatchSet: 3
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list