Prepare for extended SI2quater support

Supporting SI2quater 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
* add function estimating number of SI2quater message to hold configured
  number of (U|E)ARFCNs
* add SI2q index/count fields and pass them to rest_octets generator
  explicitly
* internalize buffer access in generate_si* functions

Change-Id: I74e4e3cb86364cec869a1472a41b4a95af0d50dd
Related: RT#8792
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index 3c70580..195fd6a 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);
 		}
 	}
@@ -2687,11 +2687,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;
 	}
@@ -2829,7 +2829,7 @@
 		e->prio_valid = true;
 	}
 
-	if (si2q_size_check(bts))
+	if (si2q_num(bts) < 2)
 		return CMD_SUCCESS;
 
 	vty_out(vty, "Warning: not enough space in SI2quater for a given EARFCN "