aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmo-bts/gsm_data_shared.h5
-rw-r--r--src/common/bts.c3
-rw-r--r--src/common/rsl.c26
-rw-r--r--src/common/vty.c40
4 files changed, 72 insertions, 2 deletions
diff --git a/include/osmo-bts/gsm_data_shared.h b/include/osmo-bts/gsm_data_shared.h
index 81cac3e3..f4fb7661 100644
--- a/include/osmo-bts/gsm_data_shared.h
+++ b/include/osmo-bts/gsm_data_shared.h
@@ -688,6 +688,11 @@ struct gsm_bts {
struct llist_head oml_queue;
unsigned int rtp_jitter_buf_ms;
bool rtp_jitter_adaptive;
+
+ uint16_t rtp_port_range_start;
+ uint16_t rtp_port_range_end;
+ uint16_t rtp_port_range_next;
+
struct {
uint8_t ciphers; /* flags A5/1==0x1, A5/2==0x2, A5/3==0x4 */
} support;
diff --git a/src/common/bts.c b/src/common/bts.c
index 74630cc3..54e5480a 100644
--- a/src/common/bts.c
+++ b/src/common/bts.c
@@ -135,6 +135,9 @@ int bts_init(struct gsm_bts *bts)
bts->paging_state = paging_init(bts, 200, 0);
bts->ul_power_target = -75; /* dBm default */
bts->rtp_jitter_adaptive = false;
+ bts->rtp_port_range_start = 16384;
+ bts->rtp_port_range_end = 17407;
+ bts->rtp_port_range_next = bts->rtp_port_range_start;
/* configurable via OML */
bts->load.ccch.load_ind_period = 112;
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",
diff --git a/src/common/vty.c b/src/common/vty.c
index 2716a7a7..60613352 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -262,6 +262,8 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
if (bts->rtp_jitter_adaptive)
vty_out(vty, " adaptive");
vty_out(vty, "%s", VTY_NEWLINE);
+ vty_out(vty, " rtp port-range %u %u%s", bts->rtp_port_range_start,
+ bts->rtp_port_range_end, VTY_NEWLINE);
vty_out(vty, " paging queue-size %u%s", paging_get_queue_max(bts->paging_state),
VTY_NEWLINE);
vty_out(vty, " paging lifetime %u%s", paging_get_lifetime(bts->paging_state),
@@ -486,6 +488,43 @@ DEFUN(cfg_bts_rtp_jitbuf,
return CMD_SUCCESS;
}
+DEFUN(cfg_bts_rtp_port_range,
+ cfg_bts_rtp_port_range_cmd,
+ "rtp port-range <1-65534> <1-65534>",
+ RTP_STR "Range of local ports to use for RTP/RTCP traffic\n")
+{
+ struct gsm_bts *bts = vty->index;
+ unsigned int start;
+ unsigned int end;
+
+ start = atoi(argv[0]);
+ end = atoi(argv[1]);
+
+ if (end < start) {
+ vty_out(vty, "range end port (%u) must be greater than the range start port (%u)!%s",
+ end, start, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ if (start & 1) {
+ vty_out(vty, "range must begin at an even port number! (%u not even)%s",
+ start, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ if ((end & 1) == 0) {
+ vty_out(vty, "range must end at an odd port number! (%u not odd)%s",
+ end, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ bts->rtp_port_range_start = start;
+ bts->rtp_port_range_end = end;
+ bts->rtp_port_range_next = bts->rtp_port_range_start;
+
+ return CMD_SUCCESS;
+}
+
#define PAG_STR "Paging related parameters\n"
DEFUN(cfg_bts_paging_queue_size,
@@ -1554,6 +1593,7 @@ int bts_vty_init(struct gsm_bts *bts, const struct log_info *cat)
install_element(BTS_NODE, &cfg_bts_oml_ip_cmd);
install_element(BTS_NODE, &cfg_bts_rtp_bind_ip_cmd);
install_element(BTS_NODE, &cfg_bts_rtp_jitbuf_cmd);
+ install_element(BTS_NODE, &cfg_bts_rtp_port_range_cmd);
install_element(BTS_NODE, &cfg_bts_band_cmd);
install_element(BTS_NODE, &cfg_description_cmd);
install_element(BTS_NODE, &cfg_no_description_cmd);