mgcp: hack to keep IuUP working

Since change If9a81d057f73150e483286472e73c45e7a453a6d removes the
RTP loopback at the beginning. This also means that the Hack we
do to run the IuUP negotiation via looping back the first few
RTP packets will not work anymore. However, we should keep that
hack as long as we do not have IuUP support in the MGW.

- Start RTP connection in loopback mode for IuUP

Change-Id: I4c7d90de4dc87e8baf7cf4a0c69d0e9e8c92e27b
diff --git a/src/libmsc/msc_mgcp.c b/src/libmsc/msc_mgcp.c
index 67a2142..c77e389 100644
--- a/src/libmsc/msc_mgcp.c
+++ b/src/libmsc/msc_mgcp.c
@@ -278,10 +278,22 @@
 	struct msgb *msg;
 	int rc;
 
+#ifdef BUILD_IU
+	struct gsm_trans *trans;
+	struct gsm_subscriber_connection *conn;
+#endif
+
 	OSMO_ASSERT(mgcp_ctx);
 	mgcp = mgcp_ctx->mgcp;
 	OSMO_ASSERT(mgcp);
 
+#ifdef BUILD_IU
+	trans = mgcp_ctx->trans;
+	OSMO_ASSERT(trans);
+	conn = trans->conn;
+	OSMO_ASSERT(conn);
+#endif
+
 	/* NOTE: In case of error, we will not be able to perform any DLCX
 	 * operation because until this point we do not have requested any
 	 * endpoint yet. */
@@ -302,6 +314,14 @@
 		return;
 	}
 
+	/* HACK: We put the connection in loopback mode at the beginnig to
+	 * trick the NodeB into doing the IuUP negotiation with itsself.
+	 * this is a hack we need because osmo-mgw does not support IuUP yet */
+#ifdef BUILD_IU
+	if (conn->via_ran == RAN_UTRAN_IU)
+		mgcp_msg.conn_mode = MGCP_CONN_LOOPBACK;
+#endif
+
 	msg = mgcp_msg_gen(mgcp, &mgcp_msg);
 	OSMO_ASSERT(msg);
 
@@ -377,10 +397,22 @@
 	struct msgb *msg;
 	int rc;
 
+#ifdef BUILD_IU
+	struct gsm_trans *trans;
+	struct gsm_subscriber_connection *conn;
+#endif
+
 	OSMO_ASSERT(mgcp_ctx);
 	mgcp = mgcp_ctx->mgcp;
 	OSMO_ASSERT(mgcp);
 
+#ifdef BUILD_IU
+	trans = mgcp_ctx->trans;
+	OSMO_ASSERT(trans);
+	conn = trans->conn;
+	OSMO_ASSERT(conn);
+#endif
+
 	switch (event) {
 	case EV_CRCX_RAN_RESP:
 		break;
@@ -405,6 +437,14 @@
 		return;
 	}
 
+	/* HACK: We put the connection in loopback mode at the beginnig to
+	 * trick the NodeB into doing the IuUP negotiation with itsself.
+	 * this is a hack we need because osmo-mgw does not support IuUP yet */
+#ifdef BUILD_IU
+	if (conn->via_ran == RAN_UTRAN_IU)
+		mgcp_msg.conn_mode = MGCP_CONN_LOOPBACK;
+#endif
+
 	msg = mgcp_msg_gen(mgcp, &mgcp_msg);
 	OSMO_ASSERT(msg);