bscnat: Refactor BSC_MS side code to allow different actions per test

Each test can now plug in different actions to be done by the emulated
BSC_MS, by passing a function to f_init(). Old hardcoded behaviour (main())
is renamed and used in already existing tests.

Change-Id: Ic82ca333267535c5859e6439deacbf3b1d1fe391
diff --git a/bsc-nat/BSC_MS_ConnectionHandler.ttcn b/bsc-nat/BSC_MS_ConnectionHandler.ttcn
index 7f2ebcd..f7126fd 100644
--- a/bsc-nat/BSC_MS_ConnectionHandler.ttcn
+++ b/bsc-nat/BSC_MS_ConnectionHandler.ttcn
@@ -25,6 +25,8 @@
 import from MGCP_Templates all;
 import from SDP_Types all;
 
+type function void_fn_bsc_ms(charstring id) runs on BSC_MS_ConnHdlr;
+
 /* this component represents a single subscriber connection at the MSC.
  * There is a 1:1 mapping between SCCP connections and RAN_ConnHdlr components.
  * We inherit all component variables, ports, functions, ... from RAN_ConnHdlr */
@@ -34,8 +36,15 @@
 	var MgcpConnectionId g_mgcp_conn_id;
 	var SDP_Message g_sdp;
 	var BSC_State g_state;
+	var BSC_MS_TestHdlrParams g_pars;
 }
 
+type record BSC_MS_TestHdlrParams {
+	SCCP_PAR_Address sccp_addr_own,
+	SCCP_PAR_Address sccp_addr_remote,
+	boolean use_osmux
+};
+
 /* Callback function from general RAN_Emulation whenever a new incoming
  * SCCP connection arrivces. Must create + start a new component */
 private function CreateCallback(BSSAP_N_CONNECT_ind conn_ind, charstring id)
@@ -90,7 +99,7 @@
 }
 
 /* main function processing various incoming events */
-function main(SCCP_PAR_Address sccp_addr_own, SCCP_PAR_Address sccp_addr_remote, boolean use_osmux)
+function bsc_ms_establish_fully(charstring id)
 runs on BSC_MS_ConnHdlr {
 	var PDU_BSSAP bssap;
 	var MgcpCommand mgcp_cmd;
@@ -104,8 +113,8 @@
 	/* generate and send the Complete Layer3 Info */
 	bssap := f_gen_cl3('901770123456789'H);
 	var BSSAP_Conn_Req creq := {
-		addr_peer := sccp_addr_remote,
-		addr_own := sccp_addr_own,
+		addr_peer := g_pars.sccp_addr_remote,
+		addr_own := g_pars.sccp_addr_own,
 		bssap := bssap
 	}
 	g_state := BSC_STATE_WAIT_ASS_REQ;
@@ -130,12 +139,12 @@
 			/* respond with CRCX_ACK */
 			g_state := BSC_STATE_WAIT_MDCX;
 
-			if (use_osmux != f_MgcpCmd_contains_par(mgcp_cmd, "X-OSMUX")) {
-				setverdict(fail, log2str("Received Osmux CID presence doesn't match presence expectancy (", use_osmux, ")"));
+			if (g_pars.use_osmux != f_MgcpCmd_contains_par(mgcp_cmd, "X-OSMUX")) {
+				setverdict(fail, log2str("Received Osmux CID presence doesn't match presence expectancy (", g_pars.use_osmux, ")"));
 				self.stop;
 			}
 
-			if (use_osmux) {
+			if (g_pars.use_osmux) {
 				osmux_cid := f_MgcpCmd_extract_osmux_cid(mgcp_cmd);
 				mgcp_resp := ts_CRCX_ACK_osmux(mgcp_cmd.line.trans_id, g_mgcp_conn_id, osmux_cid, g_sdp);
 			} else {