diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c index eb44f9b82..aac3e5177 100644 --- a/src/libosmo-mgcp/mgcp_network.c +++ b/src/libosmo-mgcp/mgcp_network.c @@ -1077,7 +1077,16 @@ static int rtp_data_net(struct osmo_fd *fd, unsigned int what) /* Check if the connection is in loopback mode, if yes, just send the * incoming data back to the origin */ + if (conn_src->conn->mode == MGCP_CONN_LOOPBACK) { + /* When we are in loopback mode, we loop back all incoming + * packets back to their origin. We will use the originating + * address data from the UDP packet header to patch the + * outgoing address in connection on the fly */ + if (conn_src->end.rtp_port == 0) { + conn_src->end.addr = addr.sin_addr; + conn_src->end.rtp_port = addr.sin_port; + } return mgcp_send_rtp(proto, &addr, buf, len, conn_src, conn_src); }