diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index 98a8ab3eeb1627732422b9af922ec0fba7c82c2b..1fbd124c38d90fe8aef756a20cb459df27159b13 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -272,9 +272,6 @@ static struct ast_jb_conf default_jbconf = }; static struct ast_jb_conf global_jbconf; -/* define this to send PRI user-user information elements */ -#undef SUPPORT_USERUSER - /*! * \note Define ZHONE_HACK to cause us to go off hook and then back on hook when * the user hangs up to reset the state machine so ring works properly. @@ -1996,7 +1993,7 @@ static void my_get_and_handle_alarms(void *pvt) { int res; struct dahdi_pvt *p = pvt; - + res = get_alarms(p); handle_alarms(p, res); } @@ -2069,7 +2066,7 @@ static void my_all_subchannels_hungup(void *pvt) law = DAHDI_LAW_DEFAULT; res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_SETLAW, &law); - if (res < 0) + if (res < 0) ast_log(LOG_WARNING, "Unable to set law on channel %d to default: %s\n", p->channel, strerror(errno)); dahdi_setlinear(p->subs[SUB_REAL].dfd, 0); @@ -2219,7 +2216,7 @@ static int dahdi_setlaw(int dfd, int law) } #endif -#ifdef HAVE_PRI +#if defined(HAVE_PRI) static struct ast_channel *my_new_pri_ast_channel(void *pvt, int state, int startpbx, enum sig_pri_law law, int transfercapability, char *exten, const struct ast_channel *requestor) { struct dahdi_pvt *p = pvt; @@ -2250,7 +2247,7 @@ static struct ast_channel *my_new_pri_ast_channel(void *pvt, int state, int star } return dahdi_new(p, state, startpbx, SUB_REAL, newlaw, transfercapability, requestor ? requestor->linkedid : ""); } -#endif +#endif /* defined(HAVE_PRI) */ static int unalloc_sub(struct dahdi_pvt *p, int x); @@ -2499,7 +2496,7 @@ static int my_on_hook(void *pvt) return dahdi_set_hook(p->subs[ANALOG_SUB_REAL].dfd, DAHDI_ONHOOK); } -#ifdef HAVE_PRI +#if defined(HAVE_PRI) static void my_pri_fixup_chans(void *old_chan, void *new_chan) { struct dahdi_pvt *old = old_chan; @@ -2556,7 +2553,7 @@ static void my_handle_dchan_exception(struct sig_pri_pri *pri, int index) if (x) { ast_log(LOG_NOTICE, "PRI got event: %s (%d) on D-channel of span %d\n", event2str(x), x, pri->span); } - /* Keep track of alarm state */ + /* Keep track of alarm state */ if (x == DAHDI_EVENT_ALARM) { pri_event_alarm(pri, index, 0); } else if (x == DAHDI_EVENT_NOALARM) { @@ -2582,7 +2579,7 @@ static struct sig_pri_callback dahdi_pri_callbacks = .fixup_chans = my_pri_fixup_chans, .set_dialing = my_set_dialing, }; -#endif /* HAVE_PRI */ +#endif /* defined(HAVE_PRI) */ /*! * \brief Send MWI state change @@ -4301,7 +4298,7 @@ static int dahdi_call(struct ast_channel *ast, char *rdest, int timeout) p->outgoing = 1; set_actual_gain(p->subs[SUB_REAL].dfd, 0, p->rxgain, p->txgain, p->law); - + #ifdef HAVE_PRI if (p->sig == SIG_PRI || p->sig == SIG_BRI || p->sig == SIG_BRI_PTMP) { struct dahdi_params ps; @@ -4340,7 +4337,8 @@ static int dahdi_call(struct ast_channel *ast, char *rdest, int timeout) ast_mutex_unlock(&p->lock); return -1; } -#ifdef HAVE_SS7 + +#if defined(HAVE_SS7) if (p->ss7) { char ss7_called_nai; int called_nai_strip; @@ -4477,7 +4475,8 @@ static int dahdi_call(struct ast_channel *ast, char *rdest, int timeout) ast_setstate(ast, AST_STATE_DIALING); ss7_rel(p->ss7); } -#endif /* HAVE_SS7 */ +#endif /* defined(HAVE_SS7) */ + #ifdef HAVE_OPENR2 if (p->mfcr2) { openr2_calling_party_category_t chancat; @@ -5203,7 +5202,7 @@ hangup_out: if (p->cidspill) ast_free(p->cidspill); p->cidspill = NULL; - + ast_mutex_unlock(&p->lock); ast_module_unref(ast_module_info->self); ast_verb(3, "Hungup '%s'\n", ast->name); @@ -5614,7 +5613,7 @@ static int parse_buffers_policy(const char *parse, int *num_buffers, int *policy { int res; char policy_str[21] = ""; - + if ((res = sscanf(parse, "%d,%20s", num_buffers, policy_str)) != 2) { ast_log(LOG_WARNING, "Parsing buffer string '%s' failed.\n", parse); return 1; @@ -5643,7 +5642,7 @@ static int dahdi_func_write(struct ast_channel *chan, const char *function, char { struct dahdi_pvt *p = chan->tech_pvt; int res = 0; - + if (!strcasecmp(data, "buffers")) { int num_bufs, policy; @@ -5668,11 +5667,11 @@ static int dahdi_func_write(struct ast_channel *chan, const char *function, char if (!strcasecmp(value, "on")) { ast_mutex_lock(&p->lock); dahdi_enable_ec(p); - ast_mutex_unlock(&p->lock); + ast_mutex_unlock(&p->lock); } else if (!strcasecmp(value, "off")) { ast_mutex_lock(&p->lock); dahdi_disable_ec(p); - ast_mutex_unlock(&p->lock); + ast_mutex_unlock(&p->lock); #ifdef HAVE_DAHDI_ECHOCANCEL_FAX_MODE } else if (!strcasecmp(value, "fax")) { int blah = 1; @@ -5684,7 +5683,7 @@ static int dahdi_func_write(struct ast_channel *chan, const char *function, char if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_ECHOCANCEL_FAX_MODE, &blah)) { ast_log(LOG_WARNING, "Unable to place echocan into fax mode on channel %d: %s\n", p->channel, strerror(errno)); } - ast_mutex_unlock(&p->lock); + ast_mutex_unlock(&p->lock); } else if (!strcasecmp(value, "voice")) { int blah = 0; @@ -5695,7 +5694,7 @@ static int dahdi_func_write(struct ast_channel *chan, const char *function, char if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_ECHOCANCEL_FAX_MODE, &blah)) { ast_log(LOG_WARNING, "Unable to place echocan into voice mode on channel %d: %s\n", p->channel, strerror(errno)); } - ast_mutex_unlock(&p->lock); + ast_mutex_unlock(&p->lock); #endif } else { ast_log(LOG_WARNING, "Unsupported value '%s' provided for '%s' item.\n", value, data); @@ -7287,7 +7286,7 @@ static struct ast_frame *__dahdi_exception(struct ast_channel *ast) return f; } f = dahdi_handle_event(ast); - + /* tell the cdr this zap device hung up */ if (f == NULL) { ast_set_hangupsource(ast, ast->name, 0); @@ -7660,7 +7659,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast) if (f && (f->frametype == AST_FRAME_DTMF)) { if (analog_lib_handles(p->sig, p->radio, p->oprmode)) { analog_handle_dtmfup(p->sig_pvt, ast, idx, &f); - } else + } else dahdi_handle_dtmfup(ast, idx, &f); } @@ -7780,6 +7779,7 @@ static int dahdi_indicate(struct ast_channel *chan, int condition, const void *d int res=-1; int idx; int func = DAHDI_FLASH; + ast_mutex_lock(&p->lock); idx = dahdi_get_index(chan, p, 0); ast_debug(1, "Requested indication %d on channel %s\n", condition, chan->name); @@ -10924,7 +10924,7 @@ static struct dahdi_pvt *mkintf(int channel, const struct dahdi_chan_conf *conf, tmp->mwisend_fsk = conf->chan.mwisend_fsk; tmp->mwisend_rpas = conf->chan.mwisend_rpas; #endif - + tmp->group = conf->chan.group; tmp->callgroup = conf->chan.callgroup; tmp->pickupgroup= conf->chan.pickupgroup; @@ -11044,7 +11044,7 @@ static struct dahdi_pvt *mkintf(int channel, const struct dahdi_chan_conf *conf, analog_config_complete(analog_p); } - } + } #ifdef HAVE_PRI else if (pchan != NULL) { pchan->channel = tmp->channel; @@ -11334,7 +11334,7 @@ static struct ast_channel *dahdi_request(const char *type, int format, const str else if (p->sig == SIG_PRI || p->sig == SIG_BRI || p->sig == SIG_BRI_PTMP) { tmp = sig_pri_request(p->sig_pvt, SIG_PRI_DEFLAW, requestor); } -#endif +#endif else { tmp = dahdi_new(p, AST_STATE_RESERVED, 0, p->owner ? SUB_CALLWAIT : SUB_REAL, 0, 0, requestor ? requestor->linkedid : ""); } @@ -12610,7 +12610,7 @@ static char *handle_pri_service_generic(struct ast_cli_entry *e, int cmd, struct struct dahdi_pvt *start, *tmp = NULL; struct dahdi_pri *pri = NULL; ast_mutex_t *lock; - + lock = &iflock; start = iflist; @@ -12635,7 +12635,7 @@ static char *handle_pri_service_generic(struct ast_cli_entry *e, int cmd, struct } } else channel = atoi(a->argv[4]); - + if (a->argc == 6) interfaceid = atoi(a->argv[5]); @@ -12706,15 +12706,15 @@ static char *handle_pri_service_generic(struct ast_cli_entry *e, int cmd, struct static char *handle_pri_service_enable_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { - case CLI_INIT: + case CLI_INIT: e->command = "pri service enable channel"; - e->usage = + e->usage = "Usage: pri service enable channel <channel> [<interface id>]\n" " Send an AT&T / NFAS / CCS ANSI T1.607 maintenance message\n" " to restore a channel to service, with optional interface id\n" " as agreed upon with remote switch operator\n"; return NULL; - case CLI_GENERATE: + case CLI_GENERATE: return NULL; } return handle_pri_service_generic(e, cmd, a, 0); @@ -12723,15 +12723,15 @@ static char *handle_pri_service_enable_channel(struct ast_cli_entry *e, int cmd, static char *handle_pri_service_disable_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { - case CLI_INIT: + case CLI_INIT: e->command = "pri service disable channel"; - e->usage = + e->usage = "Usage: pri service disable channel <chan num> [<interface id>]\n" " Send an AT&T / NFAS / CCS ANSI T1.607 maintenance message\n" " to remove a channel from service, with optional interface id\n" " as agreed upon with remote switch operator\n"; return NULL; - case CLI_GENERATE: + case CLI_GENERATE: return NULL; } return handle_pri_service_generic(e, cmd, a, 2); diff --git a/channels/sig_pri.c b/channels/sig_pri.c index 6b6613f7d07a00d0fa2fea3c185c35e8cd6e7365..edd8693f0681e862bfc48509f31058ca3feb5a73 100644 --- a/channels/sig_pri.c +++ b/channels/sig_pri.c @@ -48,6 +48,9 @@ #include "sig_pri.h" +/* define this to send PRI user-user information elements */ +#undef SUPPORT_USERUSER + static int pri_matchdigittimeout = 3000; static int pri_gendigittimeout = 8000; @@ -62,7 +65,7 @@ static int pri_gendigittimeout = 8000; #define DCHAN_AVAILABLE (DCHAN_NOTINALARM | DCHAN_UP) -#define PRI_DEADLOCK_AVOIDANCE(lock) \ +#define PRI_DEADLOCK_AVOIDANCE(p) \ do { \ sig_pri_unlock_private(p); \ usleep(1); \ @@ -338,7 +341,7 @@ static int pri_fixup_principle(struct sig_pri_pri *pri, int principle, q931_call struct sig_pri_chan *new = pri->pvts[principle], *old = pri->pvts[x]; ast_verb(3, "Moving call from channel %d to channel %d\n", - old->channel, new->channel); + old->channel, new->channel); if (new->owner) { ast_log(LOG_WARNING, "Can't fix up channel from %d to %d because %d is already in use\n", old->channel, new->channel, new->channel); @@ -533,9 +536,10 @@ static void *pri_ss_thread(void *data) int len; int timeout; - /* in the bizarre case where the channel has become a zombie before we - even get started here, abort safely - */ + /* + * In the bizarre case where the channel has become a zombie before we + * even get started here, abort safely. + */ if (!p) { ast_log(LOG_WARNING, "Channel became a zombie before simple switch could be started (%s)\n", chan->name); ast_hangup(chan); @@ -694,7 +698,7 @@ static void *pri_dchannel(void *vpri) activeidles = 0; for (x = pri->numchans; x >= 0; x--) { if (pri->pvts[x] && !pri->pvts[x]->owner && - !pri->pvts[x]->call) { + !pri->pvts[x]->call) { if (haveidles < pri->minunused) { haveidles++; } else if (!pri->pvts[x]->resetting) { @@ -720,7 +724,7 @@ static void *pri_dchannel(void *vpri) gettimeofday(&lastidle, NULL); } } else if ((haveidles < pri->minunused) && - (activeidles > pri->minidle)) { + (activeidles > pri->minidle)) { /* Mark something for hangup if there is something that can be hungup */ for (x = pri->numchans; x >= 0; x--) { @@ -731,7 +735,7 @@ static void *pri_dchannel(void *vpri) /* Stop if we have enough idle channels or can't spare any more active idle ones */ if ((haveidles >= pri->minunused) || - (activeidles <= pri->minidle)) + (activeidles <= pri->minidle)) break; } } @@ -810,12 +814,12 @@ static void *pri_dchannel(void *vpri) if (e->e != PRI_EVENT_DCHAN_DOWN) { if (!(pri->dchanavail[which] & DCHAN_UP)) { - ast_verb(2, "%s D-Channel on span %d up\n", pri_order(which), pri->span); + ast_verb(2, "%s D-Channel on span %d up\n", pri_order(which), pri->span); } pri->dchanavail[which] |= DCHAN_UP; } else { if (pri->dchanavail[which] & DCHAN_UP) { - ast_verb(2, "%s D-Channel on span %d down\n", pri_order(which), pri->span); + ast_verb(2, "%s D-Channel on span %d down\n", pri_order(which), pri->span); } pri->dchanavail[which] &= ~DCHAN_UP; } @@ -901,7 +905,7 @@ static void *pri_dchannel(void *vpri) if (!skipit) { #endif ast_verb(3, "B-channel %d/%d restarted on span %d\n", - PRI_SPAN(e->restart.channel), PRI_CHANNEL(e->restart.channel), pri->span); + PRI_SPAN(e->restart.channel), PRI_CHANNEL(e->restart.channel), pri->span); sig_pri_lock_private(pri->pvts[chanpos]); if (pri->pvts[chanpos]->call) { pri_destroycall(pri->pri, pri->pvts[chanpos]->call); @@ -1056,6 +1060,7 @@ static void *pri_dchannel(void *vpri) if (pri->pvts[chanpos]->call == e->ring.call) { ast_log(LOG_WARNING, "Duplicate setup requested on channel %d/%d already in use on span %d\n", PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span); + sig_pri_unlock_private(pri->pvts[chanpos]); break; } else { /* This is where we handle initial glare */ @@ -1095,7 +1100,7 @@ static void *pri_dchannel(void *vpri) pri->pvts[chanpos]->cid_ton = 0; } apply_plan_to_number(pri->pvts[chanpos]->rdnis, sizeof(pri->pvts[chanpos]->rdnis), pri, - e->ring.redirectingnum, e->ring.callingplanrdnis); + e->ring.redirectingnum, e->ring.callingplanrdnis); /* If immediate=yes go to s|1 */ if (pri->pvts[chanpos]->immediate) { ast_verb(3, "Going to extension s|1 because of immediate=yes\n"); @@ -1191,7 +1196,7 @@ static void *pri_dchannel(void *vpri) } } pthread_attr_destroy(&attr); - } else { + } else { ast_mutex_unlock(&pri->lock); /* Release PRI lock while we create the channel */ c = sig_pri_new_ast_channel(pri->pvts[chanpos], AST_STATE_RING, 1, (e->ring.layer1 == PRI_LAYER_1_ALAW) ? SIG_PRI_ALAW : SIG_PRI_ULAW, e->ring.ctype, pri->pvts[chanpos]->exten, NULL); @@ -1226,8 +1231,8 @@ static void *pri_dchannel(void *vpri) ast_mutex_lock(&pri->lock); ast_verb(3, "Accepting call from '%s' to '%s' on channel %d/%d, span %d\n", - plancallingnum, pri->pvts[chanpos]->exten, - pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span); + plancallingnum, pri->pvts[chanpos]->exten, + pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span); sig_pri_set_echocanceller(pri->pvts[chanpos], 1); } else { @@ -1241,8 +1246,8 @@ static void *pri_dchannel(void *vpri) } } else { ast_verb(3, "Extension '%s' in context '%s' from '%s' does not exist. Rejecting call on channel %d/%d, span %d\n", - pri->pvts[chanpos]->exten, pri->pvts[chanpos]->context, pri->pvts[chanpos]->cid_num, pri->pvts[chanpos]->logicalspan, - pri->pvts[chanpos]->prioffset, pri->span); + pri->pvts[chanpos]->exten, pri->pvts[chanpos]->context, pri->pvts[chanpos]->cid_num, pri->pvts[chanpos]->logicalspan, + pri->pvts[chanpos]->prioffset, pri->span); pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_UNALLOCATED); pri->pvts[chanpos]->call = NULL; pri->pvts[chanpos]->exten[0] = '\0'; @@ -1270,12 +1275,6 @@ static void *pri_dchannel(void *vpri) sig_pri_set_echocanceller(pri->pvts[chanpos], 1); pri_queue_control(pri->pvts[chanpos], AST_CONTROL_RINGING, pri); pri->pvts[chanpos]->alerting = 1; -#ifdef PRI_PROGRESS_MASK - if (e->ringing.progressmask & PRI_PROG_INBAND_AVAILABLE) { -#else - if (e->ringing.progress == 8) { -#endif - } #ifdef SUPPORT_USERUSER if (!ast_strlen_zero(e->ringing.useruserinfo)) { @@ -1294,11 +1293,13 @@ static void *pri_dchannel(void *vpri) /* Get chan value if e->e is not PRI_EVNT_RINGING */ chanpos = pri_find_principle(pri, e->proceeding.channel); if (chanpos > -1) { + if ((!pri->pvts[chanpos]->progress) #ifdef PRI_PROGRESS_MASK - if ((!pri->pvts[chanpos]->progress) || (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE)) { + || (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) #else - if ((!pri->pvts[chanpos]->progress) || (e->proceeding.progress == 8)) { + || (e->proceeding.progress == 8) #endif + ) { struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROGRESS, }; if (e->proceeding.cause > -1) { @@ -1316,14 +1317,16 @@ static void *pri_dchannel(void *vpri) } sig_pri_lock_private(pri->pvts[chanpos]); - ast_log(LOG_DEBUG, "Queuing frame from PRI_EVENT_PROGRESS on channel %d/%d span %d\n", - pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span); + ast_debug(1, "Queuing frame from PRI_EVENT_PROGRESS on channel %d/%d span %d\n", + pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span); pri_queue_frame(pri->pvts[chanpos], &f, pri); + if ( #ifdef PRI_PROGRESS_MASK - if (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) { + e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE #else - if (e->proceeding.progress == 8) { + e->proceeding.progress == 8 #endif + ) { /* Bring voice path up */ f.subclass = AST_CONTROL_PROGRESS; pri_queue_frame(pri->pvts[chanpos], &f, pri); @@ -1341,14 +1344,16 @@ static void *pri_dchannel(void *vpri) struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROCEEDING, }; sig_pri_lock_private(pri->pvts[chanpos]); - ast_log(LOG_DEBUG, "Queuing frame from PRI_EVENT_PROCEEDING on channel %d/%d span %d\n", - pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span); + ast_debug(1, "Queuing frame from PRI_EVENT_PROCEEDING on channel %d/%d span %d\n", + pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span); pri_queue_frame(pri->pvts[chanpos], &f, pri); + if ( #ifdef PRI_PROGRESS_MASK - if (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) { + e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE #else - if (e->proceeding.progress == 8) { + e->proceeding.progress == 8 #endif + ) { /* Bring voice path up */ f.subclass = AST_CONTROL_PROGRESS; pri_queue_frame(pri->pvts[chanpos], &f, pri); @@ -1429,37 +1434,38 @@ static void *pri_dchannel(void *vpri) ast_softhangup_nolock(pri->pvts[chanpos]->owner, AST_SOFTHANGUP_DEV); else { switch (e->hangup.cause) { - case PRI_CAUSE_USER_BUSY: - pri_queue_control(pri->pvts[chanpos], AST_CONTROL_BUSY, pri); - break; - case PRI_CAUSE_CALL_REJECTED: - case PRI_CAUSE_NETWORK_OUT_OF_ORDER: - case PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION: - case PRI_CAUSE_SWITCH_CONGESTION: - case PRI_CAUSE_DESTINATION_OUT_OF_ORDER: - case PRI_CAUSE_NORMAL_TEMPORARY_FAILURE: - pri_queue_control(pri->pvts[chanpos], AST_CONTROL_CONGESTION, pri); - break; - default: - ast_softhangup_nolock(pri->pvts[chanpos]->owner, AST_SOFTHANGUP_DEV); + case PRI_CAUSE_USER_BUSY: + pri_queue_control(pri->pvts[chanpos], AST_CONTROL_BUSY, pri); + break; + case PRI_CAUSE_CALL_REJECTED: + case PRI_CAUSE_NETWORK_OUT_OF_ORDER: + case PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION: + case PRI_CAUSE_SWITCH_CONGESTION: + case PRI_CAUSE_DESTINATION_OUT_OF_ORDER: + case PRI_CAUSE_NORMAL_TEMPORARY_FAILURE: + pri_queue_control(pri->pvts[chanpos], AST_CONTROL_CONGESTION, pri); + break; + default: + ast_softhangup_nolock(pri->pvts[chanpos]->owner, AST_SOFTHANGUP_DEV); + break; } } } ast_verb(3, "Channel %d/%d, span %d got hangup, cause %d\n", - pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, e->hangup.cause); + pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, e->hangup.cause); } else { pri_hangup(pri->pri, pri->pvts[chanpos]->call, e->hangup.cause); pri->pvts[chanpos]->call = NULL; } if (e->hangup.cause == PRI_CAUSE_REQUESTED_CHAN_UNAVAIL) { ast_verb(3, "Forcing restart of channel %d/%d on span %d since channel reported in use\n", - PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span); + PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span); pri_reset(pri->pri, PVT_TO_CHANNEL(pri->pvts[chanpos])); pri->pvts[chanpos]->resetting = 1; } if (e->hangup.aoc_units > -1) ast_verb(3, "Channel %d/%d, span %d received AOC-E charging %d unit%s\n", - pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, (int)e->hangup.aoc_units, (e->hangup.aoc_units == 1) ? "" : "s"); + pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, (int)e->hangup.aoc_units, (e->hangup.aoc_units == 1) ? "" : "s"); #ifdef SUPPORT_USERUSER if (pri->pvts[chanpos]->owner && !ast_strlen_zero(e->hangup.useruserinfo)) { @@ -1495,32 +1501,33 @@ static void *pri_dchannel(void *vpri) ast_softhangup_nolock(pri->pvts[chanpos]->owner, AST_SOFTHANGUP_DEV); else { switch (e->hangup.cause) { - case PRI_CAUSE_USER_BUSY: - pri_queue_control(pri->pvts[chanpos], AST_CONTROL_BUSY, pri); - break; - case PRI_CAUSE_CALL_REJECTED: - case PRI_CAUSE_NETWORK_OUT_OF_ORDER: - case PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION: - case PRI_CAUSE_SWITCH_CONGESTION: - case PRI_CAUSE_DESTINATION_OUT_OF_ORDER: - case PRI_CAUSE_NORMAL_TEMPORARY_FAILURE: - pri_queue_control(pri->pvts[chanpos], AST_CONTROL_CONGESTION, pri); - break; - default: - ast_softhangup_nolock(pri->pvts[chanpos]->owner, AST_SOFTHANGUP_DEV); + case PRI_CAUSE_USER_BUSY: + pri_queue_control(pri->pvts[chanpos], AST_CONTROL_BUSY, pri); + break; + case PRI_CAUSE_CALL_REJECTED: + case PRI_CAUSE_NETWORK_OUT_OF_ORDER: + case PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION: + case PRI_CAUSE_SWITCH_CONGESTION: + case PRI_CAUSE_DESTINATION_OUT_OF_ORDER: + case PRI_CAUSE_NORMAL_TEMPORARY_FAILURE: + pri_queue_control(pri->pvts[chanpos], AST_CONTROL_CONGESTION, pri); + break; + default: + ast_softhangup_nolock(pri->pvts[chanpos]->owner, AST_SOFTHANGUP_DEV); + break; } } ast_verb(3, "Channel %d/%d, span %d got hangup request, cause %d\n", PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span, e->hangup.cause); if (e->hangup.aoc_units > -1) ast_verb(3, "Channel %d/%d, span %d received AOC-E charging %d unit%s\n", - pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, (int)e->hangup.aoc_units, (e->hangup.aoc_units == 1) ? "" : "s"); + pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, (int)e->hangup.aoc_units, (e->hangup.aoc_units == 1) ? "" : "s"); } else { pri_hangup(pri->pri, pri->pvts[chanpos]->call, e->hangup.cause); pri->pvts[chanpos]->call = NULL; } if (e->hangup.cause == PRI_CAUSE_REQUESTED_CHAN_UNAVAIL) { ast_verb(3, "Forcing restart of channel %d/%d span %d since channel reported in use\n", - PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span); + PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span); pri_reset(pri->pri, PVT_TO_CHANNEL(pri->pvts[chanpos])); pri->pvts[chanpos]->resetting = 1; } @@ -1581,8 +1588,8 @@ static void *pri_dchannel(void *vpri) if (pri->pvts[x] && pri->pvts[x]->resetting) { chanpos = x; sig_pri_lock_private(pri->pvts[chanpos]); - ast_log(LOG_DEBUG, "Assuming restart ack is really for channel %d/%d span %d\n", pri->pvts[chanpos]->logicalspan, - pri->pvts[chanpos]->prioffset, pri->span); + ast_debug(1, "Assuming restart ack is really for channel %d/%d span %d\n", pri->pvts[chanpos]->logicalspan, + pri->pvts[chanpos]->prioffset, pri->span); if (pri->pvts[chanpos]->owner) { ast_log(LOG_WARNING, "Got restart ack on channel %d/%d with owner on span %d\n", pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span); @@ -1590,7 +1597,7 @@ static void *pri_dchannel(void *vpri) } pri->pvts[chanpos]->resetting = 0; ast_verb(3, "B-channel %d/%d successfully restarted on span %d\n", pri->pvts[chanpos]->logicalspan, - pri->pvts[chanpos]->prioffset, pri->span); + pri->pvts[chanpos]->prioffset, pri->span); sig_pri_unlock_private(pri->pvts[chanpos]); if (pri->resetting) pri_check_restart(pri); @@ -1611,7 +1618,7 @@ static void *pri_dchannel(void *vpri) } pri->pvts[chanpos]->resetting = 0; ast_verb(3, "B-channel %d/%d successfully restarted on span %d\n", pri->pvts[chanpos]->logicalspan, - pri->pvts[chanpos]->prioffset, pri->span); + pri->pvts[chanpos]->prioffset, pri->span); sig_pri_unlock_private(pri->pvts[chanpos]); if (pri->resetting) pri_check_restart(pri); @@ -1630,7 +1637,7 @@ static void *pri_dchannel(void *vpri) pri->pvts[chanpos]->setup_ack = 1; /* Send any queued digits */ for (x = 0;x < strlen(pri->pvts[chanpos]->dialdest); x++) { - ast_log(LOG_DEBUG, "Sending pending digit '%c'\n", pri->pvts[chanpos]->dialdest[x]); + ast_debug(1, "Sending pending digit '%c'\n", pri->pvts[chanpos]->dialdest[x]); pri_information(pri->pri, pri->pvts[chanpos]->call, pri->pvts[chanpos]->dialdest[x]); } @@ -1646,6 +1653,7 @@ static void *pri_dchannel(void *vpri) PRI_SPAN(e->notify.channel), PRI_CHANNEL(e->notify.channel), pri->span); } else { struct ast_frame f = { AST_FRAME_CONTROL, }; + sig_pri_lock_private(pri->pvts[chanpos]); switch (e->notify.info) { case PRI_NOTIFY_REMOTE_HOLD: @@ -1661,7 +1669,7 @@ static void *pri_dchannel(void *vpri) } break; default: - ast_log(LOG_DEBUG, "Event: %d\n", e->e); + ast_debug(1, "Event: %d\n", e->e); } } ast_mutex_unlock(&pri->lock); @@ -1795,7 +1803,6 @@ int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, char *rdest, i l = NULL; n = NULL; - if (!p->hidecallerid) { l = ast->connected.id.number; if (!p->hidecalleridname) { @@ -1803,7 +1810,6 @@ int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, char *rdest, i } } - if (strlen(c) < p->stripmsd) { ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd); return -1; @@ -1836,29 +1842,29 @@ int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, char *rdest, i pri_sr_set_channel(sr, PVT_TO_CHANNEL(p), exclusive, 1); pri_sr_set_bearer(sr, p->digital ? PRI_TRANS_CAP_DIGITAL : ast->transfercapability, - (p->digital ? -1 : layer1)); + (p->digital ? -1 : layer1)); if (p->pri->facilityenable) pri_facility_enable(p->pri->pri); ast_verb(3, "Requested transfer capability: 0x%.2x - %s\n", ast->transfercapability, ast_transfercapability2str(ast->transfercapability)); dp_strip = 0; - pridialplan = p->pri->dialplan - 1; - if (pridialplan == -2 || pridialplan == -3) { /* compute dynamically */ - if (strncmp(c + p->stripmsd, p->pri->internationalprefix, strlen(p->pri->internationalprefix)) == 0) { + pridialplan = p->pri->dialplan - 1; + if (pridialplan == -2 || pridialplan == -3) { /* compute dynamically */ + if (strncmp(c + p->stripmsd, p->pri->internationalprefix, strlen(p->pri->internationalprefix)) == 0) { if (pridialplan == -2) { - dp_strip = strlen(p->pri->internationalprefix); + dp_strip = strlen(p->pri->internationalprefix); } - pridialplan = PRI_INTERNATIONAL_ISDN; - } else if (strncmp(c + p->stripmsd, p->pri->nationalprefix, strlen(p->pri->nationalprefix)) == 0) { + pridialplan = PRI_INTERNATIONAL_ISDN; + } else if (strncmp(c + p->stripmsd, p->pri->nationalprefix, strlen(p->pri->nationalprefix)) == 0) { if (pridialplan == -2) { - dp_strip = strlen(p->pri->nationalprefix); + dp_strip = strlen(p->pri->nationalprefix); } - pridialplan = PRI_NATIONAL_ISDN; - } else { + pridialplan = PRI_NATIONAL_ISDN; + } else { pridialplan = PRI_LOCAL_ISDN; - } - } + } + } while (c[p->stripmsd] > '9' && c[p->stripmsd] != '*' && c[p->stripmsd] != '#') { switch (c[p->stripmsd]) { case 'U': @@ -1917,7 +1923,7 @@ int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, char *rdest, i } c++; } - pri_sr_set_called(sr, c + p->stripmsd + dp_strip, pridialplan, s ? 1 : 0); + pri_sr_set_called(sr, c + p->stripmsd + dp_strip, pridialplan, s ? 1 : 0); ldp_strip = 0; prilocaldialplan = p->pri->localdialplan - 1; @@ -2032,7 +2038,7 @@ int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, char *rdest, i int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condition, const void *data, size_t datalen) { - int res = 0; + int res = -1; switch (condition) { case AST_CONTROL_BUSY: @@ -2093,12 +2099,16 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi res = 0; break; case AST_CONTROL_PROGRESS: - ast_log(LOG_DEBUG,"Received AST_CONTROL_PROGRESS on %s\n",chan->name); + ast_debug(1,"Received AST_CONTROL_PROGRESS on %s\n",chan->name); p->digital = 0; /* Digital-only calls isn't allowing any inband progress messages */ if (!p->progress && p->pri && !p->outgoing) { if (p->pri->pri) { if (!pri_grab(p, p->pri)) { +#ifdef HAVE_PRI_PROG_W_CAUSE + pri_progress_with_cause(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1, -1); /* no cause at all */ +#else pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1); +#endif pri_rel(p->pri); } else { ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span); @@ -2256,10 +2266,11 @@ int sig_pri_start_pri(struct sig_pri_pri *pri) default: pri->dchans[i] = pri_new(pri->fds[i], pri->nodetype, pri->switchtype); #ifdef HAVE_PRI_SERVICE_MESSAGES - if (pri->enable_service_message_support) { - pri_set_service_message_support(pri->dchans[i], 1); - } + if (pri->enable_service_message_support) { + pri_set_service_message_support(pri->dchans[i], 1); + } #endif + break; } /* Force overlap dial if we're doing GR-303! */