summaryrefslogtreecommitdiff
path: root/zaptel.c
diff options
context:
space:
mode:
Diffstat (limited to 'zaptel.c')
-rwxr-xr-xzaptel.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/zaptel.c b/zaptel.c
index c3088d7..339da65 100755
--- a/zaptel.c
+++ b/zaptel.c
@@ -1989,7 +1989,8 @@ static int initialize_channel(struct zt_chan *chan)
chan->afterdialingtimer = 0;
chan->cadencepos = 0;
-
+ chan->firstcadencepos = 0; /* By default loop back to first cadence position */
+
/* HDLC & FCS stuff */
fasthdlc_init(&chan->rxhdlc);
fasthdlc_init(&chan->txhdlc);
@@ -3782,10 +3783,28 @@ static int zt_chanandpseudo_ioctl(struct inode *inode, struct file *file, unsign
if (copy_from_user(&stack.cad, (struct zt_ring_cadence *)data, sizeof(stack.cad)))
return -EIO;
memcpy(chan->ringcadence, &stack.cad, sizeof(chan->ringcadence));
+ chan->firstcadencepos = 0;
+ /* Looking for negative ringing time indicating where to loop back into ringcadence */
+ for (i=0; i<ZT_MAX_CADENCE; i+=2 ) {
+ if (chan->ringcadence[i]<0) {
+ chan->ringcadence[i] *= -1;
+ chan->firstcadencepos = i;
+ break;
+ }
+ }
} else {
/* Reset to default */
+ chan->firstcadencepos = 0;
if (chan->curzone) {
memcpy(chan->ringcadence, chan->curzone->ringcadence, sizeof(chan->ringcadence));
+ /* Looking for negative ringing time indicating where to loop back into ringcadence */
+ for (i=0; i<ZT_MAX_CADENCE; i+=2 ) {
+ if (chan->ringcadence[i]<0) {
+ chan->ringcadence[i] *= -1;
+ chan->firstcadencepos = i;
+ break;
+ }
+ }
} else {
memset(chan->ringcadence, 0, sizeof(chan->ringcadence));
chan->ringcadence[0] = chan->starttime;
@@ -4888,11 +4907,11 @@ static inline void __rbs_otimer_expire(struct zt_chan *chan)
/* Turn on the ringer now that the silent time has passed */
++chan->cadencepos;
if (chan->cadencepos >= ZT_MAX_CADENCE)
- chan->cadencepos = 0;
+ chan->cadencepos = chan->firstcadencepos;
len = chan->ringcadence[chan->cadencepos];
if (!len) {
- chan->cadencepos = 0;
+ chan->cadencepos = chan->firstcadencepos;
len = chan->ringcadence[chan->cadencepos];
}