aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/rsl.c
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2018-05-22 17:35:49 +0200
committerPhilipp Maier <pmaier@sysmocom.de>2018-05-25 15:41:35 +0200
commitf1e2d08022cf1cc7682ae5b618476ad7acb4f53a (patch)
tree2a2c245414edeca4e7f3a6fe838777d43397f941 /src/common/rsl.c
parentae3da5f8c3761567c69c2bb8866ac6a5a51eeb7f (diff)
rtp: make port range configurable, assign correct port numbers
The current implementation does not allow the user to specify a port range in which the BTS is allowed to allocate a local RTP port. Also the ports the BTS picks do not match the policy described in RFC3550. An RTP Port must be at an even port number and the matching RTCP port must be at the following (odd) port number. The BTS currently picks random port numbers for both. - Add a VTY command to specify a port range in which the BTS may assign local ports. - Pick ports as described in RFC3550. Change-Id: Id75f1dfaf898ed8750d28b1c4840e188f4cfdc87 Related: OS#2825 OS#2635
Diffstat (limited to 'src/common/rsl.c')
-rw-r--r--src/common/rsl.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/common/rsl.c b/src/common/rsl.c
index 5dd2c59f..b5d0c2b0 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -1787,6 +1787,29 @@ static char *get_rsl_local_ip(struct gsm_bts_trx *trx)
return hostbuf;
}
+static int bind_rtp(struct gsm_bts *bts, struct osmo_rtp_socket *rs, const char *ip)
+{
+ int rc;
+ unsigned int i;
+ unsigned int tries;
+
+ tries = (bts->rtp_port_range_end - bts->rtp_port_range_start) / 2;
+ for (i = 0; i < tries; i++) {
+
+ if (bts->rtp_port_range_next >= bts->rtp_port_range_end)
+ bts->rtp_port_range_next = bts->rtp_port_range_start;
+
+ rc = osmo_rtp_socket_bind(rs, ip, bts->rtp_port_range_next);
+
+ bts->rtp_port_range_next += 2;
+
+ if (rc == 0)
+ return 0;
+ }
+
+ return -1;
+}
+
static int rsl_rx_ipac_XXcx(struct msgb *msg)
{
struct abis_rsl_dchan_hdr *dch = msgb_l2(msg);
@@ -1907,8 +1930,7 @@ static int rsl_rx_ipac_XXcx(struct msgb *msg)
* back to the BSC in the CRCX_ACK */
ipstr = get_rsl_local_ip(lchan->ts->trx);
}
- rc = osmo_rtp_socket_bind(lchan->abis_ip.rtp_socket,
- ipstr, -1);
+ rc = bind_rtp(bts, lchan->abis_ip.rtp_socket, ipstr);
if (rc < 0) {
LOGP(DRTP, LOGL_ERROR,
"%s IPAC Failed to bind RTP/RTCP sockets\n",