bts: Type Definition + Template for SI3; Send SI3 at start of test

The BTS needs some of the SI3 parameters like BS_AG_BLKS_RES for
internal computations, so make sure we send it after the connection
has been established.

Change-Id: I5dc3724f79e669f52593cd776806d84b4dd4bf5c
diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index 58c7118..287d869 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -12,6 +12,7 @@
 import from Osmocom_CTRL_Adapter all;
 
 import from RSL_Types all;
+import from IPA_Types all;
 import from IPA_Emulation all;
 import from RSL_Emulation all;
 
@@ -20,6 +21,9 @@
 import from TRXC_CodecPort all;
 import from TRXC_CodecPort_CtrlFunct all;
 
+import from L3_Templates all;
+import from MobileL3_CommonIE_Types all;
+
 /* The tests assume a BTS with the following timeslot configuration:
  * TS0 : Combined CCCH + SDCCH/4
  * TS1 .. TS 4: TCH/F
@@ -75,11 +79,62 @@
 	ConnL1Pars l1_pars
 }
 
+/* Default SYSTEM INFORMATION 3 */
+template (value) GsmRrMessage ts_SI3_default := {
+	header := t_RrHeader(SYSTEM_INFORMATION_TYPE_3, 0),
+	payload := {
+		si3 := {
+			cell_id := 23,
+			lai := {
+				mcc_mnc := '262F42'H,
+				lac := 42
+			},
+			ctrl_chan_desc := {
+				msc_r99 := true,
+				att := true,
+				bs_ag_blks_res := 1,
+				ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
+				si22_ind := false,
+				cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
+				spare := '00'B,
+				bs_pa_mfrms := 0, /* 2 multiframes */
+				t3212 := 1 /* 6 minutes */
+			},
+			cell_opts := {
+				dn_ind := false,
+				pwrc := false,
+				dtx := MS_MAY_USE_UL_DTX,
+				radio_link_tout_div4 := 4/4
+			},
+			cell_sel_pars := {
+				cell_resel_hyst_2dB := 0,
+				ms_txpwr_max_cch := 0,
+				acs := '0'B,
+				neci := true,
+				rxlev_access_min := 0
+			},
+			rach_ctrl_pars := {
+				max_retrans := RACH_MAX_RETRANS_1,
+				tx_integer := '0000'B, /* 3 slots */
+				cell_bar_access := false,
+				re_not_allowed := true,
+				acc := '1111111111111111'B
+			},
+			rest_octets := ''O
+		}
+	}
+}
 
 /* global init function */
 function f_init(charstring id) runs on test_CT {
 	f_init_rsl(id);
 	RSL_CCHAN.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP});
+
+	/* Send SI3 to the BTS, it is needed for various computations */
+	var GsmRrMessage si3 := valueof(ts_SI3_default);
+	log("Sending SI3 ", si3);
+	var octetstring si3_enc := enc_GsmRrMessage(si3);
+	RSL_CCHAN.send(ts_RSL_UD(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_3, si3_enc)));
 }
 
 type function void_fn(charstring id) runs on ConnHdlr;
@@ -99,6 +154,17 @@
 	return vc_conn;
 }
 
+template ASP_RSL_Unitdata ts_RSL_UD(template RSL_Message rsl, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
+	streamId := sid,
+	rsl := rsl
+}
+
+template ASP_RSL_Unitdata tr_RSL_UD(template RSL_Message rsl,
+				    template IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := {
+	streamId := sid,
+	rsl := rsl
+}
+
 private altstep as_Tguard() runs on ConnHdlr {
 	[] g_Tguard.timeout {
 		setverdict(fail, "Tguard timeout");