[BSC] Implement per-timeslot ARFCN lists for frequency hopping

We now compute the Cell Channel Description for SI 1 by bit-wise
OR of the ARFCN bitmask of each timeslot on all the TRX of the BTS.

Also, support generating a GSM 04.08 Channel Description IE for
the hopping case (with HSN/MAIO instead of ARFCN).

What's still missing now: Sending the 04.08 Mobile Allocation IE
diff --git a/openbsc/src/system_information.c b/openbsc/src/system_information.c
index 337f756..508787d 100644
--- a/openbsc/src/system_information.c
+++ b/openbsc/src/system_information.c
@@ -177,9 +177,23 @@
 	struct gsm_bts_trx *trx;
 	struct bitvec *bv = &bts->si_common.cell_alloc;
 
+	/* Zero-initialize the bit-vector */
+	memset(&bv->data, 0, bv->data_len);
+
 	/* first we generate a bitvec of all TRX ARFCN's in our BTS */
-	llist_for_each_entry(trx, &bts->trx_list, list)
+	llist_for_each_entry(trx, &bts->trx_list, list) {
+		unsigned int i, j;
+		/* Always add the TRX's ARFCN */
 		bitvec_set_bit_pos(bv, trx->arfcn, 1);
+		for (i = 0; i < ARRAY_SIZE(trx->ts); i++) {
+			struct gsm_bts_trx_ts *ts = &trx->ts[i];
+			/* Add any ARFCNs present in hopping channels */
+			for (j = 0; j < 1024; j++) {
+				if (bitvec_get_bit_pos(&ts->hopping.arfcns, j))
+					bitvec_set_bit_pos(bv, j, 1);
+			}
+		}
+	}
 
 	/* then we generate a GSM 04.08 frequency list from the bitvec */
 	return bitvec2freq_list(chan_list, bv, bts);
@@ -191,6 +205,9 @@
 	struct gsm_bts *cur_bts;
 	struct bitvec *bv = &bts->si_common.neigh_list;
 
+	/* Zero-initialize the bit-vector */
+	memset(&bv->data, 0, bv->data_len);
+
 	/* first we generate a bitvec of the BCCH ARFCN's in our BSC */
 	llist_for_each_entry(cur_bts, &bts->network->bts_list, list) {
 		if (cur_bts == bts)