Check once if remote addr is available when sending dummy packet

It's checked in all code paths being called, which makes sense since
it's impossible to send anything if the remote address is not set. Let's
check it once in a unique to simplify the code.

Change-Id: I224dbfeda17c364b85166268e2ac1e019a87edb6
diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c
index d9a10a9..ebb41a6 100644
--- a/src/libosmo-mgcp/mgcp_osmux.c
+++ b/src/libosmo-mgcp/mgcp_osmux.c
@@ -645,9 +645,6 @@
 	 *  endpoint may have already punched the hole in the firewall. This
 	 *  approach is simple though. */
 
-	/* Wait until we have the connection information from MDCX */
-	if (!mgcp_rtp_end_remote_addr_available(&conn->end))
-		return 0;
 
 	if (endp_osmux_state_check(endp, conn, true) < 0)
 		return 0;
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 1d286ed..b4a4792 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -324,6 +324,11 @@
  * osmux connection, send the dummy packet via OSMUX */
 static void send_dummy(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn)
 {
+	/* Avoid sending dummy packet if the remote address was not yet
+	 * configured through CRCX/MDCX: */
+	if (!mgcp_rtp_end_remote_addr_available(&conn->end))
+		return;
+
 	if (mgcp_conn_rtp_is_osmux(conn))
 		osmux_send_dummy(endp, conn);
 	else
@@ -1090,7 +1095,6 @@
 	/* Send dummy packet, see also comments in mgcp_keepalive_timer_cb() */
 	OSMO_ASSERT(trunk->keepalive_interval >= MGCP_KEEPALIVE_ONCE);
 	if (conn->conn->mode & MGCP_CONN_RECV_ONLY &&
-	    mgcp_rtp_end_remote_addr_available(&conn->end) &&
 	    trunk->keepalive_interval != MGCP_KEEPALIVE_NEVER)
 		send_dummy(endp, conn);
 
@@ -1310,7 +1314,6 @@
 	/* Send dummy packet, see also comments in mgcp_keepalive_timer_cb() */
 	OSMO_ASSERT(trunk->keepalive_interval >= MGCP_KEEPALIVE_ONCE);
 	if (conn->conn->mode & MGCP_CONN_RECV_ONLY &&
-	    mgcp_rtp_end_remote_addr_available(&conn->end) &&
 	    trunk->keepalive_interval != MGCP_KEEPALIVE_NEVER)
 		send_dummy(endp, conn);
 
@@ -1579,8 +1582,7 @@
 		struct mgcp_endpoint *endp = trunk->endpoints[i];
 		llist_for_each_entry(conn, &endp->conns, entry) {
 			if (conn->type == MGCP_CONN_TYPE_RTP &&
-			    conn->mode == MGCP_CONN_RECV_ONLY &&
-			     mgcp_rtp_end_remote_addr_available(&conn->u.rtp.end))
+			    conn->mode == MGCP_CONN_RECV_ONLY)
 				send_dummy(endp, &conn->u.rtp);
 		}
 	}