From 5dbfc78aff00d0c7e939b761de806065264149ec Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Tue, 12 Dec 2017 16:20:25 +0100 Subject: [PATCH] network: use originating RTP packet address for loopback When a connection is created in loopback mode all incoming packets should be reflected back to their origin. If the user did not supply a destination address with the CRCX command all incoming packets will be tossed because no destination address is officially known yet. If there is no destination address set and the connection is in loopback mode. Then use the originating address of the incoming packet as destination address. Change-Id: I3d1abe56d016e28c97f60635eb574679d36e2c52 --- src/libosmo-mgcp/mgcp_network.c | 9 +++++++++ 1 file changed, 9 insertions(+) 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); }