2005-10-31 22:51:12 +00:00
/*
2005-11-06 15:09:47 +00:00
* Asterisk - - An open source telephony toolkit .
*
2006-02-23 17:13:57 +00:00
* Copyright ( C ) 2004 - 2006 , Christian Richter
2005-10-31 22:51:12 +00:00
*
* Christian Richter < crich @ beronet . com >
*
2005-11-06 15:09:47 +00:00
* See http : //www.asterisk.org for more information about
* the Asterisk project . Please do not directly contact
* any of the maintainers of this project for assistance ;
* the project provides a web site , mailing lists and IRC
* channels for your use .
*
2005-10-31 22:51:12 +00:00
* This program is free software , distributed under the terms of
2005-11-06 15:09:47 +00:00
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree .
*
*/
/*!
* \ file
*
* \ brief the chan_misdn channel driver for Asterisk
2007-05-07 18:18:43 +00:00
*
2005-11-06 15:09:47 +00:00
* \ author Christian Richter < crich @ beronet . com >
*
2007-05-07 18:18:43 +00:00
* \ extref MISDN http : //www.misdn.org/
*
2005-11-06 15:09:47 +00:00
* \ ingroup channel_drivers
2005-10-31 22:51:12 +00:00
*/
2006-08-21 02:11:39 +00:00
/*** MODULEINFO
< depend > isdnnet < / depend >
< depend > misdn < / depend >
< depend > suppserv < / depend >
* * */
2006-06-07 18:54:56 +00:00
# include "asterisk.h"
ASTERISK_FILE_VERSION ( __FILE__ , " $Revision$ " )
2005-10-31 22:51:12 +00:00
# include <pthread.h>
# include <sys/socket.h>
# include <sys/time.h>
# include <arpa/inet.h>
# include <fcntl.h>
# include <sys/ioctl.h>
2006-07-11 19:30:35 +00:00
# include <signal.h>
2005-10-31 22:51:12 +00:00
# include <sys/file.h>
2006-08-08 18:13:40 +00:00
# include <semaphore.h>
2005-10-31 22:51:12 +00:00
2006-06-07 18:54:56 +00:00
# include "asterisk/channel.h"
# include "asterisk/config.h"
# include "asterisk/module.h"
# include "asterisk/pbx.h"
# include "asterisk/io.h"
# include "asterisk/frame.h"
# include "asterisk/translate.h"
# include "asterisk/cli.h"
# include "asterisk/musiconhold.h"
# include "asterisk/dsp.h"
# include "asterisk/file.h"
# include "asterisk/callerid.h"
# include "asterisk/indications.h"
# include "asterisk/app.h"
# include "asterisk/features.h"
2006-07-03 16:41:43 +00:00
# include "asterisk/term.h"
2006-07-11 19:30:35 +00:00
# include "asterisk/sched.h"
2006-06-07 18:54:56 +00:00
# include "asterisk/stringfields.h"
2007-07-05 07:45:21 +00:00
# include "asterisk/abstract_jb.h"
2007-06-09 01:06:40 +00:00
# include "asterisk/causes.h"
2005-10-31 22:51:12 +00:00
2006-06-07 18:54:56 +00:00
# include "chan_misdn_config.h"
# include "isdn_lib.h"
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
char global_tracefile [ BUFFERSIZE + 1 ] ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
static int g_config_initialized = 0 ;
2005-12-09 11:01:18 +00:00
struct misdn_jb {
int size ;
int upper_threshold ;
char * samples , * ok ;
int wp , rp ;
int state_empty ;
int state_full ;
int state_buffer ;
int bytes_wrote ;
ast_mutex_t mutexjb ;
} ;
2006-02-22 21:59:46 +00:00
2007-05-07 18:17:18 +00:00
/*! \brief allocates the jb-structure and initialise the elements*/
2005-12-09 11:01:18 +00:00
struct misdn_jb * misdn_jb_init ( int size , int upper_threshold ) ;
2007-05-07 18:17:18 +00:00
/*! \brief frees the data and destroys the given jitterbuffer struct */
2005-12-09 11:01:18 +00:00
void misdn_jb_destroy ( struct misdn_jb * jb ) ;
2007-05-07 18:17:18 +00:00
/*! \brief fills the jitterbuffer with len data returns < 0 if there was an
2005-12-09 11:01:18 +00:00
error ( bufferoverun ) . */
int misdn_jb_fill ( struct misdn_jb * jb , const char * data , int len ) ;
2007-05-07 18:17:18 +00:00
/*! \brief gets len bytes out of the jitterbuffer if available, else only the
2005-12-09 11:01:18 +00:00
available data is returned and the return value indicates the number
of data . */
int misdn_jb_empty ( struct misdn_jb * jb , char * data , int len ) ;
2007-10-19 18:01:00 +00:00
static char * complete_ch ( struct ast_cli_args * a ) ;
static char * complete_debug_port ( struct ast_cli_args * a ) ;
static char * complete_show_config ( struct ast_cli_args * a ) ;
2005-12-09 11:01:18 +00:00
2007-07-02 09:34:19 +00:00
/* BEGIN: chan_misdn.h */
ast_mutex_t release_lock ;
2005-10-31 22:51:12 +00:00
enum misdn_chan_state {
2006-09-28 11:32:32 +00:00
MISDN_NOTHING = 0 , /*!< at beginning */
2005-11-06 15:09:47 +00:00
MISDN_WAITING4DIGS , /*!< when waiting for infos */
MISDN_EXTCANTMATCH , /*!< when asterisk couldnt match our ext */
2007-05-18 09:47:19 +00:00
MISDN_INCOMING_SETUP , /*!< for incoming setups*/
2005-11-06 15:09:47 +00:00
MISDN_DIALING , /*!< when pbx_start */
MISDN_PROGRESS , /*!< we got a progress */
2006-02-10 10:10:58 +00:00
MISDN_PROCEEDING , /*!< we got a progress */
2005-11-06 15:09:47 +00:00
MISDN_CALLING , /*!< when misdn_call is called */
MISDN_CALLING_ACKNOWLEDGE , /*!< when we get SETUP_ACK */
MISDN_ALERTING , /*!< when Alerting */
MISDN_BUSY , /*!< when BUSY */
MISDN_CONNECTED , /*!< when connected */
2006-05-24 07:58:52 +00:00
MISDN_PRECONNECTED , /*!< when connected */
2006-03-07 12:17:35 +00:00
MISDN_DISCONNECTED , /*!< when connected */
2006-06-21 15:21:46 +00:00
MISDN_RELEASED , /*!< when connected */
2005-11-06 15:09:47 +00:00
MISDN_BRIDGED , /*!< when bridged */
MISDN_CLEANING , /*!< when hangup from * but we were connected before */
MISDN_HUNGUP_FROM_MISDN , /*!< when DISCONNECT/RELEASE/REL_COMP cam from misdn */
MISDN_HUNGUP_FROM_AST , /*!< when DISCONNECT/RELEASE/REL_COMP came out of */
2005-10-31 22:51:12 +00:00
/* misdn_hangup */
2005-11-06 15:09:47 +00:00
MISDN_HOLDED , /*!< if this chan is holded */
2006-10-11 08:23:16 +00:00
MISDN_HOLD_DISCONNECT , /*!< if this chan is holded */
2005-10-31 22:51:12 +00:00
} ;
# define ORG_AST 1
# define ORG_MISDN 2
2006-10-11 08:23:16 +00:00
struct hold_info {
int port ;
int channel ;
} ;
2005-10-31 22:51:12 +00:00
struct chan_list {
2007-06-06 21:20:11 +00:00
char allowed_bearers [ BUFFERSIZE + 1 ] ;
2006-06-01 12:51:41 +00:00
2005-10-31 22:51:12 +00:00
enum misdn_chan_state state ;
2006-07-06 15:11:40 +00:00
int need_queue_hangup ;
int need_hangup ;
2006-08-03 16:38:00 +00:00
int need_busy ;
2006-07-06 15:11:40 +00:00
2007-04-11 15:48:54 +00:00
int originator ;
2007-05-18 09:47:19 +00:00
int noautorespond_on_setup ;
2005-10-31 22:51:12 +00:00
int norxtone ;
int notxtone ;
2006-08-08 09:19:06 +00:00
int toggle_ec ;
2006-06-08 09:51:13 +00:00
2006-02-15 19:51:33 +00:00
int incoming_early_audio ;
2006-06-08 09:51:13 +00:00
int ignore_dtmf ;
2005-10-31 22:51:12 +00:00
int pipe [ 2 ] ;
char ast_rd_buf [ 4096 ] ;
struct ast_frame frame ;
2007-05-07 18:17:18 +00:00
int faxdetect ; /*!< 0:no 1:yes 2:yes+nojump */
2006-08-08 18:13:40 +00:00
int faxdetect_timeout ;
struct timeval faxdetect_tv ;
2005-10-31 22:51:12 +00:00
int faxhandled ;
int ast_dsp ;
2005-12-09 11:01:18 +00:00
2006-02-10 14:17:28 +00:00
int jb_len ;
int jb_upper_threshold ;
2005-12-09 11:01:18 +00:00
struct misdn_jb * jb ;
2005-10-31 22:51:12 +00:00
struct ast_dsp * dsp ;
struct ast_trans_pvt * trans ;
struct ast_channel * ast ;
2006-06-17 10:37:35 +00:00
int dummy ;
2005-10-31 22:51:12 +00:00
struct misdn_bchannel * bc ;
2006-10-11 08:23:16 +00:00
struct hold_info hold_info ;
2005-10-31 22:51:12 +00:00
unsigned int l3id ;
int addr ;
2005-12-09 11:01:18 +00:00
char context [ BUFFERSIZE ] ;
2006-02-02 21:15:34 +00:00
2006-04-29 22:56:00 +00:00
int zero_read_cnt ;
int dropped_frame_cnt ;
2006-05-05 16:38:15 +00:00
int far_alerting ;
2006-10-27 11:18:32 +00:00
int nttimeout ;
2006-06-17 10:37:35 +00:00
int other_pid ;
struct chan_list * other_ch ;
2006-05-05 16:38:15 +00:00
2006-12-25 06:38:09 +00:00
const struct ind_tone_zone_sound * ts ;
2005-10-31 22:51:12 +00:00
2006-07-11 19:30:35 +00:00
int overlap_dial ;
int overlap_dial_task ;
ast_mutex_t overlap_tv_lock ;
struct timeval overlap_tv ;
2005-10-31 22:51:12 +00:00
struct chan_list * peer ;
struct chan_list * next ;
struct chan_list * prev ;
struct chan_list * first ;
} ;
2006-06-17 10:37:35 +00:00
void export_ch ( struct ast_channel * chan , struct misdn_bchannel * bc , struct chan_list * ch ) ;
void import_ch ( struct ast_channel * chan , struct misdn_bchannel * bc , struct chan_list * ch ) ;
2005-10-31 22:51:12 +00:00
struct robin_list {
char * group ;
int port ;
int channel ;
struct robin_list * next ;
struct robin_list * prev ;
} ;
static struct robin_list * robin = NULL ;
2006-05-16 14:34:21 +00:00
2006-09-20 05:13:03 +00:00
static struct ast_frame * process_ast_dsp ( struct chan_list * tmp , struct ast_frame * frame ) ;
2006-05-16 14:34:21 +00:00
2005-10-31 22:51:12 +00:00
static inline void free_robin_list_r ( struct robin_list * r )
{
2007-06-06 21:20:11 +00:00
if ( r ) {
if ( r - > next )
free_robin_list_r ( r - > next ) ;
if ( r - > group )
ast_free ( r - > group ) ;
ast_free ( r ) ;
}
2005-10-31 22:51:12 +00:00
}
2005-11-11 00:35:21 +00:00
static void free_robin_list ( void )
2005-10-31 22:51:12 +00:00
{
free_robin_list_r ( robin ) ;
2005-11-15 20:20:45 +00:00
robin = NULL ;
2005-10-31 22:51:12 +00:00
}
2005-12-09 11:01:18 +00:00
static struct robin_list * get_robin_position ( char * group )
2005-10-31 22:51:12 +00:00
{
2007-06-06 21:20:11 +00:00
struct robin_list * new ;
2005-10-31 22:51:12 +00:00
struct robin_list * iter = robin ;
for ( ; iter ; iter = iter - > next ) {
if ( ! strcasecmp ( iter - > group , group ) )
return iter ;
}
2007-06-06 21:20:11 +00:00
new = ast_calloc ( 1 , sizeof ( * new ) ) ;
2005-10-31 22:51:12 +00:00
new - > group = strndup ( group , strlen ( group ) ) ;
new - > channel = 1 ;
if ( robin ) {
new - > next = robin ;
robin - > prev = new ;
}
robin = new ;
return robin ;
}
2005-12-09 11:01:18 +00:00
2007-05-07 18:17:18 +00:00
/*! \brief the main schedule context for stuff like l1 watcher, overlap dial, ... */
2006-07-11 19:30:35 +00:00
static struct sched_context * misdn_tasks = NULL ;
static pthread_t misdn_tasks_thread ;
2006-08-17 09:14:01 +00:00
static int * misdn_ports ;
2005-12-09 11:01:18 +00:00
static void chan_misdn_log ( int level , int port , char * tmpl , . . . ) ;
static struct ast_channel * misdn_new ( struct chan_list * cl , int state , char * exten , char * callerid , int format , int port , int c ) ;
static void send_digit_to_chan ( struct chan_list * cl , char digit ) ;
2005-10-31 22:51:12 +00:00
2006-07-06 15:11:40 +00:00
static void hangup_chan ( struct chan_list * ch ) ;
static int pbx_start_chan ( struct chan_list * ch ) ;
2005-11-01 22:04:14 +00:00
# define MISDN_ASTERISK_TECH_PVT(ast) ast->tech_pvt
# define MISDN_ASTERISK_PVT(ast) 1
2007-10-09 16:04:41 +00:00
# include "asterisk/strings.h"
2005-10-31 22:51:12 +00:00
/* #define MISDN_DEBUG 1 */
2006-02-22 21:59:46 +00:00
static const char misdn_type [ ] = " mISDN " ;
2005-10-31 22:51:12 +00:00
2005-12-09 11:01:18 +00:00
static int tracing = 0 ;
2005-10-31 22:51:12 +00:00
2007-05-07 18:17:18 +00:00
/*! \brief Only alaw and mulaw is allowed for now */
2005-10-31 22:51:12 +00:00
static int prefformat = AST_FORMAT_ALAW ; /* AST_FORMAT_SLINEAR ; AST_FORMAT_ULAW | */
2005-12-09 11:01:18 +00:00
static int * misdn_debug ;
static int * misdn_debug_only ;
static int max_ports ;
2005-10-31 22:51:12 +00:00
2006-05-22 15:02:03 +00:00
static int * misdn_in_calls ;
static int * misdn_out_calls ;
2005-10-31 22:51:12 +00:00
struct chan_list dummy_cl ;
struct chan_list * cl_te = NULL ;
2005-11-01 22:04:14 +00:00
ast_mutex_t cl_te_lock ;
2005-10-31 22:51:12 +00:00
2005-12-09 11:01:18 +00:00
static enum event_response_e
2005-10-31 22:51:12 +00:00
cb_events ( enum event_e event , struct misdn_bchannel * bc , void * user_data ) ;
2006-06-26 17:37:11 +00:00
static void send_cause2ast ( struct ast_channel * ast , struct misdn_bchannel * bc , struct chan_list * ch ) ;
2005-12-09 11:01:18 +00:00
static void cl_queue_chan ( struct chan_list * * list , struct chan_list * chan ) ;
static void cl_dequeue_chan ( struct chan_list * * list , struct chan_list * chan ) ;
static struct chan_list * find_chan_by_bc ( struct chan_list * list , struct misdn_bchannel * bc ) ;
2006-06-17 10:37:35 +00:00
static struct chan_list * find_chan_by_pid ( struct chan_list * list , int pid ) ;
2005-12-09 11:01:18 +00:00
2006-07-06 15:11:40 +00:00
static int dialtone_indicate ( struct chan_list * cl ) ;
static int hanguptone_indicate ( struct chan_list * cl ) ;
static int stop_indicate ( struct chan_list * cl ) ;
2005-10-31 22:51:12 +00:00
static int start_bc_tones ( struct chan_list * cl ) ;
static int stop_bc_tones ( struct chan_list * cl ) ;
static void release_chan ( struct misdn_bchannel * bc ) ;
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
static int misdn_check_l2l1 ( struct ast_channel * chan , void * data ) ;
2005-10-31 22:51:12 +00:00
static int misdn_set_opt_exec ( struct ast_channel * chan , void * data ) ;
static int misdn_facility_exec ( struct ast_channel * chan , void * data ) ;
2005-12-09 11:01:18 +00:00
int chan_misdn_jb_empty ( struct misdn_bchannel * bc , char * buf , int len ) ;
2006-05-16 14:34:21 +00:00
void debug_numplan ( int port , int numplan , char * type ) ;
2006-05-22 15:02:03 +00:00
int add_out_calls ( int port ) ;
int add_in_calls ( int port ) ;
2007-03-26 15:59:56 +00:00
# ifdef MISDN_1_2
static int update_pipeline_config ( struct misdn_bchannel * bc ) ;
# else
2006-08-08 09:19:06 +00:00
static int update_ec_config ( struct misdn_bchannel * bc ) ;
2007-03-26 15:59:56 +00:00
# endif
2006-08-08 09:19:06 +00:00
2006-10-11 08:23:16 +00:00
/*protos*/
int chan_misdn_jb_empty ( struct misdn_bchannel * bc , char * buf , int len ) ;
2005-10-31 22:51:12 +00:00
/*************** Helpers *****************/
static struct chan_list * get_chan_by_ast ( struct ast_channel * ast )
{
struct chan_list * tmp ;
for ( tmp = cl_te ; tmp ; tmp = tmp - > next ) {
if ( tmp - > ast = = ast ) return tmp ;
}
return NULL ;
}
static struct chan_list * get_chan_by_ast_name ( char * name )
{
struct chan_list * tmp ;
for ( tmp = cl_te ; tmp ; tmp = tmp - > next ) {
if ( tmp - > ast & & strcmp ( tmp - > ast - > name , name ) = = 0 ) return tmp ;
}
return NULL ;
}
2006-06-01 12:51:41 +00:00
struct allowed_bearers {
int cap ;
int val ;
char * name ;
} ;
struct allowed_bearers allowed_bearers_array [ ] = {
{ INFO_CAPABILITY_SPEECH , 1 , " speech " } ,
{ INFO_CAPABILITY_AUDIO_3_1K , 2 , " 3_1khz " } ,
{ INFO_CAPABILITY_DIGITAL_UNRESTRICTED , 4 , " digital_unrestricted " } ,
{ INFO_CAPABILITY_DIGITAL_RESTRICTED , 8 , " digital_restriced " } ,
{ INFO_CAPABILITY_VIDEO , 16 , " video " }
} ;
2005-10-31 22:51:12 +00:00
static char * bearer2str ( int cap ) {
static char * bearers [ ] = {
" Speech " ,
" Audio 3.1k " ,
" Unres Digital " ,
" Res Digital " ,
2006-06-01 12:51:41 +00:00
" Video " ,
2005-10-31 22:51:12 +00:00
" Unknown Bearer "
} ;
switch ( cap ) {
case INFO_CAPABILITY_SPEECH :
return bearers [ 0 ] ;
break ;
case INFO_CAPABILITY_AUDIO_3_1K :
return bearers [ 1 ] ;
break ;
case INFO_CAPABILITY_DIGITAL_UNRESTRICTED :
return bearers [ 2 ] ;
break ;
case INFO_CAPABILITY_DIGITAL_RESTRICTED :
return bearers [ 3 ] ;
break ;
2006-06-01 12:51:41 +00:00
case INFO_CAPABILITY_VIDEO :
2005-10-31 22:51:12 +00:00
return bearers [ 4 ] ;
break ;
2006-06-01 12:51:41 +00:00
default :
return bearers [ 5 ] ;
break ;
2005-10-31 22:51:12 +00:00
}
}
2005-12-09 11:01:18 +00:00
2006-08-16 13:19:54 +00:00
static void print_facility ( struct FacParm * fac , struct misdn_bchannel * bc )
2005-12-09 11:01:18 +00:00
{
2006-08-15 16:49:26 +00:00
switch ( fac - > Function ) {
2007-10-29 16:34:45 +00:00
# ifdef HAVE_MISDN_FAC_RESULT
2007-10-22 10:04:04 +00:00
case Fac_RESULT :
chan_misdn_log ( 0 , bc - > port , " --> Received RESULT Operation \n " ) ;
break ;
2007-10-29 16:34:45 +00:00
# endif
# ifdef HAVE_MISDN_FAC_ERROR
2007-10-22 10:04:04 +00:00
case Fac_ERROR :
chan_misdn_log ( 0 , bc - > port , " --> Received Error Operation \n " ) ;
chan_misdn_log ( 0 , bc - > port , " --> Value:%d Error:%s \n " , fac - > u . ERROR . errorValue , fac - > u . ERROR . error ) ;
break ;
2007-10-29 16:34:45 +00:00
# endif
2007-10-22 10:04:04 +00:00
case Fac_CD :
chan_misdn_log ( 1 , bc - > port , " --> calldeflect to: %s, screened: %s \n " , fac - > u . CDeflection . DeflectedToNumber ,
fac - > u . CDeflection . PresentationAllowed ? " yes " : " no " ) ;
break ;
case Fac_AOCDCurrency :
if ( fac - > u . AOCDcur . chargeNotAvailable )
chan_misdn_log ( 1 , bc - > port , " --> AOCD currency: charge not available \n " ) ;
else if ( fac - > u . AOCDcur . freeOfCharge )
chan_misdn_log ( 1 , bc - > port , " --> AOCD currency: free of charge \n " ) ;
else if ( fac - > u . AOCDchu . billingId > = 0 )
chan_misdn_log ( 1 , bc - > port , " --> AOCD currency: currency:%s amount:%d multiplier:%d typeOfChargingInfo:%d billingId:%d \n " ,
fac - > u . AOCDcur . currency , fac - > u . AOCDcur . currencyAmount , fac - > u . AOCDcur . multiplier ,
( fac - > u . AOCDcur . typeOfChargingInfo = = 0 ) ? " subTotal " : " total " , fac - > u . AOCDcur . billingId ) ;
else
chan_misdn_log ( 1 , bc - > port , " --> AOCD currency: currency:%s amount:%d multiplier:%d typeOfChargingInfo:%d \n " ,
fac - > u . AOCDcur . currency , fac - > u . AOCDcur . currencyAmount , fac - > u . AOCDcur . multiplier ,
( fac - > u . AOCDcur . typeOfChargingInfo = = 0 ) ? " subTotal " : " total " ) ;
break ;
case Fac_AOCDChargingUnit :
if ( fac - > u . AOCDchu . chargeNotAvailable )
chan_misdn_log ( 1 , bc - > port , " --> AOCD charging unit: charge not available \n " ) ;
else if ( fac - > u . AOCDchu . freeOfCharge )
chan_misdn_log ( 1 , bc - > port , " --> AOCD charging unit: free of charge \n " ) ;
else if ( fac - > u . AOCDchu . billingId > = 0 )
chan_misdn_log ( 1 , bc - > port , " --> AOCD charging unit: recordedUnits:%d typeOfChargingInfo:%s billingId:%d \n " ,
fac - > u . AOCDchu . recordedUnits , ( fac - > u . AOCDchu . typeOfChargingInfo = = 0 ) ? " subTotal " : " total " , fac - > u . AOCDchu . billingId ) ;
else
chan_misdn_log ( 1 , bc - > port , " --> AOCD charging unit: recordedUnits:%d typeOfChargingInfo:%s \n " ,
fac - > u . AOCDchu . recordedUnits , ( fac - > u . AOCDchu . typeOfChargingInfo = = 0 ) ? " subTotal " : " total " ) ;
break ;
case Fac_None :
default :
chan_misdn_log ( 1 , bc - > port , " --> unknown facility \n " ) ;
2005-12-09 11:01:18 +00:00
}
}
2005-10-31 22:51:12 +00:00
static void print_bearer ( struct misdn_bchannel * bc )
{
2005-11-01 22:04:14 +00:00
chan_misdn_log ( 2 , bc - > port , " --> Bearer: %s \n " , bearer2str ( bc - > capability ) ) ;
2005-10-31 22:51:12 +00:00
switch ( bc - > law ) {
case INFO_CODEC_ALAW :
2005-11-01 22:04:14 +00:00
chan_misdn_log ( 2 , bc - > port , " --> Codec: Alaw \n " ) ;
2005-10-31 22:51:12 +00:00
break ;
case INFO_CODEC_ULAW :
2005-11-01 22:04:14 +00:00
chan_misdn_log ( 2 , bc - > port , " --> Codec: Ulaw \n " ) ;
2005-10-31 22:51:12 +00:00
break ;
}
}
2007-04-11 15:48:54 +00:00
static void export_aoc_vars ( int originator , struct ast_channel * ast , struct misdn_bchannel * bc )
{
char buf [ 128 ] ;
if ( ! bc - > AOCD_need_export | | ! ast )
return ;
if ( originator = = ORG_AST ) {
ast = ast_bridged_channel ( ast ) ;
if ( ! ast )
return ;
}
switch ( bc - > AOCDtype ) {
case Fac_AOCDCurrency :
pbx_builtin_setvar_helper ( ast , " AOCD_Type " , " currency " ) ;
if ( bc - > AOCD . currency . chargeNotAvailable )
pbx_builtin_setvar_helper ( ast , " AOCD_ChargeAvailable " , " no " ) ;
else {
pbx_builtin_setvar_helper ( ast , " AOCD_ChargeAvailable " , " yes " ) ;
if ( bc - > AOCD . currency . freeOfCharge )
pbx_builtin_setvar_helper ( ast , " AOCD_FreeOfCharge " , " yes " ) ;
else {
pbx_builtin_setvar_helper ( ast , " AOCD_FreeOfCharge " , " no " ) ;
if ( snprintf ( buf , sizeof ( buf ) , " %d %s " , bc - > AOCD . currency . currencyAmount * bc - > AOCD . currency . multiplier , bc - > AOCD . currency . currency ) < sizeof ( buf ) ) {
pbx_builtin_setvar_helper ( ast , " AOCD_Amount " , buf ) ;
if ( bc - > AOCD . currency . billingId > = 0 & & snprintf ( buf , sizeof ( buf ) , " %d " , bc - > AOCD . currency . billingId ) < sizeof ( buf ) )
pbx_builtin_setvar_helper ( ast , " AOCD_BillingId " , buf ) ;
}
}
}
break ;
case Fac_AOCDChargingUnit :
pbx_builtin_setvar_helper ( ast , " AOCD_Type " , " charging_unit " ) ;
if ( bc - > AOCD . chargingUnit . chargeNotAvailable )
pbx_builtin_setvar_helper ( ast , " AOCD_ChargeAvailable " , " no " ) ;
else {
pbx_builtin_setvar_helper ( ast , " AOCD_ChargeAvailable " , " yes " ) ;
if ( bc - > AOCD . chargingUnit . freeOfCharge )
pbx_builtin_setvar_helper ( ast , " AOCD_FreeOfCharge " , " yes " ) ;
else {
pbx_builtin_setvar_helper ( ast , " AOCD_FreeOfCharge " , " no " ) ;
if ( snprintf ( buf , sizeof ( buf ) , " %d " , bc - > AOCD . chargingUnit . recordedUnits ) < sizeof ( buf ) ) {
pbx_builtin_setvar_helper ( ast , " AOCD_RecordedUnits " , buf ) ;
if ( bc - > AOCD . chargingUnit . billingId > = 0 & & snprintf ( buf , sizeof ( buf ) , " %d " , bc - > AOCD . chargingUnit . billingId ) < sizeof ( buf ) )
pbx_builtin_setvar_helper ( ast , " AOCD_BillingId " , buf ) ;
}
}
}
break ;
default :
break ;
}
bc - > AOCD_need_export = 0 ;
}
2005-10-31 22:51:12 +00:00
/*************** Helpers END *************/
2006-07-11 19:30:35 +00:00
static void sighandler ( int sig )
{ }
static void * misdn_tasks_thread_func ( void * data )
{
int wait ;
struct sigaction sa ;
sa . sa_handler = sighandler ;
sa . sa_flags = SA_NODEFER ;
sigemptyset ( & sa . sa_mask ) ;
sigaddset ( & sa . sa_mask , SIGUSR1 ) ;
sigaction ( SIGUSR1 , & sa , NULL ) ;
2006-08-08 18:13:40 +00:00
sem_post ( ( sem_t * ) data ) ;
2006-07-11 19:30:35 +00:00
while ( 1 ) {
wait = ast_sched_wait ( misdn_tasks ) ;
if ( wait < 0 )
wait = 8000 ;
if ( poll ( NULL , 0 , wait ) < 0 )
chan_misdn_log ( 4 , 0 , " Waking up misdn_tasks thread \n " ) ;
ast_sched_runq ( misdn_tasks ) ;
}
return NULL ;
}
static void misdn_tasks_init ( void )
{
2006-08-08 18:13:40 +00:00
sem_t blocker ;
int i = 5 ;
2006-07-11 19:30:35 +00:00
2006-08-08 18:13:40 +00:00
if ( sem_init ( & blocker , 0 , 0 ) ) {
2006-07-11 19:30:35 +00:00
perror ( " chan_misdn: Failed to initialize semaphore! " ) ;
exit ( 1 ) ;
}
2006-08-08 18:13:40 +00:00
chan_misdn_log ( 4 , 0 , " Starting misdn_tasks thread \n " ) ;
2006-07-11 19:30:35 +00:00
misdn_tasks = sched_context_create ( ) ;
2006-08-08 18:13:40 +00:00
pthread_create ( & misdn_tasks_thread , NULL , misdn_tasks_thread_func , & blocker ) ;
2006-07-11 19:30:35 +00:00
2006-08-08 18:13:40 +00:00
while ( sem_wait ( & blocker ) & & - - i ) ;
sem_destroy ( & blocker ) ;
2006-07-11 19:30:35 +00:00
}
static void misdn_tasks_destroy ( void )
{
if ( misdn_tasks ) {
chan_misdn_log ( 4 , 0 , " Killing misdn_tasks thread \n " ) ;
if ( pthread_cancel ( misdn_tasks_thread ) = = 0 ) {
cb_log ( 4 , 0 , " Joining misdn_tasks thread \n " ) ;
pthread_join ( misdn_tasks_thread , NULL ) ;
}
sched_context_destroy ( misdn_tasks ) ;
}
}
static inline void misdn_tasks_wakeup ( void )
{
pthread_kill ( misdn_tasks_thread , SIGUSR1 ) ;
}
2007-09-21 14:40:10 +00:00
static inline int _misdn_tasks_add_variable ( int timeout , ast_sched_cb callback , const void * data , int variable )
2006-07-11 19:30:35 +00:00
{
int task_id ;
if ( ! misdn_tasks ) {
misdn_tasks_init ( ) ;
}
task_id = ast_sched_add_variable ( misdn_tasks , timeout , callback , data , variable ) ;
misdn_tasks_wakeup ( ) ;
return task_id ;
}
2007-09-21 14:40:10 +00:00
static int misdn_tasks_add ( int timeout , ast_sched_cb callback , const void * data )
2006-07-11 19:30:35 +00:00
{
return _misdn_tasks_add_variable ( timeout , callback , data , 0 ) ;
}
2007-09-21 14:40:10 +00:00
static int misdn_tasks_add_variable ( int timeout , ast_sched_cb callback , const void * data )
2006-07-11 19:30:35 +00:00
{
return _misdn_tasks_add_variable ( timeout , callback , data , 1 ) ;
}
static void misdn_tasks_remove ( int task_id )
{
ast_sched_del ( misdn_tasks , task_id ) ;
}
2007-09-21 14:40:10 +00:00
static int misdn_l1_task ( const void * data )
2006-07-11 19:30:35 +00:00
{
2006-08-17 09:14:01 +00:00
misdn_lib_isdn_l1watcher ( * ( int * ) data ) ;
chan_misdn_log ( 5 , * ( int * ) data , " L1watcher timeout \n " ) ;
2006-07-11 19:30:35 +00:00
return 1 ;
}
2007-09-21 14:40:10 +00:00
static int misdn_overlap_dial_task ( const void * data )
2006-07-11 19:30:35 +00:00
{
struct timeval tv_end , tv_now ;
int diff ;
struct chan_list * ch = ( struct chan_list * ) data ;
chan_misdn_log ( 4 , ch - > bc - > port , " overlap dial task, chan_state: %d \n " , ch - > state ) ;
if ( ch - > state ! = MISDN_WAITING4DIGS ) {
ch - > overlap_dial_task = - 1 ;
return 0 ;
}
ast_mutex_lock ( & ch - > overlap_tv_lock ) ;
tv_end = ch - > overlap_tv ;
ast_mutex_unlock ( & ch - > overlap_tv_lock ) ;
tv_end . tv_sec + = ch - > overlap_dial ;
tv_now = ast_tvnow ( ) ;
diff = ast_tvdiff_ms ( tv_end , tv_now ) ;
if ( diff < = 100 ) {
/* if we are 100ms near the timeout, we are satisfied.. */
stop_indicate ( ch ) ;
if ( ast_exists_extension ( ch - > ast , ch - > context , ch - > bc - > dad , 1 , ch - > bc - > oad ) ) {
ch - > state = MISDN_DIALING ;
if ( pbx_start_chan ( ch ) < 0 ) {
chan_misdn_log ( - 1 , ch - > bc - > port , " ast_pbx_start returned < 0 in misdn_overlap_dial_task \n " ) ;
goto misdn_overlap_dial_task_disconnect ;
}
} else {
misdn_overlap_dial_task_disconnect :
hanguptone_indicate ( ch ) ;
2007-10-22 10:18:43 +00:00
ch - > bc - > out_cause = 1 ;
2007-11-12 13:22:17 +00:00
ch - > state = MISDN_CLEANING ;
2007-10-22 10:18:43 +00:00
misdn_lib_send_event ( ch - > bc , EVENT_DISCONNECT ) ;
2006-07-11 19:30:35 +00:00
}
ch - > overlap_dial_task = - 1 ;
return 0 ;
} else
return diff ;
}
2005-12-09 11:01:18 +00:00
static void send_digit_to_chan ( struct chan_list * cl , char digit )
2005-10-31 22:51:12 +00:00
{
static const char * dtmf_tones [ ] = {
" !941+1336/100,!0/100 " , /* 0 */
" !697+1209/100,!0/100 " , /* 1 */
" !697+1336/100,!0/100 " , /* 2 */
" !697+1477/100,!0/100 " , /* 3 */
" !770+1209/100,!0/100 " , /* 4 */
" !770+1336/100,!0/100 " , /* 5 */
" !770+1477/100,!0/100 " , /* 6 */
" !852+1209/100,!0/100 " , /* 7 */
" !852+1336/100,!0/100 " , /* 8 */
" !852+1477/100,!0/100 " , /* 9 */
" !697+1633/100,!0/100 " , /* A */
" !770+1633/100,!0/100 " , /* B */
" !852+1633/100,!0/100 " , /* C */
" !941+1633/100,!0/100 " , /* D */
" !941+1209/100,!0/100 " , /* * */
" !941+1477/100,!0/100 " } ; /* # */
struct ast_channel * chan = cl - > ast ;
if ( digit > = ' 0 ' & & digit < = ' 9 ' )
ast_playtones_start ( chan , 0 , dtmf_tones [ digit - ' 0 ' ] , 0 ) ;
else if ( digit > = ' A ' & & digit < = ' D ' )
ast_playtones_start ( chan , 0 , dtmf_tones [ digit - ' A ' + 10 ] , 0 ) ;
else if ( digit = = ' * ' )
ast_playtones_start ( chan , 0 , dtmf_tones [ 14 ] , 0 ) ;
else if ( digit = = ' # ' )
ast_playtones_start ( chan , 0 , dtmf_tones [ 15 ] , 0 ) ;
else {
/* not handled */
2007-06-14 19:39:12 +00:00
ast_debug ( 1 , " Unable to handle DTMF tone '%c' for '%s' \n " , digit , chan - > name ) ;
2005-10-31 22:51:12 +00:00
}
}
2007-10-19 18:01:00 +00:00
2005-10-31 22:51:12 +00:00
/*** CLI HANDLING ***/
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_set_debug ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2005-10-31 22:51:12 +00:00
{
2007-06-06 21:20:11 +00:00
int level ;
2007-10-19 18:01:00 +00:00
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn set debug " ;
e - > usage =
" Usage: misdn set debug <level> [only] | [port <port> [only]] \n "
" Set the debug level of the mISDN channel. \n " ;
return NULL ;
case CLI_GENERATE :
return complete_debug_port ( a ) ;
}
2005-10-31 22:51:12 +00:00
2007-10-19 18:01:00 +00:00
if ( a - > argc < 4 | | a - > argc > 7 )
return CLI_SHOWUSAGE ;
2005-10-31 22:51:12 +00:00
2007-10-19 18:01:00 +00:00
level = atoi ( a - > argv [ 3 ] ) ;
switch ( a - > argc ) {
2007-06-06 21:20:11 +00:00
case 4 :
case 5 :
{
int only = 0 , i ;
2007-10-19 18:01:00 +00:00
if ( a - > argc = = 5 ) {
if ( strncasecmp ( a - > argv [ 4 ] , " only " , strlen ( a - > argv [ 4 ] ) ) )
return CLI_SHOWUSAGE ;
2007-06-06 21:20:11 +00:00
else
only = 1 ;
}
for ( i = 0 ; i < = max_ports ; i + + ) {
misdn_debug [ i ] = level ;
misdn_debug_only [ i ] = only ;
}
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " changing debug level for all ports to %d%s \n " , misdn_debug [ 0 ] , only ? " (only) " : " " ) ;
2007-06-06 21:20:11 +00:00
}
break ;
case 6 :
case 7 :
{
int port ;
2007-10-19 18:01:00 +00:00
if ( strncasecmp ( a - > argv [ 4 ] , " port " , strlen ( a - > argv [ 4 ] ) ) )
return CLI_SHOWUSAGE ;
port = atoi ( a - > argv [ 5 ] ) ;
2007-06-06 21:20:11 +00:00
if ( port < = 0 | | port > max_ports ) {
switch ( max_ports ) {
case 0 :
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " port number not valid! no ports available so you won't get lucky with any number here... \n " ) ;
2007-06-06 21:20:11 +00:00
break ;
case 1 :
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " port number not valid! only port 1 is availble. \n " ) ;
2007-06-06 21:20:11 +00:00
break ;
default :
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " port number not valid! only ports 1 to %d are available. \n " , max_ports ) ;
2005-10-31 22:51:12 +00:00
}
2007-06-06 21:20:11 +00:00
return 0 ;
}
2007-10-19 18:01:00 +00:00
if ( a - > argc = = 7 ) {
if ( strncasecmp ( a - > argv [ 6 ] , " only " , strlen ( a - > argv [ 6 ] ) ) )
return CLI_SHOWUSAGE ;
2007-06-06 21:20:11 +00:00
else
misdn_debug_only [ port ] = 1 ;
} else
misdn_debug_only [ port ] = 0 ;
misdn_debug [ port ] = level ;
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " changing debug level to %d%s for port %d \n " , misdn_debug [ port ] , misdn_debug_only [ port ] ? " (only) " : " " , port ) ;
2007-06-06 21:20:11 +00:00
}
2005-10-31 22:51:12 +00:00
}
2007-10-19 18:01:00 +00:00
return CLI_SUCCESS ;
2005-10-31 22:51:12 +00:00
}
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_set_crypt_debug ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2005-10-31 22:51:12 +00:00
{
2007-10-19 18:01:00 +00:00
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn set crypt debug " ;
e - > usage =
" Usage: misdn set crypt debug <level> \n "
" Set the crypt debug level of the mISDN channel. Level \n "
" must be 1 or 2. \n " ;
return NULL ;
case CLI_GENERATE :
return NULL ;
}
2005-10-31 22:51:12 +00:00
2007-10-19 18:01:00 +00:00
if ( a - > argc ! = 5 )
return CLI_SHOWUSAGE ;
/* Is this supposed to not do anything? */
2005-10-31 22:51:12 +00:00
2007-10-19 18:01:00 +00:00
return CLI_SUCCESS ;
}
2005-10-31 22:51:12 +00:00
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_port_block ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2006-08-03 16:38:00 +00:00
{
2007-10-19 18:01:00 +00:00
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn port block " ;
e - > usage =
" Usage: misdn port block <port> \n "
" Block the specified port by <port>. \n " ;
return NULL ;
case CLI_GENERATE :
return NULL ;
}
2007-06-11 11:40:21 +00:00
2007-10-19 18:01:00 +00:00
if ( a - > argc ! = 4 )
return CLI_SHOWUSAGE ;
2006-08-03 16:38:00 +00:00
2007-10-19 18:01:00 +00:00
misdn_lib_port_block ( atoi ( a - > argv [ 3 ] ) ) ;
2006-08-03 16:38:00 +00:00
2007-10-19 18:01:00 +00:00
return CLI_SUCCESS ;
2006-08-03 16:38:00 +00:00
}
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_port_unblock ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2006-08-03 16:38:00 +00:00
{
2007-10-19 18:01:00 +00:00
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn port unblock " ;
e - > usage =
" Usage: misdn port unblock <port> \n "
" Unblock the port specified by <port>. \n " ;
return NULL ;
case CLI_GENERATE :
return NULL ;
}
2006-08-03 16:38:00 +00:00
2007-10-19 18:01:00 +00:00
if ( a - > argc ! = 4 )
return CLI_SHOWUSAGE ;
2006-08-03 16:38:00 +00:00
2007-10-19 18:01:00 +00:00
misdn_lib_port_unblock ( atoi ( a - > argv [ 3 ] ) ) ;
2006-08-03 16:38:00 +00:00
2007-10-19 18:01:00 +00:00
return CLI_SUCCESS ;
}
2006-08-03 16:38:00 +00:00
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_restart_port ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2005-10-31 22:51:12 +00:00
{
2007-10-19 18:01:00 +00:00
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn restart port " ;
e - > usage =
" Usage: misdn restart port <port> \n "
" Restart the given port. \n " ;
return NULL ;
case CLI_GENERATE :
return NULL ;
}
2005-10-31 22:51:12 +00:00
2007-10-19 18:01:00 +00:00
if ( a - > argc ! = 4 )
return CLI_SHOWUSAGE ;
2005-10-31 22:51:12 +00:00
2007-10-19 18:01:00 +00:00
misdn_lib_port_restart ( atoi ( a - > argv [ 3 ] ) ) ;
return CLI_SUCCESS ;
2005-10-31 22:51:12 +00:00
}
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_restart_pid ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
Merged revisions 49313 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r49313 | crichter | 2007-01-03 10:06:50 +0100 (Mi, 03 Jan 2007) | 41 lines
Merged revisions 48319,48321,48467,48552,48576,49135,49303 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r48319 | crichter | 2006-12-06 15:35:25 +0100 (Mi, 06 Dez 2006) | 1 line
changed a few debugs to higher debug levels
........
r48321 | crichter | 2006-12-06 16:48:45 +0100 (Mi, 06 Dez 2006) | 1 line
added the export and import of the MISDN_ADDRESS_COMPLETE Variable to inidcate wether the extension is already completely dialed or if there might come additional digits by information elements. also added some docs for that.
........
r48467 | crichter | 2006-12-14 14:03:49 +0100 (Do, 14 Dez 2006) | 1 line
removed FIXUP state. added check for channel allocation conflict when we create a setup while the other site creates a setup on the same channel, besides the check we resolve this conflict.
........
r48552 | crichter | 2006-12-18 11:19:39 +0100 (Mo, 18 Dez 2006) | 1 line
when our PTP Partner sends us a SETUP with a preselected channel we just accept it, even when we're NT. added some checks for segfaults.
........
r48576 | crichter | 2006-12-19 14:08:51 +0100 (Di, 19 Dez 2006) | 1 line
when we reject a channel, because it's in use already, we shouldn't process the setup anymore. made the channel allocation a bit easier and more understandable, removed a few unused lines
........
r49135 | crichter | 2007-01-02 11:07:22 +0100 (Di, 02 Jan 2007) | 1 line
added check for channel ranges in the set/empty channel functions. set pmp_l1_check default to no. added misdn restart pid cli command. added cleaning of channel when we send a RELEASE_COMPLETE.
........
r49303 | crichter | 2007-01-03 09:24:00 +0100 (Mi, 03 Jan 2007) | 9 lines
* Added check for bridging in misdn_call to avoid setting echocancellation
when 2 mISDN channels are involved and when bridging is set. That lead
to a kernel panic before under different situations, because we switched
about 2 times between hardware bridging and echocancelation
* readded MISDN_URATE variable which got lost before, this should make app_v110
work again
* fixed typo
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-03 11:15:02 +00:00
{
2007-10-19 18:01:00 +00:00
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn restart pid " ;
e - > usage =
" Usage: misdn restart pid <pid> \n "
" Restart the given pid \n " ;
return NULL ;
case CLI_GENERATE :
return NULL ;
}
if ( a - > argc ! = 4 )
return CLI_SHOWUSAGE ;
Merged revisions 49313 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r49313 | crichter | 2007-01-03 10:06:50 +0100 (Mi, 03 Jan 2007) | 41 lines
Merged revisions 48319,48321,48467,48552,48576,49135,49303 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r48319 | crichter | 2006-12-06 15:35:25 +0100 (Mi, 06 Dez 2006) | 1 line
changed a few debugs to higher debug levels
........
r48321 | crichter | 2006-12-06 16:48:45 +0100 (Mi, 06 Dez 2006) | 1 line
added the export and import of the MISDN_ADDRESS_COMPLETE Variable to inidcate wether the extension is already completely dialed or if there might come additional digits by information elements. also added some docs for that.
........
r48467 | crichter | 2006-12-14 14:03:49 +0100 (Do, 14 Dez 2006) | 1 line
removed FIXUP state. added check for channel allocation conflict when we create a setup while the other site creates a setup on the same channel, besides the check we resolve this conflict.
........
r48552 | crichter | 2006-12-18 11:19:39 +0100 (Mo, 18 Dez 2006) | 1 line
when our PTP Partner sends us a SETUP with a preselected channel we just accept it, even when we're NT. added some checks for segfaults.
........
r48576 | crichter | 2006-12-19 14:08:51 +0100 (Di, 19 Dez 2006) | 1 line
when we reject a channel, because it's in use already, we shouldn't process the setup anymore. made the channel allocation a bit easier and more understandable, removed a few unused lines
........
r49135 | crichter | 2007-01-02 11:07:22 +0100 (Di, 02 Jan 2007) | 1 line
added check for channel ranges in the set/empty channel functions. set pmp_l1_check default to no. added misdn restart pid cli command. added cleaning of channel when we send a RELEASE_COMPLETE.
........
r49303 | crichter | 2007-01-03 09:24:00 +0100 (Mi, 03 Jan 2007) | 9 lines
* Added check for bridging in misdn_call to avoid setting echocancellation
when 2 mISDN channels are involved and when bridging is set. That lead
to a kernel panic before under different situations, because we switched
about 2 times between hardware bridging and echocancelation
* readded MISDN_URATE variable which got lost before, this should make app_v110
work again
* fixed typo
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-03 11:15:02 +00:00
2007-10-19 18:01:00 +00:00
misdn_lib_pid_restart ( atoi ( a - > argv [ 3 ] ) ) ;
Merged revisions 49313 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r49313 | crichter | 2007-01-03 10:06:50 +0100 (Mi, 03 Jan 2007) | 41 lines
Merged revisions 48319,48321,48467,48552,48576,49135,49303 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r48319 | crichter | 2006-12-06 15:35:25 +0100 (Mi, 06 Dez 2006) | 1 line
changed a few debugs to higher debug levels
........
r48321 | crichter | 2006-12-06 16:48:45 +0100 (Mi, 06 Dez 2006) | 1 line
added the export and import of the MISDN_ADDRESS_COMPLETE Variable to inidcate wether the extension is already completely dialed or if there might come additional digits by information elements. also added some docs for that.
........
r48467 | crichter | 2006-12-14 14:03:49 +0100 (Do, 14 Dez 2006) | 1 line
removed FIXUP state. added check for channel allocation conflict when we create a setup while the other site creates a setup on the same channel, besides the check we resolve this conflict.
........
r48552 | crichter | 2006-12-18 11:19:39 +0100 (Mo, 18 Dez 2006) | 1 line
when our PTP Partner sends us a SETUP with a preselected channel we just accept it, even when we're NT. added some checks for segfaults.
........
r48576 | crichter | 2006-12-19 14:08:51 +0100 (Di, 19 Dez 2006) | 1 line
when we reject a channel, because it's in use already, we shouldn't process the setup anymore. made the channel allocation a bit easier and more understandable, removed a few unused lines
........
r49135 | crichter | 2007-01-02 11:07:22 +0100 (Di, 02 Jan 2007) | 1 line
added check for channel ranges in the set/empty channel functions. set pmp_l1_check default to no. added misdn restart pid cli command. added cleaning of channel when we send a RELEASE_COMPLETE.
........
r49303 | crichter | 2007-01-03 09:24:00 +0100 (Mi, 03 Jan 2007) | 9 lines
* Added check for bridging in misdn_call to avoid setting echocancellation
when 2 mISDN channels are involved and when bridging is set. That lead
to a kernel panic before under different situations, because we switched
about 2 times between hardware bridging and echocancelation
* readded MISDN_URATE variable which got lost before, this should make app_v110
work again
* fixed typo
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-03 11:15:02 +00:00
2007-10-19 18:01:00 +00:00
return CLI_SUCCESS ;
Merged revisions 49313 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r49313 | crichter | 2007-01-03 10:06:50 +0100 (Mi, 03 Jan 2007) | 41 lines
Merged revisions 48319,48321,48467,48552,48576,49135,49303 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r48319 | crichter | 2006-12-06 15:35:25 +0100 (Mi, 06 Dez 2006) | 1 line
changed a few debugs to higher debug levels
........
r48321 | crichter | 2006-12-06 16:48:45 +0100 (Mi, 06 Dez 2006) | 1 line
added the export and import of the MISDN_ADDRESS_COMPLETE Variable to inidcate wether the extension is already completely dialed or if there might come additional digits by information elements. also added some docs for that.
........
r48467 | crichter | 2006-12-14 14:03:49 +0100 (Do, 14 Dez 2006) | 1 line
removed FIXUP state. added check for channel allocation conflict when we create a setup while the other site creates a setup on the same channel, besides the check we resolve this conflict.
........
r48552 | crichter | 2006-12-18 11:19:39 +0100 (Mo, 18 Dez 2006) | 1 line
when our PTP Partner sends us a SETUP with a preselected channel we just accept it, even when we're NT. added some checks for segfaults.
........
r48576 | crichter | 2006-12-19 14:08:51 +0100 (Di, 19 Dez 2006) | 1 line
when we reject a channel, because it's in use already, we shouldn't process the setup anymore. made the channel allocation a bit easier and more understandable, removed a few unused lines
........
r49135 | crichter | 2007-01-02 11:07:22 +0100 (Di, 02 Jan 2007) | 1 line
added check for channel ranges in the set/empty channel functions. set pmp_l1_check default to no. added misdn restart pid cli command. added cleaning of channel when we send a RELEASE_COMPLETE.
........
r49303 | crichter | 2007-01-03 09:24:00 +0100 (Mi, 03 Jan 2007) | 9 lines
* Added check for bridging in misdn_call to avoid setting echocancellation
when 2 mISDN channels are involved and when bridging is set. That lead
to a kernel panic before under different situations, because we switched
about 2 times between hardware bridging and echocancelation
* readded MISDN_URATE variable which got lost before, this should make app_v110
work again
* fixed typo
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-03 11:15:02 +00:00
}
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_port_up ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2005-10-31 22:51:12 +00:00
{
2007-10-19 18:01:00 +00:00
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn port up " ;
e - > usage =
" Usage: misdn port up <port> \n "
" Try to establish L1 on the given port. \n " ;
return NULL ;
case CLI_GENERATE :
return NULL ;
}
if ( a - > argc ! = 4 )
return CLI_SHOWUSAGE ;
misdn_lib_get_port_up ( atoi ( a - > argv [ 3 ] ) ) ;
return CLI_SUCCESS ;
2005-10-31 22:51:12 +00:00
}
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_port_down ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2006-03-07 11:16:56 +00:00
{
2007-10-19 18:01:00 +00:00
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn port down " ;
e - > usage =
" Usage: misdn port down <port> \n "
" Try to deacivate the L1 on the given port. \n " ;
return NULL ;
case CLI_GENERATE :
return NULL ;
}
if ( a - > argc ! = 4 )
return CLI_SHOWUSAGE ;
misdn_lib_get_port_down ( atoi ( a - > argv [ 3 ] ) ) ;
return CLI_SUCCESS ;
2006-03-07 11:16:56 +00:00
}
2007-10-19 18:01:00 +00:00
static inline void show_config_description ( int fd , enum misdn_cfg_elements elem )
2006-07-03 16:41:43 +00:00
{
char section [ BUFFERSIZE ] ;
char name [ BUFFERSIZE ] ;
char desc [ BUFFERSIZE ] ;
char def [ BUFFERSIZE ] ;
char tmp [ BUFFERSIZE ] ;
misdn_cfg_get_name ( elem , tmp , sizeof ( tmp ) ) ;
term_color ( name , tmp , COLOR_BRWHITE , 0 , sizeof ( tmp ) ) ;
misdn_cfg_get_desc ( elem , desc , sizeof ( desc ) , def , sizeof ( def ) ) ;
if ( elem < MISDN_CFG_LAST )
term_color ( section , " PORTS SECTION " , COLOR_YELLOW , 0 , sizeof ( section ) ) ;
else
term_color ( section , " GENERAL SECTION " , COLOR_YELLOW , 0 , sizeof ( section ) ) ;
if ( * def )
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 ) ;
2007-10-19 18:01:00 +00:00
return ;
2006-07-03 16:41:43 +00:00
}
2005-10-31 22:51:12 +00:00
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_show_config ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2005-10-31 22:51:12 +00:00
{
char buffer [ BUFFERSIZE ] ;
enum misdn_cfg_elements elem ;
int linebreak ;
int onlyport = - 1 ;
2006-07-03 16:41:43 +00:00
int ok = 0 ;
2007-10-19 18:01:00 +00:00
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn show config " ;
e - > usage =
" Usage: misdn show config [<port> | description <config element> | descriptions [general|ports]] \n "
" Use 0 for <port> to only print the general config. \n " ;
return NULL ;
case CLI_GENERATE :
return complete_show_config ( a ) ;
}
if ( a - > argc > = 4 ) {
if ( ! strcmp ( a - > argv [ 3 ] , " description " ) ) {
if ( a - > argc = = 5 ) {
enum misdn_cfg_elements elem = misdn_cfg_get_elem ( a - > argv [ 4 ] ) ;
2006-07-03 16:41:43 +00:00
if ( elem = = MISDN_CFG_FIRST )
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " Unknown element: %s \n " , a - > argv [ 4 ] ) ;
2006-07-03 16:41:43 +00:00
else
2007-10-19 18:01:00 +00:00
show_config_description ( a - > fd , elem ) ;
return CLI_SUCCESS ;
2006-07-03 16:41:43 +00:00
}
2007-10-19 18:01:00 +00:00
return CLI_SHOWUSAGE ;
} else if ( ! strcmp ( a - > argv [ 3 ] , " descriptions " ) ) {
if ( ( a - > argc = = 4 ) | | ( ( a - > argc = = 5 ) & & ! strcmp ( a - > argv [ 4 ] , " general " ) ) ) {
2006-07-03 16:41:43 +00:00
for ( elem = MISDN_GEN_FIRST + 1 ; elem < MISDN_GEN_LAST ; + + elem ) {
2007-10-19 18:01:00 +00:00
show_config_description ( a - > fd , elem ) ;
ast_cli ( a - > fd , " \n " ) ;
2006-07-03 16:41:43 +00:00
}
ok = 1 ;
}
2007-10-19 18:01:00 +00:00
if ( ( a - > argc = = 4 ) | | ( ( a - > argc = = 5 ) & & ! strcmp ( a - > argv [ 4 ] , " ports " ) ) ) {
2006-07-11 19:30:35 +00:00
for ( elem = MISDN_CFG_FIRST + 1 ; elem < MISDN_CFG_LAST - 1 /* the ptp hack, remove the -1 when ptp is gone */ ; + + elem ) {
2007-10-19 18:01:00 +00:00
show_config_description ( a - > fd , elem ) ;
ast_cli ( a - > fd , " \n " ) ;
2006-07-03 16:41:43 +00:00
}
ok = 1 ;
}
2007-10-19 18:01:00 +00:00
return ok ? CLI_SUCCESS : CLI_SHOWUSAGE ;
} else if ( ! sscanf ( a - > argv [ 3 ] , " %d " , & onlyport ) | | onlyport < 0 ) {
ast_cli ( a - > fd , " Unknown option: %s \n " , a - > argv [ 3 ] ) ;
return CLI_SHOWUSAGE ;
2005-10-31 22:51:12 +00:00
}
2007-10-19 18:01:00 +00:00
} else if ( a - > argc = = 3 | | onlyport = = 0 ) {
ast_cli ( a - > fd , " mISDN General-Config: \n " ) ;
2005-10-31 22:51:12 +00:00
for ( elem = MISDN_GEN_FIRST + 1 , linebreak = 1 ; elem < MISDN_GEN_LAST ; elem + + , linebreak + + ) {
2007-06-06 21:20:11 +00:00
misdn_cfg_get_config_string ( 0 , elem , buffer , sizeof ( buffer ) ) ;
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " %-36s%s " , buffer , ! ( linebreak % 2 ) ? " \n " : " " ) ;
2005-10-31 22:51:12 +00:00
}
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " \n " ) ;
2005-10-31 22:51:12 +00:00
}
if ( onlyport < 0 ) {
int port = misdn_cfg_get_next_port ( 0 ) ;
for ( ; port > 0 ; port = misdn_cfg_get_next_port ( port ) ) {
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " \n [PORT %d] \n " , port ) ;
2005-10-31 22:51:12 +00:00
for ( elem = MISDN_CFG_FIRST + 1 , linebreak = 1 ; elem < MISDN_CFG_LAST ; elem + + , linebreak + + ) {
2007-06-06 21:20:11 +00:00
misdn_cfg_get_config_string ( port , elem , buffer , sizeof ( buffer ) ) ;
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " %-36s%s " , buffer , ! ( linebreak % 2 ) ? " \n " : " " ) ;
2005-10-31 22:51:12 +00:00
}
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " \n " ) ;
2005-10-31 22:51:12 +00:00
}
}
if ( onlyport > 0 ) {
if ( misdn_cfg_is_port_valid ( onlyport ) ) {
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " [PORT %d] \n " , onlyport ) ;
2005-10-31 22:51:12 +00:00
for ( elem = MISDN_CFG_FIRST + 1 , linebreak = 1 ; elem < MISDN_CFG_LAST ; elem + + , linebreak + + ) {
2007-06-06 21:20:11 +00:00
misdn_cfg_get_config_string ( onlyport , elem , buffer , sizeof ( buffer ) ) ;
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " %-36s%s " , buffer , ! ( linebreak % 2 ) ? " \n " : " " ) ;
2005-10-31 22:51:12 +00:00
}
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " \n " ) ;
2005-10-31 22:51:12 +00:00
} else {
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " Port %d is not active! \n " , onlyport ) ;
2005-10-31 22:51:12 +00:00
}
}
2007-10-19 18:01:00 +00:00
return CLI_SUCCESS ;
2005-10-31 22:51:12 +00:00
}
struct state_struct {
enum misdn_chan_state state ;
2007-06-06 21:20:11 +00:00
char txt [ 255 ] ;
} ;
2005-10-31 22:51:12 +00:00
2005-12-09 11:01:18 +00:00
static struct state_struct state_array [ ] = {
2005-10-31 22:51:12 +00:00
{ MISDN_NOTHING , " NOTHING " } , /* at beginning */
{ MISDN_WAITING4DIGS , " WAITING4DIGS " } , /* when waiting for infos */
{ MISDN_EXTCANTMATCH , " EXTCANTMATCH " } , /* when asterisk couldnt match our ext */
2007-05-18 09:47:19 +00:00
{ MISDN_INCOMING_SETUP , " INCOMING SETUP " } , /* when pbx_start */
2005-10-31 22:51:12 +00:00
{ MISDN_DIALING , " DIALING " } , /* when pbx_start */
{ MISDN_PROGRESS , " PROGRESS " } , /* when pbx_start */
2006-06-26 17:37:11 +00:00
{ MISDN_PROCEEDING , " PROCEEDING " } , /* when pbx_start */
2005-10-31 22:51:12 +00:00
{ MISDN_CALLING , " CALLING " } , /* when misdn_call is called */
2006-06-26 17:37:11 +00:00
{ MISDN_CALLING_ACKNOWLEDGE , " CALLING_ACKNOWLEDGE " } , /* when misdn_call is called */
2005-10-31 22:51:12 +00:00
{ MISDN_ALERTING , " ALERTING " } , /* when Alerting */
{ MISDN_BUSY , " BUSY " } , /* when BUSY */
{ MISDN_CONNECTED , " CONNECTED " } , /* when connected */
2006-08-03 16:38:00 +00:00
{ MISDN_PRECONNECTED , " PRECONNECTED " } , /* when connected */
2006-06-21 15:21:46 +00:00
{ MISDN_DISCONNECTED , " DISCONNECTED " } , /* when connected */
{ MISDN_RELEASED , " RELEASED " } , /* when connected */
2005-10-31 22:51:12 +00:00
{ MISDN_BRIDGED , " BRIDGED " } , /* when bridged */
{ MISDN_CLEANING , " CLEANING " } , /* when hangup from * but we were connected before */
{ MISDN_HUNGUP_FROM_MISDN , " HUNGUP_FROM_MISDN " } , /* when DISCONNECT/RELEASE/REL_COMP cam from misdn */
{ MISDN_HOLDED , " HOLDED " } , /* when DISCONNECT/RELEASE/REL_COMP cam from misdn */
{ MISDN_HOLD_DISCONNECT , " HOLD_DISCONNECT " } , /* when DISCONNECT/RELEASE/REL_COMP cam from misdn */
{ MISDN_HUNGUP_FROM_AST , " HUNGUP_FROM_AST " } /* when DISCONNECT/RELEASE/REL_COMP came out of */
/* misdn_hangup */
} ;
2007-06-06 21:20:11 +00:00
static const char * misdn_get_ch_state ( struct chan_list * p )
2005-10-31 22:51:12 +00:00
{
int i ;
2006-06-26 17:37:11 +00:00
static char state [ 8 ] ;
2005-10-31 22:51:12 +00:00
if ( ! p ) return NULL ;
2007-06-06 21:20:11 +00:00
for ( i = 0 ; i < sizeof ( state_array ) / sizeof ( struct state_struct ) ; i + + ) {
if ( state_array [ i ] . state = = p - > state )
return state_array [ i ] . txt ;
2005-10-31 22:51:12 +00:00
}
2006-06-26 17:37:11 +00:00
2007-06-06 21:20:11 +00:00
snprintf ( state , sizeof ( state ) , " %d " , p - > state ) ;
2006-06-26 17:37:11 +00:00
return state ;
2005-10-31 22:51:12 +00:00
}
2006-02-10 14:17:28 +00:00
2006-04-24 17:11:45 +00:00
static void reload_config ( void )
2005-10-31 22:51:12 +00:00
{
int i , cfg_debug ;
2006-10-22 21:57:11 +00:00
if ( ! g_config_initialized ) {
ast_log ( LOG_WARNING , " chan_misdn is not initialized properly, still reloading ? \n " ) ;
return ;
}
2005-10-31 22:51:12 +00:00
free_robin_list ( ) ;
misdn_cfg_reload ( ) ;
2006-02-02 21:15:34 +00:00
misdn_cfg_update_ptp ( ) ;
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( 0 , MISDN_GEN_TRACEFILE , global_tracefile , sizeof ( global_tracefile ) ) ;
misdn_cfg_get ( 0 , MISDN_GEN_DEBUG , & cfg_debug , sizeof ( cfg_debug ) ) ;
2006-02-10 14:17:28 +00:00
2005-10-31 22:51:12 +00:00
for ( i = 0 ; i < = max_ports ; i + + ) {
misdn_debug [ i ] = cfg_debug ;
misdn_debug_only [ i ] = 0 ;
}
2006-02-10 14:17:28 +00:00
}
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_reload ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2006-02-10 14:17:28 +00:00
{
2007-10-19 18:01:00 +00:00
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn reload " ;
e - > usage =
" Usage: misdn reload \n "
" Reload internal mISDN config, read from the config \n "
" file. \n " ;
return NULL ;
case CLI_GENERATE :
return NULL ;
}
if ( a - > argc ! = 2 )
return CLI_SHOWUSAGE ;
ast_cli ( a - > fd , " Reloading mISDN configuration \n " ) ;
2006-02-10 14:17:28 +00:00
reload_config ( ) ;
2007-10-19 18:01:00 +00:00
return CLI_SUCCESS ;
2005-10-31 22:51:12 +00:00
}
2007-06-06 21:20:11 +00:00
static void print_bc_info ( int fd , struct chan_list * help , struct misdn_bchannel * bc )
2005-10-31 22:51:12 +00:00
{
2007-06-06 21:20:11 +00:00
struct ast_channel * ast = help - > ast ;
2005-10-31 22:51:12 +00:00
ast_cli ( fd ,
2006-03-09 18:01:27 +00:00
" * Pid:%d Prt:%d Ch:%d Mode:%s Org:%s dad:%s oad:%s rad:%s ctx:%s state:%s \n " ,
2005-12-09 11:01:18 +00:00
2005-11-01 22:04:14 +00:00
bc - > pid , bc - > port , bc - > channel ,
2007-06-06 21:20:11 +00:00
bc - > nt ? " NT " : " TE " ,
help - > originator = = ORG_AST ? " * " : " I " ,
ast ? ast - > exten : NULL ,
ast ? ast - > cid . cid_num : NULL ,
2006-03-09 18:01:27 +00:00
bc - > rad ,
2007-06-06 21:20:11 +00:00
ast ? ast - > context : NULL ,
2005-10-31 22:51:12 +00:00
misdn_get_ch_state ( help )
) ;
2005-11-01 22:04:14 +00:00
if ( misdn_debug [ bc - > port ] > 0 )
2005-10-31 22:51:12 +00:00
ast_cli ( fd ,
" --> astname: %s \n "
" --> ch_l3id: %x \n "
" --> ch_addr: %x \n "
" --> bc_addr: %x \n "
" --> bc_l3id: %x \n "
" --> display: %s \n "
" --> activated: %d \n "
2006-04-03 19:17:59 +00:00
" --> state: %s \n "
2005-10-31 22:51:12 +00:00
" --> capability: %s \n "
2007-03-26 15:59:56 +00:00
# ifdef MISDN_1_2
" --> pipeline: %s \n "
# else
2005-10-31 22:51:12 +00:00
" --> echo_cancel: %d \n "
2007-03-26 15:59:56 +00:00
# endif
2005-10-31 22:51:12 +00:00
" --> notone : rx %d tx:%d \n "
2006-10-11 08:23:16 +00:00
" --> bc_hold: %d \n " ,
2005-10-31 22:51:12 +00:00
help - > ast - > name ,
help - > l3id ,
help - > addr ,
bc - > addr ,
2007-06-06 21:20:11 +00:00
bc ? bc - > l3_id : - 1 ,
2005-10-31 22:51:12 +00:00
bc - > display ,
bc - > active ,
2006-04-03 19:17:59 +00:00
bc_state2str ( bc - > bc_state ) ,
2005-10-31 22:51:12 +00:00
bearer2str ( bc - > capability ) ,
2007-03-26 15:59:56 +00:00
# ifdef MISDN_1_2
bc - > pipeline ,
# else
bc - > ec_enable ,
# endif
2006-08-08 09:19:06 +00:00
2007-06-06 21:20:11 +00:00
help - > norxtone , help - > notxtone ,
2006-10-11 08:23:16 +00:00
bc - > holded
2005-10-31 22:51:12 +00:00
) ;
2007-06-06 21:20:11 +00:00
2005-10-31 22:51:12 +00:00
}
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_show_channels ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2005-10-31 22:51:12 +00:00
{
2007-10-19 18:01:00 +00:00
struct chan_list * help = NULL ;
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn show channels " ;
e - > usage =
" Usage: misdn show channels \n "
" Show the internal mISDN channel list \n " ;
return NULL ;
case CLI_GENERATE :
return NULL ;
}
if ( a - > argc ! = 3 )
return CLI_SHOWUSAGE ;
help = cl_te ;
2005-10-31 22:51:12 +00:00
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " Channel List: %p \n " , cl_te ) ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
for ( ; help ; help = help - > next ) {
struct misdn_bchannel * bc = help - > bc ;
struct ast_channel * ast = help - > ast ;
if ( misdn_debug [ 0 ] > 2 )
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " Bc:%p Ast:%p \n " , bc , ast ) ;
2005-10-31 22:51:12 +00:00
if ( bc ) {
2007-10-19 18:01:00 +00:00
print_bc_info ( a - > fd , help , bc ) ;
2005-10-31 22:51:12 +00:00
} else {
2006-10-11 08:23:16 +00:00
if ( help - > state = = MISDN_HOLDED ) {
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " ITS A HOLDED BC: \n " ) ;
ast_cli ( a - > fd , " --> l3_id: %x \n "
2006-10-11 08:23:16 +00:00
" --> dad:%s oad:%s \n "
" --> hold_port: %d \n "
2007-06-06 21:20:11 +00:00
" --> hold_channel: %d \n " ,
help - > l3id ,
ast - > exten ,
ast - > cid . cid_num ,
help - > hold_info . port ,
help - > hold_info . channel
2006-10-11 08:23:16 +00:00
) ;
} else {
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " * Channel in unknown STATE !!! Exten:%s, Callerid:%s \n " , ast - > exten , ast - > cid . cid_num ) ;
2006-10-11 08:23:16 +00:00
}
2005-10-31 22:51:12 +00:00
}
}
2007-06-06 21:20:11 +00:00
2007-06-25 09:46:18 +00:00
misdn_dump_chanlist ( ) ;
2007-10-19 18:01:00 +00:00
return CLI_SUCCESS ;
2005-10-31 22:51:12 +00:00
}
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_show_channel ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2005-10-31 22:51:12 +00:00
{
2007-10-19 18:01:00 +00:00
struct chan_list * help = NULL ;
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn show channel " ;
e - > usage =
" Usage: misdn show channel <channel> \n "
" Show an internal mISDN channel \n . " ;
return NULL ;
case CLI_GENERATE :
return complete_ch ( a ) ;
}
if ( a - > argc ! = 4 )
return CLI_SHOWUSAGE ;
help = cl_te ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
for ( ; help ; help = help - > next ) {
struct misdn_bchannel * bc = help - > bc ;
struct ast_channel * ast = help - > ast ;
2005-10-31 22:51:12 +00:00
if ( bc & & ast ) {
2007-10-19 18:01:00 +00:00
if ( ! strcasecmp ( ast - > name , a - > argv [ 3 ] ) ) {
print_bc_info ( a - > fd , help , bc ) ;
2005-10-31 22:51:12 +00:00
break ;
}
}
}
2007-10-19 18:01:00 +00:00
return CLI_SUCCESS ;
2005-10-31 22:51:12 +00:00
}
2005-11-01 22:04:14 +00:00
ast_mutex_t lock ;
2007-06-06 21:20:11 +00:00
int MAXTICS = 8 ;
2005-10-31 22:51:12 +00:00
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_set_tics ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2005-10-31 22:51:12 +00:00
{
2007-10-19 18:01:00 +00:00
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn set tics " ;
e - > usage =
" Usage: misdn set tics <value> \n " ;
return NULL ;
case CLI_GENERATE :
return NULL ;
}
if ( a - > argc ! = 4 )
return CLI_SHOWUSAGE ;
MAXTICS = atoi ( a - > argv [ 3 ] ) ;
return CLI_SUCCESS ;
2005-10-31 22:51:12 +00:00
}
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_show_stacks ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2005-10-31 22:51:12 +00:00
{
2005-11-01 22:04:14 +00:00
int port ;
2006-04-29 22:56:00 +00:00
2007-10-19 18:01:00 +00:00
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn show stacks " ;
e - > usage =
" Usage: misdn show stacks \n "
" Show internal mISDN stack_list. \n " ;
return NULL ;
case CLI_GENERATE :
return NULL ;
}
2005-12-09 11:01:18 +00:00
2007-10-19 18:01:00 +00:00
if ( a - > argc ! = 3 )
return CLI_SHOWUSAGE ;
ast_cli ( a - > fd , " BEGIN STACK_LIST: \n " ) ;
2007-06-06 21:20:11 +00:00
for ( port = misdn_cfg_get_next_port ( 0 ) ; port > 0 ;
port = misdn_cfg_get_next_port ( port ) ) {
2005-11-01 22:04:14 +00:00
char buf [ 128 ] ;
2007-06-06 21:20:11 +00:00
get_show_stack_details ( port , buf ) ;
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " %s Debug:%d%s \n " , buf , misdn_debug [ port ] , misdn_debug_only [ port ] ? " (only) " : " " ) ;
2005-10-31 22:51:12 +00:00
}
2007-06-06 21:20:11 +00:00
2007-10-19 18:01:00 +00:00
return CLI_SUCCESS ;
2005-10-31 22:51:12 +00:00
}
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_show_ports_stats ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2006-05-22 15:02:03 +00:00
{
int port ;
2007-10-19 18:01:00 +00:00
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn show ports stats " ;
e - > usage =
" Usage: misdn show ports stats \n "
" Show mISDNs channel's call statistics per port. \n " ;
return NULL ;
case CLI_GENERATE :
return NULL ;
}
if ( a - > argc ! = 4 )
return CLI_SHOWUSAGE ;
ast_cli ( a - > fd , " Port \t in_calls \t out_calls \n " ) ;
2007-06-06 21:20:11 +00:00
for ( port = misdn_cfg_get_next_port ( 0 ) ; port > 0 ;
port = misdn_cfg_get_next_port ( port ) ) {
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " %d \t %d \t \t %d \n " , port , misdn_in_calls [ port ] , misdn_out_calls [ port ] ) ;
2006-05-22 15:02:03 +00:00
}
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " \n " ) ;
2006-05-22 15:02:03 +00:00
2007-10-19 18:01:00 +00:00
return CLI_SUCCESS ;
2006-05-22 15:02:03 +00:00
}
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_show_port ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2005-10-31 22:51:12 +00:00
{
int port ;
2007-06-06 21:20:11 +00:00
char buf [ 128 ] ;
2005-10-31 22:51:12 +00:00
2007-10-19 18:01:00 +00:00
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn show port " ;
e - > usage =
" Usage: misdn show port <port> \n "
" Show detailed information for given port. \n " ;
return NULL ;
case CLI_GENERATE :
return NULL ;
}
if ( a - > argc ! = 4 )
return CLI_SHOWUSAGE ;
port = atoi ( a - > argv [ 3 ] ) ;
ast_cli ( a - > fd , " BEGIN STACK_LIST: \n " ) ;
2007-06-06 21:20:11 +00:00
get_show_stack_details ( port , buf ) ;
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " %s Debug:%d%s \n " , buf , misdn_debug [ port ] , misdn_debug_only [ port ] ? " (only) " : " " ) ;
2005-11-01 22:04:14 +00:00
2007-10-19 18:01:00 +00:00
return CLI_SUCCESS ;
2005-10-31 22:51:12 +00:00
}
2007-10-22 10:04:04 +00:00
static char * handle_cli_misdn_send_facility ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2005-10-31 22:51:12 +00:00
{
char * channame ;
2007-06-06 21:20:11 +00:00
char * nr ;
struct chan_list * tmp ;
2007-10-22 10:04:04 +00:00
int port ;
char * served_nr ;
struct misdn_bchannel dummy , * bc = & dummy ;
switch ( cmd ) {
2007-10-19 18:01:00 +00:00
case CLI_INIT :
2007-10-22 10:04:04 +00:00
e - > command = " misdn send facility " ;
e - > usage = " Usage: misdn send facility <type> <channel|port> \" <args> \" \n "
" \t type is one of: \n "
" \t - calldeflect \n "
" \t - CFActivate \n "
" \t - CFDeactivate \n " ;
2007-10-19 18:01:00 +00:00
return NULL ;
case CLI_GENERATE :
return complete_ch ( a ) ;
}
2007-10-22 10:04:04 +00:00
if ( a - > argc < 5 )
2007-10-19 18:01:00 +00:00
return CLI_SHOWUSAGE ;
2007-10-22 10:04:04 +00:00
if ( strstr ( a - > argv [ 3 ] , " calldeflect " ) ) {
if ( a - > argc < 6 ) {
ast_verbose ( " calldeflect requires 1 arg: ToNumber \n \n " ) ;
return 0 ;
}
channame = a - > argv [ 4 ] ;
nr = a - > argv [ 5 ] ;
ast_verbose ( " Sending Calldeflection (%s) to %s \n " , nr , channame ) ;
tmp = get_chan_by_ast_name ( channame ) ;
if ( ! tmp ) {
ast_verbose ( " Sending CD with nr %s to %s failed: Channel does not exist. \n " , nr , channame ) ;
return 0 ;
}
2007-10-19 18:01:00 +00:00
2007-10-22 10:04:04 +00:00
if ( strlen ( nr ) > = 15 ) {
ast_verbose ( " Sending CD with nr %s to %s failed: Number too long (up to 15 digits are allowed). \n " , nr , channame ) ;
return 0 ;
}
tmp - > bc - > fac_out . Function = Fac_CD ;
ast_copy_string ( ( char * ) tmp - > bc - > fac_out . u . CDeflection . DeflectedToNumber , nr , sizeof ( tmp - > bc - > fac_out . u . CDeflection . DeflectedToNumber ) ) ;
misdn_lib_send_event ( tmp - > bc , EVENT_FACILITY ) ;
} else if ( strstr ( a - > argv [ 3 ] , " CFActivate " ) ) {
if ( a - > argc < 7 ) {
ast_verbose ( " CFActivate requires 2 args: 1.FromNumber, 2.ToNumber \n \n " ) ;
return 0 ;
}
port = atoi ( a - > argv [ 4 ] ) ;
served_nr = a - > argv [ 5 ] ;
nr = a - > argv [ 6 ] ;
2007-10-19 18:01:00 +00:00
2007-10-22 10:04:04 +00:00
misdn_make_dummy ( bc , port , 0 , misdn_lib_port_is_nt ( port ) , 0 ) ;
2007-06-06 21:20:11 +00:00
2007-10-22 10:04:04 +00:00
ast_verbose ( " Sending CFActivate Port:(%d) FromNr. (%s) to Nr. (%s) \n " , port , served_nr , nr ) ;
bc - > fac_out . Function = Fac_CFActivate ;
bc - > fac_out . u . CFActivate . BasicService = 0 ; //All Services
bc - > fac_out . u . CFActivate . Procedure = 0 ; //Unconditional
ast_copy_string ( ( char * ) bc - > fac_out . u . CFActivate . ServedUserNumber , served_nr , sizeof ( bc - > fac_out . u . CFActivate . ServedUserNumber ) ) ;
ast_copy_string ( ( char * ) bc - > fac_out . u . CFActivate . ForwardedToNumber , nr , sizeof ( bc - > fac_out . u . CFActivate . ForwardedToNumber ) ) ;
misdn_lib_send_event ( bc , EVENT_FACILITY ) ;
} else if ( strstr ( a - > argv [ 3 ] , " CFDeactivate " ) ) {
if ( a - > argc < 6 ) {
ast_verbose ( " CFActivate requires 1 arg: FromNumber \n \n " ) ;
return 0 ;
}
port = atoi ( a - > argv [ 4 ] ) ;
served_nr = a - > argv [ 5 ] ;
misdn_make_dummy ( bc , port , 0 , misdn_lib_port_is_nt ( port ) , 0 ) ;
ast_verbose ( " Sending CFDeactivate Port:(%d) FromNr. (%s) \n " , port , served_nr ) ;
bc - > fac_out . Function = Fac_CFDeactivate ;
bc - > fac_out . u . CFDeactivate . BasicService = 0 ; //All Services
bc - > fac_out . u . CFDeactivate . Procedure = 0 ; //Unconditional
ast_copy_string ( ( char * ) bc - > fac_out . u . CFActivate . ServedUserNumber , served_nr , sizeof ( bc - > fac_out . u . CFActivate . ServedUserNumber ) ) ;
misdn_lib_send_event ( bc , EVENT_FACILITY ) ;
2007-06-06 21:20:11 +00:00
}
2007-10-19 18:01:00 +00:00
return CLI_SUCCESS ;
2005-10-31 22:51:12 +00:00
}
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_send_restart ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2007-06-11 11:40:21 +00:00
{
2007-10-19 18:01:00 +00:00
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn send restart " ;
e - > usage =
" Usage: misdn send restart [port [channel]] \n "
" Send a restart for every bchannel on the given port. \n " ;
return NULL ;
case CLI_GENERATE :
return NULL ;
}
2007-06-11 11:40:21 +00:00
2007-10-19 18:01:00 +00:00
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 ) ;
return CLI_SUCCESS ;
2007-06-11 11:40:21 +00:00
}
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_send_digit ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2005-10-31 22:51:12 +00:00
{
char * channame ;
char * msg ;
2007-06-06 21:20:11 +00:00
struct chan_list * tmp ;
int i , msglen ;
2007-10-19 18:01:00 +00:00
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn send digit " ;
e - > usage =
" Usage: misdn send digit <channel> \" <msg> \" \n "
" Send <digit> to <channel> as DTMF Tone \n "
" when channel is a mISDN channel \n " ;
return NULL ;
case CLI_GENERATE :
return complete_ch ( a ) ;
}
if ( a - > argc ! = 5 )
return CLI_SHOWUSAGE ;
2007-06-06 21:20:11 +00:00
2007-10-19 18:01:00 +00:00
channame = a - > argv [ 3 ] ;
msg = a - > argv [ 4 ] ;
2007-06-06 21:20:11 +00:00
msglen = strlen ( msg ) ;
2005-10-31 22:51:12 +00:00
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " Sending %s to %s \n " , msg , channame ) ;
2007-06-06 21:20:11 +00:00
tmp = get_chan_by_ast_name ( channame ) ;
if ( ! tmp ) {
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " Sending %s to %s failed Channel does not exist \n " , msg , channame ) ;
return CLI_SUCCESS ;
2007-06-06 21:20:11 +00:00
}
2005-10-31 22:51:12 +00:00
# if 1
2007-06-06 21:20:11 +00:00
for ( i = 0 ; i < msglen ; i + + ) {
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " Sending: %c \n " , msg [ i ] ) ;
2007-06-06 21:20:11 +00:00
send_digit_to_chan ( tmp , msg [ i ] ) ;
/* res = ast_safe_sleep(tmp->ast, 250); */
usleep ( 250000 ) ;
/* res = ast_waitfor(tmp->ast,100); */
}
2005-10-31 22:51:12 +00:00
# else
2007-06-06 21:20:11 +00:00
ast_dtmf_stream ( tmp - > ast , NULL , msg , 250 ) ;
2005-10-31 22:51:12 +00:00
# endif
2007-06-06 21:20:11 +00:00
2007-10-19 18:01:00 +00:00
return CLI_SUCCESS ;
2005-10-31 22:51:12 +00:00
}
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_toggle_echocancel ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2005-10-31 22:51:12 +00:00
{
2007-06-06 21:20:11 +00:00
char * channame ;
struct chan_list * tmp ;
2005-10-31 22:51:12 +00:00
2007-10-19 18:01:00 +00:00
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn toggle echocancel " ;
e - > usage =
" Usage: misdn toggle echocancel <channel> \n "
" Toggle EchoCancel on mISDN Channel. \n " ;
return NULL ;
case CLI_GENERATE :
return complete_ch ( a ) ;
}
if ( a - > argc ! = 4 )
return CLI_SHOWUSAGE ;
channame = a - > argv [ 3 ] ;
2005-10-31 22:51:12 +00:00
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " Toggling EchoCancel on %s \n " , channame ) ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
tmp = get_chan_by_ast_name ( channame ) ;
if ( ! tmp ) {
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " Toggling EchoCancel %s failed Channel does not exist \n " , channame ) ;
return CLI_SUCCESS ;
2007-06-06 21:20:11 +00:00
}
tmp - > toggle_ec = tmp - > toggle_ec ? 0 : 1 ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
if ( tmp - > toggle_ec ) {
2007-03-26 15:59:56 +00:00
# ifdef MISDN_1_2
2007-06-06 21:20:11 +00:00
update_pipeline_config ( tmp - > bc ) ;
2007-03-26 15:59:56 +00:00
# else
2007-06-06 21:20:11 +00:00
update_ec_config ( tmp - > bc ) ;
2007-03-26 15:59:56 +00:00
# endif
2007-06-06 21:20:11 +00:00
manager_ec_enable ( tmp - > bc ) ;
} else {
manager_ec_disable ( tmp - > bc ) ;
2005-10-31 22:51:12 +00:00
}
2007-06-06 21:20:11 +00:00
2007-10-19 18:01:00 +00:00
return CLI_SUCCESS ;
2005-10-31 22:51:12 +00:00
}
2007-10-19 18:01:00 +00:00
static char * handle_cli_misdn_send_display ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2005-10-31 22:51:12 +00:00
{
2007-10-19 18:01:00 +00:00
char * channame ;
char * msg ;
2007-06-06 21:20:11 +00:00
struct chan_list * tmp ;
2007-10-19 18:01:00 +00:00
switch ( cmd ) {
case CLI_INIT :
e - > command = " misdn send display " ;
e - > usage =
" Usage: misdn send display <channel> \" <msg> \" \n "
" Send <msg> to <channel> as Display Message \n "
" when channel is a mISDN channel \n " ;
return NULL ;
case CLI_GENERATE :
return complete_ch ( a ) ;
}
if ( a - > argc ! = 5 )
return CLI_SHOWUSAGE ;
2007-06-06 21:20:11 +00:00
2007-10-19 18:01:00 +00:00
channame = a - > argv [ 3 ] ;
msg = a - > argv [ 4 ] ;
2005-10-31 22:51:12 +00:00
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " Sending %s to %s \n " , msg , channame ) ;
2007-06-06 21:20:11 +00:00
tmp = get_chan_by_ast_name ( channame ) ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
if ( tmp & & tmp - > bc ) {
ast_copy_string ( tmp - > bc - > display , msg , sizeof ( tmp - > bc - > display ) ) ;
misdn_lib_send_event ( tmp - > bc , EVENT_INFORMATION ) ;
} else {
2007-10-19 18:01:00 +00:00
ast_cli ( a - > fd , " No such channel %s \n " , channame ) ;
return CLI_SUCCESS ;
2005-10-31 22:51:12 +00:00
}
2007-10-19 18:01:00 +00:00
return CLI_SUCCESS ;
2005-10-31 22:51:12 +00:00
}
2007-10-19 18:01:00 +00:00
static char * complete_ch ( struct ast_cli_args * a )
2005-10-31 22:51:12 +00:00
{
2007-11-27 22:42:57 +00:00
return ast_complete_channels ( a - > line , a - > word , a - > pos , a - > n , 3 ) ;
2005-10-31 22:51:12 +00:00
}
2007-10-19 18:01:00 +00:00
static char * complete_debug_port ( struct ast_cli_args * a )
2005-10-31 22:51:12 +00:00
{
2007-10-19 18:01:00 +00:00
if ( a - > n )
2005-10-31 22:51:12 +00:00
return NULL ;
2007-10-19 18:01:00 +00:00
switch ( a - > pos ) {
2007-06-06 21:20:11 +00:00
case 4 :
2007-10-19 18:01:00 +00:00
if ( a - > word [ 0 ] = = ' p ' )
2007-06-14 23:01:01 +00:00
return ast_strdup ( " port " ) ;
2007-10-19 18:01:00 +00:00
else if ( a - > word [ 0 ] = = ' o ' )
2007-06-14 23:01:01 +00:00
return ast_strdup ( " only " ) ;
2007-06-06 21:20:11 +00:00
break ;
case 6 :
2007-10-19 18:01:00 +00:00
if ( a - > word [ 0 ] = = ' o ' )
2007-06-14 23:01:01 +00:00
return ast_strdup ( " only " ) ;
2007-06-06 21:20:11 +00:00
break ;
2005-10-31 22:51:12 +00:00
}
return NULL ;
}
2007-10-19 18:01:00 +00:00
static char * complete_show_config ( struct ast_cli_args * a )
2006-07-03 16:41:43 +00:00
{
char buffer [ BUFFERSIZE ] ;
enum misdn_cfg_elements elem ;
2007-10-19 18:01:00 +00:00
int wordlen = strlen ( a - > word ) ;
2006-07-03 16:41:43 +00:00
int which = 0 ;
int port = 0 ;
2007-10-19 18:01:00 +00:00
switch ( a - > pos ) {
2007-06-06 21:20:11 +00:00
case 3 :
2007-10-19 18:01:00 +00:00
if ( ( ! strncmp ( a - > word , " description " , wordlen ) ) & & ( + + which > a - > n ) )
2007-06-14 23:01:01 +00:00
return ast_strdup ( " description " ) ;
2007-10-19 18:01:00 +00:00
if ( ( ! strncmp ( a - > word , " descriptions " , wordlen ) ) & & ( + + which > a - > n ) )
2007-06-14 23:01:01 +00:00
return ast_strdup ( " descriptions " ) ;
2007-10-19 18:01:00 +00:00
if ( ( ! strncmp ( a - > word , " 0 " , wordlen ) ) & & ( + + which > a - > n ) )
2007-06-14 23:01:01 +00:00
return ast_strdup ( " 0 " ) ;
2007-06-06 21:20:11 +00:00
while ( ( port = misdn_cfg_get_next_port ( port ) ) ! = - 1 ) {
snprintf ( buffer , sizeof ( buffer ) , " %d " , port ) ;
2007-10-19 18:01:00 +00:00
if ( ( ! strncmp ( a - > word , buffer , wordlen ) ) & & ( + + which > a - > n ) ) {
2007-06-14 23:01:01 +00:00
return ast_strdup ( buffer ) ;
2006-07-03 16:41:43 +00:00
}
2007-06-06 21:20:11 +00:00
}
break ;
2006-07-03 16:41:43 +00:00
case 4 :
2007-10-19 18:01:00 +00:00
if ( strstr ( a - > line , " description " ) ) {
2007-06-06 21:20:11 +00:00
for ( elem = MISDN_CFG_FIRST + 1 ; elem < MISDN_GEN_LAST ; + + elem ) {
if ( ( elem = = MISDN_CFG_LAST ) | | ( elem = = MISDN_GEN_FIRST ) )
continue ;
misdn_cfg_get_name ( elem , buffer , sizeof ( buffer ) ) ;
2007-10-19 18:01:00 +00:00
if ( ! wordlen | | ! strncmp ( a - > word , buffer , wordlen ) ) {
if ( + + which > a - > n )
2007-06-14 23:01:01 +00:00
return ast_strdup ( buffer ) ;
2006-07-03 16:41:43 +00:00
}
}
2007-10-19 18:01:00 +00:00
} else if ( strstr ( a - > line , " descriptions " ) ) {
if ( ( ! wordlen | | ! strncmp ( a - > word , " general " , wordlen ) ) & & ( + + which > a - > n ) )
2007-06-14 23:01:01 +00:00
return ast_strdup ( " general " ) ;
2007-10-19 18:01:00 +00:00
if ( ( ! wordlen | | ! strncmp ( a - > word , " ports " , wordlen ) ) & & ( + + which > a - > n ) )
2007-06-14 23:01:01 +00:00
return ast_strdup ( " ports " ) ;
2007-06-06 21:20:11 +00:00
}
break ;
2006-07-03 16:41:43 +00:00
}
return NULL ;
}
2006-08-16 15:03:09 +00:00
static struct ast_cli_entry chan_misdn_clis [ ] = {
2007-10-22 20:05:18 +00:00
AST_CLI_DEFINE ( handle_cli_misdn_port_block , " Block the given port " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_port_down , " Try to deacivate the L1 on the given port " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_port_unblock , " Unblock the given port " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_port_up , " Try to establish L1 on the given port " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_reload , " Reload internal mISDN config, read from the config file " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_restart_pid , " Restart the given pid " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_restart_port , " Restart the given port " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_show_channel , " Show an internal mISDN channel " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_show_channels , " Show the internal mISDN channel list " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_show_config , " Show internal mISDN config, read from the config file " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_show_port , " Show detailed information for given port " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_show_ports_stats , " Show mISDNs channel's call statistics per port " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_show_stacks , " Show internal mISDN stack_list " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_send_facility , " Sends a Facility Message to the mISDN Channel " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_send_digit , " Send DTMF digit to mISDN Channel " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_send_display , " Send Text to mISDN Channel " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_send_restart , " Send a restart for every bchannel on the given port " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_set_crypt_debug , " Set CryptDebuglevel of chan_misdn, at the moment, level={1,2} " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_set_debug , " Set Debuglevel of chan_misdn " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_set_tics , " ??? " ) ,
AST_CLI_DEFINE ( handle_cli_misdn_toggle_echocancel , " Toggle EchoCancel on mISDN Channel " ) ,
2005-10-31 22:51:12 +00:00
} ;
2007-06-06 21:20:11 +00:00
static int update_config ( struct chan_list * ch , int orig )
2006-02-02 21:15:34 +00:00
{
2007-06-06 21:20:11 +00:00
struct ast_channel * ast ;
struct misdn_bchannel * bc ;
int port , hdlc = 0 ;
int pres , screen ;
2006-02-02 21:15:34 +00:00
if ( ! ch ) {
ast_log ( LOG_WARNING , " Cannot configure without chanlist \n " ) ;
return - 1 ;
}
2007-06-06 21:20:11 +00:00
ast = ch - > ast ;
bc = ch - > bc ;
if ( ! ast | | ! bc ) {
2006-02-02 21:15:34 +00:00
ast_log ( LOG_WARNING , " Cannot configure without ast || bc \n " ) ;
return - 1 ;
}
2006-03-20 18:04:05 +00:00
2007-06-06 21:20:11 +00:00
port = bc - > port ;
chan_misdn_log ( 7 , port , " update_config: Getting Config \n " ) ;
misdn_cfg_get ( port , MISDN_CFG_HDLC , & hdlc , sizeof ( int ) ) ;
2006-03-20 18:04:05 +00:00
if ( hdlc ) {
switch ( bc - > capability ) {
case INFO_CAPABILITY_DIGITAL_UNRESTRICTED :
case INFO_CAPABILITY_DIGITAL_RESTRICTED :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , bc - > port , " --> CONF HDLC \n " ) ;
bc - > hdlc = 1 ;
2006-03-20 18:04:05 +00:00
break ;
}
}
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( port , MISDN_CFG_PRES , & pres , sizeof ( pres ) ) ;
misdn_cfg_get ( port , MISDN_CFG_SCREEN , & screen , sizeof ( screen ) ) ;
chan_misdn_log ( 2 , port , " --> pres: %d screen: %d \n " , pres , screen ) ;
2006-02-02 21:15:34 +00:00
if ( ( pres + screen ) < 0 ) {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 2 , port , " --> pres: %x \n " , ast - > cid . cid_pres ) ;
2006-02-02 21:15:34 +00:00
2007-06-06 21:20:11 +00:00
switch ( ast - > cid . cid_pres & 0x60 ) {
2006-02-02 21:15:34 +00:00
case AST_PRES_RESTRICTED :
2007-06-06 21:20:11 +00:00
bc - > pres = 1 ;
2006-02-02 21:15:34 +00:00
chan_misdn_log ( 2 , port , " --> PRES: Restricted (0x1) \n " ) ;
break ;
case AST_PRES_UNAVAILABLE :
2007-06-06 21:20:11 +00:00
bc - > pres = 2 ;
2006-02-02 21:15:34 +00:00
chan_misdn_log ( 2 , port , " --> PRES: Unavailable (0x2) \n " ) ;
break ;
default :
2007-06-06 21:20:11 +00:00
bc - > pres = 0 ;
2006-02-02 21:15:34 +00:00
chan_misdn_log ( 2 , port , " --> PRES: Allowed (0x0) \n " ) ;
}
2007-06-06 21:20:11 +00:00
switch ( ast - > cid . cid_pres & 0x3 ) {
2006-02-02 21:15:34 +00:00
case AST_PRES_USER_NUMBER_UNSCREENED :
2007-06-06 21:20:11 +00:00
bc - > screen = 0 ;
2006-02-02 21:15:34 +00:00
chan_misdn_log ( 2 , port , " --> SCREEN: Unscreened (0x0) \n " ) ;
break ;
case AST_PRES_USER_NUMBER_PASSED_SCREEN :
2007-06-06 21:20:11 +00:00
bc - > screen = 1 ;
2006-02-02 21:15:34 +00:00
chan_misdn_log ( 2 , port , " --> SCREEN: Passed Screen (0x1) \n " ) ;
break ;
case AST_PRES_USER_NUMBER_FAILED_SCREEN :
2007-06-06 21:20:11 +00:00
bc - > screen = 2 ;
2006-02-02 21:15:34 +00:00
chan_misdn_log ( 2 , port , " --> SCREEN: Failed Screen (0x2) \n " ) ;
break ;
case AST_PRES_NETWORK_NUMBER :
2007-06-06 21:20:11 +00:00
bc - > screen = 3 ;
2006-02-02 21:15:34 +00:00
chan_misdn_log ( 2 , port , " --> SCREEN: Network Nr. (0x3) \n " ) ;
break ;
default :
2007-06-06 21:20:11 +00:00
bc - > screen = 0 ;
2006-02-02 21:15:34 +00:00
chan_misdn_log ( 2 , port , " --> SCREEN: Unscreened (0x0) \n " ) ;
}
} else {
2007-06-06 21:20:11 +00:00
bc - > screen = screen ;
bc - > pres = pres ;
2006-02-02 21:15:34 +00:00
}
return 0 ;
}
2005-10-31 22:51:12 +00:00
2006-04-24 17:11:45 +00:00
static void config_jitterbuffer ( struct chan_list * ch )
2006-02-10 14:17:28 +00:00
{
2007-06-06 21:20:11 +00:00
struct misdn_bchannel * bc = ch - > bc ;
int len = ch - > jb_len , threshold = ch - > jb_upper_threshold ;
2006-02-10 14:17:28 +00:00
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 5 , bc - > port , " config_jb: Called \n " ) ;
2006-02-10 14:17:28 +00:00
2007-06-06 21:20:11 +00:00
if ( ! len ) {
chan_misdn_log ( 1 , bc - > port , " config_jb: Deactivating Jitterbuffer \n " ) ;
2006-02-10 14:17:28 +00:00
bc - > nojitter = 1 ;
} else {
2007-06-06 21:20:11 +00:00
if ( len < = 100 | | len > 8000 ) {
chan_misdn_log ( 0 , bc - > port , " config_jb: Jitterbuffer out of Bounds, setting to 1000 \n " ) ;
len = 1000 ;
2006-02-10 14:17:28 +00:00
}
2007-06-06 21:20:11 +00:00
2006-02-10 14:17:28 +00:00
if ( threshold > len ) {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 0 , bc - > port , " config_jb: Jitterbuffer Threshold > Jitterbuffer setting to Jitterbuffer -1 \n " ) ;
2006-02-10 14:17:28 +00:00
}
2007-06-06 21:20:11 +00:00
2006-02-10 14:17:28 +00:00
if ( ch - > jb ) {
2007-06-06 21:20:11 +00:00
cb_log ( 0 , bc - > port , " config_jb: We've got a Jitterbuffer Already on this port. \n " ) ;
2006-02-10 14:17:28 +00:00
misdn_jb_destroy ( ch - > jb ) ;
2007-06-06 21:20:11 +00:00
ch - > jb = NULL ;
2006-02-10 14:17:28 +00:00
}
2007-06-06 21:20:11 +00:00
2006-02-10 14:17:28 +00:00
ch - > jb = misdn_jb_init ( len , threshold ) ;
2006-04-04 19:09:26 +00:00
if ( ! ch - > jb )
2007-06-06 21:20:11 +00:00
bc - > nojitter = 1 ;
2006-02-10 14:17:28 +00:00
}
}
2006-05-16 14:34:21 +00:00
void debug_numplan ( int port , int numplan , char * type )
{
switch ( numplan ) {
case NUMPLAN_INTERNATIONAL :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 2 , port , " --> %s: International \n " , type ) ;
2006-05-16 14:34:21 +00:00
break ;
case NUMPLAN_NATIONAL :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 2 , port , " --> %s: National \n " , type ) ;
2006-05-16 14:34:21 +00:00
break ;
case NUMPLAN_SUBSCRIBER :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 2 , port , " --> %s: Subscriber \n " , type ) ;
2006-05-16 14:34:21 +00:00
break ;
case NUMPLAN_UNKNOWN :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 2 , port , " --> %s: Unknown \n " , type ) ;
2006-05-16 14:34:21 +00:00
break ;
/* Maybe we should cut off the prefix if present ? */
default :
chan_misdn_log ( 0 , port , " --> !!!! Wrong dialplan setting, please see the misdn.conf sample file \n " ) ;
break ;
}
}
2006-06-01 12:51:41 +00:00
2007-03-26 15:59:56 +00:00
# ifdef MISDN_1_2
static int update_pipeline_config ( struct misdn_bchannel * bc )
{
int ec ;
misdn_cfg_get ( bc - > port , MISDN_CFG_PIPELINE , bc - > pipeline , sizeof ( bc - > pipeline ) ) ;
if ( * bc - > pipeline )
return 0 ;
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( bc - > port , MISDN_CFG_ECHOCANCEL , & ec , sizeof ( ec ) ) ;
2007-03-26 15:59:56 +00:00
if ( ec = = 1 )
2007-10-01 15:23:19 +00:00
ast_copy_string ( bc - > pipeline , " mg2ec " , sizeof ( bc - > pipeline ) ) ;
2007-03-26 15:59:56 +00:00
else if ( ec > 1 )
2007-06-06 21:20:11 +00:00
snprintf ( bc - > pipeline , sizeof ( bc - > pipeline ) , " mg2ec(deftaps=%d) " , ec ) ;
2007-03-26 15:59:56 +00:00
return 0 ;
}
# else
2006-08-08 09:19:06 +00:00
static int update_ec_config ( struct misdn_bchannel * bc )
{
int ec ;
2007-06-06 21:20:11 +00:00
int port = bc - > port ;
misdn_cfg_get ( port , MISDN_CFG_ECHOCANCEL , & ec , sizeof ( ec ) ) ;
if ( ec = = 1 ) {
bc - > ec_enable = 1 ;
} else if ( ec > 1 ) {
bc - > ec_enable = 1 ;
bc - > ec_deftaps = ec ;
2006-08-08 09:19:06 +00:00
}
return 0 ;
}
2007-03-26 15:59:56 +00:00
# endif
2006-08-08 09:19:06 +00:00
2006-06-01 12:51:41 +00:00
2007-06-06 21:20:11 +00:00
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 ;
2005-11-15 20:20:45 +00:00
2005-12-09 11:01:18 +00:00
if ( ! ch ) {
ast_log ( LOG_WARNING , " Cannot configure without chanlist \n " ) ;
2005-10-31 22:51:12 +00:00
return - 1 ;
}
2007-06-06 21:20:11 +00:00
ast = ch - > ast ;
bc = ch - > bc ;
if ( ! ast | | ! bc ) {
2005-12-09 11:01:18 +00:00
ast_log ( LOG_WARNING , " Cannot configure without ast || bc \n " ) ;
2005-10-31 22:51:12 +00:00
return - 1 ;
}
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
port = bc - > port ;
chan_misdn_log ( 1 , port , " read_config: Getting Config \n " ) ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( port , MISDN_CFG_LANGUAGE , lang , sizeof ( lang ) ) ;
2006-02-02 18:33:23 +00:00
ast_string_field_set ( ast , language , lang ) ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( port , MISDN_CFG_MUSICCLASS , localmusicclass , sizeof ( localmusicclass ) ) ;
2006-02-02 18:33:23 +00:00
ast_string_field_set ( ast , musicclass , localmusicclass ) ;
2006-02-02 21:15:34 +00:00
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( port , MISDN_CFG_TXGAIN , & bc - > txgain , sizeof ( bc - > txgain ) ) ;
misdn_cfg_get ( port , MISDN_CFG_RXGAIN , & bc - > rxgain , sizeof ( bc - > rxgain ) ) ;
misdn_cfg_get ( port , MISDN_CFG_INCOMING_EARLY_AUDIO , & ch - > incoming_early_audio , sizeof ( ch - > incoming_early_audio ) ) ;
misdn_cfg_get ( port , MISDN_CFG_SENDDTMF , & bc - > send_dtmf , sizeof ( bc - > send_dtmf ) ) ;
2007-09-19 09:48:33 +00:00
misdn_cfg_get ( port , MISDN_CFG_ASTDTMF , & ch - > ast_dsp , sizeof ( int ) ) ;
if ( ch - > ast_dsp ) {
ch - > ignore_dtmf = 1 ;
}
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( port , MISDN_CFG_NEED_MORE_INFOS , & bc - > need_more_infos , sizeof ( bc - > need_more_infos ) ) ;
misdn_cfg_get ( port , MISDN_CFG_NTTIMEOUT , & ch - > nttimeout , sizeof ( ch - > nttimeout ) ) ;
misdn_cfg_get ( port , MISDN_CFG_NOAUTORESPOND_ON_SETUP , & ch - > noautorespond_on_setup , sizeof ( ch - > noautorespond_on_setup ) ) ;
misdn_cfg_get ( port , MISDN_CFG_FAR_ALERTING , & ch - > far_alerting , sizeof ( ch - > far_alerting ) ) ;
misdn_cfg_get ( port , MISDN_CFG_ALLOWED_BEARERS , & ch - > allowed_bearers , sizeof ( ch - > allowed_bearers ) ) ;
misdn_cfg_get ( port , MISDN_CFG_FAXDETECT , faxdetect , sizeof ( faxdetect ) ) ;
misdn_cfg_get ( port , MISDN_CFG_HDLC , & hdlc , sizeof ( hdlc ) ) ;
2006-06-01 12:51:41 +00:00
2006-03-20 18:04:05 +00:00
if ( hdlc ) {
switch ( bc - > capability ) {
case INFO_CAPABILITY_DIGITAL_UNRESTRICTED :
case INFO_CAPABILITY_DIGITAL_RESTRICTED :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , bc - > port , " --> CONF HDLC \n " ) ;
bc - > hdlc = 1 ;
2006-03-20 18:04:05 +00:00
break ;
}
}
2005-12-09 11:01:18 +00:00
/*Initialize new Jitterbuffer*/
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( port , MISDN_CFG_JITTERBUFFER , & ch - > jb_len , sizeof ( ch - > jb_len ) ) ;
misdn_cfg_get ( port , MISDN_CFG_JITTERBUFFER_UPPER_THRESHOLD , & ch - > jb_upper_threshold , sizeof ( ch - > jb_upper_threshold ) ) ;
config_jitterbuffer ( ch ) ;
misdn_cfg_get ( bc - > port , MISDN_CFG_CONTEXT , ch - > context , sizeof ( ch - > context ) ) ;
ast_copy_string ( ast - > context , ch - > context , sizeof ( ast - > context ) ) ;
2006-08-03 16:38:00 +00:00
2007-03-26 15:59:56 +00:00
# ifdef MISDN_1_2
update_pipeline_config ( bc ) ;
# else
2006-08-08 09:19:06 +00:00
update_ec_config ( bc ) ;
2007-03-26 15:59:56 +00:00
# endif
2006-08-08 09:19:06 +00:00
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( bc - > port , MISDN_CFG_EARLY_BCONNECT , & bc - > early_bconnect , sizeof ( bc - > early_bconnect ) ) ;
misdn_cfg_get ( port , MISDN_CFG_PICKUPGROUP , & pg , sizeof ( pg ) ) ;
misdn_cfg_get ( port , MISDN_CFG_CALLGROUP , & cg , sizeof ( cg ) ) ;
chan_misdn_log ( 5 , port , " --> * CallGrp:%s PickupGrp:%s \n " , ast_print_group ( buf , sizeof ( buf ) , cg ) , ast_print_group ( buf2 , sizeof ( buf2 ) , pg ) ) ;
ast - > pickupgroup = pg ;
ast - > callgroup = cg ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
if ( orig = = ORG_AST ) {
char callerid [ BUFFERSIZE + 1 ] ;
misdn_cfg_get ( port , MISDN_CFG_TE_CHOOSE_CHANNEL , & ( bc - > te_choose_channel ) , sizeof ( bc - > te_choose_channel ) ) ;
2006-08-08 18:13:40 +00:00
if ( strstr ( faxdetect , " outgoing " ) | | strstr ( faxdetect , " both " ) ) {
if ( strstr ( faxdetect , " nojump " ) )
2007-06-06 21:20:11 +00:00
ch - > faxdetect = 2 ;
2006-08-08 18:13:40 +00:00
else
2007-06-06 21:20:11 +00:00
ch - > faxdetect = 1 ;
2006-08-08 18:13:40 +00:00
}
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( port , MISDN_CFG_CALLERID , callerid , sizeof ( callerid ) ) ;
if ( ! ast_strlen_zero ( callerid ) ) {
chan_misdn_log ( 1 , port , " --> * Setting Cid to %s \n " , callerid ) ;
ast_copy_string ( bc - > oad , callerid , sizeof ( bc - > oad ) ) ;
2005-10-31 22:51:12 +00:00
}
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( port , MISDN_CFG_DIALPLAN , & bc - > dnumplan , sizeof ( bc - > dnumplan ) ) ;
misdn_cfg_get ( port , MISDN_CFG_LOCALDIALPLAN , & bc - > onumplan , sizeof ( bc - > onumplan ) ) ;
misdn_cfg_get ( port , MISDN_CFG_CPNDIALPLAN , & bc - > cpnnumplan , sizeof ( bc - > cpnnumplan ) ) ;
debug_numplan ( port , bc - > dnumplan , " TON " ) ;
debug_numplan ( port , bc - > onumplan , " LTON " ) ;
debug_numplan ( port , bc - > cpnnumplan , " CTON " ) ;
2006-07-11 19:30:35 +00:00
ch - > overlap_dial = 0 ;
2005-12-09 11:01:18 +00:00
} else { /** ORIGINATOR MISDN **/
2007-06-06 21:20:11 +00:00
char prefix [ BUFFERSIZE + 1 ] = " " ;
2006-08-08 18:13:40 +00:00
if ( strstr ( faxdetect , " incoming " ) | | strstr ( faxdetect , " both " ) ) {
if ( strstr ( faxdetect , " nojump " ) )
2007-06-06 21:20:11 +00:00
ch - > faxdetect = 2 ;
2006-08-08 18:13:40 +00:00
else
2007-06-06 21:20:11 +00:00
ch - > faxdetect = 1 ;
2006-08-08 18:13:40 +00:00
}
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( port , MISDN_CFG_CPNDIALPLAN , & bc - > cpnnumplan , sizeof ( bc - > cpnnumplan ) ) ;
debug_numplan ( port , bc - > cpnnumplan , " CTON " ) ;
switch ( bc - > onumplan ) {
2005-12-09 11:01:18 +00:00
case NUMPLAN_INTERNATIONAL :
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( bc - > port , MISDN_CFG_INTERNATPREFIX , prefix , sizeof ( prefix ) ) ;
2005-12-09 11:01:18 +00:00
break ;
2007-06-06 21:20:11 +00:00
2005-12-09 11:01:18 +00:00
case NUMPLAN_NATIONAL :
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( bc - > port , MISDN_CFG_NATPREFIX , prefix , sizeof ( prefix ) ) ;
2005-12-09 11:01:18 +00:00
break ;
default :
break ;
2005-10-31 22:51:12 +00:00
}
2007-06-06 21:20:11 +00:00
ast_copy_string ( buf , bc - > oad , sizeof ( buf ) ) ;
snprintf ( bc - > oad , sizeof ( bc - > oad ) , " %s%s " , prefix , buf ) ;
2005-12-09 11:01:18 +00:00
if ( ! ast_strlen_zero ( bc - > dad ) ) {
2007-06-06 21:20:11 +00:00
ast_copy_string ( bc - > orig_dad , bc - > dad , sizeof ( bc - > orig_dad ) ) ;
2005-10-31 22:51:12 +00:00
}
2007-06-06 21:20:11 +00:00
2005-12-09 11:01:18 +00:00
if ( ast_strlen_zero ( bc - > dad ) & & ! ast_strlen_zero ( bc - > keypad ) ) {
2007-06-06 21:20:11 +00:00
ast_copy_string ( bc - > dad , bc - > keypad , sizeof ( bc - > dad ) ) ;
2005-12-09 11:01:18 +00:00
}
2006-05-16 14:34:21 +00:00
2005-12-09 11:01:18 +00:00
prefix [ 0 ] = 0 ;
2007-06-06 21:20:11 +00:00
switch ( bc - > dnumplan ) {
2005-12-09 11:01:18 +00:00
case NUMPLAN_INTERNATIONAL :
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( bc - > port , MISDN_CFG_INTERNATPREFIX , prefix , sizeof ( prefix ) ) ;
2005-12-09 11:01:18 +00:00
break ;
2006-05-16 14:34:21 +00:00
case NUMPLAN_NATIONAL :
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( bc - > port , MISDN_CFG_NATPREFIX , prefix , sizeof ( prefix ) ) ;
2005-12-09 11:01:18 +00:00
break ;
default :
break ;
}
2007-06-06 21:20:11 +00:00
ast_copy_string ( buf , bc - > dad , sizeof ( buf ) ) ;
snprintf ( bc - > dad , sizeof ( bc - > dad ) , " %s%s " , prefix , buf ) ;
if ( strcmp ( bc - > dad , ast - > exten ) ) {
2006-02-02 21:15:34 +00:00
ast_copy_string ( ast - > exten , bc - > dad , sizeof ( ast - > exten ) ) ;
}
2007-06-06 21:20:11 +00:00
2006-05-02 14:26:40 +00:00
ast_set_callerid ( ast , bc - > oad , NULL , bc - > oad ) ;
2007-06-06 21:20:11 +00:00
2006-05-01 03:58:13 +00:00
if ( ! ast_strlen_zero ( bc - > rad ) ) {
if ( ast - > cid . cid_rdnis )
2007-06-06 21:20:11 +00:00
ast_free ( ast - > cid . cid_rdnis ) ;
2007-06-14 23:01:01 +00:00
ast - > cid . cid_rdnis = ast_strdup ( bc - > rad ) ;
2006-05-01 03:58:13 +00:00
}
2006-07-11 19:30:35 +00:00
misdn_cfg_get ( bc - > port , MISDN_CFG_OVERLAP_DIAL , & ch - > overlap_dial , sizeof ( ch - > overlap_dial ) ) ;
ast_mutex_init ( & ch - > overlap_tv_lock ) ;
2006-05-16 14:34:21 +00:00
} /* ORIG MISDN END */
2006-08-08 18:13:40 +00:00
ch - > overlap_dial_task = - 1 ;
2007-09-19 09:48:33 +00:00
if ( ch - > faxdetect | | ch - > ast_dsp ) {
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( port , MISDN_CFG_FAXDETECT_TIMEOUT , & ch - > faxdetect_timeout , sizeof ( ch - > faxdetect_timeout ) ) ;
2006-08-08 18:13:40 +00:00
if ( ! ch - > dsp )
ch - > dsp = ast_dsp_new ( ) ;
2007-09-19 09:48:33 +00:00
if ( ch - > dsp ) {
if ( ch - > faxdetect )
ast_dsp_set_features ( ch - > dsp , DSP_FEATURE_DTMF_DETECT | DSP_FEATURE_FAX_DETECT ) ;
else
ast_dsp_set_features ( ch - > dsp , DSP_FEATURE_DTMF_DETECT ) ;
}
2006-08-08 18:13:40 +00:00
if ( ! ch - > trans )
2007-06-06 21:20:11 +00:00
ch - > trans = ast_translator_build_path ( AST_FORMAT_SLINEAR , AST_FORMAT_ALAW ) ;
2006-08-08 18:13:40 +00:00
}
2006-08-16 13:19:54 +00:00
/* AOCD initialization */
bc - > AOCDtype = Fac_None ;
2005-12-09 11:01:18 +00:00
return 0 ;
}
/*****************************/
/*** AST Indications Start ***/
/*****************************/
static int misdn_call ( struct ast_channel * ast , char * dest , int timeout )
{
2007-06-06 21:20:11 +00:00
int port = 0 ;
2005-12-09 11:01:18 +00:00
int r ;
2007-06-06 21:20:11 +00:00
int exceed ;
int bridging ;
struct chan_list * ch = MISDN_ASTERISK_TECH_PVT ( ast ) ;
2005-12-09 11:01:18 +00:00
struct misdn_bchannel * newbc ;
2007-06-06 21:20:11 +00:00
char * opts = NULL , * ext , * tokb ;
char * dest_cp = ast_strdupa ( dest ) ;
2006-02-08 16:10:21 +00:00
2007-06-06 21:20:11 +00:00
ext = strtok_r ( dest_cp , " / " , & tokb ) ;
if ( ext ) {
ext = strtok_r ( NULL , " / " , & tokb ) ;
2005-12-09 11:01:18 +00:00
if ( ext ) {
2007-06-06 21:20:11 +00:00
opts = strtok_r ( NULL , " / " , & tokb ) ;
} else {
chan_misdn_log ( 0 , 0 , " misdn_call: No Extension given! \n " ) ;
return - 1 ;
2005-12-09 11:01:18 +00:00
}
}
if ( ! ast ) {
ast_log ( LOG_WARNING , " --> ! misdn_call called on ast_channel *ast where ast == NULL \n " ) ;
return - 1 ;
}
if ( ( ( ast - > _state ! = AST_STATE_DOWN ) & & ( ast - > _state ! = AST_STATE_RESERVED ) ) | | ! dest ) {
ast_log ( LOG_WARNING , " --> ! misdn_call called on %s, neither down nor reserved (or dest==NULL) \n " , ast - > name ) ;
2007-06-06 21:20:11 +00:00
ast - > hangupcause = AST_CAUSE_NORMAL_TEMPORARY_FAILURE ;
2005-12-09 11:01:18 +00:00
ast_setstate ( ast , AST_STATE_DOWN ) ;
return - 1 ;
}
if ( ! ch ) {
ast_log ( LOG_WARNING , " --> ! misdn_call called on %s, neither down nor reserved (or dest==NULL) \n " , ast - > name ) ;
2007-06-06 21:20:11 +00:00
ast - > hangupcause = AST_CAUSE_NORMAL_TEMPORARY_FAILURE ;
2005-12-09 11:01:18 +00:00
ast_setstate ( ast , AST_STATE_DOWN ) ;
return - 1 ;
}
2007-06-06 21:20:11 +00:00
newbc = ch - > bc ;
2005-12-09 11:01:18 +00:00
if ( ! newbc ) {
ast_log ( LOG_WARNING , " --> ! misdn_call called on %s, neither down nor reserved (or dest==NULL) \n " , ast - > name ) ;
2007-06-06 21:20:11 +00:00
ast - > hangupcause = AST_CAUSE_NORMAL_TEMPORARY_FAILURE ;
2005-12-09 11:01:18 +00:00
ast_setstate ( ast , AST_STATE_DOWN ) ;
return - 1 ;
}
2007-06-06 21:20:11 +00:00
port = newbc - > port ;
2006-05-22 15:02:03 +00:00
2007-06-06 21:20:11 +00:00
if ( ( exceed = add_out_calls ( port ) ) ) {
2006-05-22 15:02:03 +00:00
char tmp [ 16 ] ;
2007-06-06 21:20:11 +00:00
snprintf ( tmp , sizeof ( tmp ) , " %d " , exceed ) ;
pbx_builtin_setvar_helper ( ast , " MAX_OVERFLOW " , tmp ) ;
2006-05-22 15:02:03 +00:00
return - 1 ;
}
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , port , " * CALL: %s \n " , dest ) ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 2 , port , " --> * dad:%s tech:%s ctx:%s \n " , ast - > exten , ast - > name , ast - > context ) ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 3 , port , " --> * adding2newbc ext %s \n " , ast - > exten ) ;
2005-12-09 11:01:18 +00:00
if ( ast - > exten ) {
2007-06-06 21:20:11 +00:00
ast_copy_string ( ast - > exten , ext , sizeof ( ast - > exten ) ) ;
ast_copy_string ( newbc - > dad , ext , sizeof ( newbc - > dad ) ) ;
2005-12-09 11:01:18 +00:00
}
Merged revisions 58825-58826 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r58825 | crichter | 2007-03-12 13:43:24 +0100 (Mo, 12 Mär 2007) | 1 line
added UU transceiving and corect handling for rdnis
................
r58826 | crichter | 2007-03-12 14:08:06 +0100 (Mo, 12 Mär 2007) | 21 lines
Merged revisions 57034,57523,57753,58558 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r57034 | crichter | 2007-02-28 17:09:27 +0100 (Mi, 28 Feb 2007) | 1 line
fixed bugs.digium.com bugs: #9157 and bugs.beronet.com bugs: #302, #303, #304
........
r57523 | crichter | 2007-03-02 19:32:51 +0100 (Fr, 02 Mar 2007) | 1 line
fixed typo
........
r57753 | crichter | 2007-03-04 11:39:50 +0100 (So, 04 Mar 2007) | 1 line
fixed another place where the out_cause was hardcoded to 16
........
r58558 | crichter | 2007-03-09 15:43:58 +0100 (Fr, 09 Mar 2007) | 1 line
we can free channel 31 as well, since we can occupy it
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64951 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 09:31:27 +00:00
2007-06-09 01:06:40 +00:00
ast_copy_string ( newbc - > rad , S_OR ( ast - > cid . cid_rdnis , " " ) , sizeof ( newbc - > rad ) ) ;
Merged revisions 58825-58826 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r58825 | crichter | 2007-03-12 13:43:24 +0100 (Mo, 12 Mär 2007) | 1 line
added UU transceiving and corect handling for rdnis
................
r58826 | crichter | 2007-03-12 14:08:06 +0100 (Mo, 12 Mär 2007) | 21 lines
Merged revisions 57034,57523,57753,58558 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r57034 | crichter | 2007-02-28 17:09:27 +0100 (Mi, 28 Feb 2007) | 1 line
fixed bugs.digium.com bugs: #9157 and bugs.beronet.com bugs: #302, #303, #304
........
r57523 | crichter | 2007-03-02 19:32:51 +0100 (Fr, 02 Mar 2007) | 1 line
fixed typo
........
r57753 | crichter | 2007-03-04 11:39:50 +0100 (So, 04 Mar 2007) | 1 line
fixed another place where the out_cause was hardcoded to 16
........
r58558 | crichter | 2007-03-09 15:43:58 +0100 (Fr, 09 Mar 2007) | 1 line
we can free channel 31 as well, since we can occupy it
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64951 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 09:31:27 +00:00
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 3 , port , " --> * adding2newbc callerid %s \n " , ast - > cid . cid_num ) ;
if ( ast_strlen_zero ( newbc - > oad ) & & ! ast_strlen_zero ( ast - > cid . cid_num ) ) {
ast_copy_string ( newbc - > oad , ast - > cid . cid_num , sizeof ( newbc - > oad ) ) ;
}
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
newbc - > capability = ast - > transfercapability ;
pbx_builtin_setvar_helper ( ast , " TRANSFERCAPABILITY " , ast_transfercapability2str ( newbc - > capability ) ) ;
if ( ast - > transfercapability = = INFO_CAPABILITY_DIGITAL_UNRESTRICTED ) {
chan_misdn_log ( 2 , port , " --> * Call with flag Digital \n " ) ;
2005-12-09 11:01:18 +00:00
}
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
2007-06-06 21:20:11 +00:00
/* update screening and presentation */
update_config ( ch , ORG_AST ) ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
/* fill in some ies from channel vary*/
import_ch ( ast , newbc , ch ) ;
2006-02-02 21:15:34 +00:00
2007-06-06 21:20:11 +00:00
/* Finally The Options Override Everything */
if ( opts )
misdn_set_opt_exec ( ast , opts ) ;
else
chan_misdn_log ( 2 , port , " NO OPTS GIVEN \n " ) ;
Merged revisions 49313 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r49313 | crichter | 2007-01-03 10:06:50 +0100 (Mi, 03 Jan 2007) | 41 lines
Merged revisions 48319,48321,48467,48552,48576,49135,49303 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r48319 | crichter | 2006-12-06 15:35:25 +0100 (Mi, 06 Dez 2006) | 1 line
changed a few debugs to higher debug levels
........
r48321 | crichter | 2006-12-06 16:48:45 +0100 (Mi, 06 Dez 2006) | 1 line
added the export and import of the MISDN_ADDRESS_COMPLETE Variable to inidcate wether the extension is already completely dialed or if there might come additional digits by information elements. also added some docs for that.
........
r48467 | crichter | 2006-12-14 14:03:49 +0100 (Do, 14 Dez 2006) | 1 line
removed FIXUP state. added check for channel allocation conflict when we create a setup while the other site creates a setup on the same channel, besides the check we resolve this conflict.
........
r48552 | crichter | 2006-12-18 11:19:39 +0100 (Mo, 18 Dez 2006) | 1 line
when our PTP Partner sends us a SETUP with a preselected channel we just accept it, even when we're NT. added some checks for segfaults.
........
r48576 | crichter | 2006-12-19 14:08:51 +0100 (Di, 19 Dez 2006) | 1 line
when we reject a channel, because it's in use already, we shouldn't process the setup anymore. made the channel allocation a bit easier and more understandable, removed a few unused lines
........
r49135 | crichter | 2007-01-02 11:07:22 +0100 (Di, 02 Jan 2007) | 1 line
added check for channel ranges in the set/empty channel functions. set pmp_l1_check default to no. added misdn restart pid cli command. added cleaning of channel when we send a RELEASE_COMPLETE.
........
r49303 | crichter | 2007-01-03 09:24:00 +0100 (Mi, 03 Jan 2007) | 9 lines
* Added check for bridging in misdn_call to avoid setting echocancellation
when 2 mISDN channels are involved and when bridging is set. That lead
to a kernel panic before under different situations, because we switched
about 2 times between hardware bridging and echocancelation
* readded MISDN_URATE variable which got lost before, this should make app_v110
work again
* fixed typo
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-03 11:15:02 +00:00
2007-06-06 21:20:11 +00:00
/*check for bridging*/
misdn_cfg_get ( 0 , MISDN_GEN_BRIDGING , & bridging , sizeof ( bridging ) ) ;
if ( bridging & & ch - > other_ch ) {
2007-03-26 15:59:56 +00:00
# ifdef MISDN_1_2
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , port , " Disabling EC (aka Pipeline) on both Sides \n " ) ;
* ch - > bc - > pipeline = 0 ;
* ch - > other_ch - > bc - > pipeline = 0 ;
2007-03-26 15:59:56 +00:00
# else
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , port , " Disabling EC on both Sides \n " ) ;
ch - > bc - > ec_enable = 0 ;
ch - > other_ch - > bc - > ec_enable = 0 ;
2007-03-26 15:59:56 +00:00
# endif
2005-12-09 11:01:18 +00:00
}
2007-06-06 21:20:11 +00:00
r = misdn_lib_send_event ( newbc , EVENT_SETUP ) ;
/** we should have l3id after sending setup **/
ch - > l3id = newbc - > l3_id ;
2005-12-09 11:01:18 +00:00
if ( r = = - ENOCHAN ) {
2005-10-31 22:51:12 +00:00
chan_misdn_log ( 0 , port , " --> * Theres no Channel at the moment .. ! \n " ) ;
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , port , " --> * SEND: State Down pid:%d \n " , newbc ? newbc - > pid : - 1 ) ;
ast - > hangupcause = AST_CAUSE_NORMAL_CIRCUIT_CONGESTION ;
2005-10-31 22:51:12 +00:00
ast_setstate ( ast , AST_STATE_DOWN ) ;
return - 1 ;
}
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 2 , port , " --> * SEND: State Dialing pid:%d \n " , newbc ? newbc - > pid : 1 ) ;
2005-10-31 22:51:12 +00:00
ast_setstate ( ast , AST_STATE_DIALING ) ;
2007-06-06 21:20:11 +00:00
ast - > hangupcause = AST_CAUSE_NORMAL_CLEARING ;
2006-07-03 16:47:28 +00:00
2007-06-06 21:20:11 +00:00
if ( newbc - > nt )
stop_bc_tones ( ch ) ;
2006-09-28 11:32:32 +00:00
2007-06-06 21:20:11 +00:00
ch - > state = MISDN_CALLING ;
2006-07-03 16:47:28 +00:00
2005-10-31 22:51:12 +00:00
return 0 ;
}
2005-12-09 11:01:18 +00:00
static int misdn_answer ( struct ast_channel * ast )
2005-10-31 22:51:12 +00:00
{
struct chan_list * p ;
2007-06-06 21:20:11 +00:00
const char * tmp ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
if ( ! ast | | ! ( p = MISDN_ASTERISK_TECH_PVT ( ast ) ) ) return - 1 ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , p ? ( p - > bc ? p - > bc - > port : 0 ) : 0 , " * ANSWER: \n " ) ;
2005-10-31 22:51:12 +00:00
if ( ! p ) {
ast_log ( LOG_WARNING , " --> Channel not connected ?? \n " ) ;
ast_queue_hangup ( ast ) ;
}
if ( ! p - > bc ) {
chan_misdn_log ( 1 , 0 , " --> Got Answer, but theres no bc obj ?? \n " ) ;
ast_queue_hangup ( ast ) ;
}
2007-06-06 21:20:11 +00:00
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 ) ) ;
} else {
chan_misdn_log ( 3 , p - > bc - > port , " --> Connection is without BF encryption \n " ) ;
2005-10-31 22:51:12 +00:00
}
2005-11-15 20:20:45 +00:00
2007-06-06 21:20:11 +00:00
tmp = pbx_builtin_getvar_helper ( ast , " MISDN_DIGITAL_TRANS " ) ;
if ( ! ast_strlen_zero ( tmp ) & & ast_true ( tmp ) ) {
chan_misdn_log ( 1 , p - > bc - > port , " --> Connection is transparent digital \n " ) ;
p - > bc - > nodsp = 1 ;
p - > bc - > hdlc = 0 ;
p - > bc - > nojitter = 1 ;
2005-11-15 20:20:45 +00:00
}
2007-06-06 21:20:11 +00:00
2005-10-31 22:51:12 +00:00
p - > state = MISDN_CONNECTED ;
2006-07-06 15:11:40 +00:00
stop_indicate ( p ) ;
2006-04-05 14:51:48 +00:00
if ( ast_strlen_zero ( p - > bc - > cad ) ) {
chan_misdn_log ( 2 , p - > bc - > port , " --> empty cad using dad \n " ) ;
2007-06-06 21:20:11 +00:00
ast_copy_string ( p - > bc - > cad , p - > bc - > dad , sizeof ( p - > bc - > cad ) ) ;
2006-04-05 14:51:48 +00:00
}
2005-10-31 22:51:12 +00:00
misdn_lib_send_event ( p - > bc , EVENT_CONNECT ) ;
start_bc_tones ( p ) ;
2007-06-06 21:20:11 +00:00
2005-10-31 22:51:12 +00:00
return 0 ;
}
2006-08-31 01:59:02 +00:00
static int misdn_digit_begin ( struct ast_channel * chan , char digit )
{
/* XXX Modify this callback to support Asterisk controlling the length of DTMF */
return 0 ;
}
Merged revisions 51311 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r51311 | russell | 2007-01-19 11:49:38 -0600 (Fri, 19 Jan 2007) | 23 lines
Merge the changes from the /team/group/vldtmf_fixup branch.
The main bug being addressed here is a problem introduced when two SIP
channels using SIP INFO dtmf have their media directly bridged. So, when a
DTMF END frame comes into Asterisk from an incoming INFO message, Asterisk
would try to emulate a digit of some length by first sending a DTMF BEGIN
frame and sending a DTMF END later timed off of incoming audio. However,
since there was no audio coming in, the DTMF_END was never generated. This
caused DTMF based features to no longer work.
To fix this, the core now knows when a channel doesn't care about DTMF BEGIN
frames (such as a SIP channel sending INFO dtmf). If this is the case, then
Asterisk will not emulate a digit of some length, and will instead just pass
through the single DTMF END event.
Channel drivers also now get passed the length of the digit to their digit_end
callback. This improves SIP INFO support even further by enabling us to put
the real digit duration in the INFO message instead of a hard coded 250ms.
Also, for an incoming INFO message, the duration is read from the frame and
passed into the core instead of just getting ignored.
(issue #8597, maybe others...)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@51314 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-19 18:06:03 +00:00
static int misdn_digit_end ( struct ast_channel * ast , char digit , unsigned int duration )
2005-10-31 22:51:12 +00:00
{
struct chan_list * p ;
2007-06-06 21:20:11 +00:00
struct misdn_bchannel * bc ;
char buf [ 2 ] = { digit , 0 } ;
2005-10-31 22:51:12 +00:00
2006-02-02 21:15:34 +00:00
if ( ! ast | | ! ( p = MISDN_ASTERISK_TECH_PVT ( ast ) ) ) return - 1 ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
bc = p - > bc ;
chan_misdn_log ( 1 , bc ? bc - > port : 0 , " * IND : Digit %c \n " , digit ) ;
2005-10-31 22:51:12 +00:00
if ( ! bc ) {
ast_log ( LOG_WARNING , " --> !! Got Digit Event withut having bchannel Object \n " ) ;
return - 1 ;
}
switch ( p - > state ) {
2007-06-06 21:20:11 +00:00
case MISDN_CALLING :
if ( strlen ( bc - > infos_pending ) < sizeof ( bc - > infos_pending ) - 1 )
strncat ( bc - > infos_pending , buf , sizeof ( bc - > infos_pending ) - 1 ) ;
2005-10-31 22:51:12 +00:00
break ;
2007-06-06 21:20:11 +00:00
case MISDN_CALLING_ACKNOWLEDGE :
ast_copy_string ( bc - > info_dad , buf , sizeof ( bc - > info_dad ) ) ;
if ( strlen ( bc - > dad ) < sizeof ( bc - > dad ) - 1 )
strncat ( bc - > dad , buf , sizeof ( bc - > dad ) - 1 ) ;
ast_copy_string ( p - > ast - > exten , bc - > dad , sizeof ( p - > ast - > exten ) ) ;
misdn_lib_send_event ( bc , EVENT_INFORMATION ) ;
2005-10-31 22:51:12 +00:00
break ;
2007-06-25 08:57:06 +00:00
default :
/* Do not send Digits in CONNECTED State, when
* the other side is too mISDN . */
if ( p - > other_ch )
return 0 ;
if ( bc - > send_dtmf )
send_digit_to_chan ( p , digit ) ;
2005-10-31 22:51:12 +00:00
break ;
2007-06-25 09:34:05 +00:00
}
2007-06-06 21:20:11 +00:00
2005-10-31 22:51:12 +00:00
return 0 ;
}
2005-12-09 11:01:18 +00:00
static int misdn_fixup ( struct ast_channel * oldast , struct ast_channel * ast )
2005-10-31 22:51:12 +00:00
{
struct chan_list * p ;
2007-06-06 21:20:11 +00:00
2006-02-02 21:15:34 +00:00
if ( ! ast | | ! ( p = MISDN_ASTERISK_TECH_PVT ( ast ) ) ) return - 1 ;
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , p - > bc ? p - > bc - > port : 0 , " * IND: Got Fixup State:%s L3id:%x \n " , misdn_get_ch_state ( p ) , p - > l3id ) ;
p - > ast = ast ;
2005-10-31 22:51:12 +00:00
return 0 ;
}
2006-05-16 14:34:21 +00:00
static int misdn_indication ( struct ast_channel * ast , int cond , const void * data , size_t datalen )
2005-10-31 22:51:12 +00:00
{
struct chan_list * p ;
2006-02-02 21:15:34 +00:00
if ( ! ast | | ! ( p = MISDN_ASTERISK_TECH_PVT ( ast ) ) ) {
2007-06-06 21:20:11 +00:00
ast_log ( LOG_WARNING , " Returned -1 in misdn_indication \n " ) ;
2005-10-31 22:51:12 +00:00
return - 1 ;
}
if ( ! p - > bc ) {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , 0 , " * IND : Indication from %s \n " , ast - > exten ) ;
2005-10-31 22:51:12 +00:00
ast_log ( LOG_WARNING , " Private Pointer but no bc ? \n " ) ;
return - 1 ;
}
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 5 , p - > bc - > port , " * IND : Indication [%d] from %s \n " , cond , ast - > exten ) ;
2005-10-31 22:51:12 +00:00
switch ( cond ) {
case AST_CONTROL_BUSY :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , p - > bc - > port , " * IND : \t busy pid:%d \n " , p - > bc ? p - > bc - > pid : - 1 ) ;
ast_setstate ( ast , AST_STATE_BUSY ) ;
2006-06-26 17:37:11 +00:00
2007-06-06 21:20:11 +00:00
p - > bc - > out_cause = AST_CAUSE_USER_BUSY ;
2005-10-31 22:51:12 +00:00
if ( p - > state ! = MISDN_CONNECTED ) {
2006-07-06 15:11:40 +00:00
start_bc_tones ( p ) ;
2005-10-31 22:51:12 +00:00
misdn_lib_send_event ( p - > bc , EVENT_DISCONNECT ) ;
} else {
2005-12-09 11:01:18 +00:00
chan_misdn_log ( - 1 , p - > bc - > port , " --> !! Got Busy in Connected State !?! ast:%s \n " , ast - > name ) ;
2005-10-31 22:51:12 +00:00
}
2006-07-06 15:11:40 +00:00
return - 1 ;
2005-10-31 22:51:12 +00:00
case AST_CONTROL_RING :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , p - > bc - > port , " * IND : \t ring pid:%d \n " , p - > bc ? p - > bc - > pid : - 1 ) ;
2006-07-06 15:11:40 +00:00
return - 1 ;
2005-10-31 22:51:12 +00:00
case AST_CONTROL_RINGING :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , p - > bc - > port , " * IND : \t ringing pid:%d \n " , p - > bc ? p - > bc - > pid : - 1 ) ;
2006-02-02 21:15:34 +00:00
switch ( p - > state ) {
2007-06-06 21:20:11 +00:00
case MISDN_ALERTING :
chan_misdn_log ( 2 , p - > bc - > port , " --> * IND : \t ringing pid:%d but I was Ringing before, so ignoreing it \n " , p - > bc ? p - > bc - > pid : - 1 ) ;
break ;
case MISDN_CONNECTED :
chan_misdn_log ( 2 , p - > bc - > port , " --> * IND : \t ringing pid:%d but Connected, so just send TONE_ALERTING without state changes \n " , p - > bc ? p - > bc - > pid : - 1 ) ;
return - 1 ;
default :
p - > state = MISDN_ALERTING ;
chan_misdn_log ( 2 , p - > bc - > port , " --> * IND : \t ringing pid:%d \n " , p - > bc ? p - > bc - > pid : - 1 ) ;
misdn_lib_send_event ( p - > bc , EVENT_ALERTING ) ;
2006-06-17 10:37:35 +00:00
2007-06-06 21:20:11 +00:00
if ( p - > other_ch & & p - > other_ch - > bc ) {
if ( misdn_inband_avail ( p - > other_ch - > bc ) ) {
chan_misdn_log ( 2 , p - > bc - > port , " --> other End is mISDN and has inband info available \n " ) ;
break ;
}
2006-06-21 15:21:46 +00:00
2007-06-06 21:20:11 +00:00
if ( ! p - > other_ch - > bc - > nt ) {
chan_misdn_log ( 2 , p - > bc - > port , " --> other End is mISDN TE so it has inband info for sure (?) \n " ) ;
break ;
2006-06-17 10:37:35 +00:00
}
2007-06-06 21:20:11 +00:00
}
2006-06-21 15:21:46 +00:00
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 3 , p - > bc - > port , " --> * SEND: State Ring pid:%d \n " , p - > bc ? p - > bc - > pid : - 1 ) ;
ast_setstate ( ast , AST_STATE_RINGING ) ;
2006-06-17 10:37:35 +00:00
2007-06-06 21:20:11 +00:00
if ( ! p - > bc - > nt & & ( p - > originator = = ORG_MISDN ) & & ! p - > incoming_early_audio )
chan_misdn_log ( 2 , p - > bc - > port , " --> incoming_early_audio off \n " ) ;
else
return - 1 ;
2005-10-31 22:51:12 +00:00
}
break ;
case AST_CONTROL_ANSWER :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , p - > bc - > port , " --> * IND : \t answer pid:%d \n " , p - > bc ? p - > bc - > pid : - 1 ) ;
2006-02-02 21:15:34 +00:00
start_bc_tones ( p ) ;
2005-10-31 22:51:12 +00:00
break ;
case AST_CONTROL_TAKEOFFHOOK :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , p - > bc - > port , " --> * \t takeoffhook pid:%d \n " , p - > bc ? p - > bc - > pid : - 1 ) ;
2006-07-06 15:11:40 +00:00
return - 1 ;
2005-10-31 22:51:12 +00:00
case AST_CONTROL_OFFHOOK :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , p - > bc - > port , " --> * \t offhook pid:%d \n " , p - > bc ? p - > bc - > pid : - 1 ) ;
2006-07-06 15:11:40 +00:00
return - 1 ;
2005-10-31 22:51:12 +00:00
case AST_CONTROL_FLASH :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , p - > bc - > port , " --> * \t flash pid:%d \n " , p - > bc ? p - > bc - > pid : - 1 ) ;
2005-10-31 22:51:12 +00:00
break ;
case AST_CONTROL_PROGRESS :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , p - > bc - > port , " --> * IND : \t progress pid:%d \n " , p - > bc ? p - > bc - > pid : - 1 ) ;
2006-02-02 21:15:34 +00:00
misdn_lib_send_event ( p - > bc , EVENT_PROGRESS ) ;
break ;
case AST_CONTROL_PROCEEDING :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , p - > bc - > port , " --> * IND : \t proceeding pid:%d \n " , p - > bc ? p - > bc - > pid : - 1 ) ;
2006-02-02 21:15:34 +00:00
misdn_lib_send_event ( p - > bc , EVENT_PROCEEDING ) ;
2005-10-31 22:51:12 +00:00
break ;
case AST_CONTROL_CONGESTION :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , p - > bc - > port , " --> * IND : \t congestion pid:%d \n " , p - > bc ? p - > bc - > pid : - 1 ) ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
p - > bc - > out_cause = AST_CAUSE_SWITCH_CONGESTION ;
Merged revisions 58825-58826 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r58825 | crichter | 2007-03-12 13:43:24 +0100 (Mo, 12 Mär 2007) | 1 line
added UU transceiving and corect handling for rdnis
................
r58826 | crichter | 2007-03-12 14:08:06 +0100 (Mo, 12 Mär 2007) | 21 lines
Merged revisions 57034,57523,57753,58558 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r57034 | crichter | 2007-02-28 17:09:27 +0100 (Mi, 28 Feb 2007) | 1 line
fixed bugs.digium.com bugs: #9157 and bugs.beronet.com bugs: #302, #303, #304
........
r57523 | crichter | 2007-03-02 19:32:51 +0100 (Fr, 02 Mar 2007) | 1 line
fixed typo
........
r57753 | crichter | 2007-03-04 11:39:50 +0100 (So, 04 Mar 2007) | 1 line
fixed another place where the out_cause was hardcoded to 16
........
r58558 | crichter | 2007-03-09 15:43:58 +0100 (Fr, 09 Mar 2007) | 1 line
we can free channel 31 as well, since we can occupy it
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64951 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 09:31:27 +00:00
start_bc_tones ( p ) ;
misdn_lib_send_event ( p - > bc , EVENT_DISCONNECT ) ;
2005-12-09 11:01:18 +00:00
2005-11-01 22:04:14 +00:00
if ( p - > bc - > nt ) {
2006-07-06 15:11:40 +00:00
hanguptone_indicate ( p ) ;
2005-10-31 22:51:12 +00:00
}
break ;
case - 1 :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , p - > bc - > port , " --> * IND : \t -1! (stop indication) pid:%d \n " , p - > bc ? p - > bc - > pid : - 1 ) ;
2006-07-06 15:11:40 +00:00
stop_indicate ( p ) ;
2006-06-17 10:37:35 +00:00
if ( p - > state = = MISDN_CONNECTED )
2006-02-10 14:17:28 +00:00
start_bc_tones ( p ) ;
2005-10-31 22:51:12 +00:00
break ;
case AST_CONTROL_HOLD :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , p - > bc - > port , " --> * \t HOLD pid:%d \n " , p - > bc ? p - > bc - > pid : - 1 ) ;
2005-10-31 22:51:12 +00:00
break ;
case AST_CONTROL_UNHOLD :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , p - > bc - > port , " --> * \t UNHOLD pid:%d \n " , p - > bc ? p - > bc - > pid : - 1 ) ;
2005-10-31 22:51:12 +00:00
break ;
default :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , p - > bc - > port , " --> * Unknown Indication:%d pid:%d \n " , cond , p - > bc ? p - > bc - > pid : - 1 ) ;
2005-10-31 22:51:12 +00:00
}
return 0 ;
}
2005-12-09 11:01:18 +00:00
static int misdn_hangup ( struct ast_channel * ast )
2005-10-31 22:51:12 +00:00
{
struct chan_list * p ;
2007-06-06 21:20:11 +00:00
struct misdn_bchannel * bc = NULL ;
const char * varcause = NULL ;
2006-10-03 15:53:07 +00:00
2007-06-14 19:39:12 +00:00
ast_debug ( 1 , " misdn_hangup(%s) \n " , ast - > name ) ;
2007-06-06 21:20:11 +00:00
2006-09-06 18:02:25 +00:00
if ( ! ast | | ! ( p = MISDN_ASTERISK_TECH_PVT ( ast ) ) ) return - 1 ;
2007-06-06 21:20:11 +00:00
2005-10-31 22:51:12 +00:00
if ( ! p ) {
chan_misdn_log ( 3 , 0 , " misdn_hangup called, without chan_list obj. \n " ) ;
return 0 ;
}
2005-11-15 20:20:45 +00:00
2007-06-06 21:20:11 +00:00
bc = p - > bc ;
2007-08-15 11:27:51 +00:00
if ( bc ) {
const char * tmp = pbx_builtin_getvar_helper ( ast , " MISDN_USERUSER " ) ;
if ( tmp ) {
ast_log ( LOG_NOTICE , " MISDN_USERUSER: %s \n " , tmp ) ;
strcpy ( bc - > uu , tmp ) ;
bc - > uulen = strlen ( bc - > uu ) ;
}
}
2007-06-06 21:20:11 +00:00
MISDN_ASTERISK_TECH_PVT ( ast ) = NULL ;
p - > ast = NULL ;
2005-10-31 22:51:12 +00:00
2006-10-11 08:23:16 +00:00
if ( ast - > _state = = AST_STATE_RESERVED | |
p - > state = = MISDN_NOTHING | |
p - > state = = MISDN_HOLDED | |
p - > state = = MISDN_HOLD_DISCONNECT ) {
CLEAN_CH :
2005-10-31 22:51:12 +00:00
/* between request and call */
2007-06-14 19:39:12 +00:00
ast_debug ( 1 , " State Reserved (or nothing) => chanIsAvail \n " ) ;
2007-06-06 21:20:11 +00:00
MISDN_ASTERISK_TECH_PVT ( ast ) = NULL ;
2007-07-02 09:34:19 +00:00
ast_mutex_lock ( & release_lock ) ;
2005-10-31 22:51:12 +00:00
cl_dequeue_chan ( & cl_te , p ) ;
2006-09-06 18:02:25 +00:00
close ( p - > pipe [ 0 ] ) ;
close ( p - > pipe [ 1 ] ) ;
2007-06-06 21:20:11 +00:00
ast_free ( p ) ;
2007-07-02 09:34:19 +00:00
ast_mutex_unlock ( & release_lock ) ;
2005-12-09 11:01:18 +00:00
if ( bc )
misdn_lib_release ( bc ) ;
2005-10-31 22:51:12 +00:00
return 0 ;
}
2006-10-11 08:23:16 +00:00
if ( ! bc ) {
2007-06-06 21:20:11 +00:00
ast_log ( LOG_WARNING , " Hangup with private but no bc ? state:%s l3id:%x \n " , misdn_get_ch_state ( p ) , p - > l3id ) ;
2006-10-11 08:23:16 +00:00
goto CLEAN_CH ;
}
2007-06-06 21:20:11 +00:00
p - > need_hangup = 0 ;
p - > need_queue_hangup = 0 ;
p - > need_busy = 0 ;
2006-08-03 16:38:00 +00:00
2006-06-19 09:44:04 +00:00
if ( ! p - > bc - > nt )
stop_bc_tones ( p ) ;
2007-06-06 21:20:11 +00:00
bc - > out_cause = ast - > hangupcause ? ast - > hangupcause : AST_CAUSE_NORMAL_CLEARING ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
if ( ( varcause = pbx_builtin_getvar_helper ( ast , " HANGUPCAUSE " ) ) | |
( varcause = pbx_builtin_getvar_helper ( ast , " PRI_CAUSE " ) ) ) {
int tmpcause = atoi ( varcause ) ;
bc - > out_cause = tmpcause ? tmpcause : AST_CAUSE_NORMAL_CLEARING ;
}
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , bc - > port , " * IND : HANGUP \t pid:%d ctx:%s dad:%s oad:%s State:%s \n " , p - > bc ? p - > bc - > pid : - 1 , ast - > context , ast - > exten , ast - > cid . cid_num , misdn_get_ch_state ( p ) ) ;
chan_misdn_log ( 3 , bc - > port , " --> l3id:%x \n " , p - > l3id ) ;
chan_misdn_log ( 3 , bc - > port , " --> cause:%d \n " , bc - > cause ) ;
chan_misdn_log ( 2 , bc - > port , " --> out_cause:%d \n " , bc - > out_cause ) ;
chan_misdn_log ( 2 , bc - > port , " --> state:%s \n " , misdn_get_ch_state ( p ) ) ;
switch ( p - > state ) {
case MISDN_INCOMING_SETUP :
case MISDN_CALLING :
p - > state = MISDN_CLEANING ;
2007-06-25 09:34:05 +00:00
/* This is the only place in misdn_hangup, where we
* can call release_chan , else it might create lot ' s of trouble
* */
ast_log ( LOG_NOTICE , " release channel, in CALLING/INCOMING_SETUP state.. no other events happened \n " ) ;
release_chan ( bc ) ;
2007-06-06 21:20:11 +00:00
misdn_lib_send_event ( bc , EVENT_RELEASE_COMPLETE ) ;
break ;
case MISDN_HOLDED :
case MISDN_DIALING :
start_bc_tones ( p ) ;
hanguptone_indicate ( p ) ;
2006-06-17 10:37:35 +00:00
2007-11-12 13:33:13 +00:00
p - > state = MISDN_CLEANING ;
2007-06-06 21:20:11 +00:00
if ( bc - > need_disconnect )
misdn_lib_send_event ( bc , EVENT_DISCONNECT ) ;
break ;
case MISDN_CALLING_ACKNOWLEDGE :
start_bc_tones ( p ) ;
hanguptone_indicate ( p ) ;
2006-07-06 15:11:40 +00:00
2007-06-06 21:20:11 +00:00
if ( bc - > need_disconnect )
misdn_lib_send_event ( bc , EVENT_DISCONNECT ) ;
break ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
case MISDN_ALERTING :
case MISDN_PROGRESS :
case MISDN_PROCEEDING :
if ( p - > originator ! = ORG_AST )
hanguptone_indicate ( p ) ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
/*p->state=MISDN_CLEANING;*/
if ( bc - > need_disconnect )
misdn_lib_send_event ( bc , EVENT_DISCONNECT ) ;
break ;
case MISDN_CONNECTED :
case MISDN_PRECONNECTED :
/* Alerting or Disconect */
if ( p - > bc - > nt ) {
start_bc_tones ( p ) ;
hanguptone_indicate ( p ) ;
p - > bc - > progress_indicator = 8 ;
}
if ( bc - > need_disconnect )
misdn_lib_send_event ( bc , EVENT_DISCONNECT ) ;
2006-06-26 17:37:11 +00:00
2007-06-06 21:20:11 +00:00
/*p->state=MISDN_CLEANING;*/
break ;
case MISDN_DISCONNECTED :
2007-11-12 13:33:13 +00:00
if ( bc - > need_release )
misdn_lib_send_event ( bc , EVENT_RELEASE ) ;
2007-06-06 21:20:11 +00:00
p - > state = MISDN_CLEANING ; /* MISDN_HUNGUP_FROM_AST; */
break ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
case MISDN_RELEASED :
case MISDN_CLEANING :
p - > state = MISDN_CLEANING ;
break ;
2006-06-26 17:37:11 +00:00
2007-06-06 21:20:11 +00:00
case MISDN_BUSY :
break ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
case MISDN_HOLD_DISCONNECT :
/* need to send release here */
chan_misdn_log ( 1 , bc - > port , " --> cause %d \n " , bc - > cause ) ;
chan_misdn_log ( 1 , bc - > port , " --> out_cause %d \n " , bc - > out_cause ) ;
bc - > out_cause = - 1 ;
2007-11-12 13:33:13 +00:00
if ( bc - > need_release )
misdn_lib_send_event ( bc , EVENT_RELEASE ) ;
2007-06-06 21:20:11 +00:00
p - > state = MISDN_CLEANING ;
break ;
default :
if ( bc - > nt ) {
bc - > out_cause = - 1 ;
2007-11-12 13:33:13 +00:00
if ( bc - > need_release )
misdn_lib_send_event ( bc , EVENT_RELEASE ) ;
2007-06-06 21:20:11 +00:00
p - > state = MISDN_CLEANING ;
} else {
if ( bc - > need_disconnect )
misdn_lib_send_event ( bc , EVENT_DISCONNECT ) ;
2005-10-31 22:51:12 +00:00
}
2007-06-06 21:20:11 +00:00
}
2006-06-28 14:15:29 +00:00
2007-06-06 21:20:11 +00:00
p - > state = MISDN_CLEANING ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 3 , bc - > port , " --> Channel: %s hanguped new state:%s \n " , ast - > name , misdn_get_ch_state ( p ) ) ;
2006-04-04 19:09:26 +00:00
2005-10-31 22:51:12 +00:00
return 0 ;
}
2006-05-16 14:34:21 +00:00
2006-09-20 05:13:03 +00:00
static struct ast_frame * process_ast_dsp ( struct chan_list * tmp , struct ast_frame * frame )
2006-05-16 14:34:21 +00:00
{
struct ast_frame * f , * f2 ;
2006-08-08 18:13:40 +00:00
if ( tmp - > trans ) {
f2 = ast_translate ( tmp - > trans , frame , 0 ) ;
f = ast_dsp_process ( tmp - > ast , tmp - > dsp , f2 ) ;
} else {
2006-05-16 14:34:21 +00:00
chan_misdn_log ( 0 , tmp - > bc - > port , " No T-Path found \n " ) ;
return NULL ;
}
2006-08-08 18:13:40 +00:00
if ( ! f | | ( f - > frametype ! = AST_FRAME_DTMF ) )
return frame ;
2007-06-14 19:39:12 +00:00
ast_debug ( 1 , " Detected inband DTMF digit: %c \n " , f - > subclass ) ;
2006-08-08 18:13:40 +00:00
if ( tmp - > faxdetect & & ( f - > subclass = = ' f ' ) ) {
/* Fax tone -- Handle and return NULL */
if ( ! tmp - > faxhandled ) {
struct ast_channel * ast = tmp - > ast ;
tmp - > faxhandled + + ;
chan_misdn_log ( 0 , tmp - > bc - > port , " Fax detected, preparing %s for fax transfer. \n " , ast - > name ) ;
tmp - > bc - > rxgain = 0 ;
isdn_lib_update_rxgain ( tmp - > bc ) ;
tmp - > bc - > txgain = 0 ;
isdn_lib_update_txgain ( tmp - > bc ) ;
2007-03-26 15:59:56 +00:00
# ifdef MISDN_1_2
* tmp - > bc - > pipeline = 0 ;
# else
2006-08-08 18:13:40 +00:00
tmp - > bc - > ec_enable = 0 ;
2007-03-26 15:59:56 +00:00
# endif
2006-08-08 18:13:40 +00:00
isdn_lib_update_ec ( tmp - > bc ) ;
isdn_lib_stop_dtmf ( tmp - > bc ) ;
switch ( tmp - > faxdetect ) {
case 1 :
if ( strcmp ( ast - > exten , " fax " ) ) {
char * context ;
char context_tmp [ BUFFERSIZE ] ;
misdn_cfg_get ( tmp - > bc - > port , MISDN_CFG_FAXDETECT_CONTEXT , & context_tmp , sizeof ( context_tmp ) ) ;
context = ast_strlen_zero ( context_tmp ) ? ( ast_strlen_zero ( ast - > macrocontext ) ? ast - > context : ast - > macrocontext ) : context_tmp ;
2007-04-11 15:48:54 +00:00
if ( ast_exists_extension ( ast , context , " fax " , 1 , ast - > cid . cid_num ) ) {
2007-07-26 15:49:18 +00:00
ast_verb ( 3 , " Redirecting %s to fax extension (context:%s) \n " , ast - > name , context ) ;
2006-08-08 18:13:40 +00:00
/* Save the DID/DNIS when we transfer the fax call to a "fax" extension */
pbx_builtin_setvar_helper ( ast , " FAXEXTEN " , ast - > exten ) ;
if ( ast_async_goto ( ast , context , " fax " , 1 ) )
ast_log ( LOG_WARNING , " Failed to async goto '%s' into fax of '%s' \n " , ast - > name , context ) ;
} else
ast_log ( LOG_NOTICE , " Fax detected, but no fax extension ctx:%s exten:%s \n " , context , ast - > exten ) ;
2006-10-03 15:53:07 +00:00
} else {
2007-06-14 19:39:12 +00:00
ast_debug ( 1 , " Already in a fax extension, not redirecting \n " ) ;
2006-10-03 15:53:07 +00:00
}
2006-08-08 18:13:40 +00:00
break ;
case 2 :
2007-07-26 15:49:18 +00:00
ast_verb ( 3 , " Not redirecting %s to fax extension, nojump is set. \n " , ast - > name ) ;
2006-08-08 18:13:40 +00:00
break ;
}
2006-10-03 15:53:07 +00:00
} else {
2007-06-14 19:39:12 +00:00
ast_debug ( 1 , " Fax already handled \n " ) ;
2006-10-03 15:53:07 +00:00
}
2006-08-08 18:13:40 +00:00
}
if ( tmp - > ast_dsp & & ( f - > subclass ! = ' f ' ) ) {
chan_misdn_log ( 2 , tmp - > bc - > port , " --> * SEND: DTMF (AST_DSP) :%c \n " , f - > subclass ) ;
}
2007-09-19 09:48:33 +00:00
return f ;
2006-05-16 14:34:21 +00:00
}
2007-06-06 21:20:11 +00:00
static struct ast_frame * misdn_read ( struct ast_channel * ast )
2005-10-31 22:51:12 +00:00
{
struct chan_list * tmp ;
2007-08-30 14:54:30 +00:00
fd_set rrfs ;
struct timeval tv ;
int len , t ;
2006-07-06 15:11:40 +00:00
if ( ! ast ) {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , 0 , " misdn_read called without ast \n " ) ;
2006-07-06 15:11:40 +00:00
return NULL ;
}
2007-06-06 21:20:11 +00:00
if ( ! ( tmp = MISDN_ASTERISK_TECH_PVT ( ast ) ) ) {
chan_misdn_log ( 1 , 0 , " misdn_read called without ast->pvt \n " ) ;
2006-07-06 15:11:40 +00:00
return NULL ;
}
Merged revisions 62912 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r62912 | crichter | 2007-05-03 16:36:32 +0200 (Do, 03 Mai 2007) | 17 lines
Merged revisions 61357,61770,62885 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r61357 | crichter | 2007-04-11 14:05:57 +0200 (Mi, 11 Apr 2007) | 1 line
some fixes for PMP Hold/Retrieve, it should work now, when briding=no
........
r61770 | crichter | 2007-04-24 15:50:05 +0200 (Di, 24 Apr 2007) | 1 line
added lock for sending messages to avoid double sending. shuffled some empty_chans after the cb_event calls, this avoids that a release_complete from a quite different call releases a fresh created setup by accident.
........
r62885 | crichter | 2007-05-03 15:59:00 +0200 (Do, 03 Mai 2007) | 1 line
fixed the problem that misdn_write did not return -1 when called with 0 samples in a frame this resultet in a deadlock in some circumstances, when the call ended because of a busy extension. added encoding of keypad.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64955 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 09:50:33 +00:00
2007-06-06 21:20:11 +00:00
if ( ! tmp - > bc & & ! ( tmp - > state = = MISDN_HOLDED ) ) {
chan_misdn_log ( 1 , 0 , " misdn_read called without bc \n " ) ;
2006-07-06 15:11:40 +00:00
return NULL ;
}
2006-06-18 19:09:32 +00:00
2007-08-30 08:50:44 +00:00
tv . tv_sec = 0 ;
tv . tv_usec = 20000 ;
2006-04-29 22:56:00 +00:00
2007-08-30 08:50:44 +00:00
FD_ZERO ( & rrfs ) ;
FD_SET ( tmp - > pipe [ 0 ] , & rrfs ) ;
2007-08-30 14:54:30 +00:00
t = select ( FD_SETSIZE , & rrfs , NULL , NULL , & tv ) ;
2007-08-30 08:50:44 +00:00
if ( ! t ) {
chan_misdn_log ( 3 , tmp - > bc - > port , " read Select Timed out \n " ) ;
len = 160 ;
}
if ( t < 0 ) {
chan_misdn_log ( - 1 , tmp - > bc - > port , " Select Error (err=%s) \n " , strerror ( errno ) ) ;
return NULL ;
}
if ( FD_ISSET ( tmp - > pipe [ 0 ] , & rrfs ) ) {
len = read ( tmp - > pipe [ 0 ] , tmp - > ast_rd_buf , sizeof ( tmp - > ast_rd_buf ) ) ;
if ( len < = 0 ) {
/* we hangup here, since our pipe is closed */
chan_misdn_log ( 2 , tmp - > bc - > port , " misdn_read: Pipe closed, hanging up \n " ) ;
return NULL ;
}
} else {
2006-05-16 14:34:21 +00:00
return NULL ;
2006-04-03 19:17:59 +00:00
}
2007-11-16 10:06:55 +00:00
tmp - > frame . frametype = AST_FRAME_VOICE ;
2005-10-31 22:51:12 +00:00
tmp - > frame . subclass = AST_FORMAT_ALAW ;
tmp - > frame . datalen = len ;
2006-08-08 18:13:40 +00:00
tmp - > frame . samples = len ;
tmp - > frame . mallocd = 0 ;
tmp - > frame . offset = 0 ;
2007-06-06 21:20:11 +00:00
tmp - > frame . delivery = ast_tv ( 0 , 0 ) ;
2005-10-31 22:51:12 +00:00
tmp - > frame . src = NULL ;
2006-08-08 18:13:40 +00:00
tmp - > frame . data = tmp - > ast_rd_buf ;
if ( tmp - > faxdetect & & ! tmp - > faxhandled ) {
if ( tmp - > faxdetect_timeout ) {
if ( ast_tvzero ( tmp - > faxdetect_tv ) ) {
tmp - > faxdetect_tv = ast_tvnow ( ) ;
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 2 , tmp - > bc - > port , " faxdetect: starting detection with timeout: %ds ... \n " , tmp - > faxdetect_timeout ) ;
2006-08-08 18:13:40 +00:00
return process_ast_dsp ( tmp , & tmp - > frame ) ;
} else {
struct timeval tv_now = ast_tvnow ( ) ;
int diff = ast_tvdiff_ms ( tv_now , tmp - > faxdetect_tv ) ;
if ( diff < = ( tmp - > faxdetect_timeout * 1000 ) ) {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 5 , tmp - > bc - > port , " faxdetect: detecting ... \n " ) ;
2006-08-08 18:13:40 +00:00
return process_ast_dsp ( tmp , & tmp - > frame ) ;
} else {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 2 , tmp - > bc - > port , " faxdetect: stopping detection (time ran out) ... \n " ) ;
2006-08-08 18:13:40 +00:00
tmp - > faxdetect = 0 ;
return & tmp - > frame ;
}
}
} else {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 5 , tmp - > bc - > port , " faxdetect: detecting ... (no timeout) \n " ) ;
2006-08-08 18:13:40 +00:00
return process_ast_dsp ( tmp , & tmp - > frame ) ;
}
} else {
if ( tmp - > ast_dsp )
return process_ast_dsp ( tmp , & tmp - > frame ) ;
else
return & tmp - > frame ;
2006-05-16 14:34:21 +00:00
}
2005-10-31 22:51:12 +00:00
}
2005-12-09 11:01:18 +00:00
static int misdn_write ( struct ast_channel * ast , struct ast_frame * frame )
2005-10-31 22:51:12 +00:00
{
2005-12-09 11:01:18 +00:00
struct chan_list * ch ;
2005-10-31 22:51:12 +00:00
int i = 0 ;
2007-06-06 21:20:11 +00:00
if ( ! ast | | ! ( ch = MISDN_ASTERISK_TECH_PVT ( ast ) ) ) return - 1 ;
2006-10-11 08:23:16 +00:00
if ( ch - > state = = MISDN_HOLDED ) {
chan_misdn_log ( 7 , 0 , " misdn_write: Returning because holded \n " ) ;
return 0 ;
}
2005-10-31 22:51:12 +00:00
2005-12-09 11:01:18 +00:00
if ( ! ch - > bc ) {
2005-10-31 22:51:12 +00:00
ast_log ( LOG_WARNING , " private but no bc \n " ) ;
return - 1 ;
}
2005-12-09 11:01:18 +00:00
if ( ch - > notxtone ) {
2006-07-11 19:30:35 +00:00
chan_misdn_log ( 7 , ch - > bc - > port , " misdn_write: Returning because notxone \n " ) ;
2005-10-31 22:51:12 +00:00
return 0 ;
}
2006-02-02 21:15:34 +00:00
2007-06-06 21:20:11 +00:00
if ( ! frame - > subclass ) {
2006-04-03 19:17:59 +00:00
chan_misdn_log ( 4 , ch - > bc - > port , " misdn_write: * prods us \n " ) ;
2006-02-02 21:15:34 +00:00
return 0 ;
}
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
if ( ! ( frame - > subclass & prefformat ) ) {
2006-02-02 21:15:34 +00:00
2005-12-09 11:01:18 +00:00
chan_misdn_log ( - 1 , ch - > bc - > port , " Got Unsupported Frame with Format:%d \n " , frame - > subclass ) ;
2006-05-05 16:38:15 +00:00
return 0 ;
2005-10-31 22:51:12 +00:00
}
2006-04-03 19:17:59 +00:00
2007-06-06 21:20:11 +00:00
if ( ! frame - > samples ) {
2006-04-03 19:17:59 +00:00
chan_misdn_log ( 4 , ch - > bc - > port , " misdn_write: zero write \n " ) ;
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
2007-05-18 10:03:38 +00:00
if ( ! strcmp ( frame - > src , " ast_prod " ) ) {
chan_misdn_log ( 1 , ch - > bc - > port , " misdn_write: state (%s) prodded. \n " , misdn_get_ch_state ( ch ) ) ;
if ( ch - > ts ) {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 4 , ch - > bc - > port , " Starting Playtones \n " ) ;
2007-05-18 10:03:38 +00:00
misdn_lib_tone_generator_start ( ch - > bc ) ;
}
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
return 0 ;
}
2007-05-18 10:03:38 +00:00
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
return - 1 ;
2006-04-03 19:17:59 +00:00
}
if ( ! ch - > bc - > addr ) {
2006-04-04 19:09:26 +00:00
chan_misdn_log ( 8 , ch - > bc - > port , " misdn_write: no addr for bc dropping:%d \n " , frame - > samples ) ;
2006-04-03 19:17:59 +00:00
return 0 ;
}
2005-10-31 22:51:12 +00:00
2007-02-18 15:03:42 +00:00
# ifdef MISDN_DEBUG
2005-10-31 22:51:12 +00:00
{
2007-06-06 21:20:11 +00:00
int i , max = 5 > frame - > samples ? frame - > samples : 5 ;
2007-06-14 19:39:12 +00:00
ast_debug ( 1 , " write2mISDN %p %d bytes: " , p , frame - > samples ) ;
2007-06-06 21:20:11 +00:00
for ( i = 0 ; i < max ; i + + )
2007-06-14 19:39:12 +00:00
ast_debug ( 1 , " %2.2x " , ( ( char * ) frame - > data ) [ i ] ) ;
2005-10-31 22:51:12 +00:00
}
# endif
2005-12-09 11:01:18 +00:00
2006-04-03 19:17:59 +00:00
switch ( ch - > bc - > bc_state ) {
2007-06-06 21:20:11 +00:00
case BCHAN_ACTIVATED :
case BCHAN_BRIDGED :
break ;
default :
2006-04-29 22:56:00 +00:00
if ( ! ch - > dropped_frame_cnt )
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 5 , ch - > bc - > port , " BC not active (nor bridged) droping: %d frames addr:%x exten:%s cid:%s ch->state:%s bc_state:%d l3id:%x \n " , frame - > samples , ch - > bc - > addr , ast - > exten , ast - > cid . cid_num , misdn_get_ch_state ( ch ) , ch - > bc - > bc_state , ch - > bc - > l3_id ) ;
2006-04-29 22:56:00 +00:00
ch - > dropped_frame_cnt + + ;
if ( ch - > dropped_frame_cnt > 100 ) {
2007-06-06 21:20:11 +00:00
ch - > dropped_frame_cnt = 0 ;
chan_misdn_log ( 5 , ch - > bc - > port , " BC not active (nor bridged) droping: %d frames addr:%x dropped > 100 frames! \n " , frame - > samples , ch - > bc - > addr ) ;
2006-04-29 22:56:00 +00:00
}
2006-02-02 21:15:34 +00:00
return 0 ;
}
2006-05-05 16:38:15 +00:00
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 9 , ch - > bc - > port , " Sending :%d bytes 2 MISDN \n " , frame - > samples ) ;
2005-12-09 11:01:18 +00:00
if ( ! ch - > bc - > nojitter & & misdn_cap_is_speech ( ch - > bc - > capability ) ) {
/* Buffered Transmit (triggert by read from isdn side)*/
2007-06-06 21:20:11 +00:00
if ( misdn_jb_fill ( ch - > jb , frame - > data , frame - > samples ) < 0 ) {
2005-12-09 11:01:18 +00:00
if ( ch - > bc - > active )
2007-06-06 21:20:11 +00:00
cb_log ( 0 , ch - > bc - > port , " Misdn Jitterbuffer Overflow. \n " ) ;
2005-12-09 11:01:18 +00:00
}
} else {
/*transmit without jitterbuffer*/
i = misdn_lib_tx2misdn_frm ( ch - > bc , frame - > data , frame - > samples ) ;
}
2005-10-31 22:51:12 +00:00
return 0 ;
}
2005-12-09 11:01:18 +00:00
2006-04-24 17:11:45 +00:00
static enum ast_bridge_result misdn_bridge ( struct ast_channel * c0 ,
2005-11-01 22:04:14 +00:00
struct ast_channel * c1 , int flags ,
struct ast_frame * * fo ,
struct ast_channel * * rc ,
int timeoutms )
2005-10-31 22:51:12 +00:00
{
2007-06-06 21:20:11 +00:00
struct chan_list * ch1 , * ch2 ;
2005-10-31 22:51:12 +00:00
struct ast_channel * carr [ 2 ] , * who ;
2007-06-06 21:20:11 +00:00
int to = - 1 ;
2005-10-31 22:51:12 +00:00
struct ast_frame * f ;
2007-06-06 21:20:11 +00:00
int p1_b , p2_b ;
int bridging ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
ch1 = get_chan_by_ast ( c0 ) ;
ch2 = get_chan_by_ast ( c1 ) ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
carr [ 0 ] = c0 ;
carr [ 1 ] = c1 ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
if ( ! ( ch1 & & ch2 ) )
2005-10-31 22:51:12 +00:00
return - 1 ;
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( ch1 - > bc - > port , MISDN_CFG_BRIDGING , & p1_b , sizeof ( p1_b ) ) ;
misdn_cfg_get ( ch2 - > bc - > port , MISDN_CFG_BRIDGING , & p2_b , sizeof ( p2_b ) ) ;
2007-06-05 11:48:25 +00:00
2007-06-06 21:20:11 +00:00
if ( ! p1_b | | ! p2_b ) {
2007-06-05 11:48:25 +00:00
ast_log ( LOG_NOTICE , " Falling back to Asterisk bridging \n " ) ;
return AST_BRIDGE_FAILED ;
}
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( 0 , MISDN_GEN_BRIDGING , & bridging , sizeof ( bridging ) ) ;
2005-10-31 22:51:12 +00:00
if ( bridging ) {
/* trying to make a mISDN_dsp conference */
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , ch1 - > bc - > port , " I SEND: Making conference with Number:%d \n " , ch1 - > bc - > pid + 1 ) ;
misdn_lib_bridge ( ch1 - > bc , ch2 - > bc ) ;
2005-10-31 22:51:12 +00:00
}
2007-06-06 21:20:11 +00:00
2007-07-26 15:49:18 +00:00
ast_verb ( 3 , " Native bridging %s and %s \n " , c0 - > name , c1 - > name ) ;
2006-01-17 05:15:33 +00:00
2006-06-07 13:01:02 +00:00
chan_misdn_log ( 1 , ch1 - > bc - > port , " * Making Native Bridge between %s and %s \n " , ch1 - > bc - > oad , ch2 - > bc - > oad ) ;
2006-06-08 09:51:13 +00:00
2007-06-06 21:20:11 +00:00
if ( ! ( flags & AST_BRIDGE_DTMF_CHANNEL_0 ) )
ch1 - > ignore_dtmf = 1 ;
2006-06-08 09:51:13 +00:00
2007-06-06 21:20:11 +00:00
if ( ! ( flags & AST_BRIDGE_DTMF_CHANNEL_1 ) )
ch2 - > ignore_dtmf = 1 ;
2006-06-08 09:51:13 +00:00
2007-06-06 21:20:11 +00:00
for ( ; /*ever*/ ; ) {
to = - 1 ;
2005-10-31 22:51:12 +00:00
who = ast_waitfor_n ( carr , 2 , & to ) ;
2005-11-08 00:02:53 +00:00
if ( ! who ) {
2007-06-06 21:20:11 +00:00
ast_log ( LOG_NOTICE , " misdn_bridge: empty read, breaking out \n " ) ;
2006-04-07 09:31:27 +00:00
break ;
2005-11-08 00:02:53 +00:00
}
2005-10-31 22:51:12 +00:00
f = ast_read ( who ) ;
2007-06-06 21:20:11 +00:00
2005-10-31 22:51:12 +00:00
if ( ! f | | f - > frametype = = AST_FRAME_CONTROL ) {
/* got hangup .. */
2006-06-30 14:09:52 +00:00
if ( ! f )
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 4 , ch1 - > bc - > port , " Read Null Frame \n " ) ;
2006-06-30 14:09:52 +00:00
else
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 4 , ch1 - > bc - > port , " Read Frame Controll class:%d \n " , f - > subclass ) ;
* fo = f ;
* rc = who ;
2005-10-31 22:51:12 +00:00
break ;
}
2006-06-08 09:51:13 +00:00
if ( f - > frametype = = AST_FRAME_DTMF ) {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , 0 , " Read DTMF %d from %s \n " , f - > subclass , who - > exten ) ;
2006-06-08 09:51:13 +00:00
2007-06-06 21:20:11 +00:00
* fo = f ;
* rc = who ;
2006-06-08 09:51:13 +00:00
break ;
}
2006-10-27 11:18:32 +00:00
#if 0
2006-10-13 15:42:09 +00:00
if ( f - > frametype = = AST_FRAME_VOICE ) {
2006-10-27 11:18:32 +00:00
chan_misdn_log ( 1 , ch1 - > bc - > port , " I SEND: Splitting conference with Number:%d \n " , ch1 - > bc - > pid + 1 ) ;
2006-10-13 15:42:09 +00:00
continue ;
}
2006-10-27 11:18:32 +00:00
# endif
2006-10-13 15:42:09 +00:00
2005-10-31 22:51:12 +00:00
if ( who = = c0 ) {
2007-06-06 21:20:11 +00:00
ast_write ( c1 , f ) ;
2005-10-31 22:51:12 +00:00
}
else {
2007-06-06 21:20:11 +00:00
ast_write ( c0 , f ) ;
2005-10-31 22:51:12 +00:00
}
}
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , ch1 - > bc - > port , " I SEND: Splitting conference with Number:%d \n " , ch1 - > bc - > pid + 1 ) ;
misdn_lib_split_bridge ( ch1 - > bc , ch2 - > bc ) ;
2006-06-08 09:51:13 +00:00
return AST_BRIDGE_COMPLETE ;
2005-10-31 22:51:12 +00:00
}
/** AST INDICATIONS END **/
2006-07-06 15:11:40 +00:00
static int dialtone_indicate ( struct chan_list * cl )
2006-02-02 21:15:34 +00:00
{
2007-06-06 21:20:11 +00:00
const struct ind_tone_zone_sound * ts = NULL ;
struct ast_channel * ast = cl - > ast ;
int nd = 0 ;
2006-07-13 14:13:24 +00:00
Merged revisions 49313 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r49313 | crichter | 2007-01-03 10:06:50 +0100 (Mi, 03 Jan 2007) | 41 lines
Merged revisions 48319,48321,48467,48552,48576,49135,49303 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r48319 | crichter | 2006-12-06 15:35:25 +0100 (Mi, 06 Dez 2006) | 1 line
changed a few debugs to higher debug levels
........
r48321 | crichter | 2006-12-06 16:48:45 +0100 (Mi, 06 Dez 2006) | 1 line
added the export and import of the MISDN_ADDRESS_COMPLETE Variable to inidcate wether the extension is already completely dialed or if there might come additional digits by information elements. also added some docs for that.
........
r48467 | crichter | 2006-12-14 14:03:49 +0100 (Do, 14 Dez 2006) | 1 line
removed FIXUP state. added check for channel allocation conflict when we create a setup while the other site creates a setup on the same channel, besides the check we resolve this conflict.
........
r48552 | crichter | 2006-12-18 11:19:39 +0100 (Mo, 18 Dez 2006) | 1 line
when our PTP Partner sends us a SETUP with a preselected channel we just accept it, even when we're NT. added some checks for segfaults.
........
r48576 | crichter | 2006-12-19 14:08:51 +0100 (Di, 19 Dez 2006) | 1 line
when we reject a channel, because it's in use already, we shouldn't process the setup anymore. made the channel allocation a bit easier and more understandable, removed a few unused lines
........
r49135 | crichter | 2007-01-02 11:07:22 +0100 (Di, 02 Jan 2007) | 1 line
added check for channel ranges in the set/empty channel functions. set pmp_l1_check default to no. added misdn restart pid cli command. added cleaning of channel when we send a RELEASE_COMPLETE.
........
r49303 | crichter | 2007-01-03 09:24:00 +0100 (Mi, 03 Jan 2007) | 9 lines
* Added check for bridging in misdn_call to avoid setting echocancellation
when 2 mISDN channels are involved and when bridging is set. That lead
to a kernel panic before under different situations, because we switched
about 2 times between hardware bridging and echocancelation
* readded MISDN_URATE variable which got lost before, this should make app_v110
work again
* fixed typo
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-03 11:15:02 +00:00
if ( ! ast ) {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 0 , cl - > bc - > port , " No Ast in dialtone_indicate \n " ) ;
Merged revisions 49313 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r49313 | crichter | 2007-01-03 10:06:50 +0100 (Mi, 03 Jan 2007) | 41 lines
Merged revisions 48319,48321,48467,48552,48576,49135,49303 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r48319 | crichter | 2006-12-06 15:35:25 +0100 (Mi, 06 Dez 2006) | 1 line
changed a few debugs to higher debug levels
........
r48321 | crichter | 2006-12-06 16:48:45 +0100 (Mi, 06 Dez 2006) | 1 line
added the export and import of the MISDN_ADDRESS_COMPLETE Variable to inidcate wether the extension is already completely dialed or if there might come additional digits by information elements. also added some docs for that.
........
r48467 | crichter | 2006-12-14 14:03:49 +0100 (Do, 14 Dez 2006) | 1 line
removed FIXUP state. added check for channel allocation conflict when we create a setup while the other site creates a setup on the same channel, besides the check we resolve this conflict.
........
r48552 | crichter | 2006-12-18 11:19:39 +0100 (Mo, 18 Dez 2006) | 1 line
when our PTP Partner sends us a SETUP with a preselected channel we just accept it, even when we're NT. added some checks for segfaults.
........
r48576 | crichter | 2006-12-19 14:08:51 +0100 (Di, 19 Dez 2006) | 1 line
when we reject a channel, because it's in use already, we shouldn't process the setup anymore. made the channel allocation a bit easier and more understandable, removed a few unused lines
........
r49135 | crichter | 2007-01-02 11:07:22 +0100 (Di, 02 Jan 2007) | 1 line
added check for channel ranges in the set/empty channel functions. set pmp_l1_check default to no. added misdn restart pid cli command. added cleaning of channel when we send a RELEASE_COMPLETE.
........
r49303 | crichter | 2007-01-03 09:24:00 +0100 (Mi, 03 Jan 2007) | 9 lines
* Added check for bridging in misdn_call to avoid setting echocancellation
when 2 mISDN channels are involved and when bridging is set. That lead
to a kernel panic before under different situations, because we switched
about 2 times between hardware bridging and echocancelation
* readded MISDN_URATE variable which got lost before, this should make app_v110
work again
* fixed typo
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-03 11:15:02 +00:00
return - 1 ;
}
2006-07-13 14:13:24 +00:00
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( cl - > bc - > port , MISDN_CFG_NODIALTONE , & nd , sizeof ( nd ) ) ;
2006-07-13 14:13:24 +00:00
if ( nd ) {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , cl - > bc - > port , " Not sending Dialtone, because config wants it \n " ) ;
2006-07-13 14:13:24 +00:00
return 0 ;
}
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 3 , cl - > bc - > port , " --> Dial \n " ) ;
ts = ast_get_indication_tone ( ast - > zone , " dial " ) ;
cl - > ts = ts ;
2006-02-02 21:15:34 +00:00
2006-06-26 17:37:11 +00:00
if ( ts ) {
2007-06-06 21:20:11 +00:00
cl - > notxtone = 0 ;
cl - > norxtone = 0 ;
2007-05-18 10:03:38 +00:00
/* This prods us in misdn_write */
2007-06-06 21:20:11 +00:00
ast_playtones_start ( ast , 0 , ts - > data , 0 ) ;
2006-06-26 17:37:11 +00:00
}
2006-07-06 15:11:40 +00:00
return 0 ;
}
static int hanguptone_indicate ( struct chan_list * cl )
{
2007-06-06 21:20:11 +00:00
misdn_lib_send_tone ( cl - > bc , TONE_HANGUP ) ;
2006-07-06 15:11:40 +00:00
return 0 ;
}
static int stop_indicate ( struct chan_list * cl )
{
2007-06-06 21:20:11 +00:00
struct ast_channel * ast = cl - > ast ;
Merged revisions 49313 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r49313 | crichter | 2007-01-03 10:06:50 +0100 (Mi, 03 Jan 2007) | 41 lines
Merged revisions 48319,48321,48467,48552,48576,49135,49303 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r48319 | crichter | 2006-12-06 15:35:25 +0100 (Mi, 06 Dez 2006) | 1 line
changed a few debugs to higher debug levels
........
r48321 | crichter | 2006-12-06 16:48:45 +0100 (Mi, 06 Dez 2006) | 1 line
added the export and import of the MISDN_ADDRESS_COMPLETE Variable to inidcate wether the extension is already completely dialed or if there might come additional digits by information elements. also added some docs for that.
........
r48467 | crichter | 2006-12-14 14:03:49 +0100 (Do, 14 Dez 2006) | 1 line
removed FIXUP state. added check for channel allocation conflict when we create a setup while the other site creates a setup on the same channel, besides the check we resolve this conflict.
........
r48552 | crichter | 2006-12-18 11:19:39 +0100 (Mo, 18 Dez 2006) | 1 line
when our PTP Partner sends us a SETUP with a preselected channel we just accept it, even when we're NT. added some checks for segfaults.
........
r48576 | crichter | 2006-12-19 14:08:51 +0100 (Di, 19 Dez 2006) | 1 line
when we reject a channel, because it's in use already, we shouldn't process the setup anymore. made the channel allocation a bit easier and more understandable, removed a few unused lines
........
r49135 | crichter | 2007-01-02 11:07:22 +0100 (Di, 02 Jan 2007) | 1 line
added check for channel ranges in the set/empty channel functions. set pmp_l1_check default to no. added misdn restart pid cli command. added cleaning of channel when we send a RELEASE_COMPLETE.
........
r49303 | crichter | 2007-01-03 09:24:00 +0100 (Mi, 03 Jan 2007) | 9 lines
* Added check for bridging in misdn_call to avoid setting echocancellation
when 2 mISDN channels are involved and when bridging is set. That lead
to a kernel panic before under different situations, because we switched
about 2 times between hardware bridging and echocancelation
* readded MISDN_URATE variable which got lost before, this should make app_v110
work again
* fixed typo
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-03 11:15:02 +00:00
if ( ! ast ) {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 0 , cl - > bc - > port , " No Ast in stop_indicate \n " ) ;
Merged revisions 49313 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r49313 | crichter | 2007-01-03 10:06:50 +0100 (Mi, 03 Jan 2007) | 41 lines
Merged revisions 48319,48321,48467,48552,48576,49135,49303 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r48319 | crichter | 2006-12-06 15:35:25 +0100 (Mi, 06 Dez 2006) | 1 line
changed a few debugs to higher debug levels
........
r48321 | crichter | 2006-12-06 16:48:45 +0100 (Mi, 06 Dez 2006) | 1 line
added the export and import of the MISDN_ADDRESS_COMPLETE Variable to inidcate wether the extension is already completely dialed or if there might come additional digits by information elements. also added some docs for that.
........
r48467 | crichter | 2006-12-14 14:03:49 +0100 (Do, 14 Dez 2006) | 1 line
removed FIXUP state. added check for channel allocation conflict when we create a setup while the other site creates a setup on the same channel, besides the check we resolve this conflict.
........
r48552 | crichter | 2006-12-18 11:19:39 +0100 (Mo, 18 Dez 2006) | 1 line
when our PTP Partner sends us a SETUP with a preselected channel we just accept it, even when we're NT. added some checks for segfaults.
........
r48576 | crichter | 2006-12-19 14:08:51 +0100 (Di, 19 Dez 2006) | 1 line
when we reject a channel, because it's in use already, we shouldn't process the setup anymore. made the channel allocation a bit easier and more understandable, removed a few unused lines
........
r49135 | crichter | 2007-01-02 11:07:22 +0100 (Di, 02 Jan 2007) | 1 line
added check for channel ranges in the set/empty channel functions. set pmp_l1_check default to no. added misdn restart pid cli command. added cleaning of channel when we send a RELEASE_COMPLETE.
........
r49303 | crichter | 2007-01-03 09:24:00 +0100 (Mi, 03 Jan 2007) | 9 lines
* Added check for bridging in misdn_call to avoid setting echocancellation
when 2 mISDN channels are involved and when bridging is set. That lead
to a kernel panic before under different situations, because we switched
about 2 times between hardware bridging and echocancelation
* readded MISDN_URATE variable which got lost before, this should make app_v110
work again
* fixed typo
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-03 11:15:02 +00:00
return - 1 ;
}
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 3 , cl - > bc - > port , " --> None \n " ) ;
2006-07-06 15:11:40 +00:00
misdn_lib_tone_generator_stop ( cl - > bc ) ;
ast_playtones_stop ( ast ) ;
2007-05-24 09:51:01 +00:00
2007-06-06 21:20:11 +00:00
cl - > ts = NULL ;
2006-07-06 15:11:40 +00:00
/*ast_deactivate_generator(ast);*/
2007-06-06 21:20:11 +00:00
2006-02-02 21:15:34 +00:00
return 0 ;
}
2006-07-06 15:11:40 +00:00
2005-10-31 22:51:12 +00:00
static int start_bc_tones ( struct chan_list * cl )
{
2006-02-02 21:15:34 +00:00
misdn_lib_tone_generator_stop ( cl - > bc ) ;
2007-06-06 21:20:11 +00:00
cl - > notxtone = 0 ;
cl - > norxtone = 0 ;
2005-10-31 22:51:12 +00:00
return 0 ;
}
static int stop_bc_tones ( struct chan_list * cl )
{
2006-07-06 15:11:40 +00:00
if ( ! cl ) return - 1 ;
2007-06-06 21:20:11 +00:00
cl - > notxtone = 1 ;
cl - > norxtone = 1 ;
2005-10-31 22:51:12 +00:00
return 0 ;
}
2006-05-17 15:29:01 +00:00
static struct chan_list * init_chan_list ( int orig )
2005-10-31 22:51:12 +00:00
{
2007-06-06 21:20:11 +00:00
struct chan_list * cl ;
cl = ast_calloc ( 1 , sizeof ( * cl ) ) ;
2005-10-31 22:51:12 +00:00
if ( ! cl ) {
2005-12-09 11:01:18 +00:00
chan_misdn_log ( - 1 , 0 , " misdn_request: malloc failed! " ) ;
2005-10-31 22:51:12 +00:00
return NULL ;
}
2007-06-06 21:20:11 +00:00
cl - > originator = orig ;
cl - > need_queue_hangup = 1 ;
cl - > need_hangup = 1 ;
cl - > need_busy = 1 ;
cl - > overlap_dial_task = - 1 ;
2006-05-17 15:29:01 +00:00
2005-10-31 22:51:12 +00:00
return cl ;
}
static struct ast_channel * misdn_request ( const char * type , int format , void * data , int * cause )
{
struct ast_channel * tmp = NULL ;
2007-06-06 21:20:11 +00:00
char group [ BUFFERSIZE + 1 ] = " " ;
2005-10-31 22:51:12 +00:00
char buf [ 128 ] ;
2007-06-06 21:20:11 +00:00
char * buf2 = ast_strdupa ( data ) , * ext = NULL , * port_str ;
char * tokb = NULL , * p = NULL ;
int channel = 0 , port = 0 ;
2005-10-31 22:51:12 +00:00
struct misdn_bchannel * newbc = NULL ;
2007-06-06 21:20:11 +00:00
int dec = 0 ;
struct chan_list * cl = init_chan_list ( ORG_AST ) ;
snprintf ( buf , sizeof ( buf ) , " %s/%s " , misdn_type , ( char * ) data ) ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
port_str = strtok_r ( buf2 , " / " , & tokb ) ;
ext = strtok_r ( NULL , " / " , & tokb ) ;
2005-11-15 20:20:45 +00:00
2005-10-31 22:51:12 +00:00
if ( port_str ) {
2007-06-06 21:20:11 +00:00
if ( port_str [ 0 ] = = ' g ' & & port_str [ 1 ] = = ' : ' ) {
2005-10-31 22:51:12 +00:00
/* We make a group call lets checkout which ports are in my group */
port_str + = 2 ;
2007-06-06 21:20:11 +00:00
ast_copy_string ( group , port_str , sizeof ( group ) ) ;
chan_misdn_log ( 2 , 0 , " --> Group Call group: %s \n " , group ) ;
} else if ( ( p = strchr ( port_str , ' : ' ) ) ) {
2006-06-17 10:37:35 +00:00
/* we have a preselected channel */
2005-10-31 22:51:12 +00:00
* p = 0 ;
channel = atoi ( + + p ) ;
port = atoi ( port_str ) ;
2005-12-09 11:01:18 +00:00
chan_misdn_log ( 2 , port , " --> Call on preselected Channel (%d). \n " , channel ) ;
2007-06-06 21:20:11 +00:00
} else {
2005-10-31 22:51:12 +00:00
port = atoi ( port_str ) ;
}
} else {
2007-06-06 21:20:11 +00:00
ast_log ( LOG_WARNING , " --> ! IND : CALL dad:%s WITHOUT PORT/Group, check extensions.conf \n " , ext ) ;
2005-10-31 22:51:12 +00:00
return NULL ;
}
2007-05-18 09:36:16 +00:00
if ( misdn_cfg_is_group_method ( group , METHOD_STANDARD_DEC ) ) {
chan_misdn_log ( 4 , port , " --> STARTING STANDARDDEC... \n " ) ;
2007-06-06 21:20:11 +00:00
dec = 1 ;
2007-05-18 09:36:16 +00:00
}
2005-10-31 22:51:12 +00:00
if ( ! ast_strlen_zero ( group ) ) {
2007-06-06 21:20:11 +00:00
char cfg_group [ BUFFERSIZE + 1 ] ;
2005-10-31 22:51:12 +00:00
struct robin_list * rr = NULL ;
if ( misdn_cfg_is_group_method ( group , METHOD_ROUND_ROBIN ) ) {
2007-05-18 09:36:16 +00:00
chan_misdn_log ( 4 , port , " --> STARTING ROUND ROBIN... \n " ) ;
2005-10-31 22:51:12 +00:00
rr = get_robin_position ( group ) ;
}
2007-06-06 21:20:11 +00:00
2005-10-31 22:51:12 +00:00
if ( rr ) {
int robin_channel = rr - > channel ;
int port_start ;
int next_chan = 1 ;
do {
port_start = 0 ;
for ( port = misdn_cfg_get_next_port_spin ( rr - > port ) ; port > 0 & & port ! = port_start ;
port = misdn_cfg_get_next_port_spin ( port ) ) {
if ( ! port_start )
port_start = port ;
if ( port > = port_start )
next_chan = 1 ;
2006-06-21 15:21:46 +00:00
if ( port < = port_start & & next_chan ) {
2006-06-26 17:37:11 +00:00
int maxbchans = misdn_lib_get_maxchans ( port ) ;
if ( + + robin_channel > = maxbchans ) {
2005-10-31 22:51:12 +00:00
robin_channel = 1 ;
}
next_chan = 0 ;
}
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( port , MISDN_CFG_GROUPNAME , cfg_group , sizeof ( cfg_group ) ) ;
2005-10-31 22:51:12 +00:00
if ( ! strcasecmp ( cfg_group , group ) ) {
2006-02-02 21:15:34 +00:00
int port_up ;
2006-08-03 16:38:00 +00:00
int check ;
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( port , MISDN_CFG_PMP_L1_CHECK , & check , sizeof ( check ) ) ;
2006-02-15 19:32:45 +00:00
port_up = misdn_lib_port_up ( port , check ) ;
2006-06-21 15:21:46 +00:00
if ( check & & ! port_up )
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , port , " L1 is not Up on this Port \n " ) ;
2006-06-21 15:21:46 +00:00
2007-06-06 21:20:11 +00:00
if ( check & & port_up < 0 ) {
ast_log ( LOG_WARNING , " This port (%d) is blocked \n " , port ) ;
2006-08-03 16:38:00 +00:00
}
2007-06-06 21:20:11 +00:00
if ( port_up > 0 ) {
newbc = misdn_lib_get_free_bc ( port , robin_channel , 0 , 0 ) ;
2005-10-31 22:51:12 +00:00
if ( newbc ) {
2005-11-01 22:04:14 +00:00
chan_misdn_log ( 4 , port , " Success! Found port:%d channel:%d \n " , newbc - > port , newbc - > channel ) ;
2005-10-31 22:51:12 +00:00
if ( port_up )
2006-06-21 15:21:46 +00:00
chan_misdn_log ( 4 , port , " portup:%d \n " , port_up ) ;
2005-11-01 22:04:14 +00:00
rr - > port = newbc - > port ;
2005-10-31 22:51:12 +00:00
rr - > channel = newbc - > channel ;
break ;
}
}
}
}
} while ( ! newbc & & robin_channel ! = rr - > channel ) ;
2007-05-18 09:36:16 +00:00
} else {
2007-06-06 21:20:11 +00:00
for ( port = misdn_cfg_get_next_port ( 0 ) ; port > 0 ;
port = misdn_cfg_get_next_port ( port ) ) {
misdn_cfg_get ( port , MISDN_CFG_GROUPNAME , cfg_group , sizeof ( cfg_group ) ) ;
2006-02-15 19:32:45 +00:00
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 3 , port , " Group [%s] Port [%d] \n " , group , port ) ;
2005-10-31 22:51:12 +00:00
if ( ! strcasecmp ( cfg_group , group ) ) {
2006-02-02 21:15:34 +00:00
int port_up ;
2006-08-03 16:38:00 +00:00
int check ;
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( port , MISDN_CFG_PMP_L1_CHECK , & check , sizeof ( check ) ) ;
2006-02-15 19:32:45 +00:00
port_up = misdn_lib_port_up ( port , check ) ;
2007-06-06 21:20:11 +00:00
2006-02-02 21:15:34 +00:00
chan_misdn_log ( 4 , port , " portup:%d \n " , port_up ) ;
2007-06-06 21:20:11 +00:00
if ( port_up > 0 ) {
2007-05-18 09:36:16 +00:00
newbc = misdn_lib_get_free_bc ( port , 0 , 0 , dec ) ;
2005-10-31 22:51:12 +00:00
if ( newbc )
break ;
}
}
}
}
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
/* Group dial failed ?*/
if ( ! newbc ) {
ast_log ( LOG_WARNING ,
" Could not Dial out on group '%s'. \n "
" \t Either the L2 and L1 on all of these ports where DOWN (see 'show application misdn_check_l2l1') \n "
" \t Or there was no free channel on none of the ports \n \n "
, group ) ;
return NULL ;
}
} else { /* 'Normal' Port dial * Port dial */
2005-10-31 22:51:12 +00:00
if ( channel )
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , port , " --> preselected_channel: %d \n " , channel ) ;
2007-05-18 09:36:16 +00:00
newbc = misdn_lib_get_free_bc ( port , channel , 0 , dec ) ;
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
if ( ! newbc ) {
2007-06-06 21:20:11 +00:00
ast_log ( LOG_WARNING , " Could not create channel on port:%d with extensions:%s \n " , port , ext ) ;
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
return NULL ;
}
2005-10-31 22:51:12 +00:00
}
2005-12-09 11:01:18 +00:00
/* create ast_channel and link all the objects together */
2007-06-06 21:20:11 +00:00
cl - > bc = newbc ;
2005-10-31 22:51:12 +00:00
2005-12-09 11:01:18 +00:00
tmp = misdn_new ( cl , AST_STATE_RESERVED , ext , NULL , format , port , channel ) ;
2007-06-11 17:05:48 +00:00
if ( ! tmp ) {
ast_log ( LOG_ERROR , " Could not create Asterisk object \n " ) ;
return NULL ;
}
cl - > ast = tmp ;
2005-12-09 11:01:18 +00:00
/* register chan in local list */
cl_queue_chan ( & cl_te , cl ) ;
/* fill in the config into the objects */
read_config ( cl , ORG_AST ) ;
2006-07-06 15:11:40 +00:00
/* important */
2007-06-06 21:20:11 +00:00
cl - > need_hangup = 0 ;
2005-10-31 22:51:12 +00:00
return tmp ;
}
2007-06-06 21:20:11 +00:00
static int misdn_send_text ( struct ast_channel * chan , const char * text )
2006-02-02 21:15:34 +00:00
{
2007-06-06 21:20:11 +00:00
struct chan_list * tmp = chan - > tech_pvt ;
2006-02-02 21:15:34 +00:00
if ( tmp & & tmp - > bc ) {
2007-06-06 21:20:11 +00:00
ast_copy_string ( tmp - > bc - > display , text , sizeof ( tmp - > bc - > display ) ) ;
2006-02-02 21:15:34 +00:00
misdn_lib_send_event ( tmp - > bc , EVENT_INFORMATION ) ;
} else {
ast_log ( LOG_WARNING , " No chan_list but send_text request? \n " ) ;
return - 1 ;
}
return 0 ;
}
2005-12-09 11:01:18 +00:00
static struct ast_channel_tech misdn_tech = {
2007-06-06 21:20:11 +00:00
. type = " mISDN " ,
. description = " Channel driver for mISDN Support (Bri/Pri) " ,
. capabilities = AST_FORMAT_ALAW ,
. requester = misdn_request ,
. send_digit_begin = misdn_digit_begin ,
. send_digit_end = misdn_digit_end ,
. call = misdn_call ,
. bridge = misdn_bridge ,
. hangup = misdn_hangup ,
. answer = misdn_answer ,
. read = misdn_read ,
. write = misdn_write ,
. indicate = misdn_indication ,
. fixup = misdn_fixup ,
. send_text = misdn_send_text ,
. properties = 0
2005-10-31 22:51:12 +00:00
} ;
2005-12-09 11:01:18 +00:00
static struct ast_channel_tech misdn_tech_wo_bridge = {
2007-06-06 21:20:11 +00:00
. type = " mISDN " ,
. description = " Channel driver for mISDN Support (Bri/Pri) " ,
. capabilities = AST_FORMAT_ALAW ,
. requester = misdn_request ,
. send_digit_begin = misdn_digit_begin ,
. send_digit_end = misdn_digit_end ,
. call = misdn_call ,
. hangup = misdn_hangup ,
. answer = misdn_answer ,
. read = misdn_read ,
. write = misdn_write ,
. indicate = misdn_indication ,
. fixup = misdn_fixup ,
. send_text = misdn_send_text ,
. properties = 0
2005-10-31 22:51:12 +00:00
} ;
2007-06-06 21:20:11 +00:00
static int glob_channel = 0 ;
2005-10-31 22:51:12 +00:00
2006-05-24 23:21:03 +00:00
static void update_name ( struct ast_channel * tmp , int port , int c )
{
2007-06-06 21:20:11 +00:00
int chan_offset = 0 ;
2006-08-07 09:09:17 +00:00
int tmp_port = misdn_cfg_get_next_port ( 0 ) ;
2007-06-06 21:20:11 +00:00
for ( ; tmp_port > 0 ; tmp_port = misdn_cfg_get_next_port ( tmp_port ) ) {
if ( tmp_port = = port )
break ;
chan_offset + = misdn_lib_port_is_pri ( tmp_port ) ? 30 : 2 ;
2006-05-24 23:21:03 +00:00
}
2007-06-06 21:20:11 +00:00
if ( c < 0 )
c = 0 ;
2006-08-07 09:09:17 +00:00
ast_string_field_build ( tmp , name , " %s/%d-u%d " ,
misdn_type , chan_offset + c , glob_channel + + ) ;
2006-05-24 23:21:03 +00:00
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 3 , port , " --> updating channel name to [%s] \n " , tmp - > name ) ;
2006-05-24 23:21:03 +00:00
}
2005-12-09 11:01:18 +00:00
static struct ast_channel * misdn_new ( struct chan_list * chlist , int state , char * exten , char * callerid , int format , int port , int c )
2005-10-31 22:51:12 +00:00
{
struct ast_channel * tmp ;
2006-11-07 21:47:49 +00:00
char * cid_name = 0 , * cid_num = 0 ;
2007-06-06 21:20:11 +00:00
int chan_offset = 0 ;
2006-11-07 21:47:49 +00:00
int tmp_port = misdn_cfg_get_next_port ( 0 ) ;
2007-06-06 21:20:11 +00:00
int bridging ;
2006-11-07 21:47:49 +00:00
2007-06-06 21:20:11 +00:00
for ( ; tmp_port > 0 ; tmp_port = misdn_cfg_get_next_port ( tmp_port ) ) {
if ( tmp_port = = port )
break ;
chan_offset + = misdn_lib_port_is_pri ( tmp_port ) ? 30 : 2 ;
2006-11-07 21:47:49 +00:00
}
2007-06-06 21:20:11 +00:00
if ( c < 0 )
c = 0 ;
2006-11-07 21:47:49 +00:00
if ( callerid )
ast_callerid_parse ( callerid , & cid_name , & cid_num ) ;
2007-04-10 05:41:34 +00:00
tmp = ast_channel_alloc ( 1 , state , cid_num , cid_name , " " , exten , " " , 0 , " %s/%d-u%d " , misdn_type , chan_offset + c , glob_channel + + ) ;
2007-06-06 21:20:11 +00:00
2005-10-31 22:51:12 +00:00
if ( tmp ) {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 2 , 0 , " --> * NEW CHANNEL dad:%s oad:%s \n " , exten , callerid ) ;
2005-10-31 22:51:12 +00:00
tmp - > nativeformats = prefformat ;
2005-12-09 11:01:18 +00:00
2005-10-31 22:51:12 +00:00
tmp - > readformat = format ;
2006-05-05 16:38:15 +00:00
tmp - > rawreadformat = format ;
2005-10-31 22:51:12 +00:00
tmp - > writeformat = format ;
2006-05-05 16:38:15 +00:00
tmp - > rawwriteformat = format ;
2005-10-31 22:51:12 +00:00
tmp - > tech_pvt = chlist ;
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( 0 , MISDN_GEN_BRIDGING , & bridging , sizeof ( bridging ) ) ;
2005-10-31 22:51:12 +00:00
if ( bridging )
tmp - > tech = & misdn_tech ;
else
tmp - > tech = & misdn_tech_wo_bridge ;
2007-06-06 21:20:11 +00:00
2005-10-31 22:51:12 +00:00
tmp - > writeformat = format ;
tmp - > readformat = format ;
tmp - > priority = 1 ;
2007-06-06 21:20:11 +00:00
2005-11-15 20:20:45 +00:00
if ( exten )
2007-06-06 21:20:11 +00:00
ast_copy_string ( tmp - > exten , exten , sizeof ( tmp - > exten ) ) ;
2005-11-15 20:20:45 +00:00
else
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , 0 , " misdn_new: no exten given. \n " ) ;
2007-08-13 14:22:46 +00:00
if ( callerid )
2006-08-05 05:26:29 +00:00
/* Don't use ast_set_callerid() here because it will
2006-11-07 21:47:49 +00:00
* generate a needless NewCallerID event */
2006-08-05 05:26:29 +00:00
tmp - > cid . cid_ani = ast_strdup ( cid_num ) ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
if ( pipe ( chlist - > pipe ) < 0 )
ast_log ( LOG_ERROR , " Pipe failed \n " ) ;
2007-08-08 21:44:58 +00:00
ast_channel_set_fd ( tmp , 0 , chlist - > pipe [ 0 ] ) ;
2007-06-06 21:20:11 +00:00
2005-10-31 22:51:12 +00:00
if ( state = = AST_STATE_RING )
tmp - > rings = 1 ;
else
tmp - > rings = 0 ;
2005-12-09 11:01:18 +00:00
2007-07-05 07:45:21 +00:00
ast_jb_configure ( tmp , misdn_get_global_jbconf ( ) ) ;
2005-11-01 22:04:14 +00:00
} else {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( - 1 , 0 , " Unable to allocate channel structure \n " ) ;
2005-11-01 22:04:14 +00:00
}
2005-10-31 22:51:12 +00:00
return tmp ;
}
2005-12-09 11:01:18 +00:00
static struct chan_list * find_chan_by_bc ( struct chan_list * list , struct misdn_bchannel * bc )
2005-10-31 22:51:12 +00:00
{
2007-06-06 21:20:11 +00:00
struct chan_list * help = list ;
for ( ; help ; help = help - > next ) {
2005-10-31 22:51:12 +00:00
if ( help - > bc = = bc ) return help ;
}
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 6 , bc - > port , " $$$ find_chan: No channel found for oad:%s dad:%s \n " , bc - > oad , bc - > dad ) ;
2005-10-31 22:51:12 +00:00
return NULL ;
}
2006-06-17 10:37:35 +00:00
static struct chan_list * find_chan_by_pid ( struct chan_list * list , int pid )
{
2007-06-06 21:20:11 +00:00
struct chan_list * help = list ;
for ( ; help ; help = help - > next ) {
2006-10-11 08:45:40 +00:00
if ( help - > bc & & ( help - > bc - > pid = = pid ) ) return help ;
2006-06-17 10:37:35 +00:00
}
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 6 , 0 , " $$$ find_chan: No channel found for pid:%d \n " , pid ) ;
2006-06-17 10:37:35 +00:00
return NULL ;
}
2005-10-31 22:51:12 +00:00
2005-12-09 11:01:18 +00:00
static struct chan_list * find_holded ( struct chan_list * list , struct misdn_bchannel * bc )
2005-10-31 22:51:12 +00:00
{
2007-06-06 21:20:11 +00:00
struct chan_list * help = list ;
2007-06-25 09:37:49 +00:00
if ( bc - > pri ) return NULL ;
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 6 , bc - > port , " $$$ find_holded: channel:%d oad:%s dad:%s \n " , bc - > channel , bc - > oad , bc - > dad ) ;
for ( ; help ; help = help - > next ) {
chan_misdn_log ( 4 , bc - > port , " $$$ find_holded: --> holded:%d channel:%d \n " , help - > state = = MISDN_HOLDED , help - > hold_info . channel ) ;
2006-10-11 08:23:16 +00:00
if ( ( help - > state = = MISDN_HOLDED ) & &
( help - > hold_info . port = = bc - > port ) )
return help ;
2007-06-06 21:20:11 +00:00
}
chan_misdn_log ( 6 , bc - > port , " $$$ find_chan: No channel found for oad:%s dad:%s \n " , bc - > oad , bc - > dad ) ;
2005-10-31 22:51:12 +00:00
return NULL ;
}
2006-10-11 08:23:16 +00:00
static struct chan_list * find_holded_l3 ( struct chan_list * list , unsigned long l3_id , int w )
{
2007-06-06 21:20:11 +00:00
struct chan_list * help = list ;
2006-10-11 08:23:16 +00:00
2007-06-06 21:20:11 +00:00
for ( ; help ; help = help - > next ) {
2006-10-11 08:23:16 +00:00
if ( ( help - > state = = MISDN_HOLDED ) & &
( help - > l3id = = l3_id )
)
return help ;
}
2006-10-13 19:24:02 +00:00
return NULL ;
2006-10-11 08:23:16 +00:00
}
2005-12-09 11:01:18 +00:00
static void cl_queue_chan ( struct chan_list * * list , struct chan_list * chan )
2005-10-31 22:51:12 +00:00
{
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 4 , chan - > bc ? chan - > bc - > port : 0 , " * Queuing chan %p \n " , chan ) ;
2005-10-31 22:51:12 +00:00
2005-11-01 22:04:14 +00:00
ast_mutex_lock ( & cl_te_lock ) ;
2005-10-31 22:51:12 +00:00
if ( ! * list ) {
* list = chan ;
} else {
2007-06-06 21:20:11 +00:00
struct chan_list * help = * list ;
for ( ; help - > next ; help = help - > next ) ;
help - > next = chan ;
2005-10-31 22:51:12 +00:00
}
2007-06-06 21:20:11 +00:00
chan - > next = NULL ;
2005-11-01 22:04:14 +00:00
ast_mutex_unlock ( & cl_te_lock ) ;
2005-10-31 22:51:12 +00:00
}
2005-12-09 11:01:18 +00:00
static void cl_dequeue_chan ( struct chan_list * * list , struct chan_list * chan )
2005-10-31 22:51:12 +00:00
{
2007-06-06 21:20:11 +00:00
struct chan_list * help ;
2005-10-31 22:51:12 +00:00
if ( chan - > dsp )
ast_dsp_free ( chan - > dsp ) ;
if ( chan - > trans )
ast_translator_free_path ( chan - > trans ) ;
2005-12-09 11:01:18 +00:00
2005-11-01 22:04:14 +00:00
ast_mutex_lock ( & cl_te_lock ) ;
2005-10-31 22:51:12 +00:00
if ( ! * list ) {
2005-11-01 22:04:14 +00:00
ast_mutex_unlock ( & cl_te_lock ) ;
2005-10-31 22:51:12 +00:00
return ;
}
if ( * list = = chan ) {
2007-06-06 21:20:11 +00:00
* list = ( * list ) - > next ;
2005-11-01 22:04:14 +00:00
ast_mutex_unlock ( & cl_te_lock ) ;
2007-06-06 21:20:11 +00:00
return ;
2005-10-31 22:51:12 +00:00
}
2007-06-06 21:20:11 +00:00
for ( help = * list ; help - > next ; help = help - > next ) {
if ( help - > next = = chan ) {
help - > next = help - > next - > next ;
ast_mutex_unlock ( & cl_te_lock ) ;
return ;
2005-10-31 22:51:12 +00:00
}
}
2005-11-01 22:04:14 +00:00
ast_mutex_unlock ( & cl_te_lock ) ;
2005-10-31 22:51:12 +00:00
}
/** Channel Queue End **/
2006-07-06 15:11:40 +00:00
int pbx_start_chan ( struct chan_list * ch )
{
2007-06-06 21:20:11 +00:00
int ret = ast_pbx_start ( ch - > ast ) ;
2006-07-06 15:11:40 +00:00
2007-06-06 21:20:11 +00:00
if ( ret > = 0 )
ch - > need_hangup = 0 ;
2006-07-06 15:11:40 +00:00
else
2007-06-06 21:20:11 +00:00
ch - > need_hangup = 1 ;
2006-07-06 15:11:40 +00:00
return ret ;
}
static void hangup_chan ( struct chan_list * ch )
{
2007-06-06 21:20:11 +00:00
int port = ch ? ( ch - > bc ? ch - > bc - > port : 0 ) : 0 ;
2006-07-06 15:11:40 +00:00
if ( ! ch ) {
2007-06-06 21:20:11 +00:00
cb_log ( 1 , 0 , " Cannot hangup chan, no ch \n " ) ;
2006-07-06 15:11:40 +00:00
return ;
}
2007-06-06 21:20:11 +00:00
cb_log ( 5 , port , " hangup_chan called \n " ) ;
2006-07-06 15:11:40 +00:00
2007-06-06 21:20:11 +00:00
if ( ch - > need_hangup ) {
cb_log ( 2 , port , " --> hangup \n " ) ;
send_cause2ast ( ch - > ast , ch - > bc , ch ) ;
ch - > need_hangup = 0 ;
ch - > need_queue_hangup = 0 ;
2006-07-06 15:11:40 +00:00
if ( ch - > ast )
ast_hangup ( ch - > ast ) ;
return ;
}
if ( ! ch - > need_queue_hangup ) {
2007-06-06 21:20:11 +00:00
cb_log ( 2 , port , " --> No need to queue hangup \n " ) ;
2006-07-06 15:11:40 +00:00
}
2007-06-06 21:20:11 +00:00
ch - > need_queue_hangup = 0 ;
2006-07-06 15:11:40 +00:00
if ( ch - > ast ) {
2007-06-06 21:20:11 +00:00
send_cause2ast ( ch - > ast , ch - > bc , ch ) ;
2006-08-03 16:38:00 +00:00
if ( ch - > ast )
ast_queue_hangup ( ch - > ast ) ;
2007-06-06 21:20:11 +00:00
cb_log ( 2 , port , " --> queue_hangup \n " ) ;
2006-07-06 15:11:40 +00:00
} else {
2007-06-06 21:20:11 +00:00
cb_log ( 1 , port , " Cannot hangup chan, no ast \n " ) ;
2006-07-06 15:11:40 +00:00
}
}
2005-10-31 22:51:12 +00:00
/** Isdn asks us to release channel, pendant to misdn_hangup **/
static void release_chan ( struct misdn_bchannel * bc ) {
2007-07-02 09:34:19 +00:00
struct ast_channel * ast = NULL ;
2007-06-06 21:20:11 +00:00
2007-07-02 09:34:19 +00:00
ast_mutex_lock ( & release_lock ) ;
{
struct chan_list * ch = find_chan_by_bc ( cl_te , bc ) ;
if ( ! ch ) {
chan_misdn_log ( 1 , bc - > port , " release_chan: Ch not found! \n " ) ;
ast_mutex_unlock ( & release_lock ) ;
return ;
2006-07-11 19:30:35 +00:00
}
2006-05-22 15:02:03 +00:00
2007-07-02 09:34:19 +00:00
if ( ch - > ast ) {
ast = ch - > ast ;
}
2006-06-28 14:15:29 +00:00
2007-07-02 09:34:19 +00:00
chan_misdn_log ( 5 , bc - > port , " release_chan: bc with l3id: %x \n " , bc - > l3_id ) ;
2007-06-06 21:20:11 +00:00
2007-07-02 09:34:19 +00:00
/*releaseing jitterbuffer*/
if ( ch - > jb ) {
misdn_jb_destroy ( ch - > jb ) ;
ch - > jb = NULL ;
} else {
if ( ! bc - > nojitter )
chan_misdn_log ( 5 , bc - > port , " Jitterbuffer already destroyed. \n " ) ;
}
if ( ch - > overlap_dial ) {
if ( ch - > overlap_dial_task ! = - 1 ) {
misdn_tasks_remove ( ch - > overlap_dial_task ) ;
ch - > overlap_dial_task = - 1 ;
2005-10-31 22:51:12 +00:00
}
2007-07-02 09:34:19 +00:00
ast_mutex_destroy ( & ch - > overlap_tv_lock ) ;
2005-10-31 22:51:12 +00:00
}
2007-06-06 21:20:11 +00:00
2007-07-02 09:34:19 +00:00
if ( ch - > originator = = ORG_AST ) {
misdn_out_calls [ bc - > port ] - - ;
} else {
misdn_in_calls [ bc - > port ] - - ;
}
2007-06-06 21:20:11 +00:00
2007-07-02 09:34:19 +00:00
if ( ch ) {
close ( ch - > pipe [ 0 ] ) ;
close ( ch - > pipe [ 1 ] ) ;
if ( ast & & MISDN_ASTERISK_TECH_PVT ( ast ) ) {
chan_misdn_log ( 1 , bc - > port , " * RELEASING CHANNEL pid:%d ctx:%s dad:%s oad:%s state: %s \n " , bc ? bc - > pid : - 1 , ast - > context , ast - > exten , ast - > cid . cid_num , misdn_get_ch_state ( ch ) ) ;
chan_misdn_log ( 3 , bc - > port , " --> * State Down \n " ) ;
MISDN_ASTERISK_TECH_PVT ( ast ) = NULL ;
if ( ast - > _state ! = AST_STATE_RESERVED ) {
chan_misdn_log ( 3 , bc - > port , " --> Setting AST State to down \n " ) ;
ast_setstate ( ast , AST_STATE_DOWN ) ;
}
}
ch - > state = MISDN_CLEANING ;
cl_dequeue_chan ( & cl_te , ch ) ;
ast_free ( ch ) ;
} else {
/* chan is already cleaned, so exiting */
}
ast_mutex_unlock ( & release_lock ) ;
2005-10-31 22:51:12 +00:00
}
/*** release end **/
2007-07-02 09:34:19 +00:00
}
2005-10-31 22:51:12 +00:00
2005-12-09 11:01:18 +00:00
static void misdn_transfer_bc ( struct chan_list * tmp_ch , struct chan_list * holded_chan )
2005-10-31 22:51:12 +00:00
{
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 4 , 0 , " TRANSFERING %s to %s \n " , holded_chan - > ast - > name , tmp_ch - > ast - > name ) ;
tmp_ch - > state = MISDN_HOLD_DISCONNECT ;
2007-04-11 15:48:54 +00:00
ast_moh_stop ( ast_bridged_channel ( holded_chan - > ast ) ) ;
2005-10-31 22:51:12 +00:00
holded_chan - > state = MISDN_CONNECTED ;
2007-06-06 21:20:11 +00:00
/* misdn_lib_transfer(holded_chan->bc); */
2007-04-11 15:48:54 +00:00
ast_channel_masquerade ( holded_chan - > ast , ast_bridged_channel ( tmp_ch - > ast ) ) ;
2005-10-31 22:51:12 +00:00
}
2007-06-06 21:20:11 +00:00
static void do_immediate_setup ( struct misdn_bchannel * bc , struct chan_list * ch , struct ast_channel * ast )
2005-10-31 22:51:12 +00:00
{
2007-06-06 21:20:11 +00:00
char * predial ;
2005-10-31 22:51:12 +00:00
struct ast_frame fr ;
2007-06-06 21:20:11 +00:00
predial = ast_strdupa ( ast - > exten ) ;
ch - > state = MISDN_DIALING ;
2005-12-09 11:01:18 +00:00
2007-05-18 09:47:19 +00:00
if ( ! ch - > noautorespond_on_setup ) {
if ( bc - > nt ) {
int ret ;
2005-10-31 22:51:12 +00:00
ret = misdn_lib_send_event ( bc , EVENT_SETUP_ACKNOWLEDGE ) ;
} else {
2007-05-18 09:47:19 +00:00
int ret ;
if ( misdn_lib_is_ptp ( bc - > port ) ) {
ret = misdn_lib_send_event ( bc , EVENT_SETUP_ACKNOWLEDGE ) ;
} else {
ret = misdn_lib_send_event ( bc , EVENT_PROCEEDING ) ;
}
2005-10-31 22:51:12 +00:00
}
2007-05-18 09:47:19 +00:00
} else {
ch - > state = MISDN_INCOMING_SETUP ;
2005-10-31 22:51:12 +00:00
}
2006-02-15 19:51:33 +00:00
2007-04-11 15:48:54 +00:00
chan_misdn_log ( 1 , bc - > port , " * Starting Ast ctx:%s dad:%s oad:%s with 's' extension \n " , ast - > context , ast - > exten , ast - > cid . cid_num ) ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
strncpy ( ast - > exten , " s " , 2 ) ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
if ( pbx_start_chan ( ch ) < 0 ) {
ast = NULL ;
2006-07-06 15:11:40 +00:00
hangup_chan ( ch ) ;
hanguptone_indicate ( ch ) ;
2005-12-09 11:01:18 +00:00
2005-11-01 22:04:14 +00:00
if ( bc - > nt )
2005-10-31 22:51:12 +00:00
misdn_lib_send_event ( bc , EVENT_RELEASE_COMPLETE ) ;
else
misdn_lib_send_event ( bc , EVENT_DISCONNECT ) ;
}
2007-06-06 21:20:11 +00:00
while ( ! ast_strlen_zero ( predial ) ) {
2005-10-31 22:51:12 +00:00
fr . frametype = AST_FRAME_DTMF ;
2007-06-06 21:20:11 +00:00
fr . subclass = * predial ;
fr . src = NULL ;
fr . data = NULL ;
2005-10-31 22:51:12 +00:00
fr . datalen = 0 ;
2007-06-06 21:20:11 +00:00
fr . samples = 0 ;
fr . mallocd = 0 ;
fr . offset = 0 ;
fr . delivery = ast_tv ( 0 , 0 ) ;
2005-10-31 22:51:12 +00:00
if ( ch - > ast & & MISDN_ASTERISK_PVT ( ch - > ast ) & & MISDN_ASTERISK_TECH_PVT ( ch - > ast ) ) {
ast_queue_frame ( ch - > ast , & fr ) ;
}
2007-06-06 21:20:11 +00:00
predial + + ;
2005-10-31 22:51:12 +00:00
}
}
2007-06-06 21:20:11 +00:00
static void send_cause2ast ( struct ast_channel * ast , struct misdn_bchannel * bc , struct chan_list * ch ) {
2006-07-06 15:11:40 +00:00
if ( ! ast ) {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , 0 , " send_cause2ast: No Ast \n " ) ;
2006-07-06 15:11:40 +00:00
return ;
}
if ( ! bc ) {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , 0 , " send_cause2ast: No BC \n " ) ;
2006-07-06 15:11:40 +00:00
return ;
}
if ( ! ch ) {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , 0 , " send_cause2ast: No Ch \n " ) ;
2006-07-06 15:11:40 +00:00
return ;
}
2007-06-06 21:20:11 +00:00
ast - > hangupcause = bc - > cause ;
switch ( bc - > cause ) {
2005-10-31 22:51:12 +00:00
case 1 : /** Congestion Cases **/
case 2 :
case 3 :
case 4 :
case 22 :
case 27 :
2006-03-07 12:17:35 +00:00
/*
* Not Queueing the Congestion anymore , since we want to hear
* the inband message
*
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , bc ? bc - > port : 0 , " --> * SEND: Queue Congestion pid:%d \n " , bc ? bc - > pid : - 1 ) ;
ch - > state = MISDN_BUSY ;
2005-10-31 22:51:12 +00:00
ast_queue_control ( ast , AST_CONTROL_CONGESTION ) ;
2006-03-07 12:17:35 +00:00
*/
2005-10-31 22:51:12 +00:00
break ;
2007-06-06 21:20:11 +00:00
2005-10-31 22:51:12 +00:00
case 21 :
case 17 : /* user busy */
2007-06-06 21:20:11 +00:00
ch - > state = MISDN_BUSY ;
2006-08-03 16:38:00 +00:00
if ( ! ch - > need_busy ) {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , bc ? bc - > port : 0 , " Queued busy already \n " ) ;
2006-08-03 16:38:00 +00:00
break ;
}
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , bc ? bc - > port : 0 , " --> * SEND: Queue Busy pid:%d \n " , bc ? bc - > pid : - 1 ) ;
2006-08-03 16:38:00 +00:00
2005-10-31 22:51:12 +00:00
ast_queue_control ( ast , AST_CONTROL_BUSY ) ;
2007-06-06 21:20:11 +00:00
ch - > need_busy = 0 ;
2006-08-03 16:38:00 +00:00
2005-10-31 22:51:12 +00:00
break ;
}
}
2006-02-22 21:59:46 +00:00
2006-06-17 10:37:35 +00:00
void import_ch ( struct ast_channel * chan , struct misdn_bchannel * bc , struct chan_list * ch )
{
2007-06-06 21:20:11 +00:00
const char * tmp = pbx_builtin_getvar_helper ( chan , " MISDN_PID " ) ;
2006-06-17 10:37:35 +00:00
if ( tmp ) {
2007-06-06 21:20:11 +00:00
ch - > other_pid = atoi ( tmp ) ;
chan_misdn_log ( 3 , bc - > port , " --> IMPORT_PID: importing pid:%s \n " , tmp ) ;
if ( ch - > other_pid > 0 ) {
ch - > other_ch = find_chan_by_pid ( cl_te , ch - > other_pid ) ;
if ( ch - > other_ch )
ch - > other_ch - > other_ch = ch ;
2006-06-17 10:37:35 +00:00
}
}
Merged revisions 49313 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r49313 | crichter | 2007-01-03 10:06:50 +0100 (Mi, 03 Jan 2007) | 41 lines
Merged revisions 48319,48321,48467,48552,48576,49135,49303 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r48319 | crichter | 2006-12-06 15:35:25 +0100 (Mi, 06 Dez 2006) | 1 line
changed a few debugs to higher debug levels
........
r48321 | crichter | 2006-12-06 16:48:45 +0100 (Mi, 06 Dez 2006) | 1 line
added the export and import of the MISDN_ADDRESS_COMPLETE Variable to inidcate wether the extension is already completely dialed or if there might come additional digits by information elements. also added some docs for that.
........
r48467 | crichter | 2006-12-14 14:03:49 +0100 (Do, 14 Dez 2006) | 1 line
removed FIXUP state. added check for channel allocation conflict when we create a setup while the other site creates a setup on the same channel, besides the check we resolve this conflict.
........
r48552 | crichter | 2006-12-18 11:19:39 +0100 (Mo, 18 Dez 2006) | 1 line
when our PTP Partner sends us a SETUP with a preselected channel we just accept it, even when we're NT. added some checks for segfaults.
........
r48576 | crichter | 2006-12-19 14:08:51 +0100 (Di, 19 Dez 2006) | 1 line
when we reject a channel, because it's in use already, we shouldn't process the setup anymore. made the channel allocation a bit easier and more understandable, removed a few unused lines
........
r49135 | crichter | 2007-01-02 11:07:22 +0100 (Di, 02 Jan 2007) | 1 line
added check for channel ranges in the set/empty channel functions. set pmp_l1_check default to no. added misdn restart pid cli command. added cleaning of channel when we send a RELEASE_COMPLETE.
........
r49303 | crichter | 2007-01-03 09:24:00 +0100 (Mi, 03 Jan 2007) | 9 lines
* Added check for bridging in misdn_call to avoid setting echocancellation
when 2 mISDN channels are involved and when bridging is set. That lead
to a kernel panic before under different situations, because we switched
about 2 times between hardware bridging and echocancelation
* readded MISDN_URATE variable which got lost before, this should make app_v110
work again
* fixed typo
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-03 11:15:02 +00:00
2007-06-06 21:20:11 +00:00
tmp = pbx_builtin_getvar_helper ( chan , " MISDN_ADDRESS_COMPLETE " ) ;
Merged revisions 49313 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r49313 | crichter | 2007-01-03 10:06:50 +0100 (Mi, 03 Jan 2007) | 41 lines
Merged revisions 48319,48321,48467,48552,48576,49135,49303 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r48319 | crichter | 2006-12-06 15:35:25 +0100 (Mi, 06 Dez 2006) | 1 line
changed a few debugs to higher debug levels
........
r48321 | crichter | 2006-12-06 16:48:45 +0100 (Mi, 06 Dez 2006) | 1 line
added the export and import of the MISDN_ADDRESS_COMPLETE Variable to inidcate wether the extension is already completely dialed or if there might come additional digits by information elements. also added some docs for that.
........
r48467 | crichter | 2006-12-14 14:03:49 +0100 (Do, 14 Dez 2006) | 1 line
removed FIXUP state. added check for channel allocation conflict when we create a setup while the other site creates a setup on the same channel, besides the check we resolve this conflict.
........
r48552 | crichter | 2006-12-18 11:19:39 +0100 (Mo, 18 Dez 2006) | 1 line
when our PTP Partner sends us a SETUP with a preselected channel we just accept it, even when we're NT. added some checks for segfaults.
........
r48576 | crichter | 2006-12-19 14:08:51 +0100 (Di, 19 Dez 2006) | 1 line
when we reject a channel, because it's in use already, we shouldn't process the setup anymore. made the channel allocation a bit easier and more understandable, removed a few unused lines
........
r49135 | crichter | 2007-01-02 11:07:22 +0100 (Di, 02 Jan 2007) | 1 line
added check for channel ranges in the set/empty channel functions. set pmp_l1_check default to no. added misdn restart pid cli command. added cleaning of channel when we send a RELEASE_COMPLETE.
........
r49303 | crichter | 2007-01-03 09:24:00 +0100 (Mi, 03 Jan 2007) | 9 lines
* Added check for bridging in misdn_call to avoid setting echocancellation
when 2 mISDN channels are involved and when bridging is set. That lead
to a kernel panic before under different situations, because we switched
about 2 times between hardware bridging and echocancelation
* readded MISDN_URATE variable which got lost before, this should make app_v110
work again
* fixed typo
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-03 11:15:02 +00:00
if ( tmp & & ( atoi ( tmp ) = = 1 ) ) {
2007-06-06 21:20:11 +00:00
bc - > sending_complete = 1 ;
Merged revisions 49313 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r49313 | crichter | 2007-01-03 10:06:50 +0100 (Mi, 03 Jan 2007) | 41 lines
Merged revisions 48319,48321,48467,48552,48576,49135,49303 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r48319 | crichter | 2006-12-06 15:35:25 +0100 (Mi, 06 Dez 2006) | 1 line
changed a few debugs to higher debug levels
........
r48321 | crichter | 2006-12-06 16:48:45 +0100 (Mi, 06 Dez 2006) | 1 line
added the export and import of the MISDN_ADDRESS_COMPLETE Variable to inidcate wether the extension is already completely dialed or if there might come additional digits by information elements. also added some docs for that.
........
r48467 | crichter | 2006-12-14 14:03:49 +0100 (Do, 14 Dez 2006) | 1 line
removed FIXUP state. added check for channel allocation conflict when we create a setup while the other site creates a setup on the same channel, besides the check we resolve this conflict.
........
r48552 | crichter | 2006-12-18 11:19:39 +0100 (Mo, 18 Dez 2006) | 1 line
when our PTP Partner sends us a SETUP with a preselected channel we just accept it, even when we're NT. added some checks for segfaults.
........
r48576 | crichter | 2006-12-19 14:08:51 +0100 (Di, 19 Dez 2006) | 1 line
when we reject a channel, because it's in use already, we shouldn't process the setup anymore. made the channel allocation a bit easier and more understandable, removed a few unused lines
........
r49135 | crichter | 2007-01-02 11:07:22 +0100 (Di, 02 Jan 2007) | 1 line
added check for channel ranges in the set/empty channel functions. set pmp_l1_check default to no. added misdn restart pid cli command. added cleaning of channel when we send a RELEASE_COMPLETE.
........
r49303 | crichter | 2007-01-03 09:24:00 +0100 (Mi, 03 Jan 2007) | 9 lines
* Added check for bridging in misdn_call to avoid setting echocancellation
when 2 mISDN channels are involved and when bridging is set. That lead
to a kernel panic before under different situations, because we switched
about 2 times between hardware bridging and echocancelation
* readded MISDN_URATE variable which got lost before, this should make app_v110
work again
* fixed typo
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-03 11:15:02 +00:00
}
2007-06-06 21:20:11 +00:00
tmp = pbx_builtin_getvar_helper ( chan , " MISDN_USERUSER " ) ;
Merged revisions 58825-58826 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r58825 | crichter | 2007-03-12 13:43:24 +0100 (Mo, 12 Mär 2007) | 1 line
added UU transceiving and corect handling for rdnis
................
r58826 | crichter | 2007-03-12 14:08:06 +0100 (Mo, 12 Mär 2007) | 21 lines
Merged revisions 57034,57523,57753,58558 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r57034 | crichter | 2007-02-28 17:09:27 +0100 (Mi, 28 Feb 2007) | 1 line
fixed bugs.digium.com bugs: #9157 and bugs.beronet.com bugs: #302, #303, #304
........
r57523 | crichter | 2007-03-02 19:32:51 +0100 (Fr, 02 Mar 2007) | 1 line
fixed typo
........
r57753 | crichter | 2007-03-04 11:39:50 +0100 (So, 04 Mar 2007) | 1 line
fixed another place where the out_cause was hardcoded to 16
........
r58558 | crichter | 2007-03-09 15:43:58 +0100 (Fr, 09 Mar 2007) | 1 line
we can free channel 31 as well, since we can occupy it
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64951 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 09:31:27 +00:00
if ( tmp ) {
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
ast_log ( LOG_NOTICE , " MISDN_USERUSER: %s \n " , tmp ) ;
2007-06-06 21:20:11 +00:00
ast_copy_string ( bc - > uu , tmp , sizeof ( bc - > uu ) ) ;
bc - > uulen = strlen ( bc - > uu ) ;
Merged revisions 58825-58826 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r58825 | crichter | 2007-03-12 13:43:24 +0100 (Mo, 12 Mär 2007) | 1 line
added UU transceiving and corect handling for rdnis
................
r58826 | crichter | 2007-03-12 14:08:06 +0100 (Mo, 12 Mär 2007) | 21 lines
Merged revisions 57034,57523,57753,58558 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r57034 | crichter | 2007-02-28 17:09:27 +0100 (Mi, 28 Feb 2007) | 1 line
fixed bugs.digium.com bugs: #9157 and bugs.beronet.com bugs: #302, #303, #304
........
r57523 | crichter | 2007-03-02 19:32:51 +0100 (Fr, 02 Mar 2007) | 1 line
fixed typo
........
r57753 | crichter | 2007-03-04 11:39:50 +0100 (So, 04 Mar 2007) | 1 line
fixed another place where the out_cause was hardcoded to 16
........
r58558 | crichter | 2007-03-09 15:43:58 +0100 (Fr, 09 Mar 2007) | 1 line
we can free channel 31 as well, since we can occupy it
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64951 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 09:31:27 +00:00
}
2007-06-06 21:20:11 +00:00
tmp = pbx_builtin_getvar_helper ( chan , " MISDN_KEYPAD " ) ;
if ( tmp )
ast_copy_string ( bc - > keypad , tmp , sizeof ( bc - > keypad ) ) ;
2006-02-22 21:59:46 +00:00
}
2006-06-17 10:37:35 +00:00
void export_ch ( struct ast_channel * chan , struct misdn_bchannel * bc , struct chan_list * ch )
2006-02-22 21:59:46 +00:00
{
char tmp [ 32 ] ;
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 3 , bc - > port , " --> EXPORT_PID: pid:%d \n " , bc - > pid ) ;
snprintf ( tmp , sizeof ( tmp ) , " %d " , bc - > pid ) ;
pbx_builtin_setvar_helper ( chan , " _MISDN_PID " , tmp ) ;
Merged revisions 49313 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r49313 | crichter | 2007-01-03 10:06:50 +0100 (Mi, 03 Jan 2007) | 41 lines
Merged revisions 48319,48321,48467,48552,48576,49135,49303 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r48319 | crichter | 2006-12-06 15:35:25 +0100 (Mi, 06 Dez 2006) | 1 line
changed a few debugs to higher debug levels
........
r48321 | crichter | 2006-12-06 16:48:45 +0100 (Mi, 06 Dez 2006) | 1 line
added the export and import of the MISDN_ADDRESS_COMPLETE Variable to inidcate wether the extension is already completely dialed or if there might come additional digits by information elements. also added some docs for that.
........
r48467 | crichter | 2006-12-14 14:03:49 +0100 (Do, 14 Dez 2006) | 1 line
removed FIXUP state. added check for channel allocation conflict when we create a setup while the other site creates a setup on the same channel, besides the check we resolve this conflict.
........
r48552 | crichter | 2006-12-18 11:19:39 +0100 (Mo, 18 Dez 2006) | 1 line
when our PTP Partner sends us a SETUP with a preselected channel we just accept it, even when we're NT. added some checks for segfaults.
........
r48576 | crichter | 2006-12-19 14:08:51 +0100 (Di, 19 Dez 2006) | 1 line
when we reject a channel, because it's in use already, we shouldn't process the setup anymore. made the channel allocation a bit easier and more understandable, removed a few unused lines
........
r49135 | crichter | 2007-01-02 11:07:22 +0100 (Di, 02 Jan 2007) | 1 line
added check for channel ranges in the set/empty channel functions. set pmp_l1_check default to no. added misdn restart pid cli command. added cleaning of channel when we send a RELEASE_COMPLETE.
........
r49303 | crichter | 2007-01-03 09:24:00 +0100 (Mi, 03 Jan 2007) | 9 lines
* Added check for bridging in misdn_call to avoid setting echocancellation
when 2 mISDN channels are involved and when bridging is set. That lead
to a kernel panic before under different situations, because we switched
about 2 times between hardware bridging and echocancelation
* readded MISDN_URATE variable which got lost before, this should make app_v110
work again
* fixed typo
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-03 11:15:02 +00:00
if ( bc - > sending_complete ) {
2007-06-06 21:20:11 +00:00
snprintf ( tmp , sizeof ( tmp ) , " %d " , bc - > sending_complete ) ;
pbx_builtin_setvar_helper ( chan , " MISDN_ADDRESS_COMPLETE " , tmp ) ;
Merged revisions 49313 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r49313 | crichter | 2007-01-03 10:06:50 +0100 (Mi, 03 Jan 2007) | 41 lines
Merged revisions 48319,48321,48467,48552,48576,49135,49303 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r48319 | crichter | 2006-12-06 15:35:25 +0100 (Mi, 06 Dez 2006) | 1 line
changed a few debugs to higher debug levels
........
r48321 | crichter | 2006-12-06 16:48:45 +0100 (Mi, 06 Dez 2006) | 1 line
added the export and import of the MISDN_ADDRESS_COMPLETE Variable to inidcate wether the extension is already completely dialed or if there might come additional digits by information elements. also added some docs for that.
........
r48467 | crichter | 2006-12-14 14:03:49 +0100 (Do, 14 Dez 2006) | 1 line
removed FIXUP state. added check for channel allocation conflict when we create a setup while the other site creates a setup on the same channel, besides the check we resolve this conflict.
........
r48552 | crichter | 2006-12-18 11:19:39 +0100 (Mo, 18 Dez 2006) | 1 line
when our PTP Partner sends us a SETUP with a preselected channel we just accept it, even when we're NT. added some checks for segfaults.
........
r48576 | crichter | 2006-12-19 14:08:51 +0100 (Di, 19 Dez 2006) | 1 line
when we reject a channel, because it's in use already, we shouldn't process the setup anymore. made the channel allocation a bit easier and more understandable, removed a few unused lines
........
r49135 | crichter | 2007-01-02 11:07:22 +0100 (Di, 02 Jan 2007) | 1 line
added check for channel ranges in the set/empty channel functions. set pmp_l1_check default to no. added misdn restart pid cli command. added cleaning of channel when we send a RELEASE_COMPLETE.
........
r49303 | crichter | 2007-01-03 09:24:00 +0100 (Mi, 03 Jan 2007) | 9 lines
* Added check for bridging in misdn_call to avoid setting echocancellation
when 2 mISDN channels are involved and when bridging is set. That lead
to a kernel panic before under different situations, because we switched
about 2 times between hardware bridging and echocancelation
* readded MISDN_URATE variable which got lost before, this should make app_v110
work again
* fixed typo
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-03 11:15:02 +00:00
}
if ( bc - > urate ) {
2007-06-06 21:20:11 +00:00
snprintf ( tmp , sizeof ( tmp ) , " %d " , bc - > urate ) ;
pbx_builtin_setvar_helper ( chan , " MISDN_URATE " , tmp ) ;
Merged revisions 49313 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r49313 | crichter | 2007-01-03 10:06:50 +0100 (Mi, 03 Jan 2007) | 41 lines
Merged revisions 48319,48321,48467,48552,48576,49135,49303 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r48319 | crichter | 2006-12-06 15:35:25 +0100 (Mi, 06 Dez 2006) | 1 line
changed a few debugs to higher debug levels
........
r48321 | crichter | 2006-12-06 16:48:45 +0100 (Mi, 06 Dez 2006) | 1 line
added the export and import of the MISDN_ADDRESS_COMPLETE Variable to inidcate wether the extension is already completely dialed or if there might come additional digits by information elements. also added some docs for that.
........
r48467 | crichter | 2006-12-14 14:03:49 +0100 (Do, 14 Dez 2006) | 1 line
removed FIXUP state. added check for channel allocation conflict when we create a setup while the other site creates a setup on the same channel, besides the check we resolve this conflict.
........
r48552 | crichter | 2006-12-18 11:19:39 +0100 (Mo, 18 Dez 2006) | 1 line
when our PTP Partner sends us a SETUP with a preselected channel we just accept it, even when we're NT. added some checks for segfaults.
........
r48576 | crichter | 2006-12-19 14:08:51 +0100 (Di, 19 Dez 2006) | 1 line
when we reject a channel, because it's in use already, we shouldn't process the setup anymore. made the channel allocation a bit easier and more understandable, removed a few unused lines
........
r49135 | crichter | 2007-01-02 11:07:22 +0100 (Di, 02 Jan 2007) | 1 line
added check for channel ranges in the set/empty channel functions. set pmp_l1_check default to no. added misdn restart pid cli command. added cleaning of channel when we send a RELEASE_COMPLETE.
........
r49303 | crichter | 2007-01-03 09:24:00 +0100 (Mi, 03 Jan 2007) | 9 lines
* Added check for bridging in misdn_call to avoid setting echocancellation
when 2 mISDN channels are involved and when bridging is set. That lead
to a kernel panic before under different situations, because we switched
about 2 times between hardware bridging and echocancelation
* readded MISDN_URATE variable which got lost before, this should make app_v110
work again
* fixed typo
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-03 11:15:02 +00:00
}
Merged revisions 58825-58826 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r58825 | crichter | 2007-03-12 13:43:24 +0100 (Mo, 12 Mär 2007) | 1 line
added UU transceiving and corect handling for rdnis
................
r58826 | crichter | 2007-03-12 14:08:06 +0100 (Mo, 12 Mär 2007) | 21 lines
Merged revisions 57034,57523,57753,58558 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r57034 | crichter | 2007-02-28 17:09:27 +0100 (Mi, 28 Feb 2007) | 1 line
fixed bugs.digium.com bugs: #9157 and bugs.beronet.com bugs: #302, #303, #304
........
r57523 | crichter | 2007-03-02 19:32:51 +0100 (Fr, 02 Mar 2007) | 1 line
fixed typo
........
r57753 | crichter | 2007-03-04 11:39:50 +0100 (So, 04 Mar 2007) | 1 line
fixed another place where the out_cause was hardcoded to 16
........
r58558 | crichter | 2007-03-09 15:43:58 +0100 (Fr, 09 Mar 2007) | 1 line
we can free channel 31 as well, since we can occupy it
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64951 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 09:31:27 +00:00
2007-06-06 21:20:11 +00:00
if ( bc - > uulen )
pbx_builtin_setvar_helper ( chan , " MISDN_USERUSER " , bc - > uu ) ;
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
2007-06-06 21:20:11 +00:00
if ( ! ast_strlen_zero ( bc - > keypad ) )
pbx_builtin_setvar_helper ( chan , " MISDN_KEYPAD " , bc - > keypad ) ;
2006-02-22 21:59:46 +00:00
}
2006-05-22 15:02:03 +00:00
int add_in_calls ( int port )
{
int max_in_calls ;
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( port , MISDN_CFG_MAX_IN , & max_in_calls , sizeof ( max_in_calls ) ) ;
2006-05-22 15:02:03 +00:00
misdn_in_calls [ port ] + + ;
2007-06-06 21:20:11 +00:00
if ( max_in_calls > = 0 & & max_in_calls < misdn_in_calls [ port ] ) {
ast_log ( LOG_NOTICE , " Marking Incoming Call on port[%d] \n " , port ) ;
return misdn_in_calls [ port ] - max_in_calls ;
2006-05-22 15:02:03 +00:00
}
return 0 ;
}
int add_out_calls ( int port )
{
int max_out_calls ;
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( port , MISDN_CFG_MAX_OUT , & max_out_calls , sizeof ( max_out_calls ) ) ;
2006-05-22 15:02:03 +00:00
2007-06-06 21:20:11 +00:00
if ( max_out_calls > = 0 & & max_out_calls < = misdn_out_calls [ port ] ) {
ast_log ( LOG_NOTICE , " Rejecting Outgoing Call on port[%d] \n " , port ) ;
return ( misdn_out_calls [ port ] + 1 ) - max_out_calls ;
2006-05-22 15:02:03 +00:00
}
misdn_out_calls [ port ] + + ;
return 0 ;
}
2007-06-05 16:19:20 +00:00
static void start_pbx ( struct chan_list * ch , struct misdn_bchannel * bc , struct ast_channel * chan ) {
2007-06-06 21:20:11 +00:00
if ( pbx_start_chan ( ch ) < 0 ) {
2007-06-05 16:19:20 +00:00
hangup_chan ( ch ) ;
chan_misdn_log ( - 1 , bc - > port , " ast_pbx_start returned <0 in SETUP \n " ) ;
if ( bc - > nt ) {
hanguptone_indicate ( ch ) ;
2007-06-06 21:20:11 +00:00
misdn_lib_send_event ( bc , EVENT_RELEASE_COMPLETE ) ;
2007-06-05 16:19:20 +00:00
} else
misdn_lib_send_event ( bc , EVENT_RELEASE ) ;
}
}
2006-02-22 21:59:46 +00:00
2007-06-25 08:53:47 +00:00
static void wait_for_digits ( struct chan_list * ch , struct misdn_bchannel * bc , struct ast_channel * chan ) {
ch - > state = MISDN_WAITING4DIGS ;
misdn_lib_send_event ( bc , EVENT_SETUP_ACKNOWLEDGE ) ;
if ( bc - > nt & & ! bc - > dad [ 0 ] )
dialtone_indicate ( ch ) ;
}
2005-10-31 22:51:12 +00:00
/************************************************************/
/* Receive Events from isdn_lib here */
/************************************************************/
2005-12-09 11:01:18 +00:00
static enum event_response_e
2005-10-31 22:51:12 +00:00
cb_events ( enum event_e event , struct misdn_bchannel * bc , void * user_data )
{
2007-06-06 21:20:11 +00:00
struct chan_list * ch = find_chan_by_bc ( cl_te , bc ) ;
2005-10-31 22:51:12 +00:00
2006-02-02 21:15:34 +00:00
if ( event ! = EVENT_BCHAN_DATA & & event ! = EVENT_TONE_GENERATE ) { /* Debug Only Non-Bchan */
2007-06-06 21:20:11 +00:00
int debuglevel = 1 ;
if ( event = = EVENT_CLEANUP & & ! user_data )
debuglevel = 5 ;
2006-08-03 16:38:00 +00:00
2007-06-06 21:20:11 +00:00
chan_misdn_log ( debuglevel , bc - > port , " I IND :%s oad:%s dad:%s pid:%d state:%s \n " , manager_isdn_get_info ( event ) , bc - > oad , bc - > dad , bc - > pid , ch ? misdn_get_ch_state ( ch ) : " none " ) ;
if ( debuglevel = = 1 ) {
2006-08-03 16:38:00 +00:00
misdn_lib_log_ies ( bc ) ;
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 4 , bc - > port , " --> bc_state:%s \n " , bc_state2str ( bc - > bc_state ) ) ;
2006-08-03 16:38:00 +00:00
}
2005-10-31 22:51:12 +00:00
}
2006-07-06 15:11:40 +00:00
if ( ! ch ) {
switch ( event ) {
2007-06-06 21:20:11 +00:00
case EVENT_SETUP :
case EVENT_DISCONNECT :
case EVENT_PORT_ALARM :
case EVENT_RETRIEVE :
case EVENT_NEW_BC :
case EVENT_FACILITY :
break ;
case EVENT_RELEASE_COMPLETE :
chan_misdn_log ( 1 , bc - > port , " --> no Ch, so we've already released. \n " ) ;
break ;
case EVENT_CLEANUP :
case EVENT_TONE_GENERATE :
case EVENT_BCHAN_DATA :
return - 1 ;
default :
chan_misdn_log ( 1 , bc - > port , " Chan not existing at the moment bc->l3id:%x bc:%p event:%s port:%d channel:%d \n " , bc - > l3_id , bc , manager_isdn_get_info ( event ) , bc - > port , bc - > channel ) ;
return - 1 ;
2005-10-31 22:51:12 +00:00
}
}
2007-06-06 21:20:11 +00:00
if ( ch ) {
2005-10-31 22:51:12 +00:00
switch ( event ) {
2006-06-26 17:37:11 +00:00
case EVENT_TONE_GENERATE :
2007-06-06 21:20:11 +00:00
break ;
2006-06-17 10:37:35 +00:00
case EVENT_DISCONNECT :
2005-10-31 22:51:12 +00:00
case EVENT_RELEASE :
case EVENT_RELEASE_COMPLETE :
case EVENT_CLEANUP :
2006-06-17 10:37:35 +00:00
case EVENT_TIMEOUT :
2006-06-21 15:21:46 +00:00
if ( ! ch - > ast )
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 3 , bc - > port , " ast_hangup already called, so we have no ast ptr anymore in event(%s) \n " , manager_isdn_get_info ( event ) ) ;
2005-10-31 22:51:12 +00:00
break ;
default :
2007-06-06 21:20:11 +00:00
if ( ! ch - > ast | | ! MISDN_ASTERISK_PVT ( ch - > ast ) | | ! MISDN_ASTERISK_TECH_PVT ( ch - > ast ) ) {
if ( event ! = EVENT_BCHAN_DATA )
2006-06-21 15:21:46 +00:00
ast_log ( LOG_NOTICE , " No Ast or No private Pointer in Event (%d:%s) \n " , event , manager_isdn_get_info ( event ) ) ;
2005-10-31 22:51:12 +00:00
return - 1 ;
}
}
}
switch ( event ) {
2006-08-03 16:38:00 +00:00
case EVENT_PORT_ALARM :
{
2007-06-06 21:20:11 +00:00
int boa = 0 ;
misdn_cfg_get ( bc - > port , MISDN_CFG_ALARM_BLOCK , & boa , sizeof ( boa ) ) ;
2006-08-03 16:38:00 +00:00
if ( boa ) {
2007-06-06 21:20:11 +00:00
cb_log ( 1 , bc - > port , " --> blocking \n " ) ;
2006-08-03 16:38:00 +00:00
misdn_lib_port_block ( bc - > port ) ;
}
}
2007-06-06 21:20:11 +00:00
break ;
2006-02-02 21:15:34 +00:00
case EVENT_BCHAN_ACTIVATED :
break ;
2006-05-24 23:21:03 +00:00
case EVENT_NEW_CHANNEL :
update_name ( ch - > ast , bc - > port , bc - > channel ) ;
break ;
2006-02-02 21:15:34 +00:00
2005-10-31 22:51:12 +00:00
case EVENT_NEW_L3ID :
ch - > l3id = bc - > l3_id ;
2006-05-23 12:38:06 +00:00
ch - > addr = bc - > addr ;
2005-10-31 22:51:12 +00:00
break ;
case EVENT_NEW_BC :
2006-08-08 09:19:06 +00:00
if ( ! ch ) {
2007-06-06 21:20:11 +00:00
ch = find_holded ( cl_te , bc ) ;
2006-08-08 09:19:06 +00:00
}
if ( ! ch ) {
2007-06-06 21:20:11 +00:00
ast_log ( LOG_WARNING , " NEW_BC without chan_list? \n " ) ;
2006-08-08 09:19:06 +00:00
break ;
}
2005-10-31 22:51:12 +00:00
if ( bc )
2007-06-06 21:20:11 +00:00
ch - > bc = ( struct misdn_bchannel * ) user_data ;
2005-10-31 22:51:12 +00:00
break ;
case EVENT_DTMF_TONE :
{
/* sending INFOS as DTMF-Frames :) */
2007-06-06 21:20:11 +00:00
struct ast_frame fr = { 0 , } ;
2005-10-31 22:51:12 +00:00
fr . frametype = AST_FRAME_DTMF ;
fr . subclass = bc - > dtmf ;
2007-06-06 21:20:11 +00:00
fr . src = NULL ;
fr . data = NULL ;
2005-10-31 22:51:12 +00:00
fr . datalen = 0 ;
2007-06-06 21:20:11 +00:00
fr . samples = 0 ;
fr . mallocd = 0 ;
fr . offset = 0 ;
fr . delivery = ast_tv ( 0 , 0 ) ;
2005-10-31 22:51:12 +00:00
2006-06-08 09:51:13 +00:00
if ( ! ch - > ignore_dtmf ) {
chan_misdn_log ( 2 , bc - > port , " --> DTMF:%c \n " , bc - > dtmf ) ;
ast_queue_frame ( ch - > ast , & fr ) ;
} else {
chan_misdn_log ( 2 , bc - > port , " --> Ingoring DTMF:%c due to bridge flags \n " , bc - > dtmf ) ;
}
2005-10-31 22:51:12 +00:00
}
2007-06-06 21:20:11 +00:00
break ;
2005-10-31 22:51:12 +00:00
case EVENT_STATUS :
break ;
case EVENT_INFORMATION :
{
2007-06-05 16:19:20 +00:00
if ( ch - > state ! = MISDN_CONNECTED )
2006-07-06 15:11:40 +00:00
stop_indicate ( ch ) ;
Merged revisions 58825-58826 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r58825 | crichter | 2007-03-12 13:43:24 +0100 (Mo, 12 Mär 2007) | 1 line
added UU transceiving and corect handling for rdnis
................
r58826 | crichter | 2007-03-12 14:08:06 +0100 (Mo, 12 Mär 2007) | 21 lines
Merged revisions 57034,57523,57753,58558 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r57034 | crichter | 2007-02-28 17:09:27 +0100 (Mi, 28 Feb 2007) | 1 line
fixed bugs.digium.com bugs: #9157 and bugs.beronet.com bugs: #302, #303, #304
........
r57523 | crichter | 2007-03-02 19:32:51 +0100 (Fr, 02 Mar 2007) | 1 line
fixed typo
........
r57753 | crichter | 2007-03-04 11:39:50 +0100 (So, 04 Mar 2007) | 1 line
fixed another place where the out_cause was hardcoded to 16
........
r58558 | crichter | 2007-03-09 15:43:58 +0100 (Fr, 09 Mar 2007) | 1 line
we can free channel 31 as well, since we can occupy it
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64951 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 09:31:27 +00:00
2007-06-06 21:20:11 +00:00
if ( ! ch - > ast )
break ;
Merged revisions 58825-58826 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r58825 | crichter | 2007-03-12 13:43:24 +0100 (Mo, 12 Mär 2007) | 1 line
added UU transceiving and corect handling for rdnis
................
r58826 | crichter | 2007-03-12 14:08:06 +0100 (Mo, 12 Mär 2007) | 21 lines
Merged revisions 57034,57523,57753,58558 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r57034 | crichter | 2007-02-28 17:09:27 +0100 (Mi, 28 Feb 2007) | 1 line
fixed bugs.digium.com bugs: #9157 and bugs.beronet.com bugs: #302, #303, #304
........
r57523 | crichter | 2007-03-02 19:32:51 +0100 (Fr, 02 Mar 2007) | 1 line
fixed typo
........
r57753 | crichter | 2007-03-04 11:39:50 +0100 (So, 04 Mar 2007) | 1 line
fixed another place where the out_cause was hardcoded to 16
........
r58558 | crichter | 2007-03-09 15:43:58 +0100 (Fr, 09 Mar 2007) | 1 line
we can free channel 31 as well, since we can occupy it
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64951 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 09:31:27 +00:00
2005-10-31 22:51:12 +00:00
if ( ch - > state = = MISDN_WAITING4DIGS ) {
/* Ok, incomplete Setup, waiting till extension exists */
2006-10-11 08:39:50 +00:00
if ( ast_strlen_zero ( bc - > info_dad ) & & ! ast_strlen_zero ( bc - > keypad ) ) {
chan_misdn_log ( 1 , bc - > port , " --> using keypad as info \n " ) ;
2007-06-06 21:20:11 +00:00
ast_copy_string ( bc - > info_dad , bc - > keypad , sizeof ( bc - > info_dad ) ) ;
2006-10-11 08:39:50 +00:00
}
2007-06-06 21:20:11 +00:00
strncat ( bc - > dad , bc - > info_dad , sizeof ( bc - > dad ) - 1 ) ;
ast_copy_string ( ch - > ast - > exten , bc - > dad , sizeof ( ch - > ast - > exten ) ) ;
2007-06-05 16:19:20 +00:00
2006-02-08 16:10:21 +00:00
/* Check for Pickup Request first */
if ( ! strcmp ( ch - > ast - > exten , ast_pickup_ext ( ) ) ) {
if ( ast_pickup_call ( ch - > ast ) ) {
2006-07-06 15:11:40 +00:00
hangup_chan ( ch ) ;
2006-02-08 16:10:21 +00:00
} else {
2007-06-06 21:20:11 +00:00
struct ast_channel * chan = ch - > ast ;
2006-02-08 16:10:21 +00:00
ch - > state = MISDN_CALLING_ACKNOWLEDGE ;
ast_setstate ( chan , AST_STATE_DOWN ) ;
2006-07-06 15:11:40 +00:00
hangup_chan ( ch ) ;
2007-06-06 21:20:11 +00:00
ch - > ast = NULL ;
2006-02-08 16:10:21 +00:00
break ;
}
}
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
if ( ! ast_canmatch_extension ( ch - > ast , ch - > context , bc - > dad , 1 , bc - > oad ) ) {
2007-06-05 16:19:20 +00:00
if ( ast_exists_extension ( ch - > ast , ch - > context , " i " , 1 , bc - > oad ) ) {
2007-06-06 21:20:11 +00:00
ast_log ( LOG_WARNING , " Extension can never match, So jumping to 'i' extension. port(%d) \n " , bc - > port ) ;
2007-06-05 16:19:20 +00:00
strcpy ( ch - > ast - > exten , " i " ) ;
2007-07-04 08:43:27 +00:00
ch - > state = MISDN_DIALING ;
2007-06-05 16:19:20 +00:00
start_pbx ( ch , bc , ch - > ast ) ;
break ;
}
ast_log ( LOG_WARNING , " Extension can never match, so disconnecting on port(%d). "
" maybe you want to add an 'i' extension to catch this case. \n " ,
bc - > port ) ;
2005-12-09 11:01:18 +00:00
2006-07-04 17:04:21 +00:00
if ( bc - > nt )
2006-07-06 15:11:40 +00:00
hanguptone_indicate ( ch ) ;
2007-06-06 21:20:11 +00:00
ch - > state = MISDN_EXTCANTMATCH ;
bc - > out_cause = 1 ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
misdn_lib_send_event ( bc , EVENT_DISCONNECT ) ;
2005-10-31 22:51:12 +00:00
break ;
}
2006-07-11 19:30:35 +00:00
if ( ch - > overlap_dial ) {
ast_mutex_lock ( & ch - > overlap_tv_lock ) ;
ch - > overlap_tv = ast_tvnow ( ) ;
ast_mutex_unlock ( & ch - > overlap_tv_lock ) ;
if ( ch - > overlap_dial_task = = - 1 ) {
ch - > overlap_dial_task =
misdn_tasks_add_variable ( ch - > overlap_dial , misdn_overlap_dial_task , ch ) ;
}
break ;
}
2007-07-04 08:43:27 +00:00
if ( ast_exists_extension ( ch - > ast , ch - > context , bc - > dad , 1 , bc - > oad ) ) {
ch - > state = MISDN_DIALING ;
2007-06-05 16:19:20 +00:00
start_pbx ( ch , bc , ch - > ast ) ;
2007-07-04 08:43:27 +00:00
}
2005-10-31 22:51:12 +00:00
} else {
/* sending INFOS as DTMF-Frames :) */
struct ast_frame fr ;
2007-06-06 21:20:11 +00:00
int digits ;
2005-10-31 22:51:12 +00:00
fr . frametype = AST_FRAME_DTMF ;
fr . subclass = bc - > info_dad [ 0 ] ;
2007-06-06 21:20:11 +00:00
fr . src = NULL ;
fr . data = NULL ;
2005-10-31 22:51:12 +00:00
fr . datalen = 0 ;
2007-06-06 21:20:11 +00:00
fr . samples = 0 ;
fr . mallocd = 0 ;
fr . offset = 0 ;
fr . delivery = ast_tv ( 0 , 0 ) ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( 0 , MISDN_GEN_APPEND_DIGITS2EXTEN , & digits , sizeof ( digits ) ) ;
2005-11-08 00:02:53 +00:00
if ( ch - > state ! = MISDN_CONNECTED ) {
if ( digits ) {
2007-06-06 21:20:11 +00:00
strncat ( bc - > dad , bc - > info_dad , sizeof ( bc - > dad ) - 1 ) ;
ast_copy_string ( ch - > ast - > exten , bc - > dad , sizeof ( ch - > ast - > exten ) ) ;
2005-11-08 00:02:53 +00:00
ast_cdr_update ( ch - > ast ) ;
2005-10-31 22:51:12 +00:00
}
ast_queue_frame ( ch - > ast , & fr ) ;
}
}
}
2007-06-06 21:20:11 +00:00
break ;
2005-10-31 22:51:12 +00:00
case EVENT_SETUP :
{
2007-06-06 21:20:11 +00:00
struct chan_list * ch = find_chan_by_bc ( cl_te , bc ) ;
int msn_valid = misdn_cfg_is_msn_valid ( bc - > port , bc - > dad ) ;
struct ast_channel * chan ;
int exceed ;
int pres , screen ;
int ai ;
int im ;
2006-10-11 08:23:16 +00:00
if ( ch ) {
switch ( ch - > state ) {
2007-06-06 21:20:11 +00:00
case MISDN_NOTHING :
ch = NULL ;
2006-10-11 08:23:16 +00:00
break ;
2007-06-06 21:20:11 +00:00
default :
2006-10-11 08:23:16 +00:00
chan_misdn_log ( 1 , bc - > port , " --> Ignoring Call we have already one \n " ) ;
return RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE ; /* Ignore MSNs which are not in our List */
}
2005-10-31 22:51:12 +00:00
}
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
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 */
}
2006-05-22 15:02:03 +00:00
2007-06-06 21:20:11 +00:00
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 : 16 ;
return RESPONSE_RELEASE_SETUP ;
}
2006-10-11 08:34:03 +00:00
2007-06-06 21:20:11 +00:00
print_bearer ( bc ) ;
2005-10-31 22:51:12 +00:00
2007-06-05 16:19:20 +00:00
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 ;
2007-06-06 21:20:11 +00:00
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 : 16 ;
2007-06-05 16:19:20 +00:00
return RESPONSE_RELEASE_SETUP ;
}
print_bearer ( bc ) ;
2007-06-06 21:20:11 +00:00
ch = init_chan_list ( ORG_MISDN ) ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
if ( ! ch ) {
chan_misdn_log ( - 1 , bc - > port , " cb_events: malloc for chan_list failed! \n " ) ;
return 0 ;
}
2007-06-05 16:19:20 +00:00
2005-10-31 22:51:12 +00:00
ch - > bc = bc ;
2007-06-06 21:20:11 +00:00
ch - > l3id = bc - > l3_id ;
ch - > addr = bc - > addr ;
2007-04-11 15:48:54 +00:00
ch - > originator = ORG_MISDN ;
2006-02-22 21:59:46 +00:00
2007-06-06 21:20:11 +00:00
chan = misdn_new ( ch , AST_STATE_RESERVED , bc - > dad , bc - > oad , AST_FORMAT_ALAW , bc - > port , bc - > channel ) ;
2007-06-11 17:05:48 +00:00
if ( ! chan ) {
misdn_lib_send_event ( bc , EVENT_RELEASE_COMPLETE ) ;
ast_log ( LOG_ERROR , " cb_events: misdn_new failed ! \n " ) ;
return 0 ;
}
2006-02-22 21:59:46 +00:00
ch - > ast = chan ;
2007-06-06 21:20:11 +00:00
if ( ( exceed = add_in_calls ( bc - > port ) ) ) {
2006-05-22 15:02:03 +00:00
char tmp [ 16 ] ;
2007-06-06 21:20:11 +00:00
snprintf ( tmp , sizeof ( tmp ) , " %d " , exceed ) ;
pbx_builtin_setvar_helper ( chan , " MAX_OVERFLOW " , tmp ) ;
2006-05-22 15:02:03 +00:00
}
2005-12-09 11:01:18 +00:00
read_config ( ch , ORG_MISDN ) ;
2007-06-05 16:19:20 +00:00
2006-06-17 10:37:35 +00:00
export_ch ( chan , bc , ch ) ;
2007-06-06 21:20:11 +00:00
ch - > ast - > rings = 1 ;
2005-12-09 11:01:18 +00:00
ast_setstate ( ch - > ast , AST_STATE_RINGING ) ;
2005-10-31 22:51:12 +00:00
2006-07-13 14:13:24 +00:00
switch ( bc - > pres ) {
2007-06-06 21:20:11 +00:00
case 1 :
pres = AST_PRES_RESTRICTED ;
chan_misdn_log ( 2 , bc - > port , " --> PRES: Restricted (1) \n " ) ;
break ;
case 2 :
pres = AST_PRES_UNAVAILABLE ;
chan_misdn_log ( 2 , bc - > port , " --> PRES: Restricted (2) \n " ) ;
break ;
default :
pres = AST_PRES_ALLOWED ;
chan_misdn_log ( 2 , bc - > port , " --> PRES: Restricted (%d) \n " , bc - > pres ) ;
2006-07-13 14:13:24 +00:00
}
switch ( bc - > screen ) {
2007-06-06 21:20:11 +00:00
case 0 :
screen = AST_PRES_USER_NUMBER_UNSCREENED ;
chan_misdn_log ( 2 , bc - > port , " --> SCREEN: Unscreened (0) \n " ) ;
break ;
case 1 :
screen = AST_PRES_USER_NUMBER_PASSED_SCREEN ;
chan_misdn_log ( 2 , bc - > port , " --> SCREEN: Passed screen (1) \n " ) ;
break ;
case 2 :
screen = AST_PRES_USER_NUMBER_FAILED_SCREEN ;
chan_misdn_log ( 2 , bc - > port , " --> SCREEN: failed screen (2) \n " ) ;
break ;
case 3 :
screen = AST_PRES_NETWORK_NUMBER ;
chan_misdn_log ( 2 , bc - > port , " --> SCREEN: Network Number (3) \n " ) ;
break ;
default :
screen = AST_PRES_USER_NUMBER_UNSCREENED ;
chan_misdn_log ( 2 , bc - > port , " --> SCREEN: Unscreened (%d) \n " , bc - > screen ) ;
2005-10-31 22:51:12 +00:00
}
2006-07-13 14:13:24 +00:00
2007-06-06 21:20:11 +00:00
chan - > cid . cid_pres = pres + screen ;
2006-07-13 14:13:24 +00:00
2005-10-31 22:51:12 +00:00
pbx_builtin_setvar_helper ( chan , " TRANSFERCAPABILITY " , ast_transfercapability2str ( bc - > capability ) ) ;
2007-06-06 21:20:11 +00:00
chan - > transfercapability = bc - > capability ;
2007-06-05 16:19:20 +00:00
2005-10-31 22:51:12 +00:00
switch ( bc - > capability ) {
2007-06-06 21:20:11 +00:00
case INFO_CAPABILITY_DIGITAL_UNRESTRICTED :
pbx_builtin_setvar_helper ( chan , " CALLTYPE " , " DIGITAL " ) ;
break ;
default :
pbx_builtin_setvar_helper ( chan , " CALLTYPE " , " SPEECH " ) ;
2005-10-31 22:51:12 +00:00
}
/** queue new chan **/
2007-06-06 21:20:11 +00:00
cl_queue_chan ( & cl_te , ch ) ;
2006-06-01 12:51:41 +00:00
2007-06-06 21:20:11 +00:00
if ( ! strstr ( ch - > allowed_bearers , " all " ) ) {
2006-06-01 12:51:41 +00:00
int i ;
2007-06-06 21:20:11 +00:00
for ( i = 0 ; i < sizeof ( allowed_bearers_array ) / sizeof ( struct allowed_bearers ) ; i + + ) {
2006-06-01 12:51:41 +00:00
if ( allowed_bearers_array [ i ] . cap = = bc - > capability ) {
2007-06-06 21:20:11 +00:00
if ( ! strstr ( ch - > allowed_bearers , allowed_bearers_array [ i ] . name ) ) {
chan_misdn_log ( 0 , bc - > port , " Bearer Not allowed \b " ) ;
bc - > out_cause = AST_CAUSE_INCOMPATIBLE_DESTINATION ;
2007-06-05 16:19:20 +00:00
2007-06-06 21:20:11 +00:00
ch - > state = MISDN_EXTCANTMATCH ;
2006-06-01 12:51:41 +00:00
misdn_lib_send_event ( bc , EVENT_RELEASE_COMPLETE ) ;
return RESPONSE_OK ;
}
}
2007-06-05 16:19:20 +00:00
2006-06-01 12:51:41 +00:00
}
}
2007-06-05 16:19:20 +00:00
2006-02-08 16:10:21 +00:00
/* Check for Pickup Request first */
if ( ! strcmp ( chan - > exten , ast_pickup_ext ( ) ) ) {
2007-05-18 09:47:19 +00:00
if ( ! ch - > noautorespond_on_setup ) {
int ret ; /** Sending SETUP_ACK**/
ret = misdn_lib_send_event ( bc , EVENT_SETUP_ACKNOWLEDGE ) ;
} else {
ch - > state = MISDN_INCOMING_SETUP ;
}
2006-02-08 16:10:21 +00:00
if ( ast_pickup_call ( chan ) ) {
2006-07-06 15:11:40 +00:00
hangup_chan ( ch ) ;
2006-02-08 16:10:21 +00:00
} else {
ch - > state = MISDN_CALLING_ACKNOWLEDGE ;
ast_setstate ( chan , AST_STATE_DOWN ) ;
2006-07-06 15:11:40 +00:00
hangup_chan ( ch ) ;
2007-06-06 21:20:11 +00:00
ch - > ast = NULL ;
2006-02-08 16:10:21 +00:00
break ;
}
}
2007-06-05 16:19:20 +00:00
2005-10-31 22:51:12 +00:00
/*
2007-06-05 16:19:20 +00:00
added support for s extension hope it will help those poor cretains
which haven ' t overlap dial .
*/
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( bc - > port , MISDN_CFG_ALWAYS_IMMEDIATE , & ai , sizeof ( ai ) ) ;
if ( ai ) {
do_immediate_setup ( bc , ch , chan ) ;
2007-06-05 16:19:20 +00:00
break ;
2006-03-27 10:13:11 +00:00
}
/* check if we should jump into s when we have no dad */
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( bc - > port , MISDN_CFG_IMMEDIATE , & im , sizeof ( im ) ) ;
if ( im & & ast_strlen_zero ( bc - > dad ) ) {
do_immediate_setup ( bc , ch , chan ) ;
2007-06-05 16:19:20 +00:00
break ;
2005-11-15 20:20:45 +00:00
}
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 5 , bc - > port , " CONTEXT:%s \n " , ch - > context ) ;
2007-06-05 16:19:20 +00:00
if ( ! ast_canmatch_extension ( ch - > ast , ch - > context , bc - > dad , 1 , bc - > oad ) ) {
if ( ast_exists_extension ( ch - > ast , ch - > context , " i " , 1 , bc - > oad ) ) {
2007-06-06 21:20:11 +00:00
ast_log ( LOG_WARNING , " Extension can never match, So jumping to 'i' extension. port(%d) \n " , bc - > port ) ;
2007-06-05 16:19:20 +00:00
strcpy ( ch - > ast - > exten , " i " ) ;
misdn_lib_send_event ( bc , EVENT_SETUP_ACKNOWLEDGE ) ;
2007-06-06 21:20:11 +00:00
ch - > state = MISDN_DIALING ;
2007-06-05 16:19:20 +00:00
start_pbx ( ch , bc , chan ) ;
break ;
}
2005-12-09 11:01:18 +00:00
2007-06-05 16:19:20 +00:00
ast_log ( LOG_WARNING , " Extension can never match, so disconnecting on port(%d). "
" maybe you want to add an 'i' extension to catch this case. \n " ,
bc - > port ) ;
2006-07-04 17:04:21 +00:00
if ( bc - > nt )
2006-07-06 15:11:40 +00:00
hanguptone_indicate ( ch ) ;
2007-06-05 16:19:20 +00:00
2007-06-06 21:20:11 +00:00
ch - > state = MISDN_EXTCANTMATCH ;
bc - > out_cause = AST_CAUSE_UNALLOCATED ;
2005-12-09 11:01:18 +00:00
2005-11-01 22:04:14 +00:00
if ( bc - > nt )
2005-10-31 22:51:12 +00:00
misdn_lib_send_event ( bc , EVENT_RELEASE_COMPLETE ) ;
else
2006-06-01 12:51:41 +00:00
misdn_lib_send_event ( bc , EVENT_RELEASE ) ;
2007-06-05 16:19:20 +00:00
2005-10-31 22:51:12 +00:00
break ;
}
2007-06-05 16:19:20 +00:00
/* Whatever happens, when sending_complete is set or we are PTMP TE, we will definitely
* jump into the dialplan , when the dialed extension does not exist , the ' s ' extension
* will be used by Asterisk automatically . */
if ( bc - > sending_complete | | ( ! bc - > nt & & ! misdn_lib_is_ptp ( bc - > port ) ) ) {
2007-05-18 09:47:19 +00:00
if ( ! ch - > noautorespond_on_setup ) {
ch - > state = MISDN_DIALING ;
2007-06-05 16:19:20 +00:00
misdn_lib_send_event ( bc , EVENT_PROCEEDING ) ;
2005-10-31 22:51:12 +00:00
} else {
2007-05-18 09:47:19 +00:00
ch - > state = MISDN_INCOMING_SETUP ;
2005-10-31 22:51:12 +00:00
}
2007-06-05 16:19:20 +00:00
start_pbx ( ch , bc , chan ) ;
break ;
}
2005-12-09 11:01:18 +00:00
2007-11-12 13:36:45 +00:00
/*
* When we are NT and overlapdial is set and if
* the number is empty , we wait for the ISDN timeout
* instead of our own timer .
*/
if ( ch - > overlap_dial & & bc - > nt & & ! bc - > dad [ 0 ] ) {
wait_for_digits ( ch , bc , chan ) ;
break ;
}
2007-06-05 16:19:20 +00:00
/*
* If overlapdial we will definitely send a SETUP_ACKNOWLEDGE and wait for more
* Infos with a Interdigit Timeout .
* */
if ( ch - > overlap_dial ) {
ast_mutex_lock ( & ch - > overlap_tv_lock ) ;
ch - > overlap_tv = ast_tvnow ( ) ;
ast_mutex_unlock ( & ch - > overlap_tv_lock ) ;
2005-12-09 11:01:18 +00:00
2007-06-05 16:19:20 +00:00
if ( ch - > overlap_dial_task = = - 1 )
ch - > overlap_dial_task =
misdn_tasks_add_variable ( ch - > overlap_dial , misdn_overlap_dial_task , ch ) ;
2005-12-09 11:01:18 +00:00
2007-06-05 16:19:20 +00:00
wait_for_digits ( ch , bc , chan ) ;
break ;
}
2006-06-17 10:37:35 +00:00
2007-06-05 16:19:20 +00:00
/* If the extension does not exist and we're not TE_PTMP we wait for more digis
* without interdigit timeout .
* */
if ( ! ast_exists_extension ( ch - > ast , ch - > context , bc - > dad , 1 , bc - > oad ) ) {
wait_for_digits ( ch , bc , chan ) ;
break ;
}
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
2007-06-05 16:19:20 +00:00
/*
* If the extension exists let ' s just jump into it .
* */
if ( ast_exists_extension ( ch - > ast , ch - > context , bc - > dad , 1 , bc - > oad ) ) {
if ( bc - > need_more_infos )
misdn_lib_send_event ( bc , EVENT_SETUP_ACKNOWLEDGE ) ;
else
misdn_lib_send_event ( bc , EVENT_PROCEEDING ) ;
2006-07-11 19:30:35 +00:00
2007-06-06 21:20:11 +00:00
ch - > state = MISDN_DIALING ;
2007-06-05 16:19:20 +00:00
start_pbx ( ch , bc , chan ) ;
break ;
2005-10-31 22:51:12 +00:00
}
}
break ;
2007-06-05 16:19:20 +00:00
2005-10-31 22:51:12 +00:00
case EVENT_SETUP_ACKNOWLEDGE :
{
ch - > state = MISDN_CALLING_ACKNOWLEDGE ;
2006-05-24 23:21:03 +00:00
if ( bc - > channel )
update_name ( ch - > ast , bc - > port , bc - > channel ) ;
2005-10-31 22:51:12 +00:00
if ( ! ast_strlen_zero ( bc - > infos_pending ) ) {
/* TX Pending Infos */
2007-06-06 21:20:11 +00:00
strncat ( bc - > dad , bc - > infos_pending , sizeof ( bc - > dad ) - strlen ( bc - > dad ) - 1 ) ;
if ( ! ch - > ast )
break ;
2007-06-09 01:06:40 +00:00
ast_copy_string ( ch - > ast - > exten , bc - > dad , sizeof ( ch - > ast - > exten ) ) ;
2007-06-06 21:20:11 +00:00
ast_copy_string ( bc - > info_dad , bc - > infos_pending , sizeof ( bc - > info_dad ) ) ;
ast_copy_string ( bc - > infos_pending , " " , sizeof ( bc - > infos_pending ) ) ;
2005-10-31 22:51:12 +00:00
misdn_lib_send_event ( bc , EVENT_INFORMATION ) ;
}
}
break ;
case EVENT_PROCEEDING :
{
2007-06-06 21:20:11 +00:00
if ( misdn_cap_is_speech ( bc - > capability ) & &
2005-10-31 22:51:12 +00:00
misdn_inband_avail ( bc ) ) {
start_bc_tones ( ch ) ;
}
2006-02-02 21:15:34 +00:00
2006-02-10 10:10:58 +00:00
ch - > state = MISDN_PROCEEDING ;
2007-06-06 21:20:11 +00:00
if ( ! ch - > ast )
break ;
2007-02-07 09:51:06 +00:00
2006-02-02 21:15:34 +00:00
ast_queue_control ( ch - > ast , AST_CONTROL_PROCEEDING ) ;
2005-10-31 22:51:12 +00:00
}
break ;
case EVENT_PROGRESS :
2007-02-07 09:51:06 +00:00
if ( bc - > channel )
2007-06-06 21:20:11 +00:00
update_name ( ch - > ast , bc - > port , bc - > channel ) ;
2007-02-07 09:51:06 +00:00
2005-11-01 22:04:14 +00:00
if ( ! bc - > nt ) {
2005-10-31 22:51:12 +00:00
if ( misdn_cap_is_speech ( bc - > capability ) & &
misdn_inband_avail ( bc )
) {
start_bc_tones ( ch ) ;
}
2007-06-06 21:20:11 +00:00
ch - > state = MISDN_PROGRESS ;
2007-02-07 09:51:06 +00:00
2007-06-06 21:20:11 +00:00
if ( ! ch - > ast )
break ;
2007-02-07 09:51:06 +00:00
ast_queue_control ( ch - > ast , AST_CONTROL_PROGRESS ) ;
2005-10-31 22:51:12 +00:00
}
break ;
case EVENT_ALERTING :
{
ch - > state = MISDN_ALERTING ;
2007-06-06 21:20:11 +00:00
if ( ! ch - > ast )
break ;
2007-02-07 09:51:06 +00:00
2005-11-15 20:20:45 +00:00
ast_queue_control ( ch - > ast , AST_CONTROL_RINGING ) ;
ast_setstate ( ch - > ast , AST_STATE_RINGING ) ;
2007-06-06 21:20:11 +00:00
cb_log ( 7 , bc - > port , " --> Set State Ringing \n " ) ;
2005-11-15 20:20:45 +00:00
2007-06-06 21:20:11 +00:00
if ( misdn_cap_is_speech ( bc - > capability ) & & misdn_inband_avail ( bc ) ) {
cb_log ( 1 , bc - > port , " Starting Tones, we have inband Data \n " ) ;
2006-02-02 21:15:34 +00:00
start_bc_tones ( ch ) ;
2006-05-05 16:38:15 +00:00
} else {
2007-06-06 21:20:11 +00:00
cb_log ( 3 , bc - > port , " --> We have no inband Data, the other end must create ringing \n " ) ;
2006-05-05 16:38:15 +00:00
if ( ch - > far_alerting ) {
2007-06-06 21:20:11 +00:00
cb_log ( 1 , bc - > port , " --> The other end can not do ringing eh ?.. we must do all ourself.. " ) ;
2006-05-05 16:38:15 +00:00
start_bc_tones ( ch ) ;
2006-07-06 15:11:40 +00:00
/*tone_indicate(ch, TONE_FAR_ALERTING);*/
2006-05-05 16:38:15 +00:00
}
2006-02-02 21:15:34 +00:00
}
2005-10-31 22:51:12 +00:00
}
break ;
case EVENT_CONNECT :
2006-04-05 14:51:48 +00:00
{
2007-06-06 21:20:11 +00:00
struct ast_channel * bridged ;
2006-08-03 16:38:00 +00:00
/*we answer when we've got our very new L3 ID from the NT stack */
2007-06-06 21:20:11 +00:00
misdn_lib_send_event ( bc , EVENT_CONNECT_ACKNOWLEDGE ) ;
2007-02-07 09:51:06 +00:00
2007-06-06 21:20:11 +00:00
if ( ! ch - > ast )
break ;
2007-02-07 09:51:06 +00:00
2007-06-06 21:20:11 +00:00
bridged = ast_bridged_channel ( ch - > ast ) ;
2006-07-06 15:11:40 +00:00
stop_indicate ( ch ) ;
2006-05-05 16:38:15 +00:00
2007-06-06 21:20:11 +00:00
if ( bridged & & ! strcasecmp ( bridged - > tech - > type , " mISDN " ) ) {
struct chan_list * bridged_ch = MISDN_ASTERISK_TECH_PVT ( bridged ) ;
2006-04-05 14:51:48 +00:00
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , bc - > port , " --> copying cpndialplan:%d and cad:%s to the A-Channel \n " , bc - > cpnnumplan , bc - > cad ) ;
2006-05-23 12:38:06 +00:00
if ( bridged_ch ) {
2007-06-06 21:20:11 +00:00
bridged_ch - > bc - > cpnnumplan = bc - > cpnnumplan ;
ast_copy_string ( bridged_ch - > bc - > cad , bc - > cad , sizeof ( bridged_ch - > bc - > cad ) ) ;
2006-05-23 12:38:06 +00:00
}
2006-04-05 14:51:48 +00:00
}
}
2007-08-30 08:50:44 +00:00
ch - > l3id = bc - > l3_id ;
ch - > addr = bc - > addr ;
start_bc_tones ( ch ) ;
2006-05-23 12:38:06 +00:00
2007-08-30 08:50:44 +00:00
ch - > state = MISDN_CONNECTED ;
ast_queue_control ( ch - > ast , AST_CONTROL_ANSWER ) ;
break ;
2005-10-31 22:51:12 +00:00
case EVENT_CONNECT_ACKNOWLEDGE :
{
2007-06-06 21:20:11 +00:00
ch - > l3id = bc - > l3_id ;
ch - > addr = bc - > addr ;
2005-10-31 22:51:12 +00:00
start_bc_tones ( ch ) ;
2007-06-06 21:20:11 +00:00
2005-10-31 22:51:12 +00:00
ch - > state = MISDN_CONNECTED ;
}
break ;
case EVENT_DISCONNECT :
2007-06-06 21:20:11 +00:00
/*we might not have an ch->ast ptr here anymore*/
if ( ch ) {
struct chan_list * holded_ch = find_holded ( cl_te , bc ) ;
chan_misdn_log ( 3 , bc - > port , " --> org:%d nt:%d, inbandavail:%d state:%d \n " , ch - > originator , bc - > nt , misdn_inband_avail ( bc ) , ch - > state ) ;
if ( ch - > originator = = ORG_AST & & ! bc - > nt & & misdn_inband_avail ( bc ) & & ch - > state ! = MISDN_CONNECTED ) {
/* If there's inband information available (e.g. a
recorded message saying what was wrong with the
dialled number , or perhaps even giving an
alternative number , then play it instead of
immediately releasing the call */
chan_misdn_log ( 1 , bc - > port , " --> Inband Info Avail, not sending RELEASE \n " ) ;
2006-06-28 14:15:29 +00:00
2007-06-06 21:20:11 +00:00
ch - > state = MISDN_DISCONNECTED ;
start_bc_tones ( ch ) ;
2007-02-07 09:51:06 +00:00
2007-06-06 21:20:11 +00:00
if ( ch - > ast ) {
ch - > ast - > hangupcause = bc - > cause ;
if ( bc - > cause = = AST_CAUSE_USER_BUSY )
ast_queue_control ( ch - > ast , AST_CONTROL_BUSY ) ;
}
ch - > need_busy = 0 ;
break ;
2007-02-07 09:51:06 +00:00
}
2007-05-18 09:36:16 +00:00
2007-06-06 21:20:11 +00:00
/*Check for holded channel, to implement transfer*/
if ( holded_ch & & holded_ch ! = ch & & ch - > ast & & ch - > state = = MISDN_CONNECTED ) {
cb_log ( 1 , bc - > port , " --> found holded ch \n " ) ;
misdn_transfer_bc ( ch , holded_ch ) ;
}
bc - > need_disconnect = 0 ;
stop_bc_tones ( ch ) ;
2006-10-11 08:23:16 +00:00
hangup_chan ( ch ) ;
2007-06-06 21:20:11 +00:00
#if 0
} else {
ch = find_holded_l3 ( cl_te , bc - > l3_id , 1 ) ;
if ( ch ) {
hangup_chan ( ch ) ;
}
# endif
2006-10-11 08:23:16 +00:00
}
2007-06-06 21:20:11 +00:00
bc - > out_cause = - 1 ;
if ( bc - > need_release )
misdn_lib_send_event ( bc , EVENT_RELEASE ) ;
break ;
2005-10-31 22:51:12 +00:00
case EVENT_RELEASE :
{
2007-06-06 21:20:11 +00:00
bc - > need_disconnect = 0 ;
bc - > need_release = 0 ;
2007-05-18 09:36:16 +00:00
2006-07-06 15:11:40 +00:00
hangup_chan ( ch ) ;
release_chan ( bc ) ;
2005-10-31 22:51:12 +00:00
}
break ;
case EVENT_RELEASE_COMPLETE :
{
2007-06-06 21:20:11 +00:00
bc - > need_disconnect = 0 ;
bc - > need_release = 0 ;
bc - > need_release_complete = 0 ;
2007-05-18 09:36:16 +00:00
2005-10-31 22:51:12 +00:00
stop_bc_tones ( ch ) ;
2006-07-06 15:11:40 +00:00
hangup_chan ( ch ) ;
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
2007-06-06 21:20:11 +00:00
if ( ch )
ch - > state = MISDN_CLEANING ;
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
release_chan ( bc ) ;
2006-07-06 15:11:40 +00:00
}
break ;
2006-10-27 11:18:32 +00:00
case EVENT_BCHAN_ERROR :
2006-07-06 15:11:40 +00:00
case EVENT_CLEANUP :
{
stop_bc_tones ( ch ) ;
2006-08-03 16:38:00 +00:00
2007-06-06 21:20:11 +00:00
switch ( ch - > state ) {
case MISDN_CALLING :
bc - > cause = AST_CAUSE_DESTINATION_OUT_OF_ORDER ;
2006-08-03 16:38:00 +00:00
break ;
2007-06-09 01:06:40 +00:00
default :
break ;
2006-08-03 16:38:00 +00:00
}
2006-07-06 15:11:40 +00:00
hangup_chan ( ch ) ;
2005-10-31 22:51:12 +00:00
release_chan ( bc ) ;
}
break ;
2006-02-02 21:15:34 +00:00
case EVENT_TONE_GENERATE :
2005-10-31 22:51:12 +00:00
{
2007-06-06 21:20:11 +00:00
int tone_len = bc - > tone_cnt ;
struct ast_channel * ast = ch - > ast ;
2006-02-02 21:15:34 +00:00
void * tmp ;
int res ;
int ( * generate ) ( struct ast_channel * chan , void * tmp , int datalen , int samples ) ;
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 9 , bc - > port , " TONE_GEN: len:%d \n " ) ;
2006-06-06 09:40:41 +00:00
2007-06-06 21:20:11 +00:00
if ( ! ast )
break ;
if ( ! ast - > generator )
break ;
2006-06-26 17:37:11 +00:00
2006-02-02 21:15:34 +00:00
tmp = ast - > generatordata ;
ast - > generatordata = NULL ;
generate = ast - > generator - > generate ;
2006-06-17 10:37:35 +00:00
2007-06-06 21:20:11 +00:00
if ( tone_len < 0 | | tone_len > 512 ) {
ast_log ( LOG_NOTICE , " TONE_GEN: len was %d, set to 128 \n " , tone_len ) ;
tone_len = 128 ;
2006-06-17 10:37:35 +00:00
}
2006-02-02 21:15:34 +00:00
res = generate ( ast , tmp , tone_len , tone_len ) ;
ast - > generatordata = tmp ;
2006-06-06 09:40:41 +00:00
2006-02-02 21:15:34 +00:00
if ( res ) {
ast_log ( LOG_WARNING , " Auto-deactivating generator \n " ) ;
ast_deactivate_generator ( ast ) ;
} else {
2007-06-06 21:20:11 +00:00
bc - > tone_cnt = 0 ;
2006-02-02 21:15:34 +00:00
}
}
break ;
2007-06-06 21:20:11 +00:00
2006-02-02 21:15:34 +00:00
case EVENT_BCHAN_DATA :
{
2007-04-11 15:48:54 +00:00
if ( ch - > bc - > AOCD_need_export )
export_aoc_vars ( ch - > originator , ch - > ast , ch - > bc ) ;
2007-06-06 21:20:11 +00:00
if ( ! misdn_cap_is_speech ( ch - > bc - > capability ) ) {
2006-05-16 14:34:21 +00:00
struct ast_frame frame ;
/*In Data Modes we queue frames*/
frame . frametype = AST_FRAME_VOICE ; /*we have no data frames yet*/
frame . subclass = AST_FORMAT_ALAW ;
frame . datalen = bc - > bframe_len ;
2007-06-06 21:20:11 +00:00
frame . samples = bc - > bframe_len ;
frame . mallocd = 0 ;
frame . offset = 0 ;
frame . delivery = ast_tv ( 0 , 0 ) ;
2006-05-16 14:34:21 +00:00
frame . src = NULL ;
2007-06-06 21:20:11 +00:00
frame . data = bc - > bframe ;
2007-02-07 09:51:06 +00:00
if ( ch - > ast )
2007-06-06 21:20:11 +00:00
ast_queue_frame ( ch - > ast , & frame ) ;
2005-10-31 22:51:12 +00:00
} else {
2006-06-06 09:40:41 +00:00
fd_set wrfs ;
2007-06-06 21:20:11 +00:00
struct timeval tv = { 0 , 0 } ;
int t ;
2006-06-06 09:40:41 +00:00
FD_ZERO ( & wrfs ) ;
2007-06-06 21:20:11 +00:00
FD_SET ( ch - > pipe [ 1 ] , & wrfs ) ;
t = select ( FD_SETSIZE , NULL , & wrfs , NULL , & tv ) ;
2005-11-08 00:02:53 +00:00
2006-06-06 09:40:41 +00:00
if ( ! t ) {
chan_misdn_log ( 9 , bc - > port , " Select Timed out \n " ) ;
break ;
}
2007-06-06 21:20:11 +00:00
if ( t < 0 ) {
chan_misdn_log ( - 1 , bc - > port , " Select Error (err=%s) \n " , strerror ( errno ) ) ;
2006-06-06 09:40:41 +00:00
break ;
}
2007-06-06 21:20:11 +00:00
if ( FD_ISSET ( ch - > pipe [ 1 ] , & wrfs ) ) {
chan_misdn_log ( 9 , bc - > port , " writing %d bytes 2 asterisk \n " , bc - > bframe_len ) ;
if ( write ( ch - > pipe [ 1 ] , bc - > bframe , bc - > bframe_len ) < = 0 ) {
2007-09-11 16:15:10 +00:00
chan_misdn_log ( 0 , bc - > port , " Write returned <=0 (err=%s) --> hanging up channel \n " , strerror ( errno ) ) ;
Merged revisions 49313 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r49313 | crichter | 2007-01-03 10:06:50 +0100 (Mi, 03 Jan 2007) | 41 lines
Merged revisions 48319,48321,48467,48552,48576,49135,49303 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r48319 | crichter | 2006-12-06 15:35:25 +0100 (Mi, 06 Dez 2006) | 1 line
changed a few debugs to higher debug levels
........
r48321 | crichter | 2006-12-06 16:48:45 +0100 (Mi, 06 Dez 2006) | 1 line
added the export and import of the MISDN_ADDRESS_COMPLETE Variable to inidcate wether the extension is already completely dialed or if there might come additional digits by information elements. also added some docs for that.
........
r48467 | crichter | 2006-12-14 14:03:49 +0100 (Do, 14 Dez 2006) | 1 line
removed FIXUP state. added check for channel allocation conflict when we create a setup while the other site creates a setup on the same channel, besides the check we resolve this conflict.
........
r48552 | crichter | 2006-12-18 11:19:39 +0100 (Mo, 18 Dez 2006) | 1 line
when our PTP Partner sends us a SETUP with a preselected channel we just accept it, even when we're NT. added some checks for segfaults.
........
r48576 | crichter | 2006-12-19 14:08:51 +0100 (Di, 19 Dez 2006) | 1 line
when we reject a channel, because it's in use already, we shouldn't process the setup anymore. made the channel allocation a bit easier and more understandable, removed a few unused lines
........
r49135 | crichter | 2007-01-02 11:07:22 +0100 (Di, 02 Jan 2007) | 1 line
added check for channel ranges in the set/empty channel functions. set pmp_l1_check default to no. added misdn restart pid cli command. added cleaning of channel when we send a RELEASE_COMPLETE.
........
r49303 | crichter | 2007-01-03 09:24:00 +0100 (Mi, 03 Jan 2007) | 9 lines
* Added check for bridging in misdn_call to avoid setting echocancellation
when 2 mISDN channels are involved and when bridging is set. That lead
to a kernel panic before under different situations, because we switched
about 2 times between hardware bridging and echocancelation
* readded MISDN_URATE variable which got lost before, this should make app_v110
work again
* fixed typo
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-03 11:15:02 +00:00
stop_bc_tones ( ch ) ;
hangup_chan ( ch ) ;
release_chan ( bc ) ;
2006-06-06 09:40:41 +00:00
}
} else {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , bc - > port , " Write Pipe full! \n " ) ;
2005-10-31 22:51:12 +00:00
}
}
}
break ;
case EVENT_TIMEOUT :
{
2006-06-26 17:37:11 +00:00
if ( ch & & bc )
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , bc - > port , " --> state: %s \n " , misdn_get_ch_state ( ch ) ) ;
2006-06-26 17:37:11 +00:00
2006-06-17 10:37:35 +00:00
switch ( ch - > state ) {
2007-06-06 21:20:11 +00:00
case MISDN_DIALING :
case MISDN_PROGRESS :
if ( bc - > nt & & ! ch - > nttimeout )
break ;
2006-10-27 11:18:32 +00:00
2007-06-06 21:20:11 +00:00
case MISDN_CALLING :
case MISDN_ALERTING :
case MISDN_PROCEEDING :
case MISDN_CALLING_ACKNOWLEDGE :
if ( bc - > nt ) {
bc - > progress_indicator = 8 ;
hanguptone_indicate ( ch ) ;
}
2006-06-17 10:37:35 +00:00
2007-06-06 21:20:11 +00:00
bc - > out_cause = AST_CAUSE_UNALLOCATED ;
misdn_lib_send_event ( bc , EVENT_DISCONNECT ) ;
2006-06-17 10:37:35 +00:00
break ;
2007-06-06 21:20:11 +00:00
case MISDN_WAITING4DIGS :
if ( bc - > nt ) {
bc - > progress_indicator = 8 ;
bc - > out_cause = AST_CAUSE_UNALLOCATED ;
hanguptone_indicate ( ch ) ;
misdn_lib_send_event ( bc , EVENT_DISCONNECT ) ;
} else {
bc - > out_cause = AST_CAUSE_NORMAL_CLEARING ;
misdn_lib_send_event ( bc , EVENT_RELEASE ) ;
}
2006-07-06 15:11:40 +00:00
break ;
2007-06-06 21:20:11 +00:00
case MISDN_CLEANING :
chan_misdn_log ( 1 , bc - > port , " --> in state cleaning .. so ingoring, the stack should clean it for us \n " ) ;
2006-06-17 10:37:35 +00:00
break ;
2007-06-06 21:20:11 +00:00
default :
misdn_lib_send_event ( bc , EVENT_RELEASE_COMPLETE ) ;
2005-10-31 22:51:12 +00:00
}
2007-06-06 21:20:11 +00:00
}
break ;
2006-07-06 15:11:40 +00:00
2005-10-31 22:51:12 +00:00
/***************************/
/** Suplementary Services **/
/***************************/
case EVENT_RETRIEVE :
{
2007-06-06 21:20:11 +00:00
struct ast_channel * hold_ast ;
Merged revisions 62912 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r62912 | crichter | 2007-05-03 16:36:32 +0200 (Do, 03 Mai 2007) | 17 lines
Merged revisions 61357,61770,62885 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r61357 | crichter | 2007-04-11 14:05:57 +0200 (Mi, 11 Apr 2007) | 1 line
some fixes for PMP Hold/Retrieve, it should work now, when briding=no
........
r61770 | crichter | 2007-04-24 15:50:05 +0200 (Di, 24 Apr 2007) | 1 line
added lock for sending messages to avoid double sending. shuffled some empty_chans after the cb_event calls, this avoids that a release_complete from a quite different call releases a fresh created setup by accident.
........
r62885 | crichter | 2007-05-03 15:59:00 +0200 (Do, 03 Mai 2007) | 1 line
fixed the problem that misdn_write did not return -1 when called with 0 samples in a frame this resultet in a deadlock in some circumstances, when the call ended because of a busy extension. added encoding of keypad.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64955 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 09:50:33 +00:00
if ( ! ch ) {
2007-09-11 16:15:10 +00:00
chan_misdn_log ( 4 , bc - > port , " --> no CH, searching in holded \n " ) ;
2007-06-06 21:20:11 +00:00
ch = find_holded_l3 ( cl_te , bc - > l3_id , 1 ) ;
Merged revisions 62912 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r62912 | crichter | 2007-05-03 16:36:32 +0200 (Do, 03 Mai 2007) | 17 lines
Merged revisions 61357,61770,62885 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r61357 | crichter | 2007-04-11 14:05:57 +0200 (Mi, 11 Apr 2007) | 1 line
some fixes for PMP Hold/Retrieve, it should work now, when briding=no
........
r61770 | crichter | 2007-04-24 15:50:05 +0200 (Di, 24 Apr 2007) | 1 line
added lock for sending messages to avoid double sending. shuffled some empty_chans after the cb_event calls, this avoids that a release_complete from a quite different call releases a fresh created setup by accident.
........
r62885 | crichter | 2007-05-03 15:59:00 +0200 (Do, 03 Mai 2007) | 1 line
fixed the problem that misdn_write did not return -1 when called with 0 samples in a frame this resultet in a deadlock in some circumstances, when the call ended because of a busy extension. added encoding of keypad.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64955 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 09:50:33 +00:00
}
2006-08-08 09:19:06 +00:00
if ( ! ch ) {
ast_log ( LOG_WARNING , " Found no Holded channel, cannot Retrieve \n " ) ;
misdn_lib_send_event ( bc , EVENT_RETRIEVE_REJECT ) ;
break ;
}
2006-10-11 08:23:16 +00:00
/*remember the channel again*/
2007-06-06 21:20:11 +00:00
ch - > bc = bc ;
2005-10-31 22:51:12 +00:00
ch - > state = MISDN_CONNECTED ;
2006-10-11 08:23:16 +00:00
2007-06-06 21:20:11 +00:00
ch - > hold_info . port = 0 ;
ch - > hold_info . channel = 0 ;
hold_ast = ast_bridged_channel ( ch - > ast ) ;
2005-10-31 22:51:12 +00:00
if ( hold_ast ) {
ast_moh_stop ( hold_ast ) ;
}
2007-09-11 16:15:10 +00:00
if ( misdn_lib_send_event ( bc , EVENT_RETRIEVE_ACKNOWLEDGE ) < 0 ) {
chan_misdn_log ( 4 , bc - > port , " --> RETRIEVE_ACK failed \n " ) ;
2005-10-31 22:51:12 +00:00
misdn_lib_send_event ( bc , EVENT_RETRIEVE_REJECT ) ;
2007-09-11 16:15:10 +00:00
}
2005-10-31 22:51:12 +00:00
}
break ;
case EVENT_HOLD :
{
int hold_allowed ;
2007-06-06 21:20:11 +00:00
struct ast_channel * bridged = ast_bridged_channel ( ch - > ast ) ;
misdn_cfg_get ( bc - > port , MISDN_CFG_HOLD_ALLOWED , & hold_allowed , sizeof ( hold_allowed ) ) ;
2005-10-31 22:51:12 +00:00
if ( ! hold_allowed ) {
2005-12-09 11:01:18 +00:00
chan_misdn_log ( - 1 , bc - > port , " Hold not allowed this port. \n " ) ;
2005-10-31 22:51:12 +00:00
misdn_lib_send_event ( bc , EVENT_HOLD_REJECT ) ;
break ;
}
2006-10-11 08:23:16 +00:00
if ( bridged ) {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 2 , bc - > port , " Bridge Partner is of type: %s \n " , bridged - > tech - > type ) ;
2005-10-31 22:51:12 +00:00
ch - > state = MISDN_HOLDED ;
ch - > l3id = bc - > l3_id ;
misdn_lib_send_event ( bc , EVENT_HOLD_ACKNOWLEDGE ) ;
2006-04-03 19:17:59 +00:00
2006-07-19 20:44:39 +00:00
/* XXX This should queue an AST_CONTROL_HOLD frame on this channel
* instead of starting moh on the bridged channel directly */
ast_moh_start ( bridged , NULL , NULL ) ;
2006-10-11 08:23:16 +00:00
/*forget the channel now*/
2007-06-06 21:20:11 +00:00
ch - > bc = NULL ;
ch - > hold_info . port = bc - > port ;
ch - > hold_info . channel = bc - > channel ;
2006-10-11 08:23:16 +00:00
2005-10-31 22:51:12 +00:00
} else {
misdn_lib_send_event ( bc , EVENT_HOLD_REJECT ) ;
2005-11-01 22:04:14 +00:00
chan_misdn_log ( 0 , bc - > port , " We aren't bridged to anybody \n " ) ;
2005-10-31 22:51:12 +00:00
}
}
break ;
2005-12-09 11:01:18 +00:00
case EVENT_FACILITY :
2006-08-15 16:49:26 +00:00
print_facility ( & ( bc - > fac_in ) , bc ) ;
2005-12-09 11:01:18 +00:00
2006-08-15 16:49:26 +00:00
switch ( bc - > fac_in . Function ) {
2007-10-29 16:34:45 +00:00
# ifdef HAVE_MISDN_FAC_RESULT
2007-10-22 10:04:04 +00:00
case Fac_RESULT :
break ;
2007-10-29 16:34:45 +00:00
# endif
2006-08-16 13:19:54 +00:00
case Fac_CD :
2007-10-22 10:04:04 +00:00
if ( ch ) {
2007-06-06 21:20:11 +00:00
struct ast_channel * bridged = ast_bridged_channel ( ch - > ast ) ;
2006-08-16 13:19:54 +00:00
struct chan_list * ch_br ;
if ( bridged & & MISDN_ASTERISK_TECH_PVT ( bridged ) ) {
2007-06-06 21:20:11 +00:00
ch_br = MISDN_ASTERISK_TECH_PVT ( bridged ) ;
/*ch->state = MISDN_FACILITY_DEFLECTED;*/
2006-08-16 13:19:54 +00:00
if ( ch_br - > bc ) {
if ( ast_exists_extension ( bridged , ch - > context , ( char * ) bc - > fac_in . u . CDeflection . DeflectedToNumber , 1 , bc - > oad ) ) {
2007-06-06 21:20:11 +00:00
ch_br - > state = MISDN_DIALING ;
2006-08-16 13:19:54 +00:00
if ( pbx_start_chan ( ch_br ) < 0 ) {
chan_misdn_log ( - 1 , ch_br - > bc - > port , " ast_pbx_start returned < 0 in misdn_overlap_dial_task \n " ) ;
}
2006-08-15 16:49:26 +00:00
}
}
2005-12-09 11:01:18 +00:00
}
2006-08-16 13:19:54 +00:00
misdn_lib_send_event ( bc , EVENT_DISCONNECT ) ;
}
break ;
case Fac_AOCDCurrency :
2007-10-22 10:04:04 +00:00
if ( ch ) {
bc - > AOCDtype = Fac_AOCDCurrency ;
memcpy ( & ( bc - > AOCD . currency ) , & ( bc - > fac_in . u . AOCDcur ) , sizeof ( bc - > AOCD . currency ) ) ;
bc - > AOCD_need_export = 1 ;
export_aoc_vars ( ch - > originator , ch - > ast , bc ) ;
}
2006-08-16 13:19:54 +00:00
break ;
case Fac_AOCDChargingUnit :
2007-10-22 10:04:04 +00:00
if ( ch ) {
bc - > AOCDtype = Fac_AOCDChargingUnit ;
memcpy ( & ( bc - > AOCD . chargingUnit ) , & ( bc - > fac_in . u . AOCDchu ) , sizeof ( bc - > AOCD . chargingUnit ) ) ;
bc - > AOCD_need_export = 1 ;
export_aoc_vars ( ch - > originator , ch - > ast , bc ) ;
}
2006-08-16 13:19:54 +00:00
break ;
2007-10-22 10:04:04 +00:00
case Fac_None :
2007-10-29 16:34:45 +00:00
# ifdef HAVE_MISDN_FAC_ERROR
2007-10-22 10:04:04 +00:00
case Fac_ERROR :
2007-10-29 16:34:45 +00:00
# endif
2007-10-22 10:04:04 +00:00
break ;
2005-12-09 11:01:18 +00:00
default :
2006-08-15 16:49:26 +00:00
chan_misdn_log ( 0 , bc - > port , " --> not yet handled: facility type:%p \n " , bc - > fac_in . Function ) ;
2005-12-09 11:01:18 +00:00
}
break ;
2006-04-03 19:17:59 +00:00
case EVENT_RESTART :
2006-06-01 12:51:41 +00:00
2007-07-02 09:23:08 +00:00
if ( ! bc - > dummy ) {
stop_bc_tones ( ch ) ;
release_chan ( bc ) ;
}
2006-04-03 19:17:59 +00:00
break ;
2007-06-06 21:20:11 +00:00
2005-10-31 22:51:12 +00:00
default :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , 0 , " Got Unknown Event \n " ) ;
2005-10-31 22:51:12 +00:00
break ;
}
return RESPONSE_OK ;
}
/** TE STUFF END **/
/******************************************
*
* Asterisk Channel Endpoint END
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2006-08-21 02:11:39 +00:00
static int unload_module ( void )
2006-04-17 16:42:21 +00:00
{
/* First, take us out of the channel loop */
ast_log ( LOG_VERBOSE , " -- Unregistering mISDN Channel Driver -- \n " ) ;
2006-07-11 19:30:35 +00:00
misdn_tasks_destroy ( ) ;
2006-04-17 16:42:21 +00:00
2007-06-06 21:20:11 +00:00
if ( ! g_config_initialized )
return 0 ;
2006-04-17 16:42:21 +00:00
2006-09-18 19:54:18 +00:00
ast_cli_unregister_multiple ( chan_misdn_clis , sizeof ( chan_misdn_clis ) / sizeof ( struct ast_cli_entry ) ) ;
2006-04-17 16:42:21 +00:00
/* ast_unregister_application("misdn_crypt"); */
ast_unregister_application ( " misdn_set_opt " ) ;
ast_unregister_application ( " misdn_facility " ) ;
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
ast_unregister_application ( " misdn_check_l2l1 " ) ;
2006-04-17 16:42:21 +00:00
ast_channel_unregister ( & misdn_tech ) ;
free_robin_list ( ) ;
misdn_cfg_destroy ( ) ;
misdn_lib_destroy ( ) ;
if ( misdn_debug )
2007-06-06 21:20:11 +00:00
ast_free ( misdn_debug ) ;
2006-04-17 16:42:21 +00:00
if ( misdn_debug_only )
2007-06-06 21:20:11 +00:00
ast_free ( misdn_debug_only ) ;
ast_free ( misdn_ports ) ;
2006-08-17 09:14:01 +00:00
2006-04-17 16:42:21 +00:00
return 0 ;
}
2006-08-21 02:11:39 +00:00
static int load_module ( void )
2005-10-31 22:51:12 +00:00
{
2006-07-11 19:30:35 +00:00
int i , port ;
2007-11-12 12:49:19 +00:00
int ntflags = 0 , ntkc = 0 ;
2007-06-06 21:20:11 +00:00
char ports [ 256 ] = " " ;
char tempbuf [ BUFFERSIZE + 1 ] ;
char ntfile [ BUFFERSIZE + 1 ] ;
struct misdn_lib_iface iface = {
. cb_event = cb_events ,
. cb_log = chan_misdn_log ,
. cb_jb_empty = chan_misdn_jb_empty ,
} ;
2006-07-11 19:30:35 +00:00
2007-06-06 21:20:11 +00:00
max_ports = misdn_lib_maxports_get ( ) ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
if ( max_ports < = 0 ) {
2005-10-31 22:51:12 +00:00
ast_log ( LOG_ERROR , " Unable to initialize mISDN \n " ) ;
2006-09-22 15:45:51 +00:00
return AST_MODULE_LOAD_DECLINE ;
2005-10-31 22:51:12 +00:00
}
2007-08-16 21:09:46 +00:00
if ( misdn_cfg_init ( max_ports , 0 ) ) {
2006-08-08 18:13:40 +00:00
ast_log ( LOG_ERROR , " Unable to initialize misdn_config. \n " ) ;
2006-08-31 21:00:20 +00:00
return AST_MODULE_LOAD_DECLINE ;
2006-08-08 18:13:40 +00:00
}
2007-06-06 21:20:11 +00:00
g_config_initialized = 1 ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
misdn_debug = ast_malloc ( sizeof ( int ) * ( max_ports + 1 ) ) ;
if ( ! misdn_debug ) {
ast_log ( LOG_ERROR , " Out of memory for misdn_debug \n " ) ;
return AST_MODULE_LOAD_DECLINE ;
}
misdn_ports = ast_malloc ( sizeof ( int ) * ( max_ports + 1 ) ) ;
if ( ! misdn_ports ) {
ast_log ( LOG_ERROR , " Out of memory for misdn_ports \n " ) ;
return AST_MODULE_LOAD_DECLINE ;
}
misdn_cfg_get ( 0 , MISDN_GEN_DEBUG , & misdn_debug [ 0 ] , sizeof ( misdn_debug [ 0 ] ) ) ;
2006-08-17 09:14:01 +00:00
for ( i = 1 ; i < = max_ports ; i + + ) {
2005-10-31 22:51:12 +00:00
misdn_debug [ i ] = misdn_debug [ 0 ] ;
2006-08-17 09:14:01 +00:00
misdn_ports [ i ] = i ;
}
* misdn_ports = 0 ;
2007-06-06 21:20:11 +00:00
misdn_debug_only = ast_calloc ( max_ports + 1 , sizeof ( int ) ) ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( 0 , MISDN_GEN_TRACEFILE , tempbuf , sizeof ( tempbuf ) ) ;
if ( ! ast_strlen_zero ( tempbuf ) )
tracing = 1 ;
misdn_in_calls = ast_malloc ( sizeof ( int ) * ( max_ports + 1 ) ) ;
misdn_out_calls = ast_malloc ( sizeof ( int ) * ( max_ports + 1 ) ) ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
for ( i = 1 ; i < = max_ports ; i + + ) {
misdn_in_calls [ i ] = 0 ;
misdn_out_calls [ i ] = 0 ;
2006-05-22 15:02:03 +00:00
}
2007-06-06 21:20:11 +00:00
2005-11-01 22:04:14 +00:00
ast_mutex_init ( & cl_te_lock ) ;
2007-07-02 09:34:19 +00:00
ast_mutex_init ( & release_lock ) ;
2006-02-02 21:15:34 +00:00
misdn_cfg_update_ptp ( ) ;
2005-10-31 22:51:12 +00:00
misdn_cfg_get_ports_string ( ports ) ;
2006-05-23 19:40:16 +00:00
2007-06-06 21:20:11 +00:00
if ( ! ast_strlen_zero ( ports ) )
chan_misdn_log ( 0 , 0 , " Got: %s from get_ports \n " , ports ) ;
if ( misdn_lib_init ( ports , & iface , NULL ) )
chan_misdn_log ( 0 , 0 , " No te ports initialized \n " ) ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( 0 , MISDN_GEN_NTDEBUGFLAGS , & ntflags , sizeof ( ntflags ) ) ;
misdn_cfg_get ( 0 , MISDN_GEN_NTDEBUGFILE , & ntfile , sizeof ( ntfile ) ) ;
2007-11-12 12:49:19 +00:00
misdn_cfg_get ( 0 , MISDN_GEN_NTKEEPCALLS , & ntkc , sizeof ( ntkc ) ) ;
2005-10-31 22:51:12 +00:00
2007-11-12 12:49:19 +00:00
misdn_lib_nt_keepcalls ( ntkc ) ;
2007-06-06 21:20:11 +00:00
misdn_lib_nt_debug_init ( ntflags , ntfile ) ;
2006-06-29 20:12:19 +00:00
2007-06-06 21:20:11 +00:00
if ( ast_channel_register ( & misdn_tech ) ) {
ast_log ( LOG_ERROR , " Unable to register channel class %s \n " , misdn_type ) ;
unload_module ( ) ;
return AST_MODULE_LOAD_DECLINE ;
2005-10-31 22:51:12 +00:00
}
2006-09-18 19:54:18 +00:00
ast_cli_register_multiple ( chan_misdn_clis , sizeof ( chan_misdn_clis ) / sizeof ( struct ast_cli_entry ) ) ;
2007-06-06 21:20:11 +00:00
2006-05-23 12:38:06 +00:00
ast_register_application ( " misdn_set_opt " , misdn_set_opt_exec , " misdn_set_opt " ,
2005-10-31 22:51:12 +00:00
" misdn_set_opt(:<opt><optarg>:<opt><optarg>..): \n "
" Sets mISDN opts. and optargs \n "
" \n "
2006-05-23 12:38:06 +00:00
" The available options are: \n "
" d - Send display text on called phone, text is the optparam \n "
" n - don't detect dtmf tones on called channel \n "
" h - make digital outgoing call \n "
" c - make crypted outgoing call, param is keyindex \n "
" e - perform echo cancelation on this channel, \n "
" takes taps as arguments (32,64,128,256) \n "
" s - send Non Inband DTMF as inband \n "
" vr - rxgain control \n "
" vt - txgain control \n "
2007-08-17 08:29:56 +00:00
" i - Ignore detected dtmf tones, don't signal them to asterisk, they will be transported inband. \n "
2005-10-31 22:51:12 +00:00
) ;
ast_register_application ( " misdn_facility " , misdn_facility_exec , " misdn_facility " ,
" misdn_facility(<FACILITY_TYPE>|<ARG1>|..) \n "
" Sends the Facility Message FACILITY_TYPE with \n "
" the given Arguments to the current ISDN Channel \n "
" Supported Facilities are: \n "
" \n "
" type=calldeflect args=Nr where to deflect \n "
) ;
2005-12-09 11:01:18 +00:00
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
ast_register_application ( " misdn_check_l2l1 " , misdn_check_l2l1 , " misdn_check_l2l1 " ,
" misdn_check_l2l1(<port>||g:<groupname>,timeout) "
" Checks if the L2 and L1 are up on either the given <port> or \n "
" on the ports in the group with <groupname> \n "
" If the L1/L2 are down, check_l2l1 gets up the L1/L2 and waits \n "
" for <timeout> seconds that this happens. Otherwise, nothing happens \n "
" \n "
" This application, ensures the L1/L2 state of the Ports in a group \n "
" it is intended to make the pmp_l1_check option redundant and to \n "
" fix a buggy switch config from your provider \n "
" \n "
" a sample dialplan would look like: \n \n "
" exten => _X.,1,misdn_check_l2l1(g:out|2) \n "
" exten => _X.,n,dial(mISDN/g:out/${EXTEN}) \n "
" \n "
) ;
2007-06-06 21:20:11 +00:00
misdn_cfg_get ( 0 , MISDN_GEN_TRACEFILE , global_tracefile , sizeof ( global_tracefile ) ) ;
2006-05-22 15:02:03 +00:00
2006-07-11 19:30:35 +00:00
/* start the l1 watchers */
for ( port = misdn_cfg_get_next_port ( 0 ) ; port > = 0 ; port = misdn_cfg_get_next_port ( port ) ) {
int l1timeout ;
misdn_cfg_get ( port , MISDN_CFG_L1_TIMEOUT , & l1timeout , sizeof ( l1timeout ) ) ;
if ( l1timeout ) {
chan_misdn_log ( 4 , 0 , " Adding L1watcher task: port:%d timeout:%ds \n " , port , l1timeout ) ;
2006-08-17 09:14:01 +00:00
misdn_tasks_add ( l1timeout * 1000 , misdn_l1_task , & misdn_ports [ port ] ) ;
2006-07-11 19:30:35 +00:00
}
}
2007-06-06 21:20:11 +00:00
2006-09-19 18:48:17 +00:00
chan_misdn_log ( 0 , 0 , " -- mISDN Channel Driver Registered -- \n " ) ;
2005-10-31 22:51:12 +00:00
return 0 ;
}
2006-08-21 02:11:39 +00:00
static int reload ( void )
2006-02-10 14:17:28 +00:00
{
reload_config ( ) ;
return 0 ;
}
2005-10-31 22:51:12 +00:00
/*** SOME APPS ;)***/
static int misdn_facility_exec ( struct ast_channel * chan , void * data )
{
struct chan_list * ch = MISDN_ASTERISK_TECH_PVT ( chan ) ;
2007-06-06 21:20:11 +00:00
char * parse , * tok , * tokb ;
2005-10-31 22:51:12 +00:00
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 0 , 0 , " TYPE: %s \n " , chan - > tech - > type ) ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
if ( strcasecmp ( chan - > tech - > type , " mISDN " ) ) {
2005-10-31 22:51:12 +00:00
ast_log ( LOG_WARNING , " misdn_facility makes only sense with chan_misdn channels! \n " ) ;
return - 1 ;
}
2005-11-08 01:55:31 +00:00
if ( ast_strlen_zero ( ( char * ) data ) ) {
2005-10-31 22:51:12 +00:00
ast_log ( LOG_WARNING , " misdn_facility Requires arguments \n " ) ;
return - 1 ;
}
2007-06-06 21:20:11 +00:00
parse = ast_strdupa ( data ) ;
tok = strtok_r ( parse , " | " , & tokb ) ;
2005-10-31 22:51:12 +00:00
if ( ! tok ) {
ast_log ( LOG_WARNING , " misdn_facility Requires arguments \n " ) ;
return - 1 ;
}
2007-06-06 21:20:11 +00:00
if ( ! strcasecmp ( tok , " calldeflect " ) ) {
tok = strtok_r ( NULL , " | " , & tokb ) ;
2005-10-31 22:51:12 +00:00
if ( ! tok ) {
ast_log ( LOG_WARNING , " Facility: Call Defl Requires arguments \n " ) ;
}
2007-06-06 21:20:11 +00:00
2006-08-15 16:49:26 +00:00
if ( strlen ( tok ) > = sizeof ( ch - > bc - > fac_out . u . CDeflection . DeflectedToNumber ) ) {
ast_log ( LOG_WARNING , " Facility: Number argument too long (up to 15 digits are allowed). Ignoring. \n " ) ;
return 0 ;
}
2006-08-16 13:19:54 +00:00
ch - > bc - > fac_out . Function = Fac_CD ;
2007-06-06 21:20:11 +00:00
ast_copy_string ( ( char * ) ch - > bc - > fac_out . u . CDeflection . DeflectedToNumber , tok , sizeof ( ch - > bc - > fac_out . u . CDeflection . DeflectedToNumber ) ) ;
2006-08-15 16:49:26 +00:00
misdn_lib_send_event ( ch - > bc , EVENT_FACILITY ) ;
2005-10-31 22:51:12 +00:00
} else {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , ch - > bc - > port , " Unknown Facility: %s \n " , tok ) ;
2005-10-31 22:51:12 +00:00
}
2007-06-06 21:20:11 +00:00
2005-10-31 22:51:12 +00:00
return 0 ;
}
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
static int misdn_check_l2l1 ( struct ast_channel * chan , void * data )
{
2007-06-06 21:20:11 +00:00
char * parse ;
char group [ BUFFERSIZE + 1 ] ;
char * port_str ;
int port = 0 ;
int timeout ;
int dowait = 0 ;
int port_up ;
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
AST_DECLARE_APP_ARGS ( args ,
AST_APP_ARG ( grouppar ) ;
AST_APP_ARG ( timeout ) ;
) ;
if ( ast_strlen_zero ( ( char * ) data ) ) {
ast_log ( LOG_WARNING , " misdn_check_l2l1 Requires arguments \n " ) ;
return - 1 ;
}
2007-06-06 21:20:11 +00:00
parse = ast_strdupa ( data ) ;
AST_STANDARD_APP_ARGS ( args , parse ) ;
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
if ( args . argc ! = 2 ) {
ast_log ( LOG_WARNING , " Wrong argument count \n " ) ;
return 0 ;
}
/*ast_log(LOG_NOTICE, "Arguments: group/port '%s' timeout '%s'\n", args.grouppar, args.timeout);*/
2007-06-06 21:20:11 +00:00
timeout = atoi ( args . timeout ) ;
port_str = args . grouppar ;
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
2007-06-06 21:20:11 +00:00
if ( port_str [ 0 ] = = ' g ' & & port_str [ 1 ] = = ' : ' ) {
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
/* We make a group call lets checkout which ports are in my group */
port_str + = 2 ;
2007-06-06 21:20:11 +00:00
ast_copy_string ( group , port_str , sizeof ( group ) ) ;
chan_misdn_log ( 2 , 0 , " Checking Ports in group: %s \n " , group ) ;
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
for ( port = misdn_cfg_get_next_port ( port ) ;
port > 0 ;
port = misdn_cfg_get_next_port ( port ) ) {
2007-06-06 21:20:11 +00:00
char cfg_group [ BUFFERSIZE + 1 ] ;
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 2 , 0 , " trying port %d \n " , port ) ;
misdn_cfg_get ( port , MISDN_CFG_GROUPNAME , cfg_group , sizeof ( cfg_group ) ) ;
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
if ( ! strcasecmp ( cfg_group , group ) ) {
port_up = misdn_lib_port_up ( port , 1 ) ;
if ( ! port_up ) {
chan_misdn_log ( 2 , 0 , " --> port '%d' \n " , port ) ;
misdn_lib_get_port_up ( port ) ;
2007-06-06 21:20:11 +00:00
dowait = 1 ;
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
}
}
}
} else {
port = atoi ( port_str ) ;
chan_misdn_log ( 2 , 0 , " Checking Port: %d \n " , port ) ;
port_up = misdn_lib_port_up ( port , 1 ) ;
if ( ! port_up ) {
misdn_lib_get_port_up ( port ) ;
2007-06-06 21:20:11 +00:00
dowait = 1 ;
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
}
}
if ( dowait ) {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 2 , 0 , " Waiting for '%d' seconds \n " , timeout ) ;
ast_safe_sleep ( chan , timeout * 1000 ) ;
Merged revisions 63534 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r63534 | crichter | 2007-05-09 15:17:10 +0200 (Mi, 09 Mai 2007) | 17 lines
Merged revisions 62945,63402,63519 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r62945 | crichter | 2007-05-03 17:39:21 +0200 (Do, 03 Mai 2007) | 1 line
when we're in state WAITING4DIGS, we use the asterisk tone-generator which prods us, so we can't just return -1 in misdn_write in this case. Added a MISDN_KEYPAD channel variable, and fixed the sending of keypad. this enables us to modify the call forward parameters in the switch.
........
r63402 | crichter | 2007-05-08 17:07:37 +0200 (Di, 08 Mai 2007) | 1 line
added application misdn_check_l2l1 which tries to pull up the L1/L2 on all ports that have the layers down in a group. It waits then for a timeout. This helps for scenarios where multiple PMP BRIs are grouped together, or where a provider has a faulty PTP Implementation, that looses the L2 after a while.
........
r63519 | crichter | 2007-05-09 13:26:16 +0200 (Mi, 09 Mai 2007) | 1 line
release_chan frees ch, so we should never touch ch after release_chan, this may cause segfaults.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-18 10:00:21 +00:00
}
return 0 ;
}
2005-10-31 22:51:12 +00:00
static int misdn_set_opt_exec ( struct ast_channel * chan , void * data )
{
struct chan_list * ch = MISDN_ASTERISK_TECH_PVT ( chan ) ;
2007-06-06 21:20:11 +00:00
char * tok , * tokb , * parse ;
int keyidx = 0 ;
int rxgain = 0 ;
int txgain = 0 ;
int change_jitter = 0 ;
if ( strcasecmp ( chan - > tech - > type , " mISDN " ) ) {
2005-10-31 22:51:12 +00:00
ast_log ( LOG_WARNING , " misdn_set_opt makes only sense with chan_misdn channels! \n " ) ;
return - 1 ;
}
2005-11-08 01:55:31 +00:00
if ( ast_strlen_zero ( ( char * ) data ) ) {
2005-10-31 22:51:12 +00:00
ast_log ( LOG_WARNING , " misdn_set_opt Requires arguments \n " ) ;
return - 1 ;
}
2007-06-06 21:20:11 +00:00
parse = ast_strdupa ( data ) ;
for ( tok = strtok_r ( parse , " : " , & tokb ) ;
2005-10-31 22:51:12 +00:00
tok ;
2007-06-06 21:20:11 +00:00
tok = strtok_r ( NULL , " : " , & tokb ) ) {
int neglect = 0 ;
2005-10-31 22:51:12 +00:00
if ( tok [ 0 ] = = ' ! ' ) {
2007-06-06 21:20:11 +00:00
neglect = 1 ;
2005-10-31 22:51:12 +00:00
tok + + ;
}
switch ( tok [ 0 ] ) {
case ' d ' :
2007-06-06 21:20:11 +00:00
ast_copy_string ( ch - > bc - > display , + + tok , sizeof ( ch - > bc - > display ) ) ;
chan_misdn_log ( 1 , ch - > bc - > port , " SETOPT: Display:%s \n " , ch - > bc - > display ) ;
2005-10-31 22:51:12 +00:00
break ;
case ' n ' :
2005-11-01 22:04:14 +00:00
chan_misdn_log ( 1 , ch - > bc - > port , " SETOPT: No DSP \n " ) ;
2007-06-06 21:20:11 +00:00
ch - > bc - > nodsp = 1 ;
2005-10-31 22:51:12 +00:00
break ;
case ' j ' :
2006-02-10 14:17:28 +00:00
chan_misdn_log ( 1 , ch - > bc - > port , " SETOPT: jitter \n " ) ;
tok + + ;
2007-06-06 21:20:11 +00:00
change_jitter = 1 ;
2006-02-10 14:17:28 +00:00
switch ( tok [ 0 ] ) {
2007-06-06 21:20:11 +00:00
case ' b ' :
ch - > jb_len = atoi ( + + tok ) ;
chan_misdn_log ( 1 , ch - > bc - > port , " --> buffer_len:%d \n " , ch - > jb_len ) ;
2006-02-10 14:17:28 +00:00
break ;
case ' t ' :
2007-06-06 21:20:11 +00:00
ch - > jb_upper_threshold = atoi ( + + tok ) ;
chan_misdn_log ( 1 , ch - > bc - > port , " --> upper_threshold:%d \n " , ch - > jb_upper_threshold ) ;
2006-02-10 14:17:28 +00:00
break ;
case ' n ' :
2007-06-06 21:20:11 +00:00
ch - > bc - > nojitter = 1 ;
2006-02-10 14:17:28 +00:00
chan_misdn_log ( 1 , ch - > bc - > port , " --> nojitter \n " ) ;
break ;
default :
2007-06-06 21:20:11 +00:00
ch - > jb_len = 4000 ;
ch - > jb_upper_threshold = 0 ;
chan_misdn_log ( 1 , ch - > bc - > port , " --> buffer_len:%d (default) \n " , ch - > jb_len ) ;
chan_misdn_log ( 1 , ch - > bc - > port , " --> upper_threshold:%d (default) \n " , ch - > jb_upper_threshold ) ;
2006-02-10 14:17:28 +00:00
}
2005-10-31 22:51:12 +00:00
break ;
case ' v ' :
tok + + ;
2007-06-06 21:20:11 +00:00
switch ( tok [ 0 ] ) {
2005-10-31 22:51:12 +00:00
case ' r ' :
2007-06-06 21:20:11 +00:00
rxgain = atoi ( + + tok ) ;
if ( rxgain < - 8 )
rxgain = - 8 ;
if ( rxgain > 8 )
rxgain = 8 ;
ch - > bc - > rxgain = rxgain ;
chan_misdn_log ( 1 , ch - > bc - > port , " SETOPT: Volume:%d \n " , rxgain ) ;
2005-10-31 22:51:12 +00:00
break ;
case ' t ' :
2007-06-06 21:20:11 +00:00
txgain = atoi ( + + tok ) ;
if ( txgain < - 8 )
txgain = - 8 ;
if ( txgain > 8 )
txgain = 8 ;
ch - > bc - > txgain = txgain ;
chan_misdn_log ( 1 , ch - > bc - > port , " SETOPT: Volume:%d \n " , txgain ) ;
2005-10-31 22:51:12 +00:00
break ;
}
break ;
case ' c ' :
2007-06-06 21:20:11 +00:00
keyidx = atoi ( + + tok ) ;
{
char keys [ 4096 ] ;
char * key = NULL , * tmp = keys ;
int i ;
misdn_cfg_get ( 0 , MISDN_GEN_CRYPT_KEYS , keys , sizeof ( keys ) ) ;
2007-03-26 15:59:56 +00:00
2007-06-06 21:20:11 +00:00
for ( i = 0 ; i < keyidx ; i + + ) {
key = strsep ( & tmp , " , " ) ;
}
2007-03-26 15:59:56 +00:00
2007-06-06 21:20:11 +00:00
if ( key ) {
ast_copy_string ( ch - > bc - > crypt_key , key , sizeof ( ch - > bc - > crypt_key ) ) ;
}
2007-03-26 15:59:56 +00:00
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 0 , ch - > bc - > port , " SETOPT: crypt with key:%s \n " , ch - > bc - > crypt_key ) ;
break ;
2005-10-31 22:51:12 +00:00
}
case ' e ' :
2005-11-01 22:04:14 +00:00
chan_misdn_log ( 1 , ch - > bc - > port , " SETOPT: EchoCancel \n " ) ;
2005-10-31 22:51:12 +00:00
if ( neglect ) {
2006-02-10 10:10:58 +00:00
chan_misdn_log ( 1 , ch - > bc - > port , " --> disabled \n " ) ;
2007-03-26 15:59:56 +00:00
# ifdef MISDN_1_2
2007-06-06 21:20:11 +00:00
* ch - > bc - > pipeline = 0 ;
2007-03-26 15:59:56 +00:00
# else
2007-06-06 21:20:11 +00:00
ch - > bc - > ec_enable = 0 ;
2007-03-26 15:59:56 +00:00
# endif
2005-10-31 22:51:12 +00:00
} else {
2007-03-26 15:59:56 +00:00
# ifdef MISDN_1_2
update_pipeline_config ( ch - > bc ) ;
# else
2007-06-06 21:20:11 +00:00
ch - > bc - > ec_enable = 1 ;
ch - > bc - > orig = ch - > originator ;
2005-10-31 22:51:12 +00:00
tok + + ;
2007-03-26 15:59:56 +00:00
if ( * tok ) {
2007-06-06 21:20:11 +00:00
ch - > bc - > ec_deftaps = atoi ( tok ) ;
2005-10-31 22:51:12 +00:00
}
2007-03-26 15:59:56 +00:00
# endif
2005-10-31 22:51:12 +00:00
}
break ;
case ' h ' :
2005-11-01 22:04:14 +00:00
chan_misdn_log ( 1 , ch - > bc - > port , " SETOPT: Digital \n " ) ;
2006-02-02 21:15:34 +00:00
2007-06-06 21:20:11 +00:00
if ( strlen ( tok ) > 1 & & tok [ 1 ] = = ' 1 ' ) {
2006-02-02 21:15:34 +00:00
chan_misdn_log ( 1 , ch - > bc - > port , " SETOPT: HDLC \n " ) ;
2006-10-10 14:54:58 +00:00
if ( ! ch - > bc - > hdlc ) {
2007-06-06 21:20:11 +00:00
ch - > bc - > hdlc = 1 ;
2006-10-10 14:54:58 +00:00
}
2007-06-06 21:20:11 +00:00
}
ch - > bc - > capability = INFO_CAPABILITY_DIGITAL_UNRESTRICTED ;
2005-10-31 22:51:12 +00:00
break ;
case ' s ' :
2005-11-01 22:04:14 +00:00
chan_misdn_log ( 1 , ch - > bc - > port , " SETOPT: Send DTMF \n " ) ;
2007-06-06 21:20:11 +00:00
ch - > bc - > send_dtmf = 1 ;
2005-10-31 22:51:12 +00:00
break ;
case ' f ' :
2005-11-01 22:04:14 +00:00
chan_misdn_log ( 1 , ch - > bc - > port , " SETOPT: Faxdetect \n " ) ;
2007-06-06 21:20:11 +00:00
ch - > faxdetect = 1 ;
2006-08-08 18:13:40 +00:00
misdn_cfg_get ( ch - > bc - > port , MISDN_CFG_FAXDETECT_TIMEOUT , & ch - > faxdetect_timeout , sizeof ( ch - > faxdetect_timeout ) ) ;
2005-10-31 22:51:12 +00:00
break ;
case ' a ' :
2005-11-01 22:04:14 +00:00
chan_misdn_log ( 1 , ch - > bc - > port , " SETOPT: AST_DSP (for DTMF) \n " ) ;
2007-06-06 21:20:11 +00:00
ch - > ast_dsp = 1 ;
2005-10-31 22:51:12 +00:00
break ;
case ' p ' :
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , ch - > bc - > port , " SETOPT: callerpres: %s \n " , & tok [ 1 ] ) ;
2005-10-31 22:51:12 +00:00
/* CRICH: callingpres!!! */
2007-06-06 21:20:11 +00:00
if ( strstr ( tok , " allowed " ) ) {
ch - > bc - > pres = 0 ;
} else if ( strstr ( tok , " not_screened " ) ) {
ch - > bc - > pres = 1 ;
2005-10-31 22:51:12 +00:00
}
2007-08-17 08:29:56 +00:00
break ;
case ' i ' :
chan_misdn_log ( 1 , ch - > bc - > port , " Ignoring dtmf tones, just use them inband \n " ) ;
ch - > ignore_dtmf = 1 ;
break ;
default :
2005-10-31 22:51:12 +00:00
break ;
}
}
2006-02-10 14:17:28 +00:00
if ( change_jitter )
config_jitterbuffer ( ch ) ;
2007-06-06 21:20:11 +00:00
2005-10-31 22:51:12 +00:00
if ( ch - > faxdetect | | ch - > ast_dsp ) {
2007-06-06 21:20:11 +00:00
if ( ! ch - > dsp )
ch - > dsp = ast_dsp_new ( ) ;
if ( ch - > dsp )
ast_dsp_set_features ( ch - > dsp , DSP_FEATURE_DTMF_DETECT | DSP_FEATURE_FAX_DETECT ) ;
if ( ! ch - > trans )
ch - > trans = ast_translator_build_path ( AST_FORMAT_SLINEAR , AST_FORMAT_ALAW ) ;
2005-10-31 22:51:12 +00:00
}
if ( ch - > ast_dsp ) {
2007-06-06 21:20:11 +00:00
chan_misdn_log ( 1 , ch - > bc - > port , " SETOPT: with AST_DSP we deactivate mISDN_dsp \n " ) ;
ch - > bc - > nodsp = 1 ;
ch - > bc - > nojitter = 1 ;
2005-10-31 22:51:12 +00:00
}
return 0 ;
}
2005-12-09 11:01:18 +00:00
int chan_misdn_jb_empty ( struct misdn_bchannel * bc , char * buf , int len )
{
2007-06-06 21:20:11 +00:00
struct chan_list * ch = find_chan_by_bc ( cl_te , bc ) ;
2005-12-09 11:01:18 +00:00
if ( ch & & ch - > jb ) {
return misdn_jb_empty ( ch - > jb , buf , len ) ;
}
return - 1 ;
}
/*******************************************************/
/***************** JITTERBUFFER ************************/
/*******************************************************/
/* allocates the jb-structure and initialise the elements*/
struct misdn_jb * misdn_jb_init ( int size , int upper_threshold )
{
2007-06-06 21:20:11 +00:00
int i ;
struct misdn_jb * jb ;
2006-04-04 19:09:26 +00:00
2007-06-06 21:20:11 +00:00
jb = ast_malloc ( sizeof ( * jb ) ) ;
if ( ! jb ) {
chan_misdn_log ( - 1 , 0 , " No free Mem for jb \n " ) ;
2006-04-04 19:09:26 +00:00
return NULL ;
2007-06-06 21:20:11 +00:00
}
jb - > size = size ;
jb - > upper_threshold = upper_threshold ;
jb - > wp = 0 ;
jb - > rp = 0 ;
jb - > state_full = 0 ;
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 " ) ;
return NULL ;
}
jb - > ok = ast_malloc ( size * sizeof ( char ) ) ;
2006-04-04 19:09:26 +00:00
2007-06-06 21:20:11 +00:00
if ( ! jb - > ok ) {
ast_free ( jb - > samples ) ;
ast_free ( jb ) ;
chan_misdn_log ( - 1 , 0 , " No free Mem for jb->ok \n " ) ;
return NULL ;
}
for ( i = 0 ; i < size ; i + + )
jb - > ok [ i ] = 0 ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
ast_mutex_init ( & jb - > mutexjb ) ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
return jb ;
2005-12-09 11:01:18 +00:00
}
/* frees the data and destroys the given jitterbuffer struct */
void misdn_jb_destroy ( struct misdn_jb * jb )
{
ast_mutex_destroy ( & jb - > mutexjb ) ;
2007-06-06 21:20:11 +00:00
ast_free ( jb - > samples ) ;
ast_free ( jb ) ;
2005-12-09 11:01:18 +00:00
}
/* fills the jitterbuffer with len data returns < 0 if there was an
error ( bufferoverflow ) . */
int misdn_jb_fill ( struct misdn_jb * jb , const char * data , int len )
{
2007-06-06 21:20:11 +00:00
int i , j , rp , wp ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
if ( ! jb | | ! data )
return 0 ;
2006-02-02 21:15:34 +00:00
2007-06-06 21:20:11 +00:00
ast_mutex_lock ( & jb - > mutexjb ) ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
wp = jb - > wp ;
rp = jb - > rp ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
for ( i = 0 ; i < len ; i + + ) {
jb - > samples [ wp ] = data [ i ] ;
jb - > ok [ wp ] = 1 ;
wp = ( wp ! = jb - > size - 1 ) ? wp + 1 : 0 ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
if ( wp = = jb - > rp )
jb - > state_full = 1 ;
2005-12-09 11:01:18 +00:00
}
2007-06-06 21:20:11 +00:00
if ( wp > = rp )
jb - > state_buffer = wp - rp ;
else
jb - > state_buffer = jb - > size - rp + wp ;
chan_misdn_log ( 9 , 0 , " misdn_jb_fill: written:%d | Bufferstatus:%d p:%x \n " , len , jb - > state_buffer , jb ) ;
if ( jb - > state_full ) {
jb - > wp = wp ;
rp = wp ;
for ( j = 0 ; j < jb - > upper_threshold ; j + + )
rp = rp ! = 0 ? rp - 1 : jb - > size - 1 ;
jb - > rp = rp ;
jb - > state_full = 0 ;
jb - > state_empty = 1 ;
ast_mutex_unlock ( & jb - > mutexjb ) ;
return - 1 ;
}
if ( ! jb - > state_empty ) {
jb - > bytes_wrote + = len ;
if ( jb - > bytes_wrote > = jb - > upper_threshold ) {
jb - > state_empty = 1 ;
jb - > bytes_wrote = 0 ;
}
}
jb - > wp = wp ;
ast_mutex_unlock ( & jb - > mutexjb ) ;
return 0 ;
2005-12-09 11:01:18 +00:00
}
/* gets len bytes out of the jitterbuffer if available, else only the
available data is returned and the return value indicates the number
of data . */
int misdn_jb_empty ( struct misdn_jb * jb , char * data , int len )
{
2007-06-06 21:20:11 +00:00
int i , wp , rp , read = 0 ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
ast_mutex_lock ( & jb - > mutexjb ) ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
rp = jb - > rp ;
wp = jb - > wp ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
if ( jb - > state_empty ) {
for ( i = 0 ; i < len ; i + + ) {
if ( wp = = rp ) {
jb - > rp = rp ;
jb - > state_empty = 0 ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
ast_mutex_unlock ( & jb - > mutexjb ) ;
return read ;
} else {
if ( jb - > ok [ rp ] = = 1 ) {
data [ i ] = jb - > samples [ rp ] ;
jb - > ok [ rp ] = 0 ;
rp = ( rp ! = jb - > size - 1 ) ? rp + 1 : 0 ;
read + = 1 ;
}
}
2005-12-09 11:01:18 +00:00
}
2007-06-06 21:20:11 +00:00
if ( wp > = rp )
jb - > state_buffer = wp - rp ;
else
jb - > state_buffer = jb - > size - rp + wp ;
chan_misdn_log ( 9 , 0 , " misdn_jb_empty: read:%d | Bufferstatus:%d p:%x \n " , len , jb - > state_buffer , jb ) ;
2005-12-09 11:01:18 +00:00
2007-06-06 21:20:11 +00:00
jb - > rp = rp ;
} else
chan_misdn_log ( 9 , 0 , " misdn_jb_empty: Wait...requested:%d p:%x \n " , len , jb ) ;
ast_mutex_unlock ( & jb - > mutexjb ) ;
return read ;
2005-12-09 11:01:18 +00:00
}
/*******************************************************/
/*************** JITTERBUFFER END *********************/
/*******************************************************/
void chan_misdn_log ( int level , int port , char * tmpl , . . . )
{
va_list ap ;
char buf [ 1024 ] ;
char port_buf [ 8 ] ;
2007-06-06 21:20:11 +00:00
if ( ! ( ( 0 < = port ) & & ( port < = max_ports ) ) ) {
ast_log ( LOG_WARNING , " cb_log called with out-of-range port number! (%d) \n " , port ) ;
port = 0 ;
level = - 1 ;
}
snprintf ( port_buf , sizeof ( port_buf ) , " P[%2d] " , port ) ;
2005-12-09 11:01:18 +00:00
va_start ( ap , tmpl ) ;
2007-06-06 21:20:11 +00:00
vsnprintf ( buf , sizeof ( buf ) , tmpl , ap ) ;
2005-12-09 11:01:18 +00:00
va_end ( ap ) ;
if ( level = = - 1 )
ast_log ( LOG_WARNING , buf ) ;
2006-08-03 16:38:00 +00:00
2005-12-09 11:01:18 +00:00
else if ( misdn_debug_only [ port ] ?
2007-06-06 21:20:11 +00:00
( level = = 1 & & misdn_debug [ port ] ) | | ( level = = misdn_debug [ port ] )
2005-12-09 11:01:18 +00:00
: level < = misdn_debug [ port ] ) {
ast_console_puts ( port_buf ) ;
ast_console_puts ( buf ) ;
}
if ( ( level < = misdn_debug [ 0 ] ) & & ! ast_strlen_zero ( global_tracefile ) ) {
2007-06-06 21:20:11 +00:00
char ctimebuf [ 30 ] ;
2005-12-09 11:01:18 +00:00
time_t tm = time ( NULL ) ;
2007-06-06 21:20:11 +00:00
char * tmp = ctime_r ( & tm , ctimebuf ) , * p ;
FILE * fp = fopen ( global_tracefile , " a+ " ) ;
p = strchr ( tmp , ' \n ' ) ;
if ( p )
* p = ' : ' ;
2005-12-09 11:01:18 +00:00
if ( ! fp ) {
ast_console_puts ( " Error opening Tracefile: [ " ) ;
ast_console_puts ( global_tracefile ) ;
ast_console_puts ( " ] " ) ;
ast_console_puts ( strerror ( errno ) ) ;
ast_console_puts ( " \n " ) ;
return ;
}
2007-06-06 21:20:11 +00:00
fputs ( tmp , fp ) ;
2005-12-09 11:01:18 +00:00
fputs ( " " , fp ) ;
2007-06-06 21:20:11 +00:00
fputs ( port_buf , fp ) ;
2005-12-09 11:01:18 +00:00
fputs ( " " , fp ) ;
fputs ( buf , fp ) ;
fclose ( fp ) ;
}
}
2006-02-02 21:15:34 +00:00
2006-08-21 02:11:39 +00:00
AST_MODULE_INFO ( ASTERISK_GPL_KEY , AST_MODFLAG_DEFAULT , " Channel driver for mISDN Support (BRI/PRI) " ,
2007-06-06 21:20:11 +00:00
. load = load_module ,
. unload = unload_module ,
. reload = reload ,
) ;