bts: Support passing PCUIF messages over IPA multiplex

Related: SYS#5303
Change-Id: I3cd0988cb654f1c5816d1c4717255a5e802d7925
diff --git a/library/IPA_Emulation.ttcnpp b/library/IPA_Emulation.ttcnpp
index 906664f..5cdf324 100644
--- a/library/IPA_Emulation.ttcnpp
+++ b/library/IPA_Emulation.ttcnpp
@@ -55,6 +55,10 @@
 import from Osmocom_CTRL_Types all;
 #endif
 
+#ifdef IPA_EMULATION_OSMO_PCU
+import from PCUIF_Types all;
+#endif
+
 modulepar {
 	/* Use Osmocom extended IPA mux header */
 	boolean mp_ipa_mgcp_uses_osmo_ext := true;
@@ -190,6 +194,12 @@
 } with { extension "internal" }
 #endif
 
+#ifdef IPA_EMULATION_OSMO_PCU
+/* Client port for Osmocom PCU extension inside IPA */
+type port IPA_OSMO_PCU_PT message {
+	inout PCUIF_Message, ASP_IPA_Event;
+} with { extension "internal" }
+#endif
 
 
 
@@ -224,6 +234,10 @@
 	/* up-facing port for RSPRO */
 	port IPA_RSPRO_PT IPA_RSPRO_PORT;
 #endif
+#ifdef IPA_EMULATION_OSMO_PCU
+	/* up-facing port for RSPRO */
+	port IPA_OSMO_PCU_PT IPA_OSMO_PCU_PORT;
+#endif
 
 	/* up-facing port for other streams */
 	port IPA_SP_PT IPA_SP_PORT;
@@ -350,6 +364,11 @@
 		IPA_RSPRO_PORT.send(evt);
 	}
 #endif
+#ifdef IPA_EMULATION_OSMO_PCU
+	if (IPA_OSMO_PCU_PORT.checkstate("Connected")) {
+		IPA_OSMO_PCU_PORT.send(evt);
+	}
+#endif
 	/* FIXME: to other ports */
 }
 
@@ -585,6 +604,13 @@
 }
 #endif
 
+#ifdef IPA_EMULATION_OSMO_PCU
+private function f_osmo_pcu_to_user(octetstring msg) runs on IPA_Emulation_CT {
+	var PCUIF_Message pcuif_msg := dec_PCUIF_Message(msg);
+	IPA_OSMO_PCU_PORT.send(pcuif_msg);
+}
+#endif
+
 #ifdef IPA_EMULATION_MGCP
 private function f_mgcp_to_user(octetstring msg) runs on IPA_Emulation_CT {
 	var charstring msg_ch := oct2char(msg);
@@ -657,6 +683,9 @@
 #ifdef IPA_EMULATION_RSPRO
 	var RsproPDU rspro;
 #endif
+#ifdef IPA_EMULATION_OSMO_PCU
+	var PCUIF_Message pcu;
+#endif
 
 	/* Set function for dissecting the binary */
 	var f_IPL4_getMsgLen vl_f := refers(f_IPL4_fixedMsgLen);
@@ -733,6 +762,11 @@
 						f_rspro_to_user(ipa_rx.msg);
 					}
 #endif
+#ifdef IPA_EMULATION_OSMO_PCU
+					case (IPAC_PROTO_EXT_OSMO_PCU) {
+						f_osmo_pcu_to_user(ipa_rx.msg);
+					}
+#endif
 					case else {
 						IPA_SP_PORT.send(f_to_asp(ipa_rx));
 					}
@@ -826,6 +860,14 @@
 		}
 #endif
 
+#ifdef IPA_EMULATION_OSMO_PCU
+		[] IPA_OSMO_PCU_PORT.receive(PCUIF_Message:?) -> value pcu {
+			payload := enc_PCUIF_Message(pcu);
+			ipa_ud := valueof(t_ASP_IPA_UD(IPAC_PROTO_OSMO, payload, IPAC_PROTO_EXT_OSMO_PCU));
+			IPA_PORT.send(f_from_asp(f_ipa_conn_id(), ipa_ud));
+		}
+#endif
+
 #ifdef IPA_EMULATION_RSL
 		/* Received RSL -> down into IPA */
 		[] IPA_RSL_PORT.receive(ASP_RSL_Unitdata:?) -> value rsl {