2005-04-16 22:20:36 +00:00
|
|
|
/* $Id: isdn_divert.c,v 1.6.6.3 2001/09/23 22:24:36 kai Exp $
|
|
|
|
*
|
|
|
|
* DSS1 main diversion supplementary handling for i4l.
|
|
|
|
*
|
|
|
|
* Copyright 1999 by Werner Cornelius (werner@isdn4linux.de)
|
2012-02-20 03:52:38 +00:00
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* This software may be used and distributed according to the terms
|
|
|
|
* of the GNU General Public License, incorporated herein by reference.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/proc_fs.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2006-12-04 04:15:30 +00:00
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/jiffies.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include "isdn_divert.h"
|
|
|
|
|
|
|
|
/**********************************/
|
|
|
|
/* structure keeping calling info */
|
|
|
|
/**********************************/
|
2013-01-21 11:57:20 +00:00
|
|
|
struct call_struc {
|
|
|
|
isdn_ctrl ics; /* delivered setup + driver parameters */
|
2012-02-20 03:52:38 +00:00
|
|
|
ulong divert_id; /* Id delivered to user */
|
|
|
|
unsigned char akt_state; /* actual state */
|
|
|
|
char deflect_dest[35]; /* deflection destination */
|
|
|
|
struct timer_list timer; /* timer control structure */
|
|
|
|
char info[90]; /* device info output */
|
|
|
|
struct call_struc *next; /* pointer to next entry */
|
|
|
|
struct call_struc *prev;
|
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
/********************************************/
|
|
|
|
/* structure keeping deflection table entry */
|
|
|
|
/********************************************/
|
2013-01-21 11:57:20 +00:00
|
|
|
struct deflect_struc {
|
|
|
|
struct deflect_struc *next, *prev;
|
2012-02-20 03:52:38 +00:00
|
|
|
divert_rule rule; /* used rule */
|
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*****************************************/
|
|
|
|
/* variables for main diversion services */
|
|
|
|
/*****************************************/
|
|
|
|
/* diversion/deflection processes */
|
|
|
|
static struct call_struc *divert_head = NULL; /* head of remembered entrys */
|
2012-02-20 03:52:38 +00:00
|
|
|
static ulong next_id = 1; /* next info id */
|
2005-04-16 22:20:36 +00:00
|
|
|
static struct deflect_struc *table_head = NULL;
|
2012-02-20 03:52:38 +00:00
|
|
|
static struct deflect_struc *table_tail = NULL;
|
|
|
|
static unsigned char extern_wait_max = 4; /* maximum wait in s for external process */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
DEFINE_SPINLOCK(divert_lock);
|
|
|
|
|
|
|
|
/***************************/
|
|
|
|
/* timer callback function */
|
|
|
|
/***************************/
|
|
|
|
static void deflect_timer_expire(ulong arg)
|
|
|
|
{
|
2012-02-20 03:52:38 +00:00
|
|
|
unsigned long flags;
|
|
|
|
struct call_struc *cs = (struct call_struc *) arg;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&divert_lock, flags);
|
|
|
|
del_timer(&cs->timer); /* delete active timer */
|
|
|
|
spin_unlock_irqrestore(&divert_lock, flags);
|
|
|
|
|
2013-01-21 11:57:20 +00:00
|
|
|
switch (cs->akt_state) {
|
|
|
|
case DEFLECT_PROCEED:
|
|
|
|
cs->ics.command = ISDN_CMD_HANGUP; /* cancel action */
|
|
|
|
divert_if.ll_cmd(&cs->ics);
|
|
|
|
spin_lock_irqsave(&divert_lock, flags);
|
|
|
|
cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
|
|
|
|
cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
|
|
|
|
add_timer(&cs->timer);
|
|
|
|
spin_unlock_irqrestore(&divert_lock, flags);
|
|
|
|
break;
|
2012-02-20 03:52:38 +00:00
|
|
|
|
|
|
|
case DEFLECT_ALERT:
|
|
|
|
cs->ics.command = ISDN_CMD_REDIR; /* protocol */
|
|
|
|
strlcpy(cs->ics.parm.setup.phone, cs->deflect_dest, sizeof(cs->ics.parm.setup.phone));
|
|
|
|
strcpy(cs->ics.parm.setup.eazmsn, "Testtext delayed");
|
|
|
|
divert_if.ll_cmd(&cs->ics);
|
|
|
|
spin_lock_irqsave(&divert_lock, flags);
|
|
|
|
cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
|
|
|
|
cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
|
|
|
|
add_timer(&cs->timer);
|
|
|
|
spin_unlock_irqrestore(&divert_lock, flags);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DEFLECT_AUTODEL:
|
|
|
|
default:
|
|
|
|
spin_lock_irqsave(&divert_lock, flags);
|
|
|
|
if (cs->prev)
|
|
|
|
cs->prev->next = cs->next; /* forward link */
|
|
|
|
else
|
|
|
|
divert_head = cs->next;
|
|
|
|
if (cs->next)
|
|
|
|
cs->next->prev = cs->prev; /* back link */
|
|
|
|
spin_unlock_irqrestore(&divert_lock, flags);
|
|
|
|
kfree(cs);
|
|
|
|
return;
|
|
|
|
|
|
|
|
} /* switch */
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* deflect_timer_func */
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************/
|
|
|
|
/* handle call forwarding de/activations */
|
|
|
|
/* 0 = deact, 1 = act, 2 = interrogate */
|
|
|
|
/*****************************************/
|
2012-02-20 03:52:38 +00:00
|
|
|
int cf_command(int drvid, int mode,
|
|
|
|
u_char proc, char *msn,
|
|
|
|
u_char service, char *fwd_nr, ulong *procid)
|
2013-01-21 11:57:20 +00:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
2012-02-20 03:52:38 +00:00
|
|
|
int retval, msnlen;
|
|
|
|
int fwd_len;
|
|
|
|
char *p, *ielenp, tmp[60];
|
|
|
|
struct call_struc *cs;
|
|
|
|
|
|
|
|
if (strchr(msn, '.')) return (-EINVAL); /* subaddress not allowed in msn */
|
|
|
|
if ((proc & 0x7F) > 2) return (-EINVAL);
|
|
|
|
proc &= 3;
|
|
|
|
p = tmp;
|
|
|
|
*p++ = 0x30; /* enumeration */
|
|
|
|
ielenp = p++; /* remember total length position */
|
|
|
|
*p++ = 0xa; /* proc tag */
|
|
|
|
*p++ = 1; /* length */
|
|
|
|
*p++ = proc & 0x7F; /* procedure to de/activate/interrogate */
|
|
|
|
*p++ = 0xa; /* service tag */
|
|
|
|
*p++ = 1; /* length */
|
|
|
|
*p++ = service; /* service to handle */
|
|
|
|
|
2013-01-21 11:57:20 +00:00
|
|
|
if (mode == 1) {
|
|
|
|
if (!*fwd_nr) return (-EINVAL); /* destination missing */
|
2012-02-20 03:52:38 +00:00
|
|
|
if (strchr(fwd_nr, '.')) return (-EINVAL); /* subaddress not allowed */
|
|
|
|
fwd_len = strlen(fwd_nr);
|
|
|
|
*p++ = 0x30; /* number enumeration */
|
|
|
|
*p++ = fwd_len + 2; /* complete forward to len */
|
|
|
|
*p++ = 0x80; /* fwd to nr */
|
|
|
|
*p++ = fwd_len; /* length of number */
|
|
|
|
strcpy(p, fwd_nr); /* copy number */
|
|
|
|
p += fwd_len; /* pointer beyond fwd */
|
|
|
|
} /* activate */
|
|
|
|
|
|
|
|
msnlen = strlen(msn);
|
|
|
|
*p++ = 0x80; /* msn number */
|
2013-01-21 11:57:20 +00:00
|
|
|
if (msnlen > 1) {
|
|
|
|
*p++ = msnlen; /* length */
|
2012-02-20 03:52:38 +00:00
|
|
|
strcpy(p, msn);
|
|
|
|
p += msnlen;
|
2013-01-21 11:57:20 +00:00
|
|
|
} else
|
|
|
|
*p++ = 0;
|
2012-02-20 03:52:38 +00:00
|
|
|
|
|
|
|
*ielenp = p - ielenp - 1; /* set total IE length */
|
|
|
|
|
|
|
|
/* allocate mem for information struct */
|
|
|
|
if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC)))
|
|
|
|
return (-ENOMEM); /* no memory */
|
2017-03-23 13:15:57 +00:00
|
|
|
setup_timer(&cs->timer, deflect_timer_expire, (ulong)cs);
|
2012-02-20 03:52:38 +00:00
|
|
|
cs->info[0] = '\0';
|
|
|
|
cs->ics.driver = drvid;
|
|
|
|
cs->ics.command = ISDN_CMD_PROT_IO; /* protocol specific io */
|
|
|
|
cs->ics.arg = DSS1_CMD_INVOKE; /* invoke supplementary service */
|
|
|
|
cs->ics.parm.dss1_io.proc = (mode == 1) ? 7 : (mode == 2) ? 11 : 8; /* operation */
|
|
|
|
cs->ics.parm.dss1_io.timeout = 4000; /* from ETS 300 207-1 */
|
|
|
|
cs->ics.parm.dss1_io.datalen = p - tmp; /* total len */
|
|
|
|
cs->ics.parm.dss1_io.data = tmp; /* start of buffer */
|
|
|
|
|
|
|
|
spin_lock_irqsave(&divert_lock, flags);
|
|
|
|
cs->ics.parm.dss1_io.ll_id = next_id++; /* id for callback */
|
|
|
|
spin_unlock_irqrestore(&divert_lock, flags);
|
|
|
|
*procid = cs->ics.parm.dss1_io.ll_id;
|
|
|
|
|
|
|
|
sprintf(cs->info, "%d 0x%lx %s%s 0 %s %02x %d%s%s\n",
|
|
|
|
(!mode) ? DIVERT_DEACTIVATE : (mode == 1) ? DIVERT_ACTIVATE : DIVERT_REPORT,
|
|
|
|
cs->ics.parm.dss1_io.ll_id,
|
|
|
|
(mode != 2) ? "" : "0 ",
|
|
|
|
divert_if.drv_to_name(cs->ics.driver),
|
|
|
|
msn,
|
|
|
|
service & 0xFF,
|
|
|
|
proc,
|
|
|
|
(mode != 1) ? "" : " 0 ",
|
|
|
|
(mode != 1) ? "" : fwd_nr);
|
|
|
|
|
|
|
|
retval = divert_if.ll_cmd(&cs->ics); /* execute command */
|
|
|
|
|
2013-01-21 11:57:20 +00:00
|
|
|
if (!retval) {
|
|
|
|
cs->prev = NULL;
|
2012-02-20 03:52:38 +00:00
|
|
|
spin_lock_irqsave(&divert_lock, flags);
|
|
|
|
cs->next = divert_head;
|
|
|
|
divert_head = cs;
|
|
|
|
spin_unlock_irqrestore(&divert_lock, flags);
|
2013-01-21 11:57:20 +00:00
|
|
|
} else
|
2012-02-20 03:52:38 +00:00
|
|
|
kfree(cs);
|
|
|
|
return (retval);
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* cf_command */
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************/
|
|
|
|
/* handle a external deflection command */
|
|
|
|
/****************************************/
|
|
|
|
int deflect_extern_action(u_char cmd, ulong callid, char *to_nr)
|
2013-01-21 11:57:20 +00:00
|
|
|
{
|
|
|
|
struct call_struc *cs;
|
2012-02-20 03:52:38 +00:00
|
|
|
isdn_ctrl ic;
|
|
|
|
unsigned long flags;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if ((cmd & 0x7F) > 2) return (-EINVAL); /* invalid command */
|
|
|
|
cs = divert_head; /* start of parameter list */
|
2013-01-21 11:57:20 +00:00
|
|
|
while (cs) {
|
|
|
|
if (cs->divert_id == callid) break; /* found */
|
2012-02-20 03:52:38 +00:00
|
|
|
cs = cs->next;
|
|
|
|
} /* search entry */
|
|
|
|
if (!cs) return (-EINVAL); /* invalid callid */
|
|
|
|
|
|
|
|
ic.driver = cs->ics.driver;
|
|
|
|
ic.arg = cs->ics.arg;
|
|
|
|
i = -EINVAL;
|
|
|
|
if (cs->akt_state == DEFLECT_AUTODEL) return (i); /* no valid call */
|
2013-01-21 11:57:20 +00:00
|
|
|
switch (cmd & 0x7F) {
|
|
|
|
case 0: /* hangup */
|
|
|
|
del_timer(&cs->timer);
|
|
|
|
ic.command = ISDN_CMD_HANGUP;
|
|
|
|
i = divert_if.ll_cmd(&ic);
|
|
|
|
spin_lock_irqsave(&divert_lock, flags);
|
|
|
|
cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
|
|
|
|
cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
|
|
|
|
add_timer(&cs->timer);
|
|
|
|
spin_unlock_irqrestore(&divert_lock, flags);
|
|
|
|
break;
|
2012-02-20 03:52:38 +00:00
|
|
|
|
|
|
|
case 1: /* alert */
|
|
|
|
if (cs->akt_state == DEFLECT_ALERT) return (0);
|
|
|
|
cmd &= 0x7F; /* never wait */
|
|
|
|
del_timer(&cs->timer);
|
|
|
|
ic.command = ISDN_CMD_ALERT;
|
2013-01-21 11:57:20 +00:00
|
|
|
if ((i = divert_if.ll_cmd(&ic))) {
|
2012-02-20 03:52:38 +00:00
|
|
|
spin_lock_irqsave(&divert_lock, flags);
|
|
|
|
cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
|
|
|
|
cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
|
|
|
|
add_timer(&cs->timer);
|
|
|
|
spin_unlock_irqrestore(&divert_lock, flags);
|
2013-01-21 11:57:20 +00:00
|
|
|
} else
|
2012-02-20 03:52:38 +00:00
|
|
|
cs->akt_state = DEFLECT_ALERT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* redir */
|
|
|
|
del_timer(&cs->timer);
|
|
|
|
strlcpy(cs->ics.parm.setup.phone, to_nr, sizeof(cs->ics.parm.setup.phone));
|
|
|
|
strcpy(cs->ics.parm.setup.eazmsn, "Testtext manual");
|
|
|
|
ic.command = ISDN_CMD_REDIR;
|
2013-01-21 11:57:20 +00:00
|
|
|
if ((i = divert_if.ll_cmd(&ic))) {
|
2012-02-20 03:52:38 +00:00
|
|
|
spin_lock_irqsave(&divert_lock, flags);
|
|
|
|
cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
|
|
|
|
cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
|
|
|
|
add_timer(&cs->timer);
|
|
|
|
spin_unlock_irqrestore(&divert_lock, flags);
|
2013-01-21 11:57:20 +00:00
|
|
|
} else
|
2012-02-20 03:52:38 +00:00
|
|
|
cs->akt_state = DEFLECT_ALERT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
} /* switch */
|
|
|
|
return (i);
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* deflect_extern_action */
|
|
|
|
|
|
|
|
/********************************/
|
|
|
|
/* insert a new rule before idx */
|
|
|
|
/********************************/
|
|
|
|
int insertrule(int idx, divert_rule *newrule)
|
2013-01-21 11:57:20 +00:00
|
|
|
{
|
|
|
|
struct deflect_struc *ds, *ds1 = NULL;
|
2012-02-20 03:52:38 +00:00
|
|
|
unsigned long flags;
|
|
|
|
|
2013-01-21 11:57:20 +00:00
|
|
|
if (!(ds = kmalloc(sizeof(struct deflect_struc), GFP_KERNEL)))
|
2012-02-20 03:52:38 +00:00
|
|
|
return (-ENOMEM); /* no memory */
|
|
|
|
|
|
|
|
ds->rule = *newrule; /* set rule */
|
|
|
|
|
|
|
|
spin_lock_irqsave(&divert_lock, flags);
|
|
|
|
|
2013-01-21 11:57:20 +00:00
|
|
|
if (idx >= 0) {
|
|
|
|
ds1 = table_head;
|
2012-02-20 03:52:38 +00:00
|
|
|
while ((ds1) && (idx > 0))
|
|
|
|
{ idx--;
|
|
|
|
ds1 = ds1->next;
|
|
|
|
}
|
|
|
|
if (!ds1) idx = -1;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:57:20 +00:00
|
|
|
if (idx < 0) {
|
|
|
|
ds->prev = table_tail; /* previous entry */
|
2012-02-20 03:52:38 +00:00
|
|
|
ds->next = NULL; /* end of chain */
|
|
|
|
if (ds->prev)
|
|
|
|
ds->prev->next = ds; /* last forward */
|
|
|
|
else
|
|
|
|
table_head = ds; /* is first entry */
|
|
|
|
table_tail = ds; /* end of queue */
|
2013-01-21 11:57:20 +00:00
|
|
|
} else {
|
|
|
|
ds->next = ds1; /* next entry */
|
2012-02-20 03:52:38 +00:00
|
|
|
ds->prev = ds1->prev; /* prev entry */
|
|
|
|
ds1->prev = ds; /* backward chain old element */
|
|
|
|
if (!ds->prev)
|
|
|
|
table_head = ds; /* first element */
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&divert_lock, flags);
|
|
|
|
return (0);
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* insertrule */
|
|
|
|
|
|
|
|
/***********************************/
|
|
|
|
/* delete the rule at position idx */
|
|
|
|
/***********************************/
|
|
|
|
int deleterule(int idx)
|
2013-01-21 11:57:20 +00:00
|
|
|
{
|
|
|
|
struct deflect_struc *ds, *ds1;
|
2012-02-20 03:52:38 +00:00
|
|
|
unsigned long flags;
|
|
|
|
|
2013-01-21 11:57:20 +00:00
|
|
|
if (idx < 0) {
|
|
|
|
spin_lock_irqsave(&divert_lock, flags);
|
2012-02-20 03:52:38 +00:00
|
|
|
ds = table_head;
|
|
|
|
table_head = NULL;
|
|
|
|
table_tail = NULL;
|
|
|
|
spin_unlock_irqrestore(&divert_lock, flags);
|
2013-01-21 11:57:20 +00:00
|
|
|
while (ds) {
|
|
|
|
ds1 = ds;
|
2012-02-20 03:52:38 +00:00
|
|
|
ds = ds->next;
|
|
|
|
kfree(ds1);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_irqsave(&divert_lock, flags);
|
|
|
|
ds = table_head;
|
|
|
|
|
2013-01-21 11:57:20 +00:00
|
|
|
while ((ds) && (idx > 0)) {
|
|
|
|
idx--;
|
2012-02-20 03:52:38 +00:00
|
|
|
ds = ds->next;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:57:20 +00:00
|
|
|
if (!ds) {
|
2012-02-20 03:52:38 +00:00
|
|
|
spin_unlock_irqrestore(&divert_lock, flags);
|
|
|
|
return (-EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ds->next)
|
|
|
|
ds->next->prev = ds->prev; /* backward chain */
|
|
|
|
else
|
|
|
|
table_tail = ds->prev; /* end of chain */
|
|
|
|
|
|
|
|
if (ds->prev)
|
|
|
|
ds->prev->next = ds->next; /* forward chain */
|
|
|
|
else
|
|
|
|
table_head = ds->next; /* start of chain */
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&divert_lock, flags);
|
|
|
|
kfree(ds);
|
|
|
|
return (0);
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* deleterule */
|
|
|
|
|
|
|
|
/*******************************************/
|
|
|
|
/* get a pointer to a specific rule number */
|
|
|
|
/*******************************************/
|
|
|
|
divert_rule *getruleptr(int idx)
|
2013-01-21 11:57:20 +00:00
|
|
|
{
|
|
|
|
struct deflect_struc *ds = table_head;
|
2012-02-20 03:52:38 +00:00
|
|
|
|
|
|
|
if (idx < 0) return (NULL);
|
2013-01-21 11:57:20 +00:00
|
|
|
while ((ds) && (idx >= 0)) {
|
|
|
|
if (!(idx--)) {
|
|
|
|
return (&ds->rule);
|
2012-02-20 03:52:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
ds = ds->next;
|
|
|
|
}
|
|
|
|
return (NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* getruleptr */
|
|
|
|
|
|
|
|
/*************************************************/
|
|
|
|
/* called from common module on an incoming call */
|
|
|
|
/*************************************************/
|
2005-05-01 15:59:29 +00:00
|
|
|
static int isdn_divert_icall(isdn_ctrl *ic)
|
2013-01-21 11:57:20 +00:00
|
|
|
{
|
|
|
|
int retval = 0;
|
2012-02-20 03:52:38 +00:00
|
|
|
unsigned long flags;
|
|
|
|
struct call_struc *cs = NULL;
|
|
|
|
struct deflect_struc *dv;
|
|
|
|
char *p, *p1;
|
|
|
|
u_char accept;
|
|
|
|
|
|
|
|
/* first check the internal deflection table */
|
2013-01-21 11:57:20 +00:00
|
|
|
for (dv = table_head; dv; dv = dv->next) {
|
|
|
|
/* scan table */
|
2012-02-20 03:52:38 +00:00
|
|
|
if (((dv->rule.callopt == 1) && (ic->command == ISDN_STAT_ICALLW)) ||
|
|
|
|
((dv->rule.callopt == 2) && (ic->command == ISDN_STAT_ICALL)))
|
|
|
|
continue; /* call option check */
|
|
|
|
if (!(dv->rule.drvid & (1L << ic->driver)))
|
|
|
|
continue; /* driver not matching */
|
|
|
|
if ((dv->rule.si1) && (dv->rule.si1 != ic->parm.setup.si1))
|
|
|
|
continue; /* si1 not matching */
|
|
|
|
if ((dv->rule.si2) && (dv->rule.si2 != ic->parm.setup.si2))
|
|
|
|
continue; /* si2 not matching */
|
|
|
|
|
|
|
|
p = dv->rule.my_msn;
|
|
|
|
p1 = ic->parm.setup.eazmsn;
|
|
|
|
accept = 0;
|
2013-01-21 11:57:20 +00:00
|
|
|
while (*p) {
|
|
|
|
/* complete compare */
|
|
|
|
if (*p == '-') {
|
|
|
|
accept = 1; /* call accepted */
|
2012-02-20 03:52:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (*p++ != *p1++)
|
|
|
|
break; /* not accepted */
|
|
|
|
if ((!*p) && (!*p1))
|
|
|
|
accept = 1;
|
|
|
|
} /* complete compare */
|
|
|
|
if (!accept) continue; /* not accepted */
|
|
|
|
|
2013-01-21 11:57:20 +00:00
|
|
|
if ((strcmp(dv->rule.caller, "0")) ||
|
|
|
|
(ic->parm.setup.phone[0])) {
|
|
|
|
p = dv->rule.caller;
|
2012-02-20 03:52:38 +00:00
|
|
|
p1 = ic->parm.setup.phone;
|
|
|
|
accept = 0;
|
2013-01-21 11:57:20 +00:00
|
|
|
while (*p) {
|
|
|
|
/* complete compare */
|
|
|
|
if (*p == '-') {
|
|
|
|
accept = 1; /* call accepted */
|
2012-02-20 03:52:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (*p++ != *p1++)
|
|
|
|
break; /* not accepted */
|
|
|
|
if ((!*p) && (!*p1))
|
|
|
|
accept = 1;
|
|
|
|
} /* complete compare */
|
|
|
|
if (!accept) continue; /* not accepted */
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:57:20 +00:00
|
|
|
switch (dv->rule.action) {
|
|
|
|
case DEFLECT_IGNORE:
|
2013-04-02 01:37:56 +00:00
|
|
|
return 0;
|
2012-02-20 03:52:38 +00:00
|
|
|
|
|
|
|
case DEFLECT_ALERT:
|
|
|
|
case DEFLECT_PROCEED:
|
|
|
|
case DEFLECT_REPORT:
|
|
|
|
case DEFLECT_REJECT:
|
|
|
|
if (dv->rule.action == DEFLECT_PROCEED)
|
|
|
|
if ((!if_used) || ((!extern_wait_max) && (!dv->rule.waittime)))
|
|
|
|
return (0); /* no external deflection needed */
|
|
|
|
if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC)))
|
|
|
|
return (0); /* no memory */
|
2017-03-23 13:15:57 +00:00
|
|
|
setup_timer(&cs->timer, deflect_timer_expire,
|
|
|
|
(ulong)cs);
|
2012-02-20 03:52:38 +00:00
|
|
|
cs->info[0] = '\0';
|
|
|
|
|
|
|
|
cs->ics = *ic; /* copy incoming data */
|
|
|
|
if (!cs->ics.parm.setup.phone[0]) strcpy(cs->ics.parm.setup.phone, "0");
|
|
|
|
if (!cs->ics.parm.setup.eazmsn[0]) strcpy(cs->ics.parm.setup.eazmsn, "0");
|
|
|
|
cs->ics.parm.setup.screen = dv->rule.screen;
|
|
|
|
if (dv->rule.waittime)
|
|
|
|
cs->timer.expires = jiffies + (HZ * dv->rule.waittime);
|
2013-01-21 11:57:20 +00:00
|
|
|
else if (dv->rule.action == DEFLECT_PROCEED)
|
|
|
|
cs->timer.expires = jiffies + (HZ * extern_wait_max);
|
2012-02-20 03:52:38 +00:00
|
|
|
else
|
2013-01-21 11:57:20 +00:00
|
|
|
cs->timer.expires = 0;
|
2012-02-20 03:52:38 +00:00
|
|
|
cs->akt_state = dv->rule.action;
|
|
|
|
spin_lock_irqsave(&divert_lock, flags);
|
|
|
|
cs->divert_id = next_id++; /* new sequence number */
|
|
|
|
spin_unlock_irqrestore(&divert_lock, flags);
|
|
|
|
cs->prev = NULL;
|
2013-01-21 11:57:20 +00:00
|
|
|
if (cs->akt_state == DEFLECT_ALERT) {
|
|
|
|
strcpy(cs->deflect_dest, dv->rule.to_nr);
|
|
|
|
if (!cs->timer.expires) {
|
|
|
|
strcpy(ic->parm.setup.eazmsn,
|
|
|
|
"Testtext direct");
|
2012-02-20 03:52:38 +00:00
|
|
|
ic->parm.setup.screen = dv->rule.screen;
|
|
|
|
strlcpy(ic->parm.setup.phone, dv->rule.to_nr, sizeof(ic->parm.setup.phone));
|
|
|
|
cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
|
|
|
|
cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
|
|
|
|
retval = 5;
|
2013-01-21 11:57:20 +00:00
|
|
|
} else
|
2012-02-20 03:52:38 +00:00
|
|
|
retval = 1; /* alerting */
|
2013-01-21 11:57:20 +00:00
|
|
|
} else {
|
|
|
|
cs->deflect_dest[0] = '\0';
|
2012-02-20 03:52:38 +00:00
|
|
|
retval = 4; /* only proceed */
|
|
|
|
}
|
2017-07-14 12:07:00 +00:00
|
|
|
snprintf(cs->info, sizeof(cs->info),
|
|
|
|
"%d 0x%lx %s %s %s %s 0x%x 0x%x %d %d %s\n",
|
|
|
|
cs->akt_state,
|
|
|
|
cs->divert_id,
|
|
|
|
divert_if.drv_to_name(cs->ics.driver),
|
|
|
|
(ic->command == ISDN_STAT_ICALLW) ? "1" : "0",
|
|
|
|
cs->ics.parm.setup.phone,
|
|
|
|
cs->ics.parm.setup.eazmsn,
|
|
|
|
cs->ics.parm.setup.si1,
|
|
|
|
cs->ics.parm.setup.si2,
|
|
|
|
cs->ics.parm.setup.screen,
|
|
|
|
dv->rule.waittime,
|
|
|
|
cs->deflect_dest);
|
2012-02-20 03:52:38 +00:00
|
|
|
if ((dv->rule.action == DEFLECT_REPORT) ||
|
2013-01-21 11:57:20 +00:00
|
|
|
(dv->rule.action == DEFLECT_REJECT)) {
|
|
|
|
put_info_buffer(cs->info);
|
2012-02-20 03:52:38 +00:00
|
|
|
kfree(cs); /* remove */
|
|
|
|
return ((dv->rule.action == DEFLECT_REPORT) ? 0 : 2); /* nothing to do */
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2013-04-02 01:37:56 +00:00
|
|
|
return 0; /* ignore call */
|
2012-02-20 03:52:38 +00:00
|
|
|
} /* switch action */
|
2013-04-02 01:37:56 +00:00
|
|
|
break; /* will break the 'for' looping */
|
2012-02-20 03:52:38 +00:00
|
|
|
} /* scan_table */
|
|
|
|
|
2013-01-21 11:57:20 +00:00
|
|
|
if (cs) {
|
|
|
|
cs->prev = NULL;
|
2012-02-20 03:52:38 +00:00
|
|
|
spin_lock_irqsave(&divert_lock, flags);
|
|
|
|
cs->next = divert_head;
|
|
|
|
divert_head = cs;
|
|
|
|
if (cs->timer.expires) add_timer(&cs->timer);
|
|
|
|
spin_unlock_irqrestore(&divert_lock, flags);
|
|
|
|
|
|
|
|
put_info_buffer(cs->info);
|
|
|
|
return (retval);
|
2013-01-21 11:57:20 +00:00
|
|
|
} else
|
2012-02-20 03:52:38 +00:00
|
|
|
return (0);
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* isdn_divert_icall */
|
|
|
|
|
|
|
|
|
|
|
|
void deleteprocs(void)
|
2013-01-21 11:57:20 +00:00
|
|
|
{
|
|
|
|
struct call_struc *cs, *cs1;
|
2012-02-20 03:52:38 +00:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&divert_lock, flags);
|
|
|
|
cs = divert_head;
|
|
|
|
divert_head = NULL;
|
2013-01-21 11:57:20 +00:00
|
|
|
while (cs) {
|
|
|
|
del_timer(&cs->timer);
|
2012-02-20 03:52:38 +00:00
|
|
|
cs1 = cs;
|
|
|
|
cs = cs->next;
|
|
|
|
kfree(cs1);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&divert_lock, flags);
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* deleteprocs */
|
|
|
|
|
|
|
|
/****************************************************/
|
|
|
|
/* put a address including address type into buffer */
|
|
|
|
/****************************************************/
|
2005-05-01 15:59:29 +00:00
|
|
|
static int put_address(char *st, u_char *p, int len)
|
2013-01-21 11:57:20 +00:00
|
|
|
{
|
|
|
|
u_char retval = 0;
|
2012-02-20 03:52:38 +00:00
|
|
|
u_char adr_typ = 0; /* network standard */
|
|
|
|
|
|
|
|
if (len < 2) return (retval);
|
2013-01-21 11:57:20 +00:00
|
|
|
if (*p == 0xA1) {
|
|
|
|
retval = *(++p) + 2; /* total length */
|
2012-02-20 03:52:38 +00:00
|
|
|
if (retval > len) return (0); /* too short */
|
|
|
|
len = retval - 2; /* remaining length */
|
|
|
|
if (len < 3) return (0);
|
|
|
|
if ((*(++p) != 0x0A) || (*(++p) != 1)) return (0);
|
|
|
|
adr_typ = *(++p);
|
|
|
|
len -= 3;
|
|
|
|
p++;
|
|
|
|
if (len < 2) return (0);
|
|
|
|
if (*p++ != 0x12) return (0);
|
|
|
|
if (*p > len) return (0); /* check number length */
|
|
|
|
len = *p++;
|
2013-01-21 11:57:20 +00:00
|
|
|
} else if (*p == 0x80) {
|
|
|
|
retval = *(++p) + 2; /* total length */
|
|
|
|
if (retval > len) return (0);
|
|
|
|
len = retval - 2;
|
|
|
|
p++;
|
|
|
|
} else
|
|
|
|
return (0); /* invalid address information */
|
2012-02-20 03:52:38 +00:00
|
|
|
|
|
|
|
sprintf(st, "%d ", adr_typ);
|
|
|
|
st += strlen(st);
|
|
|
|
if (!len)
|
|
|
|
*st++ = '-';
|
|
|
|
else
|
|
|
|
while (len--)
|
|
|
|
*st++ = *p++;
|
|
|
|
*st = '\0';
|
|
|
|
return (retval);
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* put_address */
|
|
|
|
|
|
|
|
/*************************************/
|
2006-06-26 16:35:02 +00:00
|
|
|
/* report a successful interrogation */
|
2005-04-16 22:20:36 +00:00
|
|
|
/*************************************/
|
2005-05-01 15:59:29 +00:00
|
|
|
static int interrogate_success(isdn_ctrl *ic, struct call_struc *cs)
|
2013-01-21 11:57:20 +00:00
|
|
|
{
|
|
|
|
char *src = ic->parm.dss1_io.data;
|
2012-02-20 03:52:38 +00:00
|
|
|
int restlen = ic->parm.dss1_io.datalen;
|
|
|
|
int cnt = 1;
|
|
|
|
u_char n, n1;
|
|
|
|
char st[90], *p, *stp;
|
|
|
|
|
|
|
|
if (restlen < 2) return (-100); /* frame too short */
|
|
|
|
if (*src++ != 0x30) return (-101);
|
|
|
|
if ((n = *src++) > 0x81) return (-102); /* invalid length field */
|
|
|
|
restlen -= 2; /* remaining bytes */
|
2013-01-21 11:57:20 +00:00
|
|
|
if (n == 0x80) {
|
|
|
|
if (restlen < 2) return (-103);
|
2012-02-20 03:52:38 +00:00
|
|
|
if ((*(src + restlen - 1)) || (*(src + restlen - 2))) return (-104);
|
|
|
|
restlen -= 2;
|
2013-01-21 11:57:20 +00:00
|
|
|
} else if (n == 0x81) {
|
|
|
|
n = *src++;
|
|
|
|
restlen--;
|
|
|
|
if (n > restlen) return (-105);
|
|
|
|
restlen = n;
|
|
|
|
} else if (n > restlen)
|
|
|
|
return (-106);
|
2012-02-20 03:52:38 +00:00
|
|
|
else
|
2013-01-21 11:57:20 +00:00
|
|
|
restlen = n; /* standard format */
|
2012-02-20 03:52:38 +00:00
|
|
|
if (restlen < 3) return (-107); /* no procedure */
|
|
|
|
if ((*src++ != 2) || (*src++ != 1) || (*src++ != 0x0B)) return (-108);
|
|
|
|
restlen -= 3;
|
|
|
|
if (restlen < 2) return (-109); /* list missing */
|
2013-01-21 11:57:20 +00:00
|
|
|
if (*src == 0x31) {
|
|
|
|
src++;
|
2012-02-20 03:52:38 +00:00
|
|
|
if ((n = *src++) > 0x81) return (-110); /* invalid length field */
|
|
|
|
restlen -= 2; /* remaining bytes */
|
2013-01-21 11:57:20 +00:00
|
|
|
if (n == 0x80) {
|
|
|
|
if (restlen < 2) return (-111);
|
2012-02-20 03:52:38 +00:00
|
|
|
if ((*(src + restlen - 1)) || (*(src + restlen - 2))) return (-112);
|
|
|
|
restlen -= 2;
|
2013-01-21 11:57:20 +00:00
|
|
|
} else if (n == 0x81) {
|
|
|
|
n = *src++;
|
|
|
|
restlen--;
|
|
|
|
if (n > restlen) return (-113);
|
|
|
|
restlen = n;
|
|
|
|
} else if (n > restlen)
|
|
|
|
return (-114);
|
2012-02-20 03:52:38 +00:00
|
|
|
else
|
2013-01-21 11:57:20 +00:00
|
|
|
restlen = n; /* standard format */
|
2012-02-20 03:52:38 +00:00
|
|
|
} /* result list header */
|
|
|
|
|
2013-01-21 11:57:20 +00:00
|
|
|
while (restlen >= 2) {
|
|
|
|
stp = st;
|
2012-02-20 03:52:38 +00:00
|
|
|
sprintf(stp, "%d 0x%lx %d %s ", DIVERT_REPORT, ic->parm.dss1_io.ll_id,
|
|
|
|
cnt++, divert_if.drv_to_name(ic->driver));
|
|
|
|
stp += strlen(stp);
|
|
|
|
if (*src++ != 0x30) return (-115); /* invalid enum */
|
|
|
|
n = *src++;
|
|
|
|
restlen -= 2;
|
|
|
|
if (n > restlen) return (-116); /* enum length wrong */
|
|
|
|
restlen -= n;
|
|
|
|
p = src; /* one entry */
|
|
|
|
src += n;
|
|
|
|
if (!(n1 = put_address(stp, p, n & 0xFF))) continue;
|
|
|
|
stp += strlen(stp);
|
|
|
|
p += n1;
|
|
|
|
n -= n1;
|
|
|
|
if (n < 6) continue; /* no service and proc */
|
|
|
|
if ((*p++ != 0x0A) || (*p++ != 1)) continue;
|
|
|
|
sprintf(stp, " 0x%02x ", (*p++) & 0xFF);
|
|
|
|
stp += strlen(stp);
|
|
|
|
if ((*p++ != 0x0A) || (*p++ != 1)) continue;
|
|
|
|
sprintf(stp, "%d ", (*p++) & 0xFF);
|
|
|
|
stp += strlen(stp);
|
|
|
|
n -= 6;
|
2013-01-21 11:57:20 +00:00
|
|
|
if (n > 2) {
|
|
|
|
if (*p++ != 0x30) continue;
|
2012-02-20 03:52:38 +00:00
|
|
|
if (*p > (n - 2)) continue;
|
|
|
|
n = *p++;
|
|
|
|
if (!(n1 = put_address(stp, p, n & 0xFF))) continue;
|
|
|
|
stp += strlen(stp);
|
|
|
|
}
|
|
|
|
sprintf(stp, "\n");
|
|
|
|
put_info_buffer(st);
|
|
|
|
} /* while restlen */
|
|
|
|
if (restlen) return (-117);
|
|
|
|
return (0);
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* interrogate_success */
|
|
|
|
|
|
|
|
/*********************************************/
|
|
|
|
/* callback for protocol specific extensions */
|
|
|
|
/*********************************************/
|
2005-05-01 15:59:29 +00:00
|
|
|
static int prot_stat_callback(isdn_ctrl *ic)
|
2013-01-21 11:57:20 +00:00
|
|
|
{
|
|
|
|
struct call_struc *cs, *cs1;
|
2012-02-20 03:52:38 +00:00
|
|
|
int i;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
cs = divert_head; /* start of list */
|
|
|
|
cs1 = NULL;
|
2013-01-21 11:57:20 +00:00
|
|
|
while (cs) {
|
|
|
|
if (ic->driver == cs->ics.driver) {
|
|
|
|
switch (cs->ics.arg) {
|
|
|
|
case DSS1_CMD_INVOKE:
|
|
|
|
if ((cs->ics.parm.dss1_io.ll_id == ic->parm.dss1_io.ll_id) &&
|
|
|
|
(cs->ics.parm.dss1_io.hl_id == ic->parm.dss1_io.hl_id)) {
|
|
|
|
switch (ic->arg) {
|
|
|
|
case DSS1_STAT_INVOKE_ERR:
|
|
|
|
sprintf(cs->info, "128 0x%lx 0x%x\n",
|
|
|
|
ic->parm.dss1_io.ll_id,
|
|
|
|
ic->parm.dss1_io.timeout);
|
|
|
|
put_info_buffer(cs->info);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DSS1_STAT_INVOKE_RES:
|
|
|
|
switch (cs->ics.parm.dss1_io.proc) {
|
|
|
|
case 7:
|
|
|
|
case 8:
|
|
|
|
put_info_buffer(cs->info);
|
|
|
|
break;
|
2012-02-20 03:52:38 +00:00
|
|
|
|
2013-01-21 11:57:20 +00:00
|
|
|
case 11:
|
|
|
|
i = interrogate_success(ic, cs);
|
|
|
|
if (i)
|
|
|
|
sprintf(cs->info, "%d 0x%lx %d\n", DIVERT_REPORT,
|
|
|
|
ic->parm.dss1_io.ll_id, i);
|
|
|
|
put_info_buffer(cs->info);
|
2012-02-20 03:52:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2013-01-21 11:57:20 +00:00
|
|
|
printk(KERN_WARNING "dss1_divert: unknown proc %d\n", cs->ics.parm.dss1_io.proc);
|
2012-02-20 03:52:38 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-01-21 11:57:20 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
printk(KERN_WARNING "dss1_divert unknown invoke answer %lx\n", ic->arg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
cs1 = cs; /* remember structure */
|
|
|
|
cs = NULL;
|
|
|
|
continue; /* abort search */
|
|
|
|
} /* id found */
|
|
|
|
break;
|
2012-02-20 03:52:38 +00:00
|
|
|
|
|
|
|
case DSS1_CMD_INVOKE_ABORT:
|
|
|
|
printk(KERN_WARNING "dss1_divert unhandled invoke abort\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
printk(KERN_WARNING "dss1_divert unknown cmd 0x%lx\n", cs->ics.arg);
|
|
|
|
break;
|
|
|
|
} /* switch ics.arg */
|
|
|
|
cs = cs->next;
|
|
|
|
} /* driver ok */
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:57:20 +00:00
|
|
|
if (!cs1) {
|
|
|
|
printk(KERN_WARNING "dss1_divert unhandled process\n");
|
2012-02-20 03:52:38 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:57:20 +00:00
|
|
|
if (cs1->ics.driver == -1) {
|
2012-02-20 03:52:38 +00:00
|
|
|
spin_lock_irqsave(&divert_lock, flags);
|
|
|
|
del_timer(&cs1->timer);
|
|
|
|
if (cs1->prev)
|
|
|
|
cs1->prev->next = cs1->next; /* forward link */
|
|
|
|
else
|
|
|
|
divert_head = cs1->next;
|
|
|
|
if (cs1->next)
|
|
|
|
cs1->next->prev = cs1->prev; /* back link */
|
|
|
|
spin_unlock_irqrestore(&divert_lock, flags);
|
|
|
|
kfree(cs1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* prot_stat_callback */
|
|
|
|
|
|
|
|
|
|
|
|
/***************************/
|
|
|
|
/* status callback from HL */
|
|
|
|
/***************************/
|
2005-05-01 15:59:29 +00:00
|
|
|
static int isdn_divert_stat_callback(isdn_ctrl *ic)
|
2013-01-21 11:57:20 +00:00
|
|
|
{
|
|
|
|
struct call_struc *cs, *cs1;
|
2012-02-20 03:52:38 +00:00
|
|
|
unsigned long flags;
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
retval = -1;
|
|
|
|
cs = divert_head; /* start of list */
|
2013-01-21 11:57:20 +00:00
|
|
|
while (cs) {
|
|
|
|
if ((ic->driver == cs->ics.driver) &&
|
|
|
|
(ic->arg == cs->ics.arg)) {
|
|
|
|
switch (ic->command) {
|
|
|
|
case ISDN_STAT_DHUP:
|
|
|
|
sprintf(cs->info, "129 0x%lx\n", cs->divert_id);
|
|
|
|
del_timer(&cs->timer);
|
|
|
|
cs->ics.driver = -1;
|
|
|
|
break;
|
2012-02-20 03:52:38 +00:00
|
|
|
|
|
|
|
case ISDN_STAT_CAUSE:
|
|
|
|
sprintf(cs->info, "130 0x%lx %s\n", cs->divert_id, ic->parm.num);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISDN_STAT_REDIR:
|
|
|
|
sprintf(cs->info, "131 0x%lx\n", cs->divert_id);
|
|
|
|
del_timer(&cs->timer);
|
|
|
|
cs->ics.driver = -1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
sprintf(cs->info, "999 0x%lx 0x%x\n", cs->divert_id, (int)(ic->command));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
put_info_buffer(cs->info);
|
|
|
|
retval = 0;
|
|
|
|
}
|
|
|
|
cs1 = cs;
|
|
|
|
cs = cs->next;
|
2013-01-21 11:57:20 +00:00
|
|
|
if (cs1->ics.driver == -1) {
|
2012-02-20 03:52:38 +00:00
|
|
|
spin_lock_irqsave(&divert_lock, flags);
|
|
|
|
if (cs1->prev)
|
|
|
|
cs1->prev->next = cs1->next; /* forward link */
|
|
|
|
else
|
|
|
|
divert_head = cs1->next;
|
|
|
|
if (cs1->next)
|
|
|
|
cs1->next->prev = cs1->prev; /* back link */
|
|
|
|
spin_unlock_irqrestore(&divert_lock, flags);
|
|
|
|
kfree(cs1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (retval); /* not found */
|
|
|
|
} /* isdn_divert_stat_callback */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
/********************/
|
|
|
|
/* callback from ll */
|
2012-02-20 03:52:38 +00:00
|
|
|
/********************/
|
2005-04-16 22:20:36 +00:00
|
|
|
int ll_callback(isdn_ctrl *ic)
|
|
|
|
{
|
2013-01-21 11:57:20 +00:00
|
|
|
switch (ic->command) {
|
|
|
|
case ISDN_STAT_ICALL:
|
2012-02-20 03:52:38 +00:00
|
|
|
case ISDN_STAT_ICALLW:
|
|
|
|
return (isdn_divert_icall(ic));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISDN_STAT_PROT:
|
2013-01-21 11:57:20 +00:00
|
|
|
if ((ic->arg & 0xFF) == ISDN_PTYPE_EURO) {
|
|
|
|
if (ic->arg != DSS1_STAT_INVOKE_BRD)
|
2012-02-20 03:52:38 +00:00
|
|
|
return (prot_stat_callback(ic));
|
|
|
|
else
|
|
|
|
return (0); /* DSS1 invoke broadcast */
|
2013-01-21 11:57:20 +00:00
|
|
|
} else
|
2012-02-20 03:52:38 +00:00
|
|
|
return (-1); /* protocol not euro */
|
|
|
|
|
|
|
|
default:
|
|
|
|
return (isdn_divert_stat_callback(ic));
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* ll_callback */
|