BSC_Tests: Prepare for tests based on {RSL,BSSMAP}_Emulation

The existing tests were implemented directly on top of the BSSMAP
and RSL CodecPorts.  If we loop in the RSL_Emulation and
BSSMAP_Emulation components, we can properly multiplex/demultiplex
multiple MS (radio channels) on both the RSL and the MSC (SCCP
connection) side.

In order to have a single component that handles both the RSL and the
BSSAP side of a given channel/subscriber/call, we introduce the concept
of BSSMAP "Expects", where the test csse can register the L3 INFO that
it sends in the RLL ESTablish INDication on the RSL side, so the BSSMAP
handler cna route the BSC-originated SCCP connection with that L3 INFO
back to the same component.  This is a bit inspired "in spirit" of the
"expect" mechanism of netfilter connection tracking.

Change-Id: I71f777cd4f290422fa68897952b6505875e35f0e
diff --git a/bsc/BSSAP_Adapter.ttcn b/bsc/BSSAP_Adapter.ttcn
index 60c7103..f1ff5b6 100644
--- a/bsc/BSSAP_Adapter.ttcn
+++ b/bsc/BSSAP_Adapter.ttcn
@@ -22,6 +22,9 @@
 
 import from BSSAP_CodecPort all;
 import from BSSMAP_Templates all;
+import from BSSMAP_Emulation all;
+
+import from MSC_ConnectionHandler all;
 
 type component BSSAP_Adapter_CT {
 	/* component references */
@@ -33,6 +36,9 @@
 	var octetstring g_sio;
 	var MSC_SCCP_MTP3_parameters g_sccp_pars;
 	var SCCP_PAR_Address g_sccp_addr_own, g_sccp_addr_peer;
+
+	/* handler mode */
+	var BSSMAP_Emulation_CT vc_BSSMAP;
 }
 
 modulepar {
@@ -79,24 +85,33 @@
 }
 
 
-function f_bssap_init(charstring id) runs on BSSAP_Adapter_CT
+function f_bssap_init(charstring id, boolean handler_mode := false) runs on BSSAP_Adapter_CT
 {
 	init_pars();
 
 	/* create components */
 	vc_M3UA := M3UA_CT.create(id & "-M3UA");
 	vc_SCCP := SCCP_CT.create(id & "-SCCP");
+	if (handler_mode) {
+		vc_BSSMAP := BSSMAP_Emulation_CT.create(id & "-BSSMAP");
+	}
 
 	map(vc_M3UA:SCTP_PORT, system:sctp);
 
 	/* connect MTP3 service provider (M3UA) to lower side of SCCP */
 	connect(vc_M3UA:MTP3_SP_PORT, vc_SCCP:MTP3_SCCP_PORT);
-
-	/* connect BSSNAP dispatcher to upper side of SCCP */
-	connect(self:BSSAP, vc_SCCP:SCCP_SP_PORT);
+	if (handler_mode) {
+		connect(vc_BSSMAP:BSSAP, vc_SCCP:SCCP_SP_PORT);
+	} else {
+		/* connect BSSNAP dispatcher to upper side of SCCP */
+		connect(self:BSSAP, vc_SCCP:SCCP_SP_PORT);
+	}
 
 	vc_M3UA.start(f_M3UA_Emulation(mp_sctp_addr));
 	vc_SCCP.start(SCCPStart(g_sccp_pars));
+	if (handler_mode) {
+		vc_BSSMAP.start(BSSMAP_Emulation.main(MSC_BssmapOps, ""));
+	}
 }
 
 private altstep as_reset_ack() runs on BSSAP_Adapter_CT {