diff --git a/ChangeLog b/ChangeLog index 156c0c4..178fcf7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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) diff --git a/src/rtpproxy.c b/src/rtpproxy.c index 5fc7b75..ed3b686 100644 --- a/src/rtpproxy.c +++ b/src/rtpproxy.c @@ -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); diff --git a/src/rtpproxy.h b/src/rtpproxy.h index 02c81f9..2776176 100644 --- a/src/rtpproxy.h +++ b/src/rtpproxy.h @@ -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); /* diff --git a/src/rtpproxy_relay.c b/src/rtpproxy_relay.c index 7d5aae1..5177765 100644 --- a/src/rtpproxy_relay.c +++ b/src/rtpproxy_relay.c @@ -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 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 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