BSSAP/IPA integration: Wait for SCCPLite to be established

Before this patch, we had some problems related to synchronization
between the IPA transport, SCCP emulation and BSSAP layer in SCCPlite
configurations.

This code ensures that f_bssap_init() will block until the IPA
connection (client or server) is established, and then start the SCCP
and BSSAP emulation components in the right order.

This in turn ensures that the initial BSSMAP RESET that we're sending
from the TTCN-3 side is only sent once the IPA connection is fully
established, and the CCM Identity handshake has happened before.

Change-Id: I483ddd45c1cf631a5a9d8f862b6ca728b38bdc14
Related: OS#2544
diff --git a/library/IPA_Emulation.ttcnpp b/library/IPA_Emulation.ttcnpp
index 41a3968..df2b15e 100644
--- a/library/IPA_Emulation.ttcnpp
+++ b/library/IPA_Emulation.ttcnpp
@@ -243,6 +243,9 @@
 }
 
 private function f_send_IPA_EVT(template ASP_IPA_Event evt) runs on IPA_Emulation_CT {
+	if (IPA_SP_PORT.checkstate("Connected")) {
+		IPA_SP_PORT.send(evt);
+	}
 #ifdef IPA_EMULATION_RSL
 	if (IPA_RSL_PORT.checkstate("Connected")) {
 		IPA_RSL_PORT.send(evt);
@@ -368,6 +371,7 @@
 			 * the TCP connection is established.  Other implementations may differ.
 			 * We currently ignore it completely - but actually we should make sure that
 			 * one ID_ACK is received by the server at some point */
+			f_send_IPA_EVT(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_ID_ACK));
 		}
 		case (IPAC_MSGT_ID_RESP) {
 			log("IPA ID RESP: ", ccm.u.resp);
@@ -635,4 +639,24 @@
 	}
 }
 
+/***********************************************************************
+ * IPA Event waiter component. Wait for ASP_IPA_EVENT_ID_ACK
+ ***********************************************************************/
+
+type component IPA_EventWaiter_CT {
+	port IPA_SP_PT IPA_SP_PORT;
+}
+
+function waiter_main(template ASP_IPA_Event wait_for := t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_ID_ACK))
+runs on IPA_EventWaiter_CT {
+
+	alt {
+	[] IPA_SP_PORT.receive(wait_for) {
+		setverdict(pass);
+		}
+	[] IPA_SP_PORT.receive { repeat; }
+	}
+}
+
+
 }