@ -468,6 +468,7 @@ static void print_facility(struct FacParm *fac, struct misdn_bchannel *bc)
case Fac_None :
default :
chan_misdn_log ( 1 , bc - > port , " --> unknown facility \n " ) ;
break ;
}
}
@ -760,7 +761,8 @@ static char *handle_cli_misdn_set_debug(struct ast_cli_entry *e, int cmd, struct
case 4 :
case 5 :
{
int only = 0 , i ;
int i ;
int only = 0 ;
if ( a - > argc = = 5 ) {
if ( strncasecmp ( a - > argv [ 4 ] , " only " , strlen ( a - > argv [ 4 ] ) ) )
return CLI_SHOWUSAGE ;
@ -979,8 +981,6 @@ static inline void show_config_description(int fd, enum misdn_cfg_elements elem)
ast_cli ( fd , " [%s] %s (Default: %s) \n \t %s \n " , section , name , def , desc ) ;
else
ast_cli ( fd , " [%s] %s \n \t %s \n " , section , name , desc ) ;
return ;
}
static char * handle_cli_misdn_show_config ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
@ -1218,7 +1218,7 @@ static void print_bc_info (int fd, struct chan_list *help, struct misdn_bchannel
static char * handle_cli_misdn_show_channels ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
{
struct chan_list * help = NULL ;
struct chan_list * help ;
switch ( cmd ) {
case CLI_INIT :
@ -1280,7 +1280,7 @@ static char *handle_cli_misdn_show_channels(struct ast_cli_entry *e, int cmd, st
static char * handle_cli_misdn_show_channel ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
{
struct chan_list * help = NULL ;
struct chan_list * help ;
switch ( cmd ) {
case CLI_INIT :
@ -1514,6 +1514,9 @@ static char *handle_cli_misdn_send_facility(struct ast_cli_entry *e, int cmd, st
static char * handle_cli_misdn_send_restart ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
{
int port ;
int channel ;
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn send restart " ;
@ -1528,10 +1531,14 @@ static char *handle_cli_misdn_send_restart(struct ast_cli_entry *e, int cmd, str
if ( a - > argc < 4 | | a - > argc > 5 )
return CLI_SHOWUSAGE ;
if ( a - > argc = = 5 )
misdn_lib_send_restart ( atoi ( a - > argv [ 3 ] ) , atoi ( a - > argv [ 4 ] ) ) ;
else
misdn_lib_send_restart ( atoi ( a - > argv [ 3 ] ) , - 1 ) ;
port = atoi ( a - > argv [ 3 ] ) ;
if ( a - > argc = = 5 ) {
channel = atoi ( a - > argv [ 4 ] ) ;
misdn_lib_send_restart ( port , channel ) ;
} else {
misdn_lib_send_restart ( port , - 1 ) ;
}
return CLI_SUCCESS ;
}
@ -1946,10 +1953,15 @@ static int read_config(struct chan_list *ch, int orig)
{
struct ast_channel * ast ;
struct misdn_bchannel * bc ;
int port , hdlc = 0 ;
char lang [ BUFFERSIZE + 1 ] , localmusicclass [ BUFFERSIZE + 1 ] , faxdetect [ BUFFERSIZE + 1 ] ;
char buf [ 256 ] , buf2 [ 256 ] ;
ast_group_t pg , cg ;
int port ;
int hdlc = 0 ;
char lang [ BUFFERSIZE + 1 ] ;
char localmusicclass [ BUFFERSIZE + 1 ] ;
char faxdetect [ BUFFERSIZE + 1 ] ;
char buf [ 256 ] ;
char buf2 [ 256 ] ;
ast_group_t pg ;
ast_group_t cg ;
if ( ! ch ) {
ast_log ( LOG_WARNING , " Cannot configure without chanlist \n " ) ;
@ -2311,7 +2323,6 @@ static int misdn_answer(struct ast_channel *ast)
}
tmp = pbx_builtin_getvar_helper ( p - > ast , " CRYPT_KEY " ) ;
if ( ! ast_strlen_zero ( tmp ) ) {
chan_misdn_log ( 1 , p - > bc - > port , " --> Connection will be BF crypted \n " ) ;
ast_copy_string ( p - > bc - > crypt_key , tmp , sizeof ( p - > bc - > crypt_key ) ) ;
@ -3155,7 +3166,6 @@ static struct chan_list *init_chan_list(int orig)
struct chan_list * cl ;
cl = ast_calloc ( 1 , sizeof ( * cl ) ) ;
if ( ! cl ) {
chan_misdn_log ( - 1 , 0 , " misdn_request: malloc failed! " ) ;
return NULL ;
@ -3276,7 +3286,6 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat
}
}
} while ( ! newbc & & robin_channel ! = rr - > channel ) ;
} else {
for ( port = misdn_cfg_get_next_port ( 0 ) ; port > 0 ;
port = misdn_cfg_get_next_port ( port ) ) {
@ -3443,7 +3452,6 @@ static struct ast_channel *misdn_new(struct chan_list *chlist, int state, char
}
tmp = ast_channel_alloc ( 1 , state , cid_num , cid_name , " " , exten , " " , 0 , " %s/%s%d-u%d " , misdn_type , c ? " " : " tmp " , chan_offset + c , glob_channel + + ) ;
if ( tmp ) {
chan_misdn_log ( 2 , 0 , " --> * NEW CHANNEL dad:%s oad:%s \n " , exten , callerid ) ;
@ -3479,7 +3487,6 @@ static struct ast_channel *misdn_new(struct chan_list *chlist, int state, char
if ( pipe ( chlist - > pipe ) < 0 )
ast_log ( LOG_ERROR , " Pipe failed \n " ) ;
ast_channel_set_fd ( tmp , 0 , chlist - > pipe [ 0 ] ) ;
if ( state = = AST_STATE_RING )
@ -3715,9 +3722,8 @@ static void release_chan(struct misdn_bchannel *bc) {
} else {
/* chan is already cleaned, so exiting */
}
ast_mutex_unlock ( & release_lock ) ;
}
ast_mutex_unlock ( & release_lock ) ;
/*** release end **/
}
@ -3854,7 +3860,9 @@ static void send_cause2ast(struct ast_channel *ast, struct misdn_bchannel *bc, s
void import_ch ( struct ast_channel * chan , struct misdn_bchannel * bc , struct chan_list * ch )
{
const char * tmp = pbx_builtin_getvar_helper ( chan , " MISDN_PID " ) ;
const char * tmp ;
tmp = pbx_builtin_getvar_helper ( chan , " MISDN_PID " ) ;
if ( tmp ) {
ch - > other_pid = atoi ( tmp ) ;
chan_misdn_log ( 3 , bc - > port , " --> IMPORT_PID: importing pid:%s \n " , tmp ) ;
@ -3878,9 +3886,10 @@ void import_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_
}
tmp = pbx_builtin_getvar_helper ( chan , " MISDN_KEYPAD " ) ;
if ( tmp )
if ( tmp ) {
ast_copy_string ( bc - > keypad , tmp , sizeof ( bc - > keypad ) ) ;
}
}
void export_ch ( struct ast_channel * chan , struct misdn_bchannel * bc , struct chan_list * ch )
{
@ -3899,8 +3908,9 @@ void export_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_
pbx_builtin_setvar_helper ( chan , " MISDN_URATE " , tmp ) ;
}
if ( bc - > uulen )
if ( bc - > uulen ) {
pbx_builtin_setvar_helper ( chan , " MISDN_USERUSER " , bc - > uu ) ;
}
if ( ! ast_strlen_zero ( bc - > keypad ) )
pbx_builtin_setvar_helper ( chan , " MISDN_KEYPAD " , bc - > keypad ) ;
@ -4061,7 +4071,9 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
case EVENT_DTMF_TONE :
{
/* sending INFOS as DTMF-Frames :) */
struct ast_frame fr = { 0 , } ;
struct ast_frame fr ;
memset ( & fr , 0 , sizeof ( fr ) ) ;
fr . frametype = AST_FRAME_DTMF ;
fr . subclass = bc - > dtmf ;
fr . src = NULL ;
@ -4158,6 +4170,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
/* sending INFOS as DTMF-Frames :) */
struct ast_frame fr ;
int digits ;
memset ( & fr , 0 , sizeof ( fr ) ) ;
fr . frametype = AST_FRAME_DTMF ;
fr . subclass = bc - > info_dad [ 0 ] ;
@ -4218,21 +4231,6 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
print_bearer ( bc ) ;
if ( ! bc - > nt & & ! msn_valid ) {
chan_misdn_log ( 1 , bc - > port , " --> Ignoring Call, its not in our MSN List \n " ) ;
return RESPONSE_IGNORE_SETUP ; /* Ignore MSNs which are not in our List */
}
if ( bc - > cw ) {
int cause ;
chan_misdn_log ( 0 , bc - > port , " --> Call Waiting on PMP sending RELEASE_COMPLETE \n " ) ;
misdn_cfg_get ( bc - > port , MISDN_CFG_REJECT_CAUSE , & cause , sizeof ( cause ) ) ;
bc - > out_cause = cause ? cause : AST_CAUSE_NORMAL_CLEARING ;
return RESPONSE_RELEASE_SETUP ;
}
print_bearer ( bc ) ;
ch = init_chan_list ( ORG_MISDN ) ;
if ( ! ch ) {
@ -4499,7 +4497,6 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
break ;
case EVENT_PROCEEDING :
{
if ( misdn_cap_is_speech ( bc - > capability ) & &
misdn_inband_avail ( bc ) ) {
start_bc_tones ( ch ) ;
@ -4514,7 +4511,6 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
}
break ;
case EVENT_PROGRESS :
if ( bc - > channel )
update_name ( ch - > ast , bc - > port , bc - > channel ) ;
@ -5551,7 +5547,6 @@ struct misdn_jb *misdn_jb_init(int size, int upper_threshold)
jb - > state_empty = 0 ;
jb - > bytes_wrote = 0 ;
jb - > samples = ast_malloc ( size * sizeof ( char ) ) ;
if ( ! jb - > samples ) {
ast_free ( jb ) ;
chan_misdn_log ( - 1 , 0 , " No free Mem for jb->samples \n " ) ;
@ -5559,7 +5554,6 @@ struct misdn_jb *misdn_jb_init(int size, int upper_threshold)
}
jb - > ok = ast_malloc ( size * sizeof ( char ) ) ;
if ( ! jb - > ok ) {
ast_free ( jb - > samples ) ;
ast_free ( jb ) ;
@ -5618,7 +5612,7 @@ int misdn_jb_fill(struct misdn_jb *jb, const char *data, int len)
rp = wp ;
for ( j = 0 ; j < jb - > upper_threshold ; j + + )
rp = rp ! = 0 ? rp - 1 : jb - > size - 1 ;
rp = ( rp ! = 0 ) ? rp - 1 : jb - > size - 1 ;
jb - > rp = rp ;
jb - > state_full = 0 ;
jb - > state_empty = 1 ;