|
|
|
@ -3505,6 +3505,26 @@ void export_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void start_pbx(struct chan_list *ch, struct misdn_bchannel *bc, struct ast_channel *chan) {
|
|
|
|
|
if (pbx_start_chan(ch)<0) {
|
|
|
|
|
hangup_chan(ch);
|
|
|
|
|
chan_misdn_log(-1, bc->port, "ast_pbx_start returned <0 in SETUP\n");
|
|
|
|
|
if (bc->nt) {
|
|
|
|
|
hanguptone_indicate(ch);
|
|
|
|
|
misdn_lib_send_event(bc, EVENT_RELEASE_COMPLETE );
|
|
|
|
|
} else
|
|
|
|
|
misdn_lib_send_event(bc, EVENT_RELEASE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
dialtone_indicate(ch);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************/
|
|
|
|
|
/* Receive Events from isdn_lib here */
|
|
|
|
@ -3633,41 +3653,30 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
|
|
|
|
|
|
|
|
|
|
case EVENT_INFORMATION:
|
|
|
|
|
{
|
|
|
|
|
int stop_tone;
|
|
|
|
|
misdn_cfg_get( 0, MISDN_GEN_STOP_TONE, &stop_tone, sizeof(int));
|
|
|
|
|
int l;
|
|
|
|
|
|
|
|
|
|
if ( (ch->state != MISDN_CONNECTED) && stop_tone ) {
|
|
|
|
|
if ( ch->state != MISDN_CONNECTED )
|
|
|
|
|
stop_indicate(ch);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!ch->ast) break;
|
|
|
|
|
|
|
|
|
|
if (ch->state == MISDN_WAITING4DIGS ) {
|
|
|
|
|
/* Ok, incomplete Setup, waiting till extension exists */
|
|
|
|
|
|
|
|
|
|
if (ast_strlen_zero(bc->info_dad) && ! ast_strlen_zero(bc->keypad)) {
|
|
|
|
|
chan_misdn_log(1, bc->port, " --> using keypad as info\n");
|
|
|
|
|
strcpy(bc->info_dad,bc->keypad);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
int l = sizeof(bc->dad);
|
|
|
|
|
l = sizeof(bc->dad);
|
|
|
|
|
strncat(bc->dad,bc->info_dad, l);
|
|
|
|
|
bc->dad[l-1] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
int l = sizeof(ch->ast->exten);
|
|
|
|
|
l = sizeof(ch->ast->exten);
|
|
|
|
|
strncpy(ch->ast->exten, bc->dad, l);
|
|
|
|
|
ch->ast->exten[l-1] = 0;
|
|
|
|
|
}
|
|
|
|
|
/* chan_misdn_log(5, bc->port, "Can Match Extension: dad:%s oad:%s\n",bc->dad,bc->oad);*/
|
|
|
|
|
|
|
|
|
|
/* Check for Pickup Request first */
|
|
|
|
|
if (!strcmp(ch->ast->exten, ast_pickup_ext())) {
|
|
|
|
|
int ret;/** Sending SETUP_ACK**/
|
|
|
|
|
ret = misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE );
|
|
|
|
|
if (ast_pickup_call(ch->ast)) {
|
|
|
|
|
hangup_chan(ch);
|
|
|
|
|
} else {
|
|
|
|
@ -3681,15 +3690,23 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)) {
|
|
|
|
|
ast_log(LOG_WARNING, "Extension can never match, So jumping to 'i' extension. port(%d)\n",bc->port);
|
|
|
|
|
strcpy(ch->ast->exten, "i");
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
chan_misdn_log(-1, bc->port, "Extension can never match, so disconnecting\n");
|
|
|
|
|
if (bc->nt)
|
|
|
|
|
hanguptone_indicate(ch);
|
|
|
|
|
ch->state=MISDN_EXTCANTMATCH;
|
|
|
|
|
bc->out_cause=1;
|
|
|
|
|
|
|
|
|
|
misdn_lib_send_event(bc, EVENT_DISCONNECT );
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -3704,21 +3721,8 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ast_exists_extension(ch->ast, ch->context, bc->dad, 1, bc->oad)) {
|
|
|
|
|
ch->state=MISDN_DIALING;
|
|
|
|
|
|
|
|
|
|
stop_indicate(ch);
|
|
|
|
|
/* chan_misdn_log(1, bc->port, " --> * Starting Ast ctx:%s\n", ch->context);*/
|
|
|
|
|
if (pbx_start_chan(ch)<0) {
|
|
|
|
|
hangup_chan(ch);
|
|
|
|
|
|
|
|
|
|
chan_misdn_log(-1, bc->port, "ast_pbx_start returned < 0 in INFO\n");
|
|
|
|
|
if (bc->nt) hanguptone_indicate(ch);
|
|
|
|
|
|
|
|
|
|
misdn_lib_send_event(bc, EVENT_DISCONNECT );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ast_exists_extension(ch->ast, ch->context, bc->dad, 1, bc->oad))
|
|
|
|
|
start_pbx(ch, bc, ch->ast);
|
|
|
|
|
} else {
|
|
|
|
|
/* sending INFOS as DTMF-Frames :) */
|
|
|
|
|
struct ast_frame fr;
|
|
|
|
@ -3767,7 +3771,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
int msn_valid = misdn_cfg_is_msn_valid(bc->port, bc->dad);
|
|
|
|
|
if (!bc->nt && ! msn_valid) {
|
|
|
|
|
chan_misdn_log(1, bc->port, " --> Ignoring Call, its not in our MSN List\n");
|
|
|
|
@ -3784,7 +3788,6 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
|
|
|
|
|
|
|
|
|
|
print_bearer(bc);
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
struct chan_list *ch=init_chan_list(ORG_MISDN);
|
|
|
|
|
struct ast_channel *chan;
|
|
|
|
|
|
|
|
|
@ -3851,7 +3854,6 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
|
|
|
|
|
/** queue new chan **/
|
|
|
|
|
cl_queue_chan(&cl_te, ch) ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!strstr(ch->allowed_bearers,"all")) {
|
|
|
|
|
int i;
|
|
|
|
|
for (i=0; i< sizeof(allowed_bearers_array)/sizeof(struct allowed_bearers); i++) {
|
|
|
|
@ -3892,7 +3894,6 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
|
|
|
|
|
added support for s extension hope it will help those poor cretains
|
|
|
|
|
which haven't overlap dial.
|
|
|
|
|
*/
|
|
|
|
|
{
|
|
|
|
|
int ai;
|
|
|
|
|
misdn_cfg_get( bc->port, MISDN_CFG_ALWAYS_IMMEDIATE, &ai, sizeof(ai));
|
|
|
|
|
if ( ai ) {
|
|
|
|
@ -3900,28 +3901,31 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* check if we should jump into s when we have no dad */
|
|
|
|
|
{
|
|
|
|
|
int im;
|
|
|
|
|
misdn_cfg_get( bc->port, MISDN_CFG_IMMEDIATE, &im, sizeof(im));
|
|
|
|
|
if ( im && ast_strlen_zero(bc->dad) ) {
|
|
|
|
|
do_immediate_setup(bc, ch , chan);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
chan_misdn_log(5,bc->port,"CONTEXT:%s\n",ch->context);
|
|
|
|
|
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)) {
|
|
|
|
|
ast_log(LOG_WARNING, "Extension can never match, So jumping to 'i' extension. port(%d)\n",bc->port);
|
|
|
|
|
strcpy(ch->ast->exten, "i");
|
|
|
|
|
misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE);
|
|
|
|
|
ch->state=MISDN_DIALING;
|
|
|
|
|
start_pbx(ch, bc, chan);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
chan_misdn_log(-1, bc->port, "Extension can never match, so disconnecting\n");
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
if (bc->nt)
|
|
|
|
|
hanguptone_indicate(ch);
|
|
|
|
|
|
|
|
|
|
ch->state=MISDN_EXTCANTMATCH;
|
|
|
|
|
bc->out_cause=1;
|
|
|
|
|
|
|
|
|
@ -3933,86 +3937,62 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!ch->overlap_dial && ast_exists_extension(ch->ast, ch->context, bc->dad, 1, bc->oad)) {
|
|
|
|
|
|
|
|
|
|
/* 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))) {
|
|
|
|
|
if (!ch->noautorespond_on_setup) {
|
|
|
|
|
ch->state=MISDN_DIALING;
|
|
|
|
|
|
|
|
|
|
if (!bc->sending_complete &&
|
|
|
|
|
(bc->nt || (bc->need_more_infos && misdn_lib_is_ptp(bc->port)))) {
|
|
|
|
|
int ret;
|
|
|
|
|
ret = misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE );
|
|
|
|
|
} else {
|
|
|
|
|
int ret;
|
|
|
|
|
ret= misdn_lib_send_event(bc, EVENT_PROCEEDING );
|
|
|
|
|
}
|
|
|
|
|
misdn_lib_send_event(bc, EVENT_PROCEEDING );
|
|
|
|
|
} else {
|
|
|
|
|
ch->state = MISDN_INCOMING_SETUP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pbx_start_chan(ch)<0) {
|
|
|
|
|
hangup_chan(ch);
|
|
|
|
|
|
|
|
|
|
chan_misdn_log(-1, bc->port, "ast_pbx_start returned <0 in SETUP\n");
|
|
|
|
|
chan=NULL;
|
|
|
|
|
|
|
|
|
|
if (bc->nt) {
|
|
|
|
|
hanguptone_indicate(ch);
|
|
|
|
|
misdn_lib_send_event(bc, EVENT_RELEASE_COMPLETE );
|
|
|
|
|
} else
|
|
|
|
|
misdn_lib_send_event(bc, EVENT_RELEASE);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
if (bc->sending_complete) {
|
|
|
|
|
ch->state=MISDN_EXTCANTMATCH;
|
|
|
|
|
bc->out_cause=1;
|
|
|
|
|
|
|
|
|
|
if (bc->nt) {
|
|
|
|
|
chan_misdn_log(0,bc->port," --> sending_complete so we never match ..\n");
|
|
|
|
|
misdn_lib_send_event(bc, EVENT_RELEASE_COMPLETE);
|
|
|
|
|
} else {
|
|
|
|
|
chan_misdn_log(0,bc->port," --> sending_complete so we never match ..\n");
|
|
|
|
|
misdn_lib_send_event(bc, EVENT_RELEASE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
int ret= misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE );
|
|
|
|
|
if (ret == -ENOCHAN) {
|
|
|
|
|
ast_log(LOG_WARNING,"Channel was catched, before we could Acknowledge\n");
|
|
|
|
|
misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
|
|
|
|
|
}
|
|
|
|
|
/* send tone to phone :) */
|
|
|
|
|
|
|
|
|
|
/** ADD IGNOREPAT **/
|
|
|
|
|
|
|
|
|
|
ch->state=MISDN_WAITING4DIGS;
|
|
|
|
|
int stop_tone, dad_len;
|
|
|
|
|
misdn_cfg_get( 0, MISDN_GEN_STOP_TONE, &stop_tone, sizeof(int));
|
|
|
|
|
|
|
|
|
|
dad_len = ast_strlen_zero(bc->dad);
|
|
|
|
|
|
|
|
|
|
if ( !dad_len && stop_tone )
|
|
|
|
|
stop_indicate(ch);
|
|
|
|
|
else {
|
|
|
|
|
if (bc->nt)
|
|
|
|
|
dialtone_indicate(ch);
|
|
|
|
|
start_pbx(ch, bc, chan);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ch->overlap_dial && !dad_len) {
|
|
|
|
|
/*
|
|
|
|
|
* 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);
|
|
|
|
|
if (ch->overlap_dial_task == -1) {
|
|
|
|
|
|
|
|
|
|
if (ch->overlap_dial_task == -1)
|
|
|
|
|
ch->overlap_dial_task =
|
|
|
|
|
misdn_tasks_add_variable(ch->overlap_dial, misdn_overlap_dial_task, ch);
|
|
|
|
|
|
|
|
|
|
wait_for_digits(ch, bc, chan);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 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);
|
|
|
|
|
|
|
|
|
|
ch->state=MISDN_DIALING;
|
|
|
|
|
start_pbx(ch, bc, chan);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case EVENT_SETUP_ACKNOWLEDGE:
|
|
|
|
|
{
|
|
|
|
|
ch->state = MISDN_CALLING_ACKNOWLEDGE;
|
|
|
|
|