aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authormartinp <martinp@f38db490-d61c-443f-a65b-d21fe96a405b>2003-08-25 20:39:07 +0000
committermartinp <martinp@f38db490-d61c-443f-a65b-d21fe96a405b>2003-08-25 20:39:07 +0000
commit92d99f5cb0ad1ab41e9e95ca98c874a45e2ae5e3 (patch)
treee18d641058bceec160cb02356cb8cfc2edefe6e0 /channels
parent082653c9380180ec63428fa60b354ee35f6eb5e2 (diff)
Don't allow to place calls when a dchannel is down (for PRI). Also when we detect that d-channel is down -> destroy the calls.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1429 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rwxr-xr-xchannels/chan_zap.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index e21d69b4f..6468f14c1 100755
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -2653,10 +2653,12 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
case ZT_EVENT_ALARM:
#ifdef ZAPATA_PRI
#ifdef PRI_DESTROYCALL
- if (p->call && p->pri && p->pri->pri)
- pri_destroycall(p->pri->pri, p->call);
- else
- ast_log(LOG_WARNING, "The PRI Call have not been destroyed\n");
+ if (p->call) {
+ if (p->pri && p->pri->pri)
+ pri_destroycall(p->pri->pri, p->call);
+ else
+ ast_log(LOG_WARNING, "The PRI Call have not been destroyed\n");
+ }
p->call = NULL;
#else
#error Please "cvs update" and recompile libpri
@@ -5120,7 +5122,11 @@ static struct zt_pvt *mkintf(int channel, int signalling, int radio)
/* Hang it up to be sure it's good */
zt_set_hook(tmp->subs[SUB_REAL].zfd, ZT_ONHOOK);
}
- tmp->inalarm = 0;
+ /* the dchannel is down so put the channel in alarm */
+ if (tmp->pri && tmp->pri->up == 0) {
+ tmp->inalarm = 1;
+ else
+ tmp->inalarm = 0;
memset(&si, 0, sizeof(si));
if (ioctl(tmp->subs[SUB_REAL].zfd,ZT_SPANSTAT,&si) == -1) {
ast_log(LOG_ERROR, "Unable to get span status: %s\n", strerror(errno));
@@ -5522,6 +5528,7 @@ static void *pri_dchannel(void *vpri)
struct ast_channel *idle;
pthread_t p;
time_t t;
+ int i;
gettimeofday(&lastidle, NULL);
if (strlen(pri->idledial) && strlen(pri->idleext)) {
/* Need to do idle dialing, check to be sure though */
@@ -5677,12 +5684,31 @@ static void *pri_dchannel(void *vpri)
pri->lastreset -= RESET_INTERVAL;
pri->lastreset += 5;
pri->resetting = 0;
+ /* Take the channels from inalarm condition */
+ for (i=0; i<=pri->channels; i++)
+ if (pri->pvt[i]) {
+ pri->pvt[i]->inalarm = 0;
+ }
break;
case PRI_EVENT_DCHAN_DOWN:
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "D-Channel on span %d down\n", pri->span);
pri->up = 0;
pri->resetting = 0;
+ /* Hangup active channels and put them in alarm mode */
+ for (i=0; i<=pri->channels; i++) {
+ struct zt_pvt *p = pri->pvt[i];
+ if (p) {
+ if (p->call) {
+ if (p->pri && p->pri->pri)
+ pri_destroycall(p->pri->pri, p->call);
+ else
+ ast_log(LOG_WARNING, "The PRI Call have not been destroyed on channel %s\n",p->owner->name);
+ }
+ p->call = NULL;
+ p->inalarm = 1;
+ }
+ }
break;
case PRI_EVENT_RESTART:
chan = e->restart.channel;
@@ -6149,7 +6175,7 @@ static int start_pri(struct zt_pri *pri)
if (p.sigtype != ZT_SIG_HDLCFCS) {
close(pri->fd);
pri->fd = -1;
- ast_log(LOG_ERROR, "D-channel %x is not in HDLC/FCS mode. See /etc/tormenta.conf\n", x);
+ ast_log(LOG_ERROR, "D-channel %d is not in HDLC/FCS mode. See /etc/tormenta.conf\n", x);
return -1;
}
bi.txbufpolicy = ZT_POLICY_IMMEDIATE;