aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2013-02-09 11:01:19 +0100
committerHarald Welte <laforge@gnumonks.org>2013-02-09 11:01:19 +0100
commitd426d458ca96ba29793e35b1b2a73fbcb3b2c888 (patch)
treede7da99594fb08a670389446098c66bad09cfeee
parentbd3f854f3c2d468722b26289fa52e381da41a455 (diff)
Permit libortp to use the connect() syscall, enabling later getsockname()
If we bind a local socket to INADDR_ANY, then getsockname() will always return 0.0.0.0 for the local IP address _unless_ the socket was previously connected to a specific remote IP/port using connect(). This will have the side effect that we only accept RTP packets from the one IP/port that we have connect()ed to, but that is actually intentional and useful in our applications.
-rw-r--r--src/trau/osmo_ortp.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/trau/osmo_ortp.c b/src/trau/osmo_ortp.c
index a9503ea..0e1e108 100644
--- a/src/trau/osmo_ortp.c
+++ b/src/trau/osmo_ortp.c
@@ -351,6 +351,11 @@ int osmo_rtp_socket_connect(struct osmo_rtp_socket *rs, const char *ip, uint16_t
{
int rc;
+ /* enable the use of connect() so later getsockname() will
+ * actually return the IP address that was chosen for the local
+ * sid of the connection */
+ rtp_session_set_connected_mode(rs->sess, 1);
+
rc = rtp_session_set_remote_addr(rs->sess, ip, port);
if (rc < 0)
return rc;