- replaced some malloc() by osip_malloc(),

(hopefully) fixed a sporadic crash in sdp_message_parse()
- RTP timeouts on some PBX systems that include an video
  stream, but the called UA has no video capability.
This commit is contained in:
Thomas Ries 2006-02-11 09:43:19 +00:00
parent fa9e811bb9
commit 34fb9113ab
6 changed files with 47 additions and 22 deletions

View File

@ -1,5 +1,9 @@
0.5.12
======
8-Feb-2006: - replaced some malloc() by osip_malloc(),
(hopefully) fixed a sporadic crash in sdp_message_parse()
6-Feb-2006: - RTP timeouts on some PBX systems that include an video
stream, but the called UA has no video capability.
3-Feb-2006: - rewrite complete incoming request URI
31-Jan-2006: - CALLIDHOST_SIZE to 128: support longer hostnames
1-Jan-2006: - short-dial: use "302 Moved" to point to target

View File

@ -102,7 +102,7 @@ int auth_include_authrq(osip_message_t *sipmsg) {
osip_proxy_authenticate_set_auth_type(p_auth, osip_strdup("Digest"));
osip_proxy_authenticate_set_nonce(p_auth, osip_strdup(auth_generate_nonce()));
realm=malloc(strlen(configuration.proxy_auth_realm)+3); /* add 2x" and \0 */
realm=osip_malloc(strlen(configuration.proxy_auth_realm)+3); /* add 2x" and \0 */
if (realm) {
sprintf(realm,"\"%s\"",configuration.proxy_auth_realm);
osip_proxy_authenticate_set_realm(p_auth, realm);

View File

@ -822,6 +822,10 @@ int proxy_rewrite_invitation_body(sip_ticket_t *ticket, int direction){
if (sts != 0) {
ERROR("rewrite_invitation_body: unable to sip_body_to_str");
}
DEBUGC(-1, "rewrite_invitation_body: payload %i bytes", bodybuflen);
DUMP_BUFFER(-1, bodybuff, bodybuflen);
sts = sdp_message_init(&sdp);
sts = sdp_message_parse (sdp, bodybuff);
if (sts != 0) {
@ -1137,11 +1141,11 @@ int proxy_rewrite_request_uri(osip_message_t *mymsg, int idx){
url=osip_message_get_uri(mymsg);
/* set the true scheme */
if (url->scheme) osip_free(url->scheme);url->scheme=NULL;
if (url->scheme) {osip_free(url->scheme);url->scheme=NULL;}
if (urlmap[idx].true_url->scheme) {
DEBUGC(DBCLASS_BABBLE,"proxy_rewrite_request_uri: scheme=%s",
urlmap[idx].true_url->scheme);
scheme = (char *)malloc(strlen(urlmap[idx].true_url->scheme)+1);
scheme = (char *)osip_malloc(strlen(urlmap[idx].true_url->scheme)+1);
memcpy(scheme, urlmap[idx].true_url->scheme,
strlen(urlmap[idx].true_url->scheme));
scheme[strlen(urlmap[idx].true_url->scheme)]='\0';
@ -1149,11 +1153,11 @@ int proxy_rewrite_request_uri(osip_message_t *mymsg, int idx){
}
/* set the true username */
if (url->username) osip_free(url->username);url->username=NULL;
if (url->username) {osip_free(url->username);url->username=NULL;}
if (urlmap[idx].true_url->username) {
DEBUGC(DBCLASS_BABBLE,"proxy_rewrite_request_uri: username=%s",
urlmap[idx].true_url->username);
username = (char*)malloc(strlen(urlmap[idx].true_url->scheme)+1);
username = (char*)osip_malloc(strlen(urlmap[idx].true_url->username)+1);
memcpy(username, urlmap[idx].true_url->username,
strlen(urlmap[idx].true_url->username));
username[strlen(urlmap[idx].true_url->username)]='\0';
@ -1161,22 +1165,22 @@ int proxy_rewrite_request_uri(osip_message_t *mymsg, int idx){
}
/* set the true host */
if (url->host) osip_free(url->host);url->host=NULL;
if (url->host) {osip_free(url->host);url->host=NULL;}
if (urlmap[idx].true_url->host) {
DEBUGC(DBCLASS_BABBLE,"proxy_rewrite_request_uri: host=%s",
urlmap[idx].true_url->host);
host = (char *)malloc(strlen(urlmap[idx].true_url->host)+1);
host = (char *)osip_malloc(strlen(urlmap[idx].true_url->host)+1);
memcpy(host, urlmap[idx].true_url->host, strlen(urlmap[idx].true_url->host));
host[strlen(urlmap[idx].true_url->host)]='\0';
osip_uri_set_host(url, host);
}
/* set the true port */
if (url->port) osip_free(url->port);url->port=NULL;
if (url->port) {osip_free(url->port);url->port=NULL;}
if (urlmap[idx].true_url->port) {
DEBUGC(DBCLASS_BABBLE,"proxy_rewrite_request_uri: port=%s",
urlmap[idx].true_url->port);
port = (char *)malloc(strlen(urlmap[idx].true_url->port)+1);
port = (char *)osip_malloc(strlen(urlmap[idx].true_url->port)+1);
memcpy(port, urlmap[idx].true_url->port, strlen(urlmap[idx].true_url->port));
port[strlen(urlmap[idx].true_url->port)]='\0';
osip_uri_set_port(url, port);

View File

@ -97,7 +97,7 @@ int rtp_stop_fwd (osip_call_id_t *callid, int direction) {
if (configuration.rtp_proxy_enable == 0) {
sts = STS_SUCCESS;
} else if (configuration.rtp_proxy_enable == 1) { // Relay
sts = rtp_relay_stop_fwd(callid, direction, 0);
sts = rtp_relay_stop_fwd(callid, direction, -1, 0);
} else {
ERROR("CONFIG: rtp_proxy_enable has invalid value",
configuration.rtp_proxy_enable);

View File

@ -46,4 +46,5 @@ int rtp_relay_start_fwd (osip_call_id_t *callid, char *client_id,
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 rtp_direction, int nolock);
int rtp_relay_stop_fwd (osip_call_id_t *callid, int rtp_direction,
int media_stream_no, int nolock);

View File

@ -334,7 +334,7 @@ static void *rtpproxy_main(void *arg) {
/* don't lock the mutex, as we own the lock */
callid.number=rtp_proxytable[i].callid_number;
callid.host=rtp_proxytable[i].callid_host;
rtp_relay_stop_fwd(&callid, rtp_proxytable[i].direction, 1);
rtp_relay_stop_fwd(&callid, rtp_proxytable[i].direction, -1, 1);
}
}
}
@ -356,13 +356,20 @@ static void *rtpproxy_main(void *arg) {
/* this one has expired, clean it up */
callid.number=rtp_proxytable[i].callid_number;
callid.host=rtp_proxytable[i].callid_host;
INFO("RTP stream %s@%s (media=%i) has expired",
callid.number, callid.host,
rtp_proxytable[i].media_stream_no);
DEBUGC(DBCLASS_RTP,"RTP stream rx_sock=%i tx_sock=%i "
"%s@%s (idx=%i) has expired",
rtp_proxytable[i].rtp_rx_sock,
rtp_proxytable[i].rtp_tx_sock,
callid.number, callid.host, i);
/* don't lock the mutex, as we own the lock already here */
rtp_relay_stop_fwd(&callid, rtp_proxytable[i].direction, 1);
/* Don't lock the mutex, as we own the lock already here */
/* Only stop the stream we caught is timeout and not everything.
* This may be a multiple stream conversation (audio/video) and
* just one (unused?) has timed out. Seen with VoIPEX PBX! */
rtp_relay_stop_fwd(&callid, rtp_proxytable[i].direction,
rtp_proxytable[i].media_stream_no, 1);
}
}
} /* if (t>...) */
@ -419,21 +426,21 @@ int rtp_relay_start_fwd (osip_call_id_t *callid, char *client_id,
* so if this test fails maybe it's just necessary to increase
* the constants CALLIDNUM_SIZE and/or CALLIDHOST_SIZE.
*/
if (callid->number && strlen(callid->number) > CALLIDNUM_SIZE) {
if (callid->number && (strlen(callid->number) >= CALLIDNUM_SIZE)) {
ERROR("rtp_relay_start_fwd: received callid number [%s] "
"has too many characters (%i, max=%i)",
callid->number, strlen(callid->number),CALLIDNUM_SIZE);
return STS_FAILURE;
}
if (callid->host && strlen(callid->host) > CALLIDHOST_SIZE) {
if (callid->host && (strlen(callid->host) >= CALLIDHOST_SIZE)) {
ERROR("rtp_relay_start_fwd: received callid host [%s] "
"has too many characters (%i, max=%i)",
callid->host, strlen(callid->host),CALLIDHOST_SIZE);
return STS_FAILURE;
}
if (client_id && strlen(client_id) > CLIENT_ID_SIZE) {
if (client_id && (strlen(client_id) >= CLIENT_ID_SIZE)) {
ERROR("rtp_relay_start_fwd: client ID [%s] has too many characters "
"(%i, max=%i) (maybe you need to increase CLIENT_ID_SIZE",
"(%i, max=%i)",
client_id, strlen(client_id),CLIENT_ID_SIZE);
return STS_FAILURE;
}
@ -663,12 +670,16 @@ unlock_and_exit:
/*
* stop a rtp stream on the proxy
*
* if media_stream_no == -1, all media streams will be stopped,
* otherwise only the specified one.
*
* RETURNS
* STS_SUCCESS on success
* STS_FAILURE on error
*/
int rtp_relay_stop_fwd (osip_call_id_t *callid,
int rtp_direction, int nolock) {
int rtp_direction,
int media_stream_no, int nolock) {
int i, sts;
int retsts=STS_SUCCESS;
int got_match=0;
@ -713,14 +724,18 @@ int rtp_relay_stop_fwd (osip_call_id_t *callid,
/*
* find the proper entry in rtp_proxytable
* we need to loop the whole table, as there might be multiple
* media strema active for the same callid (audio + video stream)
* media streams active for the same callid (audio + video stream)
* if media_stream_no == -1, all streams are stoppen, otherwise
* if media_stream_no > 0 only the specified stream is stopped.
*/
for (i=0; i<RTPPROXY_SIZE; i++) {
cid.number = rtp_proxytable[i].callid_number;
cid.host = rtp_proxytable[i].callid_host;
if (rtp_proxytable[i].rtp_rx_sock &&
(compare_callid(callid, &cid) == STS_SUCCESS) &&
(rtp_proxytable[i].direction == rtp_direction)) {
(rtp_proxytable[i].direction == rtp_direction) &&
((media_stream_no < 0) ||
(media_stream_no == rtp_proxytable[i].media_stream_no))) {
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",
@ -817,7 +832,8 @@ void rtpproxy_kill( void ) {
if (rtp_proxytable[i].rtp_rx_sock != 0) {
cid.number = rtp_proxytable[i].callid_number;
cid.host = rtp_proxytable[i].callid_host;
sts = rtp_relay_stop_fwd(&cid, rtp_proxytable[i].direction, 0);
sts = rtp_relay_stop_fwd(&cid, rtp_proxytable[i].direction,
rtp_proxytable[i].media_stream_no, 0);
}
}