bscnat: Introduce test TC_ctrl_location

It checks location-state TRAP is forwaded correctly in BSC-NAT from BSC
towards locally connected CTRL client, with variable names updated to
contain BSC/BTS indexes.
It also verifies commands can be applied (SET) in inverse direction.

Change-Id: If28aba011a1903788cacbc10c0b62954925d4b1f
diff --git a/bsc-nat/BSCNAT_Tests.ttcn b/bsc-nat/BSCNAT_Tests.ttcn
index 81afcfa..9d2fc4b 100644
--- a/bsc-nat/BSCNAT_Tests.ttcn
+++ b/bsc-nat/BSCNAT_Tests.ttcn
@@ -20,6 +20,10 @@
 
 import from MTP3asp_Types all;
 
+import from Osmocom_CTRL_Functions all;
+import from Osmocom_CTRL_Types all;
+import from Osmocom_CTRL_Adapter all;
+
 import from SCCP_Types all;
 import from SCCPasp_Types all;
 import from SCCP_Emulation all;
@@ -48,7 +52,7 @@
 	SCCP_PAR_Address sccp_addr_own
 }
 
-type component test_CT {
+type component test_CT extends CTRL_Adapter_CT {
 	var MscState msc[NUM_MSC];
 	var BscState bsc[NUM_BSC];
 
@@ -65,6 +69,9 @@
 	PortNumber mp_msc_port := 5000;
 	charstring mp_msc_ip := "127.0.0.1";
 
+	/* port number to which to establish the IPA CTRL connection */
+	integer mp_nat_ctrl_port := 4250;
+	/* port number to which to establish the SCCPLite connection */
 	PortNumber mp_nat_port := 5000;
 	charstring mp_nat_ip := "127.0.0.1";
 
@@ -144,6 +151,7 @@
 
 	f_init_vty("VirtBSCNAT");
 	f_vty_allow_osmux(use_osmux);
+	f_ipa_ctrl_start(mp_nat_ip, mp_nat_ctrl_port);
 
 	for (i := 0; i < NUM_MSC; i := i+1) {
 		f_init_MscState(msc[i], mp_msc_pc +i, mp_bsc_pc, mp_msc_ssn, mp_bsc_ssn);
@@ -206,9 +214,26 @@
 	f_TC_recv_dump(true);
 }
 
+testcase TC_ctrl_location() runs on test_CT {
+	timer T := 30.0;
+
+	f_init(refers(bsc_ms_do_nothing),
+	       refers(bsc_ctrl_location),
+	       refers(CreateCallback_establish_fully),
+	       false);
+
+	f_ctrl_exp_trap(IPA_CTRL, "net.0.bsc.0.bts.0.location-state",
+			"1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01",
+			10.0);
+	f_ctrl_set(IPA_CTRL, "net.0.bsc.0.rf_locked", "1");
+
+	f_wait_finish(T);
+}
+
 control {
 	execute( TC_recv_dump() );
 	execute( TC_recv_dump_osmux() );
+	execute( TC_ctrl_location() );
 }
 
 }