- when allocating local ports for RTP relaying, do this

in a round-robin way over the available port range.
This commit is contained in:
Thomas Ries 2005-03-20 10:35:59 +00:00
parent 0984731872
commit 4acb6d6e34
2 changed files with 21 additions and 2 deletions

View File

@ -1,5 +1,7 @@
0.5.11
======
20-Mar-2005: - when allocating local ports for RTP relaying, do this
in a round-robin way over the available port range.
1-Mar-2005: - working on running siproxd in front of a routing device
and NOT on the firewall itself.
19-Feb-2005: - more work on new libosip API

View File

@ -389,7 +389,9 @@ int rtp_relay_start_fwd (osip_call_id_t *callid, char *client_id,
int media_stream_no, struct in_addr local_ipaddr,
int *local_port, struct in_addr remote_ipaddr,
int remote_port) {
int i, j;
static int prev_used_port = 0;
int num_ports;
int i2, i, j;
int sock, port;
int freeidx;
int sts=STS_SUCCESS;
@ -526,7 +528,20 @@ int rtp_relay_start_fwd (osip_call_id_t *callid, char *client_id,
/* find a local port number to use and bind to it */
sock=0;
port=0;
for (i=configuration.rtp_port_low; i<=configuration.rtp_port_high; i+=2) {
// for (i=configuration.rtp_port_low; i<=configuration.rtp_port_high; i+=2) {
DEBUGC(DBCLASS_RTP,"*****a prev_used_port=%i",prev_used_port);
if ((prev_used_port < configuration.rtp_port_low) ||
(prev_used_port > configuration.rtp_port_high)) {
prev_used_port = configuration.rtp_port_high;
}
num_ports = configuration.rtp_port_high - configuration.rtp_port_low + 1;
for (i2 = (prev_used_port - configuration.rtp_port_low + 1);
i2 < (num_ports + prev_used_port - configuration.rtp_port_low + 1);
i2 += 2) {
i = (i2%num_ports) + configuration.rtp_port_low;
DEBUGC(DBCLASS_RTP,"***** i=%i, i2=%i",i,i2);
for (j=0; j<RTPPROXY_SIZE; j++) {
/* check if port already in use */
if ((memcmp(&rtp_proxytable[j].local_ipaddr,
@ -542,6 +557,8 @@ int rtp_relay_start_fwd (osip_call_id_t *callid, char *client_id,
if (sock) break;
}
} /* for i */
prev_used_port = port;
DEBUGC(DBCLASS_RTP,"*****z prev_used_port=%i",prev_used_port);
DEBUGC(DBCLASS_RTP,"rtp_relay_start_fwd: addr=%s, port=%i, sock=%i "
"freeidx=%i", utils_inet_ntoa(local_ipaddr), port, sock, freeidx);