@ -1324,6 +1324,7 @@ static int make_trunk(unsigned short callno, int locked)
ast_log ( LOG_WARNING , " Unable to trunk call: Insufficient space \n " ) ;
return - 1 ;
}
if ( option_debug )
ast_log ( LOG_DEBUG , " Made call %d into trunk call %d \n " , callno , x ) ;
/* We move this call from a non-trunked to a trunked call */
update_max_trunk ( ) ;
@ -2537,6 +2538,7 @@ static int schedule_delivery(struct iax_frame *fr, int updatehistory, int fromtr
fr - > af . delivery = ast_tvadd ( iaxs [ fr - > callno ] - > rxcore , ast_samp2tv ( fr - > ts , 1000 ) ) ;
else {
#if 0
if ( option_debug )
ast_log ( LOG_DEBUG , " schedule_delivery: set delivery to 0 as we don't have an rxcore yet, or frame is from trunk. \n " ) ;
# endif
fr - > af . delivery = ast_tv ( 0 , 0 ) ;
@ -3179,6 +3181,7 @@ static int iax2_hangup(struct ast_channel *c)
memset ( & ied , 0 , sizeof ( ied ) ) ;
ast_mutex_lock ( & iaxsl [ callno ] ) ;
if ( callno & & iaxs [ callno ] ) {
if ( option_debug )
ast_log ( LOG_DEBUG , " We're hanging up %s now... \n " , c - > name ) ;
alreadygone = ast_test_flag ( iaxs [ callno ] , IAX_ALREADYGONE ) ;
/* Send the hangup unless we have had a transmission error or are already gone */
@ -3194,6 +3197,7 @@ static int iax2_hangup(struct ast_channel *c)
iax2_predestroy ( callno ) ;
/* If we were already gone to begin with, destroy us now */
if ( alreadygone & & iaxs [ callno ] ) {
if ( option_debug )
ast_log ( LOG_DEBUG , " Really destroying %s now... \n " , c - > name ) ;
iax2_destroy ( callno ) ;
}
@ -3708,7 +3712,7 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str
* silent periods are multiples of
* frame size too ) */
if ( iaxdebug & & abs ( ms - p - > nextpred ) > MAX_TIMESTAMP_SKEW )
if ( option_debug & & iaxdebug & & abs ( ms - p - > nextpred ) > MAX_TIMESTAMP_SKEW )
ast_log ( LOG_DEBUG , " predicted timestamp skew (%u) > max (%u), using real ts instead. \n " ,
abs ( ms - p - > nextpred ) , MAX_TIMESTAMP_SKEW ) ;
@ -3807,6 +3811,7 @@ static struct iax2_trunk_peer *find_tpeer(struct sockaddr_in *sin, int fd)
# ifdef SO_NO_CHECK
setsockopt ( tpeer - > sockfd , SOL_SOCKET , SO_NO_CHECK , & nochecksums , sizeof ( nochecksums ) ) ;
# endif
if ( option_debug )
ast_log ( LOG_DEBUG , " Created trunk peer for '%s:%d' \n " , ast_inet_ntoa ( tpeer - > addr . sin_addr ) , ntohs ( tpeer - > addr . sin_port ) ) ;
}
}
@ -3835,6 +3840,7 @@ static int iax2_trunk_queue(struct chan_iax2_pvt *pvt, struct iax_frame *fr)
tpeer - > trunkdataalloc + = DEFAULT_TRUNKDATA ;
tpeer - > trunkdata = tmp ;
if ( option_debug )
ast_log ( LOG_DEBUG , " Expanded trunk '%s:%d' to %d bytes \n " , ast_inet_ntoa ( tpeer - > addr . sin_addr ) , ntohs ( tpeer - > addr . sin_port ) , tpeer - > trunkdataalloc ) ;
} else {
ast_log ( LOG_WARNING , " Maximum trunk data space exceeded to %s:%d \n " , ast_inet_ntoa ( tpeer - > addr . sin_addr ) , ntohs ( tpeer - > addr . sin_port ) ) ;
@ -4766,6 +4772,7 @@ static int iax2_write(struct ast_channel *c, struct ast_frame *f)
/* Simple, just queue for transmission */
res = iax2_send ( iaxs [ callno ] , f , 0 , - 1 , 0 , 0 , 0 ) ;
} else {
if ( option_debug )
ast_log ( LOG_DEBUG , " Write error: %s \n " , strerror ( errno ) ) ;
}
}
@ -5063,9 +5070,7 @@ static int raw_hangup(struct sockaddr_in *sin, unsigned short src, unsigned shor
fh . csub = compress_subclass ( IAX_COMMAND_INVAL ) ;
if ( iaxdebug )
iax_showframe ( NULL , & fh , 0 , sin , 0 ) ;
#if 0
if ( option_debug )
# endif
ast_log ( LOG_DEBUG , " Raw Hangup %s:%d, src=%d, dst=%d \n " ,
ast_inet_ntoa ( sin - > sin_addr ) , ntohs ( sin - > sin_port ) , src , dst ) ;
return sendto ( sockfd , & fh , sizeof ( fh ) , 0 , ( struct sockaddr * ) sin , sizeof ( * sin ) ) ;
@ -5796,6 +5801,7 @@ static void __expire_registry(const void *data)
peer - > expire = - 1 ;
if ( option_debug )
ast_log ( LOG_DEBUG , " Expiring registration for peer '%s' \n " , peer - > name ) ;
if ( ast_test_flag ( ( & globalflags ) , IAX_RTUPDATE ) & & ( ast_test_flag ( peer , IAX_TEMPONLY | IAX_RTCACHEFRIENDS ) ) )
realtime_update_peer ( peer - > name , & peer - > addr , 0 ) ;
@ -6262,6 +6268,7 @@ static int send_trunk(struct iax2_trunk_peer *tpeer, struct timeval *now)
res = transmit_trunk ( fr , & tpeer - > addr , tpeer - > sockfd ) ;
calls = tpeer - > calls ;
#if 0
if ( option_debug )
ast_log ( LOG_DEBUG , " Trunking %d call chunks in %d bytes to %s:%d, ts=%d \n " , calls , fr - > datalen , ast_inet_ntoa ( tpeer - > addr . sin_addr ) , ntohs ( tpeer - > addr . sin_port ) , ntohl ( mth - > ts ) ) ;
# endif
/* Reset transmit trunk side data */
@ -6343,6 +6350,7 @@ static int timing_read(int *id, int fd, short events, void *cbdata)
ast_mutex_lock ( & drop - > lock ) ;
/* Once we have this lock, we're sure nobody else is using it or could use it once we release it,
because by the time they could get tpeerlock , we ' ve already grabbed it */
if ( option_debug )
ast_log ( LOG_DEBUG , " Dropping unused iax2 trunk peer '%s:%d' \n " , ast_inet_ntoa ( drop - > addr . sin_addr ) , ntohs ( drop - > addr . sin_port ) ) ;
free ( drop - > trunkdata ) ;
ast_mutex_unlock ( & drop - > lock ) ;
@ -7077,7 +7085,7 @@ static int socket_process(struct iax2_thread *thread)
ast_mutex_unlock ( & iaxsl [ fr - > callno ] ) ;
return 1 ;
}
} else
} else if ( option_debug )
ast_log ( LOG_DEBUG , " Received iseqno %d not within window %d->%d \n " , fr - > iseqno , iaxs [ fr - > callno ] - > rseqno , iaxs [ fr - > callno ] - > oseqno ) ;
}
if ( inaddrcmp ( & sin , & iaxs [ fr - > callno ] - > addr ) & &
@ -7126,6 +7134,7 @@ static int socket_process(struct iax2_thread *thread)
if ( f . frametype = = AST_FRAME_VOICE ) {
if ( f . subclass ! = iaxs [ fr - > callno ] - > voiceformat ) {
iaxs [ fr - > callno ] - > voiceformat = f . subclass ;
if ( option_debug )
ast_log ( LOG_DEBUG , " Ooh, voice format changed to %d \n " , f . subclass ) ;
if ( iaxs [ fr - > callno ] - > owner ) {
int orignative ;
@ -7146,6 +7155,7 @@ retryowner:
ast_mutex_unlock ( & iaxs [ fr - > callno ] - > owner - > lock ) ;
}
} else {
if ( option_debug )
ast_log ( LOG_DEBUG , " Neat, somebody took away the channel at a magical time but i found it! \n " ) ;
ast_mutex_unlock ( & iaxsl [ fr - > callno ] ) ;
return 1 ;
@ -7155,6 +7165,7 @@ retryowner:
}
if ( f . frametype = = AST_FRAME_VIDEO ) {
if ( f . subclass ! = iaxs [ fr - > callno ] - > videoformat ) {
if ( option_debug )
ast_log ( LOG_DEBUG , " Ooh, video format changed to %d \n " , f . subclass & ~ 0x1 ) ;
iaxs [ fr - > callno ] - > videoformat = f . subclass & ~ 0x1 ;
}
@ -7466,6 +7477,7 @@ retryowner:
break ;
case IAX_COMMAND_HANGUP :
ast_set_flag ( iaxs [ fr - > callno ] , IAX_ALREADYGONE ) ;
if ( option_debug )
ast_log ( LOG_DEBUG , " Immediately destroying %d, having received hangup \n " , fr - > callno ) ;
/* Set hangup cause according to remote */
if ( ies . causecode & & iaxs [ fr - > callno ] - > owner )
@ -7484,6 +7496,7 @@ retryowner:
ast_log ( LOG_WARNING , " Call rejected by %s: %s \n " ,
ast_inet_ntoa ( iaxs [ fr - > callno ] - > addr . sin_addr ) ,
ies . cause ? ies . cause : " <Unknown> " ) ;
if ( option_debug )
ast_log ( LOG_DEBUG , " Immediately destroying %d, having received reject \n " ,
fr - > callno ) ;
}
@ -7752,6 +7765,7 @@ retryowner2:
}
if ( ! format ) {
if ( ! ast_test_flag ( iaxs [ fr - > callno ] , IAX_CODEC_NOCAP ) ) {
if ( option_debug )
ast_log ( LOG_DEBUG , " We don't do requested format %s, falling back to peer capability %d \n " , ast_getformatname ( iaxs [ fr - > callno ] - > peerformat ) , iaxs [ fr - > callno ] - > peercapability ) ;
format = iaxs [ fr - > callno ] - > peercapability & iaxs [ fr - > callno ] - > capability ;
}
@ -7883,12 +7897,14 @@ retryowner2:
break ;
case IAX_COMMAND_INVAL :
iaxs [ fr - > callno ] - > error = ENOTCONN ;
if ( option_debug )
ast_log ( LOG_DEBUG , " Immediately destroying %d, having received INVAL \n " , fr - > callno ) ;
iax2_destroy ( fr - > callno ) ;
if ( option_debug )
ast_log ( LOG_DEBUG , " Destroying call %d \n " , fr - > callno ) ;
break ;
case IAX_COMMAND_VNAK :
if ( option_debug )
ast_log ( LOG_DEBUG , " Received VNAK: resending outstanding frames \n " ) ;
/* Force retransmission */
vnak_retransmit ( fr - > callno , fr - > iseqno ) ;
@ -8084,6 +8100,7 @@ retryowner2:
}
break ;
default :
if ( option_debug )
ast_log ( LOG_DEBUG , " Unknown IAX command %d on %d/%d \n " , f . subclass , fr - > callno , iaxs [ fr - > callno ] - > peercallno ) ;
memset ( & ied0 , 0 , sizeof ( ied0 ) ) ;
iax_ie_append_byte ( & ied0 , IAX_IE_IAX_UNKNOWN , f . subclass ) ;
@ -8416,6 +8433,7 @@ static int iax2_provision(struct sockaddr_in *end, int sockfd, char *dest, const
ast_log ( LOG_DEBUG , " Provisioning '%s' from template '%s' \n " , dest , template ) ;
if ( iax_provision_build ( & provdata , & sig , template , force ) ) {
if ( option_debug )
ast_log ( LOG_DEBUG , " No provisioning found for template '%s' \n " , template ) ;
return 0 ;
}
@ -8723,7 +8741,7 @@ static void *sched_thread(void *ignore)
pthread_testcancel ( ) ;
count = ast_sched_runq ( sched ) ;
if ( count > = 20 )
if ( option_debug & & count > = 20 )
ast_log ( LOG_DEBUG , " chan_iax2: ast_sched_runq ran %d scheduled tasks all at once \n " , count ) ;
}
return NULL ;
@ -8783,13 +8801,13 @@ static void *network_thread(void *ignore)
pthread_testcancel ( ) ;
if ( count > = 20 )
if ( option_debug & & count > = 20 )
ast_log ( LOG_DEBUG , " chan_iax2: Sent %d queued outbound frames all at once \n " , count ) ;
/* Now do the IO, and run scheduled tasks */
res = ast_io_wait ( io , wakeup ) ;
if ( res > = 0 ) {
if ( res > = 20 )
if ( option_debug & & res > = 20 )
ast_log ( LOG_DEBUG , " chan_iax2: ast_io_wait ran %d I/Os all at once \n " , res ) ;
}
}
@ -8866,6 +8884,7 @@ static int check_srcaddr(struct sockaddr *sa, socklen_t salen)
res = bind ( sd , sa , salen ) ;
if ( res < 0 ) {
if ( option_debug )
ast_log ( LOG_DEBUG , " Can't bind: %s \n " , strerror ( errno ) ) ;
close ( sd ) ;
return 1 ;
@ -8945,6 +8964,7 @@ static int peer_set_srcaddr(struct iax2_peer *peer, const char *srcaddr)
srcaddr , peer - > name ) ;
return - 1 ;
} else {
if ( option_debug )
ast_log ( LOG_DEBUG , " Using sourceaddress %s for '%s' \n " , srcaddr , peer - > name ) ;
return 0 ;
}
@ -9954,6 +9974,7 @@ static int cache_get_callno_locked(const char *data)
if ( create_addr ( pds . peer , & sin , & cai ) )
return - 1 ;
if ( option_debug )
ast_log ( LOG_DEBUG , " peer: %s, username: %s, password: %s, context: %s \n " ,
pds . peer , pds . username , pds . password , pds . context ) ;