@ -27462,49 +27462,44 @@ static int sip_removeheader(struct ast_channel *chan, const char *data)
static int sip_sipredirect ( struct sip_pvt * p , const char * dest )
static int sip_sipredirect ( struct sip_pvt * p , const char * dest )
{
{
char * cdest ;
char * cdest ;
char * extension , * host , * port ;
char * extension , * domain ;
char tmp [ 80 ] ;
cdest = ast_strdupa ( dest ) ;
cdest = ast_strdupa ( dest ) ;
extension = strsep ( & cdest , " @ " ) ;
extension = strsep ( & cdest , " @ " ) ;
host = strsep ( & cdest , " : " ) ;
domain = strsep ( & cdest , " : " ) ;
port = strsep ( & cdest , " : " ) ;
if ( ast_strlen_zero ( extension ) ) {
if ( ast_strlen_zero ( extension ) ) {
ast_log ( LOG_ERROR , " Missing mandatory argument: extension \n " ) ;
ast_log ( LOG_ERROR , " Missing mandatory argument: extension \n " ) ;
return 0 ;
return 0 ;
}
}
/* we'll issue the redirect message here */
/* we'll issue the redirect message here */
if ( ! host ) {
if ( ! domain ) {
char * localtmp ;
char * local_to_header ;
char to_header [ 256 ] ;
ast_copy_string ( t mp , get_header ( & p - > initreq , " To " ) , sizeof ( t mp ) ) ;
ast_copy_string ( t o_header , get_header ( & p - > initreq , " To " ) , sizeof ( t o_header ) ) ;
if ( ast_strlen_zero ( t mp ) ) {
if ( ast_strlen_zero ( t o_header ) ) {
ast_log ( LOG_ERROR , " Cannot retrieve the 'To' header from the original SIP request! \n " ) ;
ast_log ( LOG_ERROR , " Cannot retrieve the 'To' header from the original SIP request! \n " ) ;
return 0 ;
return 0 ;
}
}
if ( ( ( localtmp = strcasestr ( tmp , " sip: " ) ) | | ( local tmp = strcasestr ( tmp , " sips: " ) ) )
if ( ( ( local_to_header = strcasestr ( to_header , " sip: " ) ) | | ( local _to_header = strcasestr ( to_header , " sips: " ) ) )
& & ( local tmp = strchr ( localtmp , ' @ ' ) ) ) {
& & ( local _to_header = strchr ( local_to_header , ' @ ' ) ) ) {
char l host[ 80 ] , lport [ 80 ] ;
char l domain[ 256 ] ;
memset ( lhost , 0 , sizeof ( lhost ) ) ;
memset ( ldomain , 0 , sizeof ( ldomain ) ) ;
memset ( lport , 0 , sizeof ( lport ) ) ;
local_to_header + + ;
localtmp + + ;
/* This is okey because lhost and lport are as big as tmp */
/* This is okey because lhost and lport are as big as tmp */
sscanf ( local tmp, " %80[^<>:; ]:%80[^<>:; ] " , lhost , lport ) ;
sscanf ( local _to_header, " %256[^<>; ] " , ldomain ) ;
if ( ast_strlen_zero ( l host ) ) {
if ( ast_strlen_zero ( l domain ) ) {
ast_log ( LOG_ERROR , " Can't find the host address \n " ) ;
ast_log ( LOG_ERROR , " Can't find the host address \n " ) ;
return 0 ;
return 0 ;
}
}
host = ast_strdupa ( lhost ) ;
domain = ast_strdupa ( ldomain ) ;
if ( ! ast_strlen_zero ( lport ) ) {
port = ast_strdupa ( lport ) ;
}
}
}
}
}
ast_string_field_build ( p , our_contact , " Transfer <sip:%s@%s %s%s >" , extension , host, port ? " : " : " " , port ? port : " " ) ;
ast_string_field_build ( p , our_contact , " Transfer <sip:%s@%s >" , extension , domain ) ;
transmit_response_reliable ( p , " 302 Moved Temporarily " , & p - > initreq ) ;
transmit_response_reliable ( p , " 302 Moved Temporarily " , & p - > initreq ) ;
sip_scheddestroy ( p , SIP_TRANS_TIMEOUT ) ; /* Make sure we stop send this reply. */
sip_scheddestroy ( p , SIP_TRANS_TIMEOUT ) ; /* Make sure we stop send this reply. */