library/IPA_Emulation: server mode: expose IPA IDENTITY RESPONSE

Change-Id: I685c2697cdbe932572e1839420d0c74c8fa94ee2
Related: OS#4546
diff --git a/library/IPA_Emulation.ttcnpp b/library/IPA_Emulation.ttcnpp
index 3762449..60c6061 100644
--- a/library/IPA_Emulation.ttcnpp
+++ b/library/IPA_Emulation.ttcnpp
@@ -79,25 +79,33 @@
 type enumerated ASP_IPA_EventType {
 	ASP_IPA_EVENT_DOWN,
 	ASP_IPA_EVENT_UP,
+	ASP_IPA_EVENT_ID_RESP,
 	ASP_IPA_EVENT_ID_ACK
 }
 
 /* an event indicating us whether or not a connection is physically up or down,
- * and whether we have received an ID_ACK */
+ * and whether we have received an ID_RESP or ID_ACK */
 type record ASP_IPA_Event {
 	ASP_IPA_EventType	ev_type,
-	integer			conn_id
+	integer			conn_id,
+
+	/* Presence of these fields depends on event type */
+	IpaCcmIdResp		id_resp optional  // ASP_IPA_EVENT_ID_RESP
 }
 
-template (value) ASP_IPA_Event ts_ASP_IPA_EV(ASP_IPA_EventType ev_type, integer conn_id) := {
+template (value) ASP_IPA_Event ts_ASP_IPA_EV(ASP_IPA_EventType ev_type, integer conn_id,
+					     template (omit) IpaCcmIdResp id_resp := omit) := {
 	ev_type := ev_type,
-	conn_id := conn_id
+	conn_id := conn_id,
+	id_resp := id_resp
 }
 
 template ASP_IPA_Event tr_ASP_IPA_EV(template ASP_IPA_EventType ev_type,
-				     template integer conn_id := ?) := {
+				     template integer conn_id := ?,
+				     template IpaCcmIdResp id_resp := *) := {
 	ev_type := ev_type,
-	conn_id := conn_id
+	conn_id := conn_id,
+	id_resp := id_resp
 }
 
 template ASP_IPA_Unitdata t_ASP_IPA_UD(IpaStreamId sid, octetstring pl,
@@ -424,6 +432,16 @@
 	}
 }
 
+template PDU_IPA_CCM tr_IPA_ID_RESP := {
+	msg_type := IPAC_MSGT_ID_RESP,
+	u := {
+		resp := {
+			{ ?, IPAC_IDTAG_UNITNAME, ? },
+			{ ?, IPAC_IDTAG_UNITID, ? }
+		}
+	}
+}
+
 /* receive IPA CCM message */
 private function f_ccm_rx_client(PDU_IPA_CCM ccm) runs on IPA_Emulation_CT {
 	select (ccm.msg_type) {
@@ -458,6 +476,15 @@
 		}
 		case (IPAC_MSGT_ID_RESP) {
 			log("IPA ID RESP: ", ccm.u.resp);
+
+			/* make sure that the response contains all fields we requested */
+			if (not match(ccm, tr_IPA_ID_RESP)) {
+				log("IPA identity response ", ccm.u.resp, " mismatch");
+				return;
+			}
+
+			/* forward to the upper layers, so they can map conn_id with unit_id */
+			f_send_IPA_EVT(ts_ASP_IPA_EV(ASP_IPA_EVENT_ID_RESP, conn_id, ccm.u.resp));
 			/* acknowledge any identity that the client may have sent */
 			f_ccm_tx(valueof(ts_IPA_ACK), conn_id);
 		}