@ -5729,7 +5729,7 @@ static int iax2_getpeertrunk(struct sockaddr_in sin)
}
/*! \brief Create new call, interface with the PBX core */
static struct ast_channel * ast_iax2_new ( int callno , int state , format_t capability , const char * linkedid )
static struct ast_channel * ast_iax2_new ( int callno , int state , format_t capability , const char * linkedid , unsigned int cachable )
{
struct ast_channel * tmp ;
struct chan_iax2_pvt * i ;
@ -5798,6 +5798,10 @@ static struct ast_channel *ast_iax2_new(int callno, int state, format_t capabili
i - > owner = tmp ;
i - > capability = capability ;
if ( ! cachable ) {
tmp - > flags | = AST_FLAG_DISABLE_DEVSTATE_CACHE ;
}
/* Set inherited variables */
if ( i - > vars ) {
for ( v = i - > vars ; v ; v = v - > next )
@ -8084,7 +8088,7 @@ static int register_verify(int callno, struct sockaddr_in *sin, struct iax_ies *
/* if challenge has been sent, but no challenge response if given, reject. */
goto return_unref ;
}
ast_devstate_changed ( AST_DEVICE_UNKNOWN , " IAX2/%s " , p - > name ) ; /* Activate notification */
ast_devstate_changed ( AST_DEVICE_UNKNOWN , AST_DEVSTATE_CACHABLE , " IAX2/%s " , p - > name ) ; /* Activate notification */
/* either Authentication has taken place, or a REGAUTH must be sent before verifying registration */
res = 0 ;
@ -8638,7 +8642,7 @@ static void __expire_registry(const void *data)
if ( ! ast_test_flag64 ( peer , IAX_TEMPONLY ) )
ast_db_del ( " IAX/Registry " , peer - > name ) ;
register_peer_exten ( peer , 0 ) ;
ast_devstate_changed ( AST_DEVICE_UNAVAILABLE , " IAX2/%s " , peer - > name ) ; /* Activate notification */
ast_devstate_changed ( AST_DEVICE_UNAVAILABLE , AST_DEVSTATE_CACHABLE , " IAX2/%s " , peer - > name ) ; /* Activate notification */
if ( iax2_regfunk )
iax2_regfunk ( peer - > name , 0 ) ;
@ -8693,7 +8697,7 @@ static void reg_source_db(struct iax2_peer *p)
}
}
ast_devstate_changed ( AST_DEVICE_UNKNOWN , " IAX2/%s " , p - > name ) ; /* Activate notification */
ast_devstate_changed ( AST_DEVICE_UNKNOWN , AST_DEVSTATE_CACHABLE , " IAX2/%s " , p - > name ) ; /* Activate notification */
p - > expire = iax2_sched_add ( sched , ( p - > expiry + 10 ) * 1000 , expire_registry , peer_ref ( p ) ) ;
if ( p - > expire = = - 1 ) {
@ -8770,14 +8774,14 @@ static int update_registry(struct sockaddr_in *sin, int callno, char *devtype, i
ast_test_flag ( & iaxs [ callno ] - > state , IAX_STATE_AUTHENTICATED ) ? " AUTHENTICATED " : " UNAUTHENTICATED " , ast_inet_ntoa ( sin - > sin_addr ) , ntohs ( sin - > sin_port ) ) ;
manager_event ( EVENT_FLAG_SYSTEM , " PeerStatus " , " ChannelType: IAX2 \r \n Peer: IAX2/%s \r \n PeerStatus: Registered \r \n " , p - > name ) ;
register_peer_exten ( p , 1 ) ;
ast_devstate_changed ( AST_DEVICE_UNKNOWN , " IAX2/%s " , p - > name ) ; /* Activate notification */
ast_devstate_changed ( AST_DEVICE_UNKNOWN , AST_DEVSTATE_CACHABLE , " IAX2/%s " , p - > name ) ; /* Activate notification */
} else if ( ! ast_test_flag64 ( p , IAX_TEMPONLY ) ) {
ast_verb ( 3 , " Unregistered IAX2 '%s' (%s) \n " , p - > name ,
ast_test_flag ( & iaxs [ callno ] - > state , IAX_STATE_AUTHENTICATED ) ? " AUTHENTICATED " : " UNAUTHENTICATED " ) ;
manager_event ( EVENT_FLAG_SYSTEM , " PeerStatus " , " ChannelType: IAX2 \r \n Peer: IAX2/%s \r \n PeerStatus: Unregistered \r \n " , p - > name ) ;
register_peer_exten ( p , 0 ) ;
ast_db_del ( " IAX/Registry " , p - > name ) ;
ast_devstate_changed ( AST_DEVICE_UNAVAILABLE , " IAX2/%s " , p - > name ) ; /* Activate notification */
ast_devstate_changed ( AST_DEVICE_UNAVAILABLE , AST_DEVSTATE_CACHABLE , " IAX2/%s " , p - > name ) ; /* Activate notification */
}
/* Update the host */
/* Verify that the host is really there */
@ -10291,7 +10295,8 @@ static int socket_process(struct iax2_thread *thread)
( f . frametype = = AST_FRAME_IAX ) ) {
if ( ast_test_flag64 ( iaxs [ fr - > callno ] , IAX_DELAYPBXSTART ) ) {
ast_clear_flag64 ( iaxs [ fr - > callno ] , IAX_DELAYPBXSTART ) ;
if ( ! ast_iax2_new ( fr - > callno , AST_STATE_RING , iaxs [ fr - > callno ] - > chosenformat , NULL ) ) {
if ( ! ast_iax2_new ( fr - > callno , AST_STATE_RING , iaxs [ fr - > callno ] - > chosenformat , NULL ,
ast_test_flag ( & iaxs [ fr - > callno ] - > state , IAX_STATE_AUTHENTICATED ) ) ) {
ast_variables_destroy ( ies . vars ) ;
ast_mutex_unlock ( & iaxsl [ fr - > callno ] ) ;
return 1 ;
@ -10924,13 +10929,13 @@ static int socket_process(struct iax2_thread *thread)
if ( iaxs [ fr - > callno ] - > pingtime < = peer - > maxms ) {
ast_log ( LOG_NOTICE , " Peer '%s' is now REACHABLE! Time: %d \n " , peer - > name , iaxs [ fr - > callno ] - > pingtime ) ;
manager_event ( EVENT_FLAG_SYSTEM , " PeerStatus " , " ChannelType: IAX2 \r \n Peer: IAX2/%s \r \n PeerStatus: Reachable \r \n Time: %d \r \n " , peer - > name , iaxs [ fr - > callno ] - > pingtime ) ;
ast_devstate_changed ( AST_DEVICE_NOT_INUSE , " IAX2/%s " , peer - > name ) ; /* Activate notification */
ast_devstate_changed ( AST_DEVICE_NOT_INUSE , AST_DEVSTATE_CACHABLE , " IAX2/%s " , peer - > name ) ; /* Activate notification */
}
} else if ( ( peer - > historicms > 0 ) & & ( peer - > historicms < = peer - > maxms ) ) {
if ( iaxs [ fr - > callno ] - > pingtime > peer - > maxms ) {
ast_log ( LOG_NOTICE , " Peer '%s' is now TOO LAGGED (%d ms)! \n " , peer - > name , iaxs [ fr - > callno ] - > pingtime ) ;
manager_event ( EVENT_FLAG_SYSTEM , " PeerStatus " , " ChannelType: IAX2 \r \n Peer: IAX2/%s \r \n PeerStatus: Lagged \r \n Time: %d \r \n " , peer - > name , iaxs [ fr - > callno ] - > pingtime ) ;
ast_devstate_changed ( AST_DEVICE_UNAVAILABLE , " IAX2/%s " , peer - > name ) ; /* Activate notification */
ast_devstate_changed ( AST_DEVICE_UNAVAILABLE , AST_DEVSTATE_CACHABLE , " IAX2/%s " , peer - > name ) ; /* Activate notification */
}
}
peer - > lastms = iaxs [ fr - > callno ] - > pingtime ;
@ -11172,7 +11177,7 @@ static int socket_process(struct iax2_thread *thread)
using_prefs ) ;
ast_set_flag ( & iaxs [ fr - > callno ] - > state , IAX_STATE_STARTED ) ;
if ( ! ( c = ast_iax2_new ( fr - > callno , AST_STATE_RING , format , NULL )) )
if ( ! ( c = ast_iax2_new ( fr - > callno , AST_STATE_RING , format , NULL , 1 )) )
iax2_destroy ( fr - > callno ) ;
else if ( ies . vars ) {
struct ast_datastore * variablestore ;
@ -11243,7 +11248,7 @@ immediatedial:
ast_getformatname_multiple ( tmp , sizeof ( tmp ) , iaxs [ fr - > callno ] - > peerformat ) ) ;
ast_set_flag ( & iaxs [ fr - > callno ] - > state , IAX_STATE_STARTED ) ;
send_command ( iaxs [ fr - > callno ] , AST_FRAME_CONTROL , AST_CONTROL_PROGRESS , 0 , NULL , 0 , - 1 ) ;
if ( ! ( c = ast_iax2_new ( fr - > callno , AST_STATE_RING , iaxs [ fr - > callno ] - > peerformat , NULL )) )
if ( ! ( c = ast_iax2_new ( fr - > callno , AST_STATE_RING , iaxs [ fr - > callno ] - > peerformat , NULL , 1 )) )
iax2_destroy ( fr - > callno ) ;
else if ( ies . vars ) {
struct ast_datastore * variablestore ;
@ -11996,7 +12001,7 @@ static void __iax2_poke_noanswer(const void *data)
if ( peer - > lastms > - 1 ) {
ast_log ( LOG_NOTICE , " Peer '%s' is now UNREACHABLE! Time: %d \n " , peer - > name , peer - > lastms ) ;
manager_event ( EVENT_FLAG_SYSTEM , " PeerStatus " , " ChannelType: IAX2 \r \n Peer: IAX2/%s \r \n PeerStatus: Unreachable \r \n Time: %d \r \n " , peer - > name , peer - > lastms ) ;
ast_devstate_changed ( AST_DEVICE_UNAVAILABLE , " IAX2/%s " , peer - > name ) ; /* Activate notification */
ast_devstate_changed ( AST_DEVICE_UNAVAILABLE , AST_DEVSTATE_CACHABLE , " IAX2/%s " , peer - > name ) ; /* Activate notification */
}
if ( ( callno = peer - > callno ) > 0 ) {
ast_mutex_lock ( & iaxsl [ callno ] ) ;
@ -12164,7 +12169,7 @@ static struct ast_channel *iax2_request(const char *type, format_t format, const
if ( cai . found )
ast_string_field_set ( iaxs [ callno ] , host , pds . peer ) ;
c = ast_iax2_new ( callno , AST_STATE_DOWN , cai . capability , requestor ? requestor - > linkedid : NULL );
c = ast_iax2_new ( callno , AST_STATE_DOWN , cai . capability , requestor ? requestor - > linkedid : NULL , cai . found );
ast_mutex_unlock ( & iaxsl [ callno ] ) ;