- RTP proxy: don't try to forward empty RTP packets
- renamed some variables of rtp_proxytable_t to make better sense (changed meaning in fullduplex RTP proxy)
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
=====
|
||||
28-Jan-2004: - don't die on INVITE requests that include no Contact
|
||||
header - which is legal. (patch by Robert Högberg)
|
||||
- RTP proxy: don't try to forward empty RTP packets
|
||||
- renamed some variables of rtp_proxytable_t to make
|
||||
better sense (changed meaning in fullduplex RTP proxy)
|
||||
27-Jan-2004: - added doc/KNOWN_BUGS
|
||||
- better branch parameter calculation (via header),
|
||||
now honors RFC3261 for stateless proxies (section 16.11)
|
||||
|
||||
+4
-4
@@ -66,16 +66,16 @@ int rtpproxy_init( void ) {
|
||||
*/
|
||||
int rtp_start_fwd (osip_call_id_t *callid, int direction,
|
||||
int media_stream_no,
|
||||
struct in_addr outbound_ipaddr, int *outboundport,
|
||||
struct in_addr lcl_client_ipaddr, int lcl_clientport) {
|
||||
struct in_addr local_ipaddr, int *local_port,
|
||||
struct in_addr remote_ipaddr, int remote_port) {
|
||||
int sts=STS_FAILURE;
|
||||
|
||||
if (configuration.rtp_proxy_enable == 0) {
|
||||
sts = STS_SUCCESS;
|
||||
} else if (configuration.rtp_proxy_enable == 1) { // Relay
|
||||
sts = rtp_relay_start_fwd (callid, direction, media_stream_no,
|
||||
outbound_ipaddr, outboundport,
|
||||
lcl_client_ipaddr, lcl_clientport);
|
||||
local_ipaddr, local_port,
|
||||
remote_ipaddr, remote_port);
|
||||
} else {
|
||||
ERROR("CONFIG: rtp_proxy_enable has invalid value",
|
||||
configuration.rtp_proxy_enable);
|
||||
|
||||
+8
-8
@@ -28,10 +28,10 @@ typedef struct {
|
||||
char callid_host[CALLIDHOST_SIZE]; /* --"-- */
|
||||
int direction; /* Direction of RTP stream */
|
||||
int media_stream_no;
|
||||
struct in_addr outbound_ipaddr; /* lcl outbound IP */
|
||||
int outboundport; /* lcl allocd outbound port */
|
||||
struct in_addr inbound_client_ipaddr; /* lcl inbound UA IP */
|
||||
int inbound_client_port; /* lcl inbound UA port */
|
||||
struct in_addr local_ipaddr; /* local IP */
|
||||
int local_port; /* local allocated port */
|
||||
struct in_addr remote_ipaddr; /* remote IP */
|
||||
int remote_port; /* remote port */
|
||||
time_t timestamp; /* last 'stream alive' TS */
|
||||
} rtp_proxytable_t;
|
||||
|
||||
@@ -41,8 +41,8 @@ typedef struct {
|
||||
int rtp_relay_init(void);
|
||||
int rtp_relay_start_fwd (osip_call_id_t *callid, int direction,
|
||||
int media_stream_no,
|
||||
struct in_addr outbound_ipaddr, int *outboundport,
|
||||
struct in_addr lcl_client_ipaddr, int lcl_clientport);
|
||||
struct in_addr local_ipaddr, int *local_port,
|
||||
struct in_addr remote_ipaddr, int remote_port);
|
||||
int rtp_relay_stop_fwd (osip_call_id_t *callid, int direction, int nolock);
|
||||
|
||||
|
||||
@@ -52,8 +52,8 @@ int rtp_relay_stop_fwd (osip_call_id_t *callid, int direction, int nolock);
|
||||
int rtp_masq_init(void);
|
||||
int rtp_masq_start_fwd (osip_call_id_t *callid, int direction,
|
||||
int media_stream_no,
|
||||
struct in_addr outbound_ipaddr, int *outboundport,
|
||||
struct in_addr lcl_client_ipaddr, int lcl_clientport);
|
||||
struct in_addr local_ipaddr, int *local_port,
|
||||
struct in_addr remote_ipaddr, int remote_port);
|
||||
int rtp_masq_stop_fwd (osip_call_id_t *callid, int direction);
|
||||
|
||||
/*
|
||||
|
||||
+71
-60
@@ -113,7 +113,6 @@ static void *rtpproxy_main(void *arg) {
|
||||
int i, sts;
|
||||
int num_fd;
|
||||
osip_call_id_t callid;
|
||||
//&&&& static int rtp_socket=0;
|
||||
static char rtp_buff[RTP_BUFFER_SIZE];
|
||||
int count;
|
||||
|
||||
@@ -157,47 +156,59 @@ static void *rtpproxy_main(void *arg) {
|
||||
count=read(rtp_proxytable[i].rtp_rx_sock, rtp_buff, RTP_BUFFER_SIZE);
|
||||
|
||||
if (count<0) {
|
||||
WARN("read() returned error [%s]",strerror(errno));
|
||||
}
|
||||
|
||||
//&&&& /* write to dest via socket rtp__socket */
|
||||
//&&&& sts = sipsock_send_udp(&rtp_socket,
|
||||
//&&&& rtp_proxytable[i].inbound_client_ipaddr,
|
||||
//&&&& rtp_proxytable[i].inbound_client_port,
|
||||
//&&&& rtp_buff, count, 0); /* don't dump it */
|
||||
if (rtp_proxytable[i].rtp_tx_sock == 0)
|
||||
{
|
||||
int j;
|
||||
osip_call_id_t callid;
|
||||
int direction = rtp_proxytable[i].direction;
|
||||
int media_stream_no = rtp_proxytable[i].media_stream_no;
|
||||
|
||||
callid.number = rtp_proxytable[i].callid_number;
|
||||
callid.host = rtp_proxytable[i].callid_host;
|
||||
|
||||
for (j=0;(j<RTPPROXY_SIZE);j++) {
|
||||
osip_call_id_t cid;
|
||||
|
||||
cid.number = rtp_proxytable[j].callid_number;
|
||||
cid.host = rtp_proxytable[j].callid_host;
|
||||
|
||||
if ( (rtp_proxytable[j].rtp_rx_sock != 0) &&
|
||||
(direction != rtp_proxytable[j].direction) &&
|
||||
(media_stream_no == rtp_proxytable[j].media_stream_no) &&
|
||||
(compare_callid(&callid, &cid) == STS_SUCCESS) ) {
|
||||
rtp_proxytable[i].rtp_tx_sock = rtp_proxytable[j].rtp_rx_sock;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rtp_proxytable[i].rtp_tx_sock != 0) {
|
||||
/* write to dest via socket rtp_tx_sock */
|
||||
sts = sipsock_send_udp(&rtp_proxytable[i].rtp_tx_sock,
|
||||
rtp_proxytable[i].inbound_client_ipaddr,
|
||||
rtp_proxytable[i].inbound_client_port,
|
||||
rtp_buff, count, 0); /* don't dump it */
|
||||
int j;
|
||||
WARN("read() [fd=%i, %s:%i] returned error [%s]",
|
||||
rtp_proxytable[i].rtp_rx_sock,
|
||||
utils_inet_ntoa(rtp_proxytable[i].local_ipaddr),
|
||||
rtp_proxytable[i].local_port, strerror(errno));
|
||||
for (j=0; j<RTPPROXY_SIZE;j++) {
|
||||
DEBUGC(DBCLASS_RTP, "%i - rx:%i tx:%i %s@%s dir:%i",
|
||||
rtp_proxytable[j].rtp_tx_sock,
|
||||
rtp_proxytable[j].callid_number,
|
||||
rtp_proxytable[j].callid_host,
|
||||
rtp_proxytable[j].direction);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* forwarding an RTP packet only makes sense if we really
|
||||
* have got some data in it (count > 0)
|
||||
*/
|
||||
if (count > 0) {
|
||||
if (rtp_proxytable[i].rtp_tx_sock == 0) {
|
||||
int j;
|
||||
osip_call_id_t callid;
|
||||
int direction = rtp_proxytable[i].direction;
|
||||
int media_stream_no = rtp_proxytable[i].media_stream_no;
|
||||
|
||||
callid.number = rtp_proxytable[i].callid_number;
|
||||
callid.host = rtp_proxytable[i].callid_host;
|
||||
|
||||
for (j=0;(j<RTPPROXY_SIZE);j++) {
|
||||
osip_call_id_t cid;
|
||||
|
||||
cid.number = rtp_proxytable[j].callid_number;
|
||||
cid.host = rtp_proxytable[j].callid_host;
|
||||
|
||||
if ( (rtp_proxytable[j].rtp_rx_sock != 0) &&
|
||||
(direction != rtp_proxytable[j].direction) &&
|
||||
(media_stream_no == rtp_proxytable[j].media_stream_no) &&
|
||||
(compare_callid(&callid, &cid) == STS_SUCCESS) ) {
|
||||
rtp_proxytable[i].rtp_tx_sock = rtp_proxytable[j].rtp_rx_sock;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} /* rtp_tx_sock == 0 */
|
||||
|
||||
if (rtp_proxytable[i].rtp_tx_sock != 0) {
|
||||
/* write to dest via socket rtp_tx_sock */
|
||||
sts = sipsock_send_udp(&rtp_proxytable[i].rtp_tx_sock,
|
||||
rtp_proxytable[i].remote_ipaddr,
|
||||
rtp_proxytable[i].remote_port,
|
||||
rtp_buff, count, 0); /* don't dump it */
|
||||
}
|
||||
} /* count > 0 */
|
||||
|
||||
/* update timestamp of last usage */
|
||||
rtp_proxytable[i].timestamp=t;
|
||||
|
||||
@@ -249,9 +260,9 @@ static void *rtpproxy_main(void *arg) {
|
||||
* STS_FAILURE on error
|
||||
*/
|
||||
int rtp_relay_start_fwd (osip_call_id_t *callid, int direction,
|
||||
int media_stream_no, struct in_addr outbound_ipaddr,
|
||||
int *outboundport, struct in_addr lcl_client_ipaddr,
|
||||
int lcl_clientport) {
|
||||
int media_stream_no, struct in_addr local_ipaddr,
|
||||
int *local_port, struct in_addr remote_ipaddr,
|
||||
int remote_port) {
|
||||
int i, j;
|
||||
int sock, port;
|
||||
int freeidx;
|
||||
@@ -319,17 +330,17 @@ int rtp_relay_start_fwd (osip_call_id_t *callid, int direction,
|
||||
* for a given media stream
|
||||
* (seen with KPhone during HOLD/unHOLD)
|
||||
*/
|
||||
if (rtp_proxytable[i].inbound_client_port != lcl_clientport) {
|
||||
if (rtp_proxytable[i].remote_port != remote_port) {
|
||||
DEBUGC(DBCLASS_RTP,"RTP port number changed %i -> %i",
|
||||
rtp_proxytable[i].inbound_client_port, lcl_clientport);
|
||||
rtp_proxytable[i].inbound_client_port = lcl_clientport;
|
||||
rtp_proxytable[i].remote_port, remote_port);
|
||||
rtp_proxytable[i].remote_port = remote_port;
|
||||
}
|
||||
/* return the already known port number */
|
||||
DEBUGC(DBCLASS_RTP,"RTP stream already active (port=%i, "
|
||||
"id=%s, #=%i)", rtp_proxytable[i].outboundport,
|
||||
"id=%s, #=%i)", rtp_proxytable[i].local_port,
|
||||
rtp_proxytable[i].callid_number,
|
||||
rtp_proxytable[i].media_stream_no);
|
||||
*outboundport=rtp_proxytable[i].outboundport;
|
||||
*local_port=rtp_proxytable[i].local_port;
|
||||
sts = STS_SUCCESS;
|
||||
goto unlock_and_exit;
|
||||
}
|
||||
@@ -359,21 +370,21 @@ int rtp_relay_start_fwd (osip_call_id_t *callid, int direction,
|
||||
random start offset
|
||||
- for i=x to (p1-p0)+x; p=p0+mod(x,p1-p0) */
|
||||
|
||||
/* find a local outbound port number to use and bind to it*/
|
||||
/* find a local outbound 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 (j=0; j<RTPPROXY_SIZE; j++) {
|
||||
/* outbound port already in use */
|
||||
if ((memcmp(&rtp_proxytable[j].outbound_ipaddr,
|
||||
&outbound_ipaddr, sizeof(struct in_addr))== 0) &&
|
||||
(rtp_proxytable[j].outboundport == i) ) break;
|
||||
if ((memcmp(&rtp_proxytable[j].local_ipaddr,
|
||||
&local_ipaddr, sizeof(struct in_addr))== 0) &&
|
||||
(rtp_proxytable[j].local_port == i) ) break;
|
||||
}
|
||||
|
||||
/* port is available, try to allocate */
|
||||
if (j == RTPPROXY_SIZE) {
|
||||
port=i;
|
||||
sock=sockbind(outbound_ipaddr, port, 0);
|
||||
sock=sockbind(local_ipaddr, port, 0);
|
||||
/* if success break, else try further on */
|
||||
if (sock) break;
|
||||
}
|
||||
@@ -406,15 +417,15 @@ int rtp_relay_start_fwd (osip_call_id_t *callid, int direction,
|
||||
|
||||
rtp_proxytable[freeidx].direction = direction;
|
||||
rtp_proxytable[freeidx].media_stream_no = media_stream_no;
|
||||
memcpy(&rtp_proxytable[freeidx].outbound_ipaddr,
|
||||
&outbound_ipaddr, sizeof(struct in_addr));
|
||||
rtp_proxytable[freeidx].outboundport=port;
|
||||
memcpy(&rtp_proxytable[freeidx].inbound_client_ipaddr,
|
||||
&lcl_client_ipaddr, sizeof(struct in_addr));
|
||||
rtp_proxytable[freeidx].inbound_client_port=lcl_clientport;
|
||||
memcpy(&rtp_proxytable[freeidx].local_ipaddr,
|
||||
&local_ipaddr, sizeof(struct in_addr));
|
||||
rtp_proxytable[freeidx].local_port=port;
|
||||
memcpy(&rtp_proxytable[freeidx].remote_ipaddr,
|
||||
&remote_ipaddr, sizeof(struct in_addr));
|
||||
rtp_proxytable[freeidx].remote_port=remote_port;
|
||||
time(&rtp_proxytable[freeidx].timestamp);
|
||||
|
||||
*outboundport=port;
|
||||
*local_port=port;
|
||||
|
||||
/* prepare FD set for next select operation */
|
||||
rtp_recreate_fdset();
|
||||
|
||||
+3
-2
@@ -165,8 +165,9 @@ int sipsock_send_udp(int *sock, struct in_addr addr, int port,
|
||||
|
||||
if (sts == -1) {
|
||||
if (errno != ECONNREFUSED) {
|
||||
ERROR("sendto() [%s:%i] call failed: %s", utils_inet_ntoa(addr),
|
||||
port, strerror(errno));
|
||||
ERROR("sendto() [%s:%i size=%i] call failed: %s",
|
||||
utils_inet_ntoa(addr),
|
||||
port, size, strerror(errno));
|
||||
return STS_FAILURE;
|
||||
}
|
||||
DEBUGC(DBCLASS_BABBLE,"sendto() [%s:%i] call failed: %s",
|
||||
|
||||
Reference in New Issue
Block a user