@ -48,6 +48,9 @@
# include "sig_pri.h"
/* define this to send PRI user-user information elements */
# undef SUPPORT_USERUSER
static int pri_matchdigittimeout = 3000 ;
static int pri_gendigittimeout = 8000 ;
@ -62,7 +65,7 @@ static int pri_gendigittimeout = 8000;
# define DCHAN_AVAILABLE (DCHAN_NOTINALARM | DCHAN_UP)
# define PRI_DEADLOCK_AVOIDANCE( lock ) \
# define PRI_DEADLOCK_AVOIDANCE( p ) \
do { \
sig_pri_unlock_private ( p ) ; \
usleep ( 1 ) ; \
@ -533,8 +536,9 @@ static void *pri_ss_thread(void *data)
int len ;
int timeout ;
/* in the bizarre case where the channel has become a zombie before we
even get started here , abort safely
/*
* In the bizarre case where the channel has become a zombie before we
* even get started here , abort safely .
*/
if ( ! p ) {
ast_log ( LOG_WARNING , " Channel became a zombie before simple switch could be started (%s) \n " , chan - > name ) ;
@ -1056,6 +1060,7 @@ static void *pri_dchannel(void *vpri)
if ( pri - > pvts [ chanpos ] - > call = = e - > ring . call ) {
ast_log ( LOG_WARNING , " Duplicate setup requested on channel %d/%d already in use on span %d \n " ,
PRI_SPAN ( e - > ring . channel ) , PRI_CHANNEL ( e - > ring . channel ) , pri - > span ) ;
sig_pri_unlock_private ( pri - > pvts [ chanpos ] ) ;
break ;
} else {
/* This is where we handle initial glare */
@ -1270,12 +1275,6 @@ static void *pri_dchannel(void *vpri)
sig_pri_set_echocanceller ( pri - > pvts [ chanpos ] , 1 ) ;
pri_queue_control ( pri - > pvts [ chanpos ] , AST_CONTROL_RINGING , pri ) ;
pri - > pvts [ chanpos ] - > alerting = 1 ;
# ifdef PRI_PROGRESS_MASK
if ( e - > ringing . progressmask & PRI_PROG_INBAND_AVAILABLE ) {
# else
if ( e - > ringing . progress = = 8 ) {
# endif
}
# ifdef SUPPORT_USERUSER
if ( ! ast_strlen_zero ( e - > ringing . useruserinfo ) ) {
@ -1294,11 +1293,13 @@ static void *pri_dchannel(void *vpri)
/* Get chan value if e->e is not PRI_EVNT_RINGING */
chanpos = pri_find_principle ( pri , e - > proceeding . channel ) ;
if ( chanpos > - 1 ) {
if ( ( ! pri - > pvts [ chanpos ] - > progress )
# ifdef PRI_PROGRESS_MASK
if ( ( ! pri - > pvts [ chanpos ] - > progress ) | | ( e - > proceeding . progressmask & PRI_PROG_INBAND_AVAILABLE ) ) {
| | ( e - > proceeding . progressmask & PRI_PROG_INBAND_AVAILABLE )
# else
if ( ( ! pri - > pvts [ chanpos ] - > progress ) | | ( e - > proceeding . progress = = 8 ) ) {
| | ( e - > proceeding . progress = = 8 )
# endif
) {
struct ast_frame f = { AST_FRAME_CONTROL , AST_CONTROL_PROGRESS , } ;
if ( e - > proceeding . cause > - 1 ) {
@ -1316,14 +1317,16 @@ static void *pri_dchannel(void *vpri)
}
sig_pri_lock_private ( pri - > pvts [ chanpos ] ) ;
ast_ log( LOG_DEBUG , " Queuing frame from PRI_EVENT_PROGRESS on channel %d/%d span %d \n " ,
ast_ debug( 1 , " Queuing frame from PRI_EVENT_PROGRESS on channel %d/%d span %d \n " ,
pri - > pvts [ chanpos ] - > logicalspan , pri - > pvts [ chanpos ] - > prioffset , pri - > span ) ;
pri_queue_frame ( pri - > pvts [ chanpos ] , & f , pri ) ;
if (
# ifdef PRI_PROGRESS_MASK
if ( e - > proceeding . progressmask & PRI_PROG_INBAND_AVAILABLE ) {
e - > proceeding . progressmask & PRI_PROG_INBAND_AVAILABLE
# else
if ( e - > proceeding . progress = = 8 ) {
e - > proceeding . progress = = 8
# endif
) {
/* Bring voice path up */
f . subclass = AST_CONTROL_PROGRESS ;
pri_queue_frame ( pri - > pvts [ chanpos ] , & f , pri ) ;
@ -1341,14 +1344,16 @@ static void *pri_dchannel(void *vpri)
struct ast_frame f = { AST_FRAME_CONTROL , AST_CONTROL_PROCEEDING , } ;
sig_pri_lock_private ( pri - > pvts [ chanpos ] ) ;
ast_ log( LOG_DEBUG , " Queuing frame from PRI_EVENT_PROCEEDING on channel %d/%d span %d \n " ,
ast_ debug( 1 , " Queuing frame from PRI_EVENT_PROCEEDING on channel %d/%d span %d \n " ,
pri - > pvts [ chanpos ] - > logicalspan , pri - > pvts [ chanpos ] - > prioffset , pri - > span ) ;
pri_queue_frame ( pri - > pvts [ chanpos ] , & f , pri ) ;
if (
# ifdef PRI_PROGRESS_MASK
if ( e - > proceeding . progressmask & PRI_PROG_INBAND_AVAILABLE ) {
e - > proceeding . progressmask & PRI_PROG_INBAND_AVAILABLE
# else
if ( e - > proceeding . progress = = 8 ) {
e - > proceeding . progress = = 8
# endif
) {
/* Bring voice path up */
f . subclass = AST_CONTROL_PROGRESS ;
pri_queue_frame ( pri - > pvts [ chanpos ] , & f , pri ) ;
@ -1442,6 +1447,7 @@ static void *pri_dchannel(void *vpri)
break ;
default :
ast_softhangup_nolock ( pri - > pvts [ chanpos ] - > owner , AST_SOFTHANGUP_DEV ) ;
break ;
}
}
}
@ -1508,6 +1514,7 @@ static void *pri_dchannel(void *vpri)
break ;
default :
ast_softhangup_nolock ( pri - > pvts [ chanpos ] - > owner , AST_SOFTHANGUP_DEV ) ;
break ;
}
}
ast_verb ( 3 , " Channel %d/%d, span %d got hangup request, cause %d \n " , PRI_SPAN ( e - > hangup . channel ) , PRI_CHANNEL ( e - > hangup . channel ) , pri - > span , e - > hangup . cause ) ;
@ -1581,7 +1588,7 @@ static void *pri_dchannel(void *vpri)
if ( pri - > pvts [ x ] & & pri - > pvts [ x ] - > resetting ) {
chanpos = x ;
sig_pri_lock_private ( pri - > pvts [ chanpos ] ) ;
ast_ log( LOG_DEBUG , " Assuming restart ack is really for channel %d/%d span %d \n " , pri - > pvts [ chanpos ] - > logicalspan ,
ast_ debug( 1 , " Assuming restart ack is really for channel %d/%d span %d \n " , pri - > pvts [ chanpos ] - > logicalspan ,
pri - > pvts [ chanpos ] - > prioffset , pri - > span ) ;
if ( pri - > pvts [ chanpos ] - > owner ) {
ast_log ( LOG_WARNING , " Got restart ack on channel %d/%d with owner on span %d \n " , pri - > pvts [ chanpos ] - > logicalspan ,
@ -1630,7 +1637,7 @@ static void *pri_dchannel(void *vpri)
pri - > pvts [ chanpos ] - > setup_ack = 1 ;
/* Send any queued digits */
for ( x = 0 ; x < strlen ( pri - > pvts [ chanpos ] - > dialdest ) ; x + + ) {
ast_ log( LOG_DEBUG , " Sending pending digit '%c' \n " , pri - > pvts [ chanpos ] - > dialdest [ x ] ) ;
ast_ debug( 1 , " Sending pending digit '%c' \n " , pri - > pvts [ chanpos ] - > dialdest [ x ] ) ;
pri_information ( pri - > pri , pri - > pvts [ chanpos ] - > call ,
pri - > pvts [ chanpos ] - > dialdest [ x ] ) ;
}
@ -1646,6 +1653,7 @@ static void *pri_dchannel(void *vpri)
PRI_SPAN ( e - > notify . channel ) , PRI_CHANNEL ( e - > notify . channel ) , pri - > span ) ;
} else {
struct ast_frame f = { AST_FRAME_CONTROL , } ;
sig_pri_lock_private ( pri - > pvts [ chanpos ] ) ;
switch ( e - > notify . info ) {
case PRI_NOTIFY_REMOTE_HOLD :
@ -1661,7 +1669,7 @@ static void *pri_dchannel(void *vpri)
}
break ;
default :
ast_ log( LOG_DEBUG , " Event: %d \n " , e - > e ) ;
ast_ debug( 1 , " Event: %d \n " , e - > e ) ;
}
}
ast_mutex_unlock ( & pri - > lock ) ;
@ -1795,7 +1803,6 @@ int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, char *rdest, i
l = NULL ;
n = NULL ;
if ( ! p - > hidecallerid ) {
l = ast - > connected . id . number ;
if ( ! p - > hidecalleridname ) {
@ -1803,7 +1810,6 @@ int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, char *rdest, i
}
}
if ( strlen ( c ) < p - > stripmsd ) {
ast_log ( LOG_WARNING , " Number '%s' is shorter than stripmsd (%d) \n " , c , p - > stripmsd ) ;
return - 1 ;
@ -2032,7 +2038,7 @@ int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, char *rdest, i
int sig_pri_indicate ( struct sig_pri_chan * p , struct ast_channel * chan , int condition , const void * data , size_t datalen )
{
int res = 0 ;
int res = - 1 ;
switch ( condition ) {
case AST_CONTROL_BUSY :
@ -2093,12 +2099,16 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi
res = 0 ;
break ;
case AST_CONTROL_PROGRESS :
ast_ log( LOG_DEBUG , " Received AST_CONTROL_PROGRESS on %s \n " , chan - > name ) ;
ast_ debug( 1 , " Received AST_CONTROL_PROGRESS on %s \n " , chan - > name ) ;
p - > digital = 0 ; /* Digital-only calls isn't allowing any inband progress messages */
if ( ! p - > progress & & p - > pri & & ! p - > outgoing ) {
if ( p - > pri - > pri ) {
if ( ! pri_grab ( p , p - > pri ) ) {
# ifdef HAVE_PRI_PROG_W_CAUSE
pri_progress_with_cause ( p - > pri - > pri , p - > call , PVT_TO_CHANNEL ( p ) , 1 , - 1 ) ; /* no cause at all */
# else
pri_progress ( p - > pri - > pri , p - > call , PVT_TO_CHANNEL ( p ) , 1 ) ;
# endif
pri_rel ( p - > pri ) ;
} else {
ast_log ( LOG_WARNING , " Unable to grab PRI on span %d \n " , p - > pri - > span ) ;
@ -2260,6 +2270,7 @@ int sig_pri_start_pri(struct sig_pri_pri *pri)
pri_set_service_message_support ( pri - > dchans [ i ] , 1 ) ;
}
# endif
break ;
}
/* Force overlap dial if we're doing GR-303! */