- Fix for local-UA to local-UA RTP proxying, symmetric

RTP was not working.
This commit is contained in:
Thomas Ries
2004-02-07 16:54:09 +00:00
parent b044b72456
commit c9d86d78d7
4 changed files with 106 additions and 94 deletions
+67 -65
View File
@@ -1,13 +1,15 @@
0.5.3
=====
1-Feb-2004: - Added handling of Max-Forwards header
- a detected via loop results in an 482 Loop detected
31-Jan-2004: - Allow 2 of my vias in header to let 2 UA's sitting
behind the same siproxd have conversation together
7-Feb-2004: - Fix for local-UA to local-UA RTP proxying, symmetric
RTP was not working.
1-Feb-2004: - Added handling of Max-Forwards header
- a detected via loop results in an 482 Loop detected
31-Jan-2004: - Allow 2 of my vias in header to let 2 UA's sitting
behind the same siproxd have conversation together
UA1 -->--\ > /-->--\
siproxd Registrar
UA2 --<--/ < \--<--/
- Redone code for evaluation if a received packet
- Redone code for evaluation if a received packet
is coming from the inbound or outbound network
- RTP streams are now identified by call_id AND
USERNAME of the contact header. This provides
@@ -17,26 +19,26 @@
UA1 -->--\
siproxd
UA2 --<--/
- Rewriting of SUBSCRIBE messages should now work.
- Rewriting of SUBSCRIBE messages should now work.
- Removed obsolete prototypes from rtpproxy.h
- If the RTP stream in one direction is found to be
- If the RTP stream in one direction is found to be
aborted (sendto() failure), also stop the stream
for the opposite direction
0.5.2
=====
31-Jan-2004: - Released 0.5.2
30-Jan-2004: - If RTP proxy is disabled, don't rewrite incomming
SDP bodies (patch from Robert Högberg)
29-Jan-2004: - new doc/RFC3261_compliance.txt and comments in the
code that refer to the RFC.
28-Jan-2004: - don't die on INVITE requests that include no Contact
31-Jan-2004: - Released 0.5.2
30-Jan-2004: - If RTP proxy is disabled, don't rewrite incomming
SDP bodies (patch from Robert Högberg)
29-Jan-2004: - new doc/RFC3261_compliance.txt and comments in the
code that refer to the RFC.
28-Jan-2004: - don't die on INVITE requests that include no Contact
header - which is legal. (patch from Robert Högberg)
- RTP proxy: don't try to forward empty RTP packets
- renamed some variables of rtp_proxytable_t to make
- 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),
27-Jan-2004: - added doc/KNOWN_BUGS
- better branch parameter calculation (via header),
now honors RFC3261 for stateless proxies (section 16.11)
- SIP request: remove a Route header pointing to myself.
This was an issue with Linphone 0.12.1.
@@ -46,14 +48,14 @@
use one single port (and socket) on each side (inbound/
outbound) to send and receive RTP traffic for every
active stream (patch from Christof Meerwald).
22-Jan-2004: - ./configure option: --enable-static to build
a completely statically linked executable
22-Jan-2004: - ./configure option: --enable-static to build
a completely statically linked executable
- REGISTER honors the expires parameter
of the contact header
- Contact header of REGISTER response must be
rewritten back to the local (true) URL
18-Jan-2004: - security_check_raw:
size check: >= 16 bytes
18-Jan-2004: - security_check_raw:
size check: >= 16 bytes
- at exit, check registration file to be writable
- no WARNING if SIP user-agent header is not supplied.
- Call logging: distinguish between In & Out
@@ -61,70 +63,70 @@
0.5.1
=====
22-Dec-2003: - Released 0.5.1
21-Dec-2003: - possibility to log call establishment
17-Dec-2003: - full duplex RTP proxy (many thanks to Chris Ross for
his work on this). Up to now, only the RTP *Relay*
22-Dec-2003: - Released 0.5.1
21-Dec-2003: - possibility to log call establishment
17-Dec-2003: - full duplex RTP proxy (many thanks to Chris Ross for
his work on this). Up to now, only the RTP *Relay*
has been tested (it works with KPhone, BudgeTone)
- fix: SIP phones that allocate a random port for
- fix: SIP phones that allocate a random port for
incomming SIP traffic should now work (like BudgeTone)
- fix: some SIP phones do change the RTP port number
- fix: some SIP phones do change the RTP port number
during a session (like KPhone during HOLD/unHOLD)
- textual corrections
15-Dec-2003: - use only even port numbers for RTP traffic
05-Dec-2003: - some changes & enhancements inspired by Chris Ross:
* 183 Trying *may* contain SDP data
- textual corrections
15-Dec-2003: - use only even port numbers for RTP traffic
05-Dec-2003: - some changes & enhancements inspired by Chris Ross:
* 183 Trying *may* contain SDP data
* compare_url: now does compare the scheme,
if a host is not resolveable, hostnames will be
compared as strings
04-Dec-2003: - have registrations persistent across restarts of
the daemon ('registration_file' config option)
29-Nov-2003: - some documentation & FAQ updates
04-Dec-2003: - have registrations persistent across restarts of
the daemon ('registration_file' config option)
29-Nov-2003: - some documentation & FAQ updates
0.5.0
=====
26-Nov-2003: - released 0.5.0
- included preliminary support for IPTABLES (netfiler)
based systems.
24-Nov-2003: - some fixes in sockbind() (FreeBSD) by Jeremy Shaw
23-Nov-2003: - got the gethostbyname() failure problem solved.
(the resolver needs a shared lib that was tried
to load AFTER chrooting...)
22-Nov-2003: - utils.c: use gethostbyname_r() in favor of
gethostbyname - if available (siproxd uses threads!)
- some small items & cleanup
19-Nov-2003: - Integrated a patch from Chris Ross:
* have siproxd compile on Solaris and BSD/OS (more to come)
* ./configure option --with-libosip-prefix
* properly handle getopt_long()/getopt()
18-Nov-2003: - readconfig.c: include sysconfdir to the list of locations
where siproxd will search for its config file
14-Nov-2003: - rtpproxy.c: sys/types.h needed for *BSD
- tested: siproxd builds on FreeBSD 4.9
2-Nov-2003: - rtpproxy bugfix: On repetitive INVITES, the UDP media
26-Nov-2003: - released 0.5.0
- included preliminary support for IPTABLES (netfiler)
based systems.
24-Nov-2003: - some fixes in sockbind() (FreeBSD) by Jeremy Shaw
23-Nov-2003: - got the gethostbyname() failure problem solved.
(the resolver needs a shared lib that was tried
to load AFTER chrooting...)
22-Nov-2003: - utils.c: use gethostbyname_r() in favor of
gethostbyname - if available (siproxd uses threads!)
- some small items & cleanup
19-Nov-2003: - Integrated a patch from Chris Ross:
* have siproxd compile on Solaris and BSD/OS (more to come)
* ./configure option --with-libosip-prefix
* properly handle getopt_long()/getopt()
18-Nov-2003: - readconfig.c: include sysconfdir to the list of locations
where siproxd will search for its config file
14-Nov-2003: - rtpproxy.c: sys/types.h needed for *BSD
- tested: siproxd builds on FreeBSD 4.9
2-Nov-2003: - rtpproxy bugfix: On repetitive INVITES, the UDP media
port could end up as -1 in the rewritten packet.
1-Nov-2003: - siproxd can use another outbound proxy (chaining)
- Linux 2.4.x: siproxd with RTP relay could hang
1-Nov-2003: - siproxd can use another outbound proxy (chaining)
- Linux 2.4.x: siproxd with RTP relay could hang
on termination (Thread termination). Fixed.
0.4.2
=====
31-Oct-2003: - released 0.4.2
- Makefile: install siproxd to sbin (was bin)
24-Oct-2003: - SPEC file: included config files & more docu
19-Oct-2003: - included compiling support for DMALLOC debugging
- fixed 2 memory leaks in proxy.c
31-Oct-2003: - released 0.4.2
- Makefile: install siproxd to sbin (was bin)
24-Oct-2003: - SPEC file: included config files & more docu
19-Oct-2003: - included compiling support for DMALLOC debugging
- fixed 2 memory leaks in proxy.c
0.4.1
=====
12-Oct-2003: - released 0.4.1
12-Oct-2003: - Local registration of UAs was simply broken. Fixed.
12-Oct-2003: - released 0.4.1
12-Oct-2003: - Local registration of UAs was simply broken. Fixed.
0.4.0
=====
11-Oct-2003: - released 0.4.0
08-Oct-2003: - rtpproxy_masq: fixed an issue in port allocation
which lead to syslog entries from IPCHAINS complaining
11-Oct-2003: - released 0.4.0
08-Oct-2003: - rtpproxy_masq: fixed an issue in port allocation
which lead to syslog entries from IPCHAINS complaining
about 'already used connection' in the syslog.
- added INFO() for incomming SIP Calls
04-Oct-2003: - Siproxd now also works as outbound proxy 'only',
+15 -8
View File
@@ -330,14 +330,14 @@ int proxy_request (osip_message_t *request, struct sockaddr_in *from) {
}
#endif
/* rewrite Contact header to represent the masqued address */
sip_rewrite_contact(request, DIR_OUTGOING);
/* if an INVITE, rewrite body */
if (MSG_IS_INVITE(request)) {
sts = proxy_rewrite_invitation_body(request, DIR_OUTGOING);
}
/* rewrite Contact header to represent the masqued address */
sip_rewrite_contact(request, DIR_OUTGOING);
/* if this is CANCEL/BYE request, stop RTP proxying */
if (MSG_IS_BYE(request) || MSG_IS_CANCEL(request)) {
/* stop the RTP proxying stream(s) */
@@ -806,6 +806,7 @@ int proxy_rewrite_invitation_body(osip_message_t *mymsg, int direction){
int media_stream_no;
sdp_connection_t *sdp_conn;
sdp_media_t *sdp_med;
int rtp_direction=0;
/*
* get SDP structure
@@ -877,15 +878,21 @@ if (configuration.debuglevel)
/* figure out what address to use for RTP masquerading */
if (MSG_IS_REQUEST(mymsg)) {
if (direction == DIR_INCOMING)
if (direction == DIR_INCOMING) {
map_addr = inside_addr;
else
rtp_direction = DIR_OUTGOING;
} else {
map_addr = outside_addr;
rtp_direction = DIR_INCOMING;
}
} else /* MSG_IS_REPONSE(mymsg) */ {
if (direction == DIR_INCOMING)
if (direction == DIR_INCOMING) {
map_addr = inside_addr;
else
rtp_direction = DIR_OUTGOING;
} else {
map_addr = outside_addr;
rtp_direction = DIR_INCOMING;
}
}
/*
@@ -929,7 +936,7 @@ if (configuration.debuglevel)
rtp_start_fwd(osip_message_get_call_id(mymsg),
user,
direction,
rtp_direction,
media_stream_no,
map_addr, &map_port,
msg_addr, msg_port);
+4 -4
View File
@@ -20,13 +20,13 @@
#define CALLIDNUM_SIZE 256
#define CALLIDHOST_SIZE 32
#define CLIENT_ID_SIZE 128
typedef struct {
int rtp_rx_sock; /* rx socket (0 -> free slot)*/
int rtp_tx_sock; /* tx socket */
char callid_number[CALLIDNUM_SIZE]; /* call ID */
char callid_host[CALLIDHOST_SIZE]; /* --"-- */
char client_id[USERNAME_SIZE];
char client_id[CLIENT_ID_SIZE];
int direction; /* Direction of RTP stream */
int media_stream_no;
struct in_addr local_ipaddr; /* local IP */
@@ -41,7 +41,7 @@ typedef struct {
*/
int rtp_relay_init(void);
int rtp_relay_start_fwd (osip_call_id_t *callid, char *client_id,
int direction, int media_stream_no,
int rtp_direction, int media_stream_no,
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);
int rtp_relay_stop_fwd (osip_call_id_t *callid, int rtp_direction, int nolock);
+20 -17
View File
@@ -183,23 +183,26 @@ static void *rtpproxy_main(void *arg) {
* have got some data in it (count > 0)
*/
if (count > 0) {
/* find the corresponding TX socket */
if (rtp_proxytable[i].rtp_tx_sock == 0) {
int j;
int direction = rtp_proxytable[i].direction;
int rtp_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++) {
char *client_id = rtp_proxytable[i].client_id;
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) &&
(rtp_direction != rtp_proxytable[j].direction) &&
(media_stream_no == rtp_proxytable[j].media_stream_no) &&
(compare_callid(&callid, &cid) == STS_SUCCESS) ) {
(compare_callid(&callid, &cid) == STS_SUCCESS) &&
(strcmp(rtp_proxytable[j].client_id, client_id) != 0) ) {
rtp_proxytable[i].rtp_tx_sock = rtp_proxytable[j].rtp_rx_sock;
break;
}
@@ -280,7 +283,7 @@ static void *rtpproxy_main(void *arg) {
* STS_FAILURE on error
*/
int rtp_relay_start_fwd (osip_call_id_t *callid, char *client_id,
int direction,
int rtp_direction,
int media_stream_no, struct in_addr local_ipaddr,
int *local_port, struct in_addr remote_ipaddr,
int remote_port) {
@@ -319,17 +322,17 @@ int rtp_relay_start_fwd (osip_call_id_t *callid, char *client_id,
strlen(callid->host),CALLIDHOST_SIZE);
return STS_FAILURE;
}
if (client_id && strlen(client_id) > USERNAME_SIZE) {
ERROR("rtp_relay_start_fwd: received contact user "
"has too many characters (%i, max=%i)",
strlen(client_id),USERNAME_SIZE);
if (client_id && strlen(client_id) > CLIENT_ID_SIZE) {
ERROR("rtp_relay_start_fwd: client ID has too many characters "
"(%i, max=%i) (maybe you need to increase CLIENT_ID_SIZE",
strlen(client_id),CLIENT_ID_SIZE);
return STS_FAILURE;
}
DEBUGC(DBCLASS_RTP,"rtp_relay_start_fwd: starting RTP proxy "
"stream for: %s@%s (%s) #=%i",
callid->number, callid->host,
((direction == DIR_INCOMING) ? "incoming" : "outgoing"),
"stream for: %s@%s[%s] (%s) #=%i",
callid->number, callid->host, client_id,
((rtp_direction == DIR_INCOMING) ? "incoming RTP" : "outgoing RTP"),
media_stream_no);
/* lock mutex */
@@ -355,7 +358,7 @@ int rtp_relay_start_fwd (osip_call_id_t *callid, char *client_id,
cid.host = rtp_proxytable[i].callid_host;
if (rtp_proxytable[i].rtp_rx_sock &&
(compare_callid(callid, &cid) == STS_SUCCESS) &&
(rtp_proxytable[i].direction == direction) &&
(rtp_proxytable[i].direction == rtp_direction) &&
(rtp_proxytable[i].media_stream_no == media_stream_no) &&
(strcmp(rtp_proxytable[i].client_id, client_id) == 0)) {
/*
@@ -456,7 +459,7 @@ int rtp_relay_start_fwd (osip_call_id_t *callid, char *client_id,
rtp_proxytable[freeidx].client_id[0]='\0';
}
rtp_proxytable[freeidx].direction = direction;
rtp_proxytable[freeidx].direction = rtp_direction;
rtp_proxytable[freeidx].media_stream_no = media_stream_no;
memcpy(&rtp_proxytable[freeidx].local_ipaddr,
&local_ipaddr, sizeof(struct in_addr));
@@ -492,7 +495,7 @@ unlock_and_exit:
* STS_FAILURE on error
*/
int rtp_relay_stop_fwd (osip_call_id_t *callid,
int direction, int nolock) {
int rtp_direction, int nolock) {
int i, sts;
int retsts=STS_SUCCESS;
int got_match=0;
@@ -506,7 +509,7 @@ int rtp_relay_stop_fwd (osip_call_id_t *callid,
DEBUGC(DBCLASS_RTP,"rtp_relay_stop_fwd: stopping RTP proxy "
"stream for: %s@%s (%s)",
callid->number, callid->host,
((direction == DIR_INCOMING) ? "incoming" : "outgoing"));
((rtp_direction == DIR_INCOMING) ? "incoming" : "outgoing"));
/*
* lock mutex - only if not requested to skip the lock.
@@ -544,7 +547,7 @@ int rtp_relay_stop_fwd (osip_call_id_t *callid,
cid.host = rtp_proxytable[i].callid_host;
if (rtp_proxytable[i].rtp_rx_sock &&
(compare_callid(callid, &cid) == STS_SUCCESS) &&
(rtp_proxytable[i].direction == direction)) {
(rtp_proxytable[i].direction == rtp_direction)) {
sts = close(rtp_proxytable[i].rtp_rx_sock);
DEBUGC(DBCLASS_RTP,"closed socket %i for RTP stream "
"%s:%s == %s:%s (idx=%i) sts=%i",
@@ -569,7 +572,7 @@ int rtp_relay_stop_fwd (osip_call_id_t *callid,
DEBUGC(DBCLASS_RTP,
"rtp_relay_stop_fwd: can't find active stream for %s@%s (%s)",
callid->number, callid->host,
((direction == DIR_INCOMING) ? "incoming" : "outgoing"));
((rtp_direction == DIR_INCOMING) ? "incoming RTP" : "outgoing RTP"));
retsts = STS_FAILURE;
goto unlock_and_exit;
}