From d426d458ca96ba29793e35b1b2a73fbcb3b2c888 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 9 Feb 2013 11:01:19 +0100 Subject: 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. --- src/trau/osmo_ortp.c | 5 +++++ 1 file changed, 5 insertions(+) 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; -- cgit v1.2.3