Allow multiple bts objects in PCU

This patch doesn't really tests whether osmo-pcu can work on a multi-bts
environment, but it prepares the data structures to be able to do so at
any later point in time.

Change-Id: I6b10913f46c19d438c4e250a436a7446694b725a
diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp
index 798dc3c..24fd109 100644
--- a/tests/tbf/TbfTest.cpp
+++ b/tests/tbf/TbfTest.cpp
@@ -95,8 +95,7 @@
 static void test_tbf_tlli_update()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	GprsMs *ms, *ms_new;
 
 	fprintf(stderr, "=== start %s ===\n", __func__);
@@ -254,8 +253,7 @@
 static void test_tbf_final_ack(enum test_tbf_final_ack_mode test_mode)
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	uint8_t ts_no = 4;
 	unsigned i;
 	uint8_t ms_class = 45;
@@ -340,8 +338,7 @@
 static void test_tbf_delayed_release()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	uint8_t ts_no = 4;
 	unsigned i;
 	uint8_t ms_class = 45;
@@ -411,8 +408,7 @@
 static void test_tbf_imsi()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	uint8_t ts_no = 4;
 	uint8_t ms_class = 45;
 	uint8_t trx_no;
@@ -473,8 +469,7 @@
 static void test_tbf_exhaustion()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	unsigned i;
 	uint8_t ts_no = 4;
 	uint8_t ms_class = 45;
@@ -517,8 +512,7 @@
 static void test_tbf_dl_llc_loss()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	uint8_t ts_no = 4;
 	uint8_t ms_class = 45;
 	int rc = 0;
@@ -1699,8 +1693,7 @@
 static void test_tbf_single_phase()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	int ts_no = 7;
 	uint32_t fn = DUMMY_FN; /* 17,25,9 */
 	uint32_t tlli = 0xf1223344;
@@ -1724,8 +1717,7 @@
 static void test_tbf_egprs_two_phase_puan(void)
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	int ts_no = 7;
 	uint32_t fn = 2654218;
 	uint16_t qta = 31;
@@ -1780,8 +1772,7 @@
 static void test_immediate_assign_rej_single_block()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	uint32_t fn = 2654218;
 	uint16_t qta = 31;
 	int ts_no = 7;
@@ -1814,8 +1805,7 @@
 static void test_immediate_assign_rej_multi_block()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	uint32_t fn = 2654218;
 	uint16_t qta = 31;
 	int ts_no = 7;
@@ -1856,8 +1846,7 @@
 static void test_tbf_two_phase()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	int ts_no = 7;
 	uint32_t fn = 2654218;
 	uint16_t qta = 31;
@@ -1889,8 +1878,7 @@
 static void test_tbf_ra_update_rach()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	int ts_no = 7;
 	uint32_t fn = 2654218;
 	uint16_t qta = 31;
@@ -1956,8 +1944,7 @@
 static void test_tbf_dl_flow_and_rach_two_phase()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	int ts_no = 7;
 	uint32_t fn = 2654218;
 	uint16_t qta = 31;
@@ -2018,8 +2005,7 @@
 static void test_tbf_dl_flow_and_rach_single_phase()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	int ts_no = 7;
 	uint32_t fn = 2654218;
 	uint16_t qta = 31;
@@ -2079,8 +2065,7 @@
 static void test_tbf_dl_reuse()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	int ts_no = 7;
 	uint32_t fn = 2654218;
 	uint16_t qta = 31;
@@ -2180,8 +2165,7 @@
 static void test_tbf_gprs_egprs()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	uint8_t ts_no = 4;
 	uint8_t ms_class = 45;
 	int rc = 0;
@@ -2248,8 +2232,7 @@
 static void test_tbf_ws()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	GprsMs *ms;
 	uint8_t ts_no = 4;
 	uint8_t ms_class = 12;
@@ -2294,8 +2277,7 @@
 static void test_tbf_update_ws(void)
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	GprsMs *ms;
 	uint8_t ts_no = 4;
 	uint8_t ms_class = 11;
@@ -2339,8 +2321,7 @@
 static void test_tbf_puan_urbb_len(void)
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	int ts_no = 7;
 	uint32_t fn = 2654218;
 	uint16_t qta = 31;
@@ -2479,8 +2460,7 @@
 static void test_tbf_li_decoding(void)
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	int ts_no = 7;
 	uint32_t fn = 2654218;
 	uint16_t qta = 31;
@@ -2516,8 +2496,7 @@
 static void test_tbf_epdan_out_of_rx_window(void)
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	uint8_t ms_class = 11;
 	uint8_t egprs_ms_class = 11;
 	uint8_t trx_no;
@@ -2608,8 +2587,7 @@
 static void test_tbf_egprs_two_phase_spb(void)
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	int ts_no = 7;
 	uint32_t fn = 2654218;
 	uint16_t qta = 31;
@@ -2640,8 +2618,7 @@
 static void test_tbf_egprs_two_phase()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	int ts_no = 7;
 	uint32_t fn = 2654218;
 	uint16_t qta = 31;
@@ -3064,8 +3041,7 @@
 static void test_tbf_egprs_retx_dl(void)
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	uint8_t ts_no = 4;
 
 	fprintf(stderr, "=== start %s ===\n", __func__);
@@ -3093,8 +3069,7 @@
 static void test_tbf_egprs_spb_dl(void)
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	uint8_t ts_no = 4;
 
 	fprintf(stderr, "=== start %s ===\n", __func__);
@@ -3124,8 +3099,7 @@
 static void test_tbf_egprs_dl()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	uint8_t ts_no = 4;
 	int i;
 
@@ -3148,8 +3122,7 @@
 static void test_packet_access_rej_prr_no_other_tbfs()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	uint32_t fn = 2654218;
 	int ts_no = 7;
 	uint8_t trx_no = 0;
@@ -3184,8 +3157,7 @@
 static void test_packet_access_rej_prr()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	uint32_t fn = 2654218;
 	uint16_t qta = 31;
 	int ts_no = 7;
@@ -3255,8 +3227,7 @@
 void test_packet_access_rej_epdan()
 {
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
-	the_pcu->bts = bts_alloc(the_pcu);
-	struct gprs_rlcmac_bts *bts = the_pcu->bts;
+	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
 	uint32_t tlli = 0xffeeddcc;
 	static uint8_t exp[] = { 0x40, 0x84, 0x7f, 0xf7, 0x6e, 0xe6, 0x41, 0x4b,
 				 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b,