GSUP Support and first test against OsmoHLR

Change-Id: Idd7a6aca1ab193da39294f49a3adc4c1cd7cecff
diff --git a/library/IPA_Emulation.ttcn b/library/IPA_Emulation.ttcn
index ddedb39..9bad69f 100644
--- a/library/IPA_Emulation.ttcn
+++ b/library/IPA_Emulation.ttcn
@@ -17,6 +17,7 @@
 import from RSL_Types all;
 
 import from MGCP_Types all;
+import from GSUP_Types all;
 
 import from Osmocom_CTRL_Types all;
 
@@ -99,6 +100,12 @@
 	inout CtrlMessage, ASP_IPA_Event;
 } with { extension "internal" }
 
+/* Client port for CTRL inside IPA */
+type port IPA_GSUP_PT message {
+	inout GSUP_PDU, ASP_IPA_Event;
+} with { extension "internal" }
+
+
 type component IPA_Emulation_CT {
 	/* down-facing port to IPA codec port */
 	port IPA_CODEC_PT IPA_PORT;
@@ -110,6 +117,9 @@
 	port IPA_RSL_PT IPA_RSL_PORT;
 	/* up-facing port for CTRL */
 	port IPA_CTRL_PT IPA_CTRL_PORT;
+	/* up-facing port for GSUP */
+	port IPA_GSUP_PT IPA_GSUP_PORT;
+
 	/* up-facing port for other streams */
 	port IPA_SP_PT IPA_SP_PORT;
 
@@ -193,6 +203,9 @@
 	if (IPA_CTRL_PORT.checkstate("Connected")) {
 		IPA_CTRL_PORT.send(evt);
 	}
+	if (IPA_GSUP_PORT.checkstate("Connected")) {
+		IPA_GSUP_PORT.send(evt);
+	}
 	/* FIXME: to other ports */
 }
 
@@ -348,6 +361,10 @@
 	IPA_CTRL_PORT.send(dec_CtrlMessage(msg_ch));
 }
 
+private function f_gsup_to_user(octetstring msg) runs on IPA_Emulation_CT {
+	IPA_GSUP_PORT.send(dec_GSUP_PDU(msg));
+}
+
 private function f_mgcp_to_ud(octetstring payload) runs on IPA_Emulation_CT return ASP_IPA_Unitdata {
 	if (mp_ipa_mgcp_uses_osmo_ext) {
 		return valueof(t_ASP_IPA_UD(IPAC_PROTO_MGCP_OLD, payload));
@@ -365,6 +382,7 @@
 	var MgcpCommand mgcp_cmd;
 	var MgcpResponse mgcp_rsp;
 	var CtrlMessage ctrl_msg;
+	var GSUP_PDU gsup_msg;
 	var octetstring payload;
 	var ASP_RSL_Unitdata rsl;
 
@@ -399,6 +417,8 @@
 						f_mgcp_to_user(ipa_rx.msg);
 					} case (IPAC_PROTO_EXT_CTRL) {
 						f_ctrl_to_user(ipa_rx.msg);
+					} case (IPAC_PROTO_EXT_GSUP) {
+						f_gsup_to_user(ipa_rx.msg);
 					} case else {
 						IPA_SP_PORT.send(f_to_asp(ipa_rx));
 					}
@@ -451,6 +471,12 @@
 			IPA_PORT.send(f_from_asp(g_ipa_conn_id, ipa_ud));
 		}
 
+		[] IPA_GSUP_PORT.receive(GSUP_PDU:?) -> value gsup_msg {
+			payload := enc_GSUP_PDU(gsup_msg);
+			ipa_ud := valueof(t_ASP_IPA_UD(IPAC_PROTO_OSMO, payload, IPAC_PROTO_EXT_GSUP));
+			IPA_PORT.send(f_from_asp(g_ipa_conn_id, ipa_ud));
+		}
+
 		/* Received RSL -> down into IPA */
 		[] IPA_RSL_PORT.receive(ASP_RSL_Unitdata:?) -> value rsl {
 			IPA_PORT.send(f_from_rsl(g_ipa_conn_id, rsl));