Restructure SI2quater generation

In preparation for extended SI2q messages:

* add SI2q-specific accessor macro
* add *_offset variables to gsm_bts struct
* internalize memory check while generating rest octets - introduce
  budget concept (number of bits available in a given message)
* internalize *arfcn_size() functions as they are not needed outside of
  si2q_num() anymore
* change rest octets generation to work with gsm_bts struct directly
* do not generate rest octets if no SI2q is necessary
* adjust unit tests accordingly (cosmetic changes only to avoid
  regressions)

Requires: I92e12e91605bdab9916a3f665705287572434f74 in libosmocore

Change-Id: Ib554cf7ffc949a321571e1ae2ada1160e1b35fa6
Related: RT#8792
diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h
index edc550e..0e5bc91 100644
--- a/openbsc/include/openbsc/gsm_data_shared.h
+++ b/openbsc/include/openbsc/gsm_data_shared.h
@@ -25,6 +25,7 @@
 #endif
 
 #include <openbsc/common_cs.h>
+#include <openbsc/rest_octets.h>
 
 struct osmo_bsc_data;
 
@@ -485,6 +486,7 @@
 	struct gsm_bts_trx_ts ts[TRX_NR_TS];
 };
 
+#define GSM_BTS_SI2Q(bts)	(struct gsm48_system_information_type_2quater *)((bts)->si_buf[SYSINFO_TYPE_2quater])
 #define GSM_BTS_SI(bts, i)	(void *)((bts)->si_buf[i])
 #define GSM_LCHAN_SI(lchan, i)	(void *)((lchan)->si.buf[i])
 
@@ -717,10 +719,13 @@
 	/* bitmask of all SI that are present/valid in si_buf */
 	uint32_t si_valid;
 	/* 3GPP TS 44.018 Table 10.5.2.33b.1 INDEX and COUNT for SI2quater */
-	uint8_t si2q_index;
-	uint8_t si2q_count;
+	uint8_t si2q_index; /* distinguish individual SI2quater messages */
+	uint8_t si2q_count; /* si2q_index for the last (highest indexed) individual SI2quater message */
 	/* buffers where we put the pre-computed SI */
 	sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE];
+	/* offsets used while generating SI2quater */
+	size_t e_offset;
+	size_t u_offset;
 
 	/* ip.accesss Unit ID's have Site/BTS/TRX layout */
 	union {