aboutsummaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2013-02-09 11:38:30 +0100
committerHarald Welte <laforge@gnumonks.org>2013-02-09 11:38:30 +0100
commit0bb2974b370080b43282323364ebc6b0b6480803 (patch)
treed45d9083bd815aa81027fab74ad0b0295f61784a /src/common
parent550d22be5b2ddc376ccae937bd34c921dcf4a071 (diff)
Fix determination of locally bound IP for RTP sockets
After we create a socket and bind it to INADDR_ANY, we cannot yet use getsockname() to resolve the locally bound IP. This only works after the socket has been connected to the remote IP. So we have to move the osmo_rtp_get_bound_ip_port() to a code section after osmo_rtp_socket_connect() has already happened. With the code prior to this commit, unless "rtp bind-ip" was used in the config file, we reported "0.0.0.0" as the "Source IP AddresS" in the IPA CRCX ACK to the BSC. This is of course wrong, as the BSC will then use this "0.0.0.0" as destination address for the incoming RTP stream :( Please note that for this fix to work, you also need a libosmoabis.git with commit d426d458ca96ba29793e35b1b2a73fbcb3b2c888 which actually causes osmo_rtp_socket_connect() to actually issue connect() on the socket at all.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/rsl.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/common/rsl.c b/src/common/rsl.c
index e1a8e8fc..1d1be91a 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -1,7 +1,7 @@
/* GSM TS 08.58 RSL, BTS Side */
/* (C) 2011 by Andreas Eversberg <jolly@eversberg.eu>
- * (C) 2011 by Harald Welte <laforge@gnumonks.org>
+ * (C) 2011-2013 by Harald Welte <laforge@gnumonks.org>
*
* All Rights Reserved
*
@@ -1275,13 +1275,6 @@ static int rsl_rx_ipac_XXcx(struct msgb *msg)
return tx_ipac_XXcx_nack(lchan, RSL_ERR_RES_UNAVAIL,
inc_ip_port, dch->c.msg_type);
}
- rc = osmo_rtp_get_bound_ip_port(lchan->abis_ip.rtp_socket,
- &lchan->abis_ip.bound_ip,
- &lchan->abis_ip.bound_port);
- if (rc < 0)
- LOGP(DRSL, LOGL_ERROR, "%s IPAC cannot obtain "
- "locally bound IP/port: %d\n",
- gsm_lchan_name(lchan), rc);
/* FIXME: multiplex connection, BSC proxy */
} else {
/* MDCX */
@@ -1319,6 +1312,14 @@ static int rsl_rx_ipac_XXcx(struct msgb *msg)
/* save IP address and port number */
lchan->abis_ip.connect_ip = ntohl(ia.s_addr);
lchan->abis_ip.connect_port = ntohs(*connect_port);
+
+ rc = osmo_rtp_get_bound_ip_port(lchan->abis_ip.rtp_socket,
+ &lchan->abis_ip.bound_ip,
+ &lchan->abis_ip.bound_port);
+ if (rc < 0)
+ LOGP(DRSL, LOGL_ERROR, "%s IPAC cannot obtain "
+ "locally bound IP/port: %d\n",
+ gsm_lchan_name(lchan), rc);
} else {
/* FIXME: discard all codec frames */
}