1996-10-13 20:04:59 +00:00
|
|
|
/* $Id$
|
1997-01-27 16:00:38 +00:00
|
|
|
|
1998-11-15 23:55:28 +00:00
|
|
|
* Author Karsten Keil (keil@isdn4linux.de)
|
1996-10-13 20:04:59 +00:00
|
|
|
* based on the teles driver from Jan den Ouden
|
|
|
|
*
|
1998-11-15 23:55:28 +00:00
|
|
|
* This file is (c) under GNU PUBLIC LICENSE
|
|
|
|
* For changes and modifications please read
|
|
|
|
* ../../../Documentation/isdn/HiSax.cert
|
|
|
|
*
|
1996-10-13 20:04:59 +00:00
|
|
|
* Thanks to Jan den Ouden
|
|
|
|
* Fritz Elfert
|
|
|
|
*
|
|
|
|
* $Log$
|
1999-10-14 20:25:29 +00:00
|
|
|
* Revision 2.38 1999/10/11 22:16:27 keil
|
|
|
|
* Suspend/Resume is possible without explicit ID too
|
|
|
|
*
|
1999-10-11 22:16:27 +00:00
|
|
|
* Revision 2.37 1999/09/20 19:49:47 keil
|
|
|
|
* Fix wrong init of PStack
|
|
|
|
*
|
1999-09-20 19:49:47 +00:00
|
|
|
* Revision 2.36 1999/09/20 12:13:13 keil
|
|
|
|
* Fix hang if no protocol was selected
|
|
|
|
*
|
1999-09-20 12:13:13 +00:00
|
|
|
* Revision 2.35 1999/09/04 06:20:05 keil
|
|
|
|
* Changes from kernel set_current_state()
|
|
|
|
*
|
1999-09-04 06:20:07 +00:00
|
|
|
* Revision 2.34 1999/08/25 20:02:34 werner
|
|
|
|
* Changed return values for stat_icall(w) from 3->4 and 4->5 because of conflicts
|
|
|
|
* with existing software definitions. (PtP incomplete called party number)
|
|
|
|
*
|
1999-08-25 20:02:34 +00:00
|
|
|
* Revision 2.33 1999/08/25 17:00:09 keil
|
|
|
|
* Make ISAR V32bis modem running
|
|
|
|
* Make LL->HL interface open for additional commands
|
|
|
|
*
|
1999-08-25 17:00:09 +00:00
|
|
|
* Revision 2.32 1999/08/22 20:27:01 calle
|
|
|
|
* backported changes from kernel 2.3.14:
|
|
|
|
* - several #include "config.h" gone, others come.
|
|
|
|
* - "struct device" changed to "struct net_device" in 2.3.14, added a
|
|
|
|
* define in isdn_compat.h for older kernel versions.
|
|
|
|
*
|
1999-08-22 20:27:19 +00:00
|
|
|
* Revision 2.31 1999/08/05 20:43:10 keil
|
|
|
|
* ISAR analog modem support
|
|
|
|
*
|
1999-08-05 20:43:22 +00:00
|
|
|
* Revision 2.30 1999/07/25 16:24:04 keil
|
|
|
|
* Fixed TEI now working again
|
|
|
|
*
|
1999-07-25 16:24:04 +00:00
|
|
|
* Revision 2.29 1999/07/13 21:05:41 werner
|
|
|
|
* Modified set_channel_limit to use new callback ISDN_STAT_DISCH.
|
|
|
|
*
|
1999-07-13 21:05:41 +00:00
|
|
|
* Revision 2.28 1999/07/09 08:30:02 keil
|
|
|
|
* cosmetics
|
|
|
|
*
|
1999-07-09 08:30:08 +00:00
|
|
|
* Revision 2.27 1999/07/05 23:51:38 werner
|
|
|
|
* Allow limiting of available HiSax B-chans per card. Controlled by hisaxctrl
|
|
|
|
* hisaxctrl id 10 <nr. of chans 0-2>
|
|
|
|
*
|
1999-07-05 23:51:46 +00:00
|
|
|
* Revision 2.26 1999/07/01 08:11:21 keil
|
|
|
|
* Common HiSax version for 2.0, 2.1, 2.2 and 2.3 kernel
|
|
|
|
*
|
1999-07-01 08:12:15 +00:00
|
|
|
* Revision 2.25 1999/01/02 11:17:20 keil
|
|
|
|
* Changes for 2.2
|
|
|
|
*
|
1999-01-02 11:17:20 +00:00
|
|
|
* Revision 2.24 1998/11/15 23:54:24 keil
|
|
|
|
* changes from 2.0
|
|
|
|
*
|
1998-11-15 23:55:28 +00:00
|
|
|
* Revision 2.23 1998/09/30 22:21:57 keil
|
|
|
|
* cosmetics
|
|
|
|
*
|
1998-09-30 22:21:57 +00:00
|
|
|
* Revision 2.22 1998/08/20 13:50:29 keil
|
|
|
|
* More support for hybrid modem (not working yet)
|
|
|
|
*
|
1998-08-20 13:50:42 +00:00
|
|
|
* Revision 2.21 1998/08/13 23:36:15 keil
|
|
|
|
* HiSax 3.1 - don't work stable with current LinkLevel
|
|
|
|
*
|
1998-08-13 23:36:54 +00:00
|
|
|
* Revision 2.20 1998/06/26 15:13:05 fritz
|
|
|
|
* Added handling of STAT_ICALL with incomplete CPN.
|
|
|
|
* Added AT&L for ttyI emulator.
|
|
|
|
* Added more locking stuff in tty_write.
|
|
|
|
*
|
1998-06-26 15:13:17 +00:00
|
|
|
* Revision 2.19 1998/05/25 14:08:06 keil
|
|
|
|
* HiSax 3.0
|
|
|
|
* fixed X.75 and leased line to work again
|
|
|
|
* Point2Point and fixed TEI are runtime options now:
|
|
|
|
* hisaxctrl <id> 7 1 set PTP
|
|
|
|
* hisaxctrl <id> 8 <TEIVALUE *2 >
|
|
|
|
* set fixed TEI to TEIVALUE (0-63)
|
|
|
|
*
|
1998-05-25 14:08:10 +00:00
|
|
|
* Revision 2.18 1998/05/25 12:57:40 keil
|
|
|
|
* HiSax golden code from certification, Don't use !!!
|
|
|
|
* No leased lines, no X75, but many changes.
|
|
|
|
*
|
1998-05-25 12:58:26 +00:00
|
|
|
* Revision 2.17 1998/04/15 16:46:06 keil
|
|
|
|
* RESUME support
|
|
|
|
*
|
1998-04-15 16:46:06 +00:00
|
|
|
* Revision 2.16 1998/04/10 10:35:17 paul
|
|
|
|
* fixed (silly?) warnings from egcs on Alpha.
|
|
|
|
*
|
1998-04-10 10:35:30 +00:00
|
|
|
* Revision 2.15 1998/03/19 13:18:37 keil
|
|
|
|
* Start of a CAPI like interface for supplementary Service
|
|
|
|
* first service: SUSPEND
|
|
|
|
*
|
1998-03-19 13:18:57 +00:00
|
|
|
* Revision 2.14 1998/03/07 22:56:54 tsbogend
|
|
|
|
* made HiSax working on Linux/Alpha
|
|
|
|
*
|
1998-03-07 22:57:08 +00:00
|
|
|
* Revision 2.13 1998/02/12 23:07:16 keil
|
|
|
|
* change for 2.1.86 (removing FREE_READ/FREE_WRITE from [dev]_kfree_skb()
|
|
|
|
*
|
1998-02-12 23:08:50 +00:00
|
|
|
* Revision 2.12 1998/02/09 10:55:54 keil
|
|
|
|
* New leased line mode
|
|
|
|
*
|
1998-02-09 10:56:02 +00:00
|
|
|
* Revision 2.11 1998/02/02 13:35:19 keil
|
|
|
|
* config B-channel delay
|
|
|
|
*
|
1998-02-02 13:35:19 +00:00
|
|
|
* Revision 2.10 1997/11/06 17:09:15 keil
|
|
|
|
* New 2.1 init code
|
|
|
|
*
|
1997-11-06 17:13:35 +00:00
|
|
|
* Revision 2.9 1997/10/29 19:01:58 keil
|
|
|
|
* new LL interface
|
|
|
|
*
|
1997-10-29 19:02:01 +00:00
|
|
|
* Revision 2.8 1997/10/10 20:56:44 fritz
|
|
|
|
* New HL interface.
|
|
|
|
*
|
1997-10-10 20:56:50 +00:00
|
|
|
* Revision 2.7 1997/10/01 09:21:28 fritz
|
|
|
|
* Removed old compatibility stuff for 2.0.X kernels.
|
|
|
|
* From now on, this code is for 2.1.X ONLY!
|
|
|
|
* Old stuff is still in the separate branch.
|
|
|
|
*
|
1997-10-01 09:22:21 +00:00
|
|
|
* Revision 2.6 1997/09/11 17:26:58 keil
|
|
|
|
* Open B-channel if here are incomming packets
|
|
|
|
*
|
1997-09-11 17:26:58 +00:00
|
|
|
* Revision 2.5 1997/08/07 17:46:05 keil
|
|
|
|
* Fix Incomming Call without broadcast
|
|
|
|
*
|
1997-08-07 17:46:05 +00:00
|
|
|
* Revision 2.4 1997/08/03 14:37:58 keil
|
|
|
|
* Activate Layer2 in PtP mode
|
|
|
|
*
|
1997-08-03 14:37:58 +00:00
|
|
|
* Revision 2.3 1997/07/31 19:23:40 keil
|
|
|
|
* LAYER2_WATCHING for PtP
|
|
|
|
*
|
1997-07-31 19:23:40 +00:00
|
|
|
* Revision 2.2 1997/07/31 11:48:18 keil
|
|
|
|
* experimental REJECT after ALERTING
|
|
|
|
*
|
1997-07-31 11:48:18 +00:00
|
|
|
* Revision 2.1 1997/07/30 17:12:59 keil
|
|
|
|
* more changes for 'One TEI per card'
|
|
|
|
*
|
1997-07-30 17:13:02 +00:00
|
|
|
* Revision 2.0 1997/07/27 21:12:21 keil
|
|
|
|
* CRef based L3; new channel handling; many other stuff
|
|
|
|
*
|
1997-07-27 21:12:21 +00:00
|
|
|
* Revision 1.31 1997/06/26 11:09:23 keil
|
|
|
|
* New managment and minor changes
|
|
|
|
*
|
1997-07-31 11:48:18 +00:00
|
|
|
* old logs removed /KKe
|
1996-10-16 21:29:45 +00:00
|
|
|
*
|
1996-10-13 20:04:59 +00:00
|
|
|
*/
|
1997-01-27 16:00:38 +00:00
|
|
|
|
1996-10-13 20:04:59 +00:00
|
|
|
#define __NO_VERSION__
|
|
|
|
#include "hisax.h"
|
1998-03-19 13:18:57 +00:00
|
|
|
#include "../avmb1/capicmd.h" /* this should be moved in a common place */
|
1996-10-13 20:04:59 +00:00
|
|
|
|
|
|
|
#ifdef MODULE
|
1999-07-01 08:12:15 +00:00
|
|
|
#ifdef COMPAT_HAS_NEW_SYMTAB
|
1999-01-02 11:17:20 +00:00
|
|
|
#define MOD_USE_COUNT ( GET_USE_COUNT (&__this_module))
|
1999-07-01 08:12:15 +00:00
|
|
|
#else
|
|
|
|
extern long mod_use_count_;
|
|
|
|
#define MOD_USE_COUNT mod_use_count_
|
|
|
|
#endif /* COMPAT_HAS_NEW_SYMTAB */
|
|
|
|
#endif /* MODULE */
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-07-27 21:12:21 +00:00
|
|
|
const char *lli_revision = "$Revision$";
|
1997-01-21 22:16:39 +00:00
|
|
|
|
1996-10-13 20:04:59 +00:00
|
|
|
extern struct IsdnCard cards[];
|
1997-01-27 16:00:38 +00:00
|
|
|
extern int nrcards;
|
|
|
|
extern void HiSax_mod_dec_use_count(void);
|
|
|
|
extern void HiSax_mod_inc_use_count(void);
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-07-27 21:12:21 +00:00
|
|
|
static int init_b_st(struct Channel *chanp, int incoming);
|
|
|
|
static void release_b_st(struct Channel *chanp);
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-01-27 16:00:38 +00:00
|
|
|
static struct Fsm callcfsm =
|
1997-06-26 11:09:23 +00:00
|
|
|
{NULL, 0, 0, NULL, NULL};
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-01-27 16:00:38 +00:00
|
|
|
static int chancount = 0;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1998-11-15 23:55:28 +00:00
|
|
|
/* experimental REJECT after ALERTING for CALLBACK to beat the 4s delay */
|
1998-08-13 23:36:54 +00:00
|
|
|
#define ALERT_REJECT 0
|
1997-07-31 11:48:18 +00:00
|
|
|
|
1998-02-02 13:35:19 +00:00
|
|
|
/* Value to delay the sending of the first B-channel paket after CONNECT
|
|
|
|
* here is no value given by ITU, but experience shows that 300 ms will
|
|
|
|
* work on many networks, if you or your other side is behind local exchanges
|
|
|
|
* a greater value may be recommented. If the delay is to short the first paket
|
|
|
|
* will be lost and autodetect on many comercial routers goes wrong !
|
1998-11-15 23:55:28 +00:00
|
|
|
* You can adjust this value on runtime with
|
1998-02-02 13:35:19 +00:00
|
|
|
* hisaxctrl <id> 2 <value>
|
|
|
|
* value is in milliseconds
|
|
|
|
*/
|
|
|
|
#define DEFAULT_B_DELAY 300
|
|
|
|
|
1997-07-27 21:12:21 +00:00
|
|
|
/* Flags for remembering action done in lli */
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
#define FLG_START_B 0
|
1997-02-09 00:23:10 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Find card with given driverId
|
|
|
|
*/
|
|
|
|
static inline struct IsdnCardState
|
|
|
|
*
|
|
|
|
hisax_findcard(int driverid)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < nrcards; i++)
|
1997-07-27 21:12:21 +00:00
|
|
|
if (cards[i].cs)
|
|
|
|
if (cards[i].cs->myid == driverid)
|
|
|
|
return (cards[i].cs);
|
1997-02-09 00:23:10 +00:00
|
|
|
return (struct IsdnCardState *) 0;
|
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1998-05-25 12:58:26 +00:00
|
|
|
int
|
|
|
|
discard_queue(struct sk_buff_head *q)
|
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
|
|
|
int ret=0;
|
|
|
|
|
|
|
|
while ((skb = skb_dequeue(q))) {
|
1999-07-01 08:12:15 +00:00
|
|
|
idev_kfree_skb(skb, FREE_READ);
|
1998-05-25 12:58:26 +00:00
|
|
|
ret++;
|
|
|
|
}
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
1996-10-13 20:04:59 +00:00
|
|
|
static void
|
1998-11-15 23:55:28 +00:00
|
|
|
link_debug(struct Channel *chanp, int direction, char *fmt, ...)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1998-11-15 23:55:28 +00:00
|
|
|
va_list args;
|
|
|
|
char tmp[16];
|
|
|
|
|
|
|
|
va_start(args, fmt);
|
|
|
|
sprintf(tmp, "Ch%d %s ", chanp->chan,
|
|
|
|
direction ? "LL->HL" : "HL->LL");
|
|
|
|
VHiSax_putstatus(chanp->cs, tmp, fmt, args);
|
|
|
|
va_end(args);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enum {
|
1999-07-01 08:12:15 +00:00
|
|
|
ST_NULL, /* 0 inactive */
|
|
|
|
ST_OUT_DIAL, /* 1 outgoing, SETUP send; awaiting confirm */
|
|
|
|
ST_IN_WAIT_LL, /* 2 incoming call received; wait for LL confirm */
|
|
|
|
ST_IN_ALERT_SENT, /* 3 incoming call received; ALERT send */
|
|
|
|
ST_IN_WAIT_CONN_ACK, /* 4 incoming CONNECT send; awaiting CONN_ACK */
|
|
|
|
ST_WAIT_BCONN, /* 5 CONNECT/CONN_ACK received, awaiting b-channel prot. estbl. */
|
|
|
|
ST_ACTIVE, /* 6 active, b channel prot. established */
|
|
|
|
ST_WAIT_BRELEASE, /* 7 call clear. (initiator), awaiting b channel prot. rel. */
|
|
|
|
ST_WAIT_BREL_DISC, /* 8 call clear. (receiver), DISCONNECT req. received */
|
|
|
|
ST_WAIT_DCOMMAND, /* 9 call clear. (receiver), awaiting DCHANNEL message */
|
|
|
|
ST_WAIT_DRELEASE, /* 10 DISCONNECT sent, awaiting RELEASE */
|
|
|
|
ST_WAIT_D_REL_CNF, /* 11 RELEASE sent, awaiting RELEASE confirm */
|
|
|
|
ST_IN_PROCEED_SEND, /* 12 incoming call, proceeding send */
|
1996-10-13 20:04:59 +00:00
|
|
|
};
|
1999-07-01 08:12:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define STATE_COUNT (ST_IN_PROCEED_SEND + 1)
|
|
|
|
|
|
|
|
static char *strState[] =
|
|
|
|
{
|
|
|
|
"ST_NULL",
|
|
|
|
"ST_OUT_DIAL",
|
|
|
|
"ST_IN_WAIT_LL",
|
|
|
|
"ST_IN_ALERT_SENT",
|
|
|
|
"ST_IN_WAIT_CONN_ACK",
|
|
|
|
"ST_WAIT_BCONN",
|
|
|
|
"ST_ACTIVE",
|
1997-01-27 16:00:38 +00:00
|
|
|
"ST_WAIT_BRELEASE",
|
|
|
|
"ST_WAIT_BREL_DISC",
|
|
|
|
"ST_WAIT_DCOMMAND",
|
|
|
|
"ST_WAIT_DRELEASE",
|
|
|
|
"ST_WAIT_D_REL_CNF",
|
1999-07-01 08:12:15 +00:00
|
|
|
"ST_IN_PROCEED_SEND",
|
1996-10-13 20:04:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
1997-01-27 16:00:38 +00:00
|
|
|
EV_DIAL, /* 0 */
|
|
|
|
EV_SETUP_CNF, /* 1 */
|
|
|
|
EV_ACCEPTB, /* 2 */
|
|
|
|
EV_DISCONNECT_IND, /* 3 */
|
1999-07-01 08:12:15 +00:00
|
|
|
EV_RELEASE, /* 4 */
|
|
|
|
EV_LEASED, /* 5 */
|
|
|
|
EV_LEASED_REL, /* 6 */
|
1997-01-27 16:00:38 +00:00
|
|
|
EV_SETUP_IND, /* 7 */
|
1999-07-01 08:12:15 +00:00
|
|
|
EV_ACCEPTD, /* 8 */
|
|
|
|
EV_SETUP_CMPL_IND, /* 9 */
|
|
|
|
EV_BC_EST, /* 10 */
|
|
|
|
EV_WRITEBUF, /* 11 */
|
|
|
|
EV_HANGUP, /* 12 */
|
|
|
|
EV_BC_REL, /* 13 */
|
|
|
|
EV_CINF, /* 14 */
|
|
|
|
EV_SUSPEND, /* 15 */
|
|
|
|
EV_RESUME, /* 16 */
|
|
|
|
EV_NOSETUP_RSP, /* 17 */
|
|
|
|
EV_SETUP_ERR, /* 18 */
|
|
|
|
EV_CONNECT_ERR, /* 19 */
|
|
|
|
EV_PROCEED, /* 20 */
|
|
|
|
EV_ALERT, /* 21 */
|
|
|
|
EV_REDIR, /* 22 */
|
1996-10-13 20:04:59 +00:00
|
|
|
};
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
#define EVENT_COUNT (EV_REDIR + 1)
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-01-27 16:00:38 +00:00
|
|
|
static char *strEvent[] =
|
|
|
|
{
|
|
|
|
"EV_DIAL",
|
|
|
|
"EV_SETUP_CNF",
|
|
|
|
"EV_ACCEPTB",
|
|
|
|
"EV_DISCONNECT_IND",
|
1999-07-01 08:12:15 +00:00
|
|
|
"EV_RELEASE",
|
|
|
|
"EV_LEASED",
|
|
|
|
"EV_LEASED_REL",
|
1997-01-27 16:00:38 +00:00
|
|
|
"EV_SETUP_IND",
|
|
|
|
"EV_ACCEPTD",
|
|
|
|
"EV_SETUP_CMPL_IND",
|
|
|
|
"EV_BC_EST",
|
|
|
|
"EV_WRITEBUF",
|
|
|
|
"EV_HANGUP",
|
|
|
|
"EV_BC_REL",
|
|
|
|
"EV_CINF",
|
|
|
|
"EV_SUSPEND",
|
|
|
|
"EV_RESUME",
|
1997-01-21 22:16:39 +00:00
|
|
|
"EV_NOSETUP_RSP",
|
|
|
|
"EV_SETUP_ERR",
|
|
|
|
"EV_CONNECT_ERR",
|
1999-07-01 08:12:15 +00:00
|
|
|
"EV_PROCEED",
|
|
|
|
"EV_ALERT",
|
|
|
|
"EV_REDIR",
|
1996-10-13 20:04:59 +00:00
|
|
|
};
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
|
1997-02-11 01:36:58 +00:00
|
|
|
static inline void
|
1999-07-01 08:12:15 +00:00
|
|
|
HL_LL(struct Channel *chanp, int command)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
isdn_ctrl ic;
|
1999-08-05 20:43:22 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
ic.driver = chanp->cs->myid;
|
|
|
|
ic.command = command;
|
|
|
|
ic.arg = chanp->chan;
|
|
|
|
chanp->cs->iif.statcallb(&ic);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
lli_deliver_cause(struct Channel *chanp)
|
|
|
|
{
|
|
|
|
isdn_ctrl ic;
|
|
|
|
|
|
|
|
if (chanp->proc->para.cause == NO_CAUSE)
|
1997-02-11 01:36:58 +00:00
|
|
|
return;
|
1999-07-01 08:12:15 +00:00
|
|
|
ic.driver = chanp->cs->myid;
|
|
|
|
ic.command = ISDN_STAT_CAUSE;
|
|
|
|
ic.arg = chanp->chan;
|
1997-07-27 21:12:21 +00:00
|
|
|
if (chanp->cs->protocol == ISDN_PTYPE_EURO)
|
1999-07-01 08:12:15 +00:00
|
|
|
sprintf(ic.parm.num, "E%02X%02X", chanp->proc->para.loc & 0x7f,
|
1997-07-27 21:12:21 +00:00
|
|
|
chanp->proc->para.cause & 0x7f);
|
1997-02-11 01:36:58 +00:00
|
|
|
else
|
1999-07-01 08:12:15 +00:00
|
|
|
sprintf(ic.parm.num, "%02X%02X", chanp->proc->para.loc & 0x7f,
|
1997-07-27 21:12:21 +00:00
|
|
|
chanp->proc->para.cause & 0x7f);
|
1999-07-01 08:12:15 +00:00
|
|
|
chanp->cs->iif.statcallb(&ic);
|
1997-07-27 21:12:21 +00:00
|
|
|
}
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
static inline void
|
|
|
|
lli_close(struct FsmInst *fi)
|
1997-07-27 21:12:21 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
1998-02-09 10:56:02 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
FsmChangeState(fi, ST_NULL);
|
|
|
|
chanp->Flags = 0;
|
|
|
|
chanp->cs->cardmsg(chanp->cs, MDL_INFO_REL, (void *) (long)chanp->chan);
|
1997-07-27 21:12:21 +00:00
|
|
|
}
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
static void
|
|
|
|
lli_leased_in(struct FsmInst *fi, int event, void *arg)
|
1997-07-27 21:12:21 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
|
|
|
|
isdn_ctrl ic;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
chanp->cs->cardmsg(chanp->cs, MDL_INFO_SETUP, (void *) (long)chanp->chan);
|
|
|
|
FsmChangeState(fi, ST_IN_WAIT_LL);
|
|
|
|
if (chanp->debug & 1)
|
|
|
|
link_debug(chanp, 0, "STAT_ICALL_LEASED");
|
|
|
|
ic.driver = chanp->cs->myid;
|
|
|
|
ic.command = ((chanp->chan < 2) ? ISDN_STAT_ICALL : ISDN_STAT_ICALLW);
|
|
|
|
ic.arg = chanp->chan;
|
|
|
|
ic.parm.setup.si1 = 7;
|
|
|
|
ic.parm.setup.si2 = 0;
|
|
|
|
ic.parm.setup.plan = 0;
|
|
|
|
ic.parm.setup.screen = 0;
|
|
|
|
sprintf(ic.parm.setup.eazmsn,"%d", chanp->chan + 1);
|
|
|
|
sprintf(ic.parm.setup.phone,"LEASED%d", chanp->cs->myid);
|
|
|
|
ret = chanp->cs->iif.statcallb(&ic);
|
|
|
|
if (chanp->debug & 1)
|
|
|
|
link_debug(chanp, 1, "statcallb ret=%d", ret);
|
|
|
|
|
|
|
|
if (!ret) {
|
|
|
|
chanp->cs->cardmsg(chanp->cs, MDL_INFO_REL, (void *) (long)chanp->chan);
|
|
|
|
FsmChangeState(fi, ST_NULL);
|
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
|
1996-10-13 20:04:59 +00:00
|
|
|
/*
|
|
|
|
* Dial out
|
|
|
|
*/
|
1999-07-01 08:12:15 +00:00
|
|
|
static void
|
|
|
|
lli_init_bchan_out(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
|
|
|
|
FsmChangeState(fi, ST_WAIT_BCONN);
|
|
|
|
if (chanp->debug & 1)
|
|
|
|
link_debug(chanp, 0, "STAT_DCONN");
|
|
|
|
HL_LL(chanp, ISDN_STAT_DCONN);
|
|
|
|
init_b_st(chanp, 0);
|
|
|
|
chanp->b_st->lli.l4l3(chanp->b_st, DL_ESTABLISH | REQUEST, NULL);
|
|
|
|
}
|
|
|
|
|
1996-10-13 20:04:59 +00:00
|
|
|
static void
|
1997-07-27 21:12:21 +00:00
|
|
|
lli_prep_dialout(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-01-27 16:00:38 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
|
|
|
|
FsmDelTimer(&chanp->drel_timer, 60);
|
|
|
|
FsmDelTimer(&chanp->dial_timer, 73);
|
|
|
|
chanp->l2_active_protocol = chanp->l2_protocol;
|
|
|
|
chanp->incoming = 0;
|
1996-12-08 19:51:17 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
chanp->cs->cardmsg(chanp->cs, MDL_INFO_SETUP, (void *) (long)chanp->chan);
|
|
|
|
if (chanp->leased) {
|
|
|
|
lli_init_bchan_out(fi, event, arg);
|
|
|
|
} else {
|
|
|
|
FsmChangeState(fi, ST_OUT_DIAL);
|
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st, CC_SETUP | REQUEST, chanp);
|
|
|
|
}
|
1996-12-08 19:51:17 +00:00
|
|
|
}
|
|
|
|
|
1996-10-13 20:04:59 +00:00
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_resume(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-01-27 16:00:38 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
FsmDelTimer(&chanp->drel_timer, 60);
|
|
|
|
FsmDelTimer(&chanp->dial_timer, 73);
|
|
|
|
chanp->l2_active_protocol = chanp->l2_protocol;
|
|
|
|
chanp->incoming = 0;
|
|
|
|
|
|
|
|
chanp->cs->cardmsg(chanp->cs, MDL_INFO_SETUP, (void *) (long)chanp->chan);
|
|
|
|
if (chanp->leased) {
|
|
|
|
lli_init_bchan_out(fi, event, arg);
|
|
|
|
} else {
|
|
|
|
FsmChangeState(fi, ST_OUT_DIAL);
|
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st, CC_RESUME | REQUEST, chanp);
|
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-07-27 21:12:21 +00:00
|
|
|
lli_go_active(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-01-27 16:00:38 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
1999-08-05 20:43:22 +00:00
|
|
|
isdn_ctrl ic;
|
|
|
|
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-01-27 16:00:38 +00:00
|
|
|
FsmChangeState(fi, ST_ACTIVE);
|
|
|
|
chanp->data_open = !0;
|
1999-08-05 20:43:22 +00:00
|
|
|
if (chanp->bcs->conmsg)
|
|
|
|
strcpy(ic.parm.num, chanp->bcs->conmsg);
|
|
|
|
else
|
|
|
|
ic.parm.num[0] = 0;
|
1997-01-27 16:00:38 +00:00
|
|
|
if (chanp->debug & 1)
|
1999-08-05 20:43:22 +00:00
|
|
|
link_debug(chanp, 0, "STAT_BCONN %s", ic.parm.num);
|
|
|
|
ic.driver = chanp->cs->myid;
|
|
|
|
ic.command = ISDN_STAT_BCONN;
|
|
|
|
ic.arg = chanp->chan;
|
|
|
|
chanp->cs->iif.statcallb(&ic);
|
1998-03-07 22:57:08 +00:00
|
|
|
chanp->cs->cardmsg(chanp->cs, MDL_INFO_CONN, (void *) (long)chanp->chan);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
|
1998-04-15 16:46:06 +00:00
|
|
|
/*
|
|
|
|
* RESUME
|
|
|
|
*/
|
|
|
|
|
1997-01-21 22:16:39 +00:00
|
|
|
/* incomming call */
|
1996-10-13 20:04:59 +00:00
|
|
|
|
|
|
|
static void
|
1997-07-27 21:12:21 +00:00
|
|
|
lli_deliver_call(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-01-27 16:00:38 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
isdn_ctrl ic;
|
|
|
|
int ret;
|
|
|
|
|
1998-03-07 22:57:08 +00:00
|
|
|
chanp->cs->cardmsg(chanp->cs, MDL_INFO_SETUP, (void *) (long)chanp->chan);
|
1997-01-27 16:00:38 +00:00
|
|
|
/*
|
|
|
|
* Report incoming calls only once to linklevel, use CallFlags
|
|
|
|
* which is set to 3 with each broadcast message in isdnl1.c
|
|
|
|
* and resetted if a interface answered the STAT_ICALL.
|
|
|
|
*/
|
1997-10-29 19:02:01 +00:00
|
|
|
if (1) { /* for only one TEI */
|
1997-01-27 16:00:38 +00:00
|
|
|
FsmChangeState(fi, ST_IN_WAIT_LL);
|
|
|
|
if (chanp->debug & 1)
|
1999-07-01 08:12:15 +00:00
|
|
|
link_debug(chanp, 0, (chanp->chan < 2) ? "STAT_ICALL" : "STAT_ICALLW");
|
1997-07-27 21:12:21 +00:00
|
|
|
ic.driver = chanp->cs->myid;
|
1999-07-01 08:12:15 +00:00
|
|
|
ic.command = ((chanp->chan < 2) ? ISDN_STAT_ICALL : ISDN_STAT_ICALLW);
|
|
|
|
|
1997-01-27 16:00:38 +00:00
|
|
|
ic.arg = chanp->chan;
|
|
|
|
/*
|
|
|
|
* No need to return "unknown" for calls without OAD,
|
|
|
|
* cause that's handled in linklevel now (replaced by '0')
|
|
|
|
*/
|
1997-07-27 21:12:21 +00:00
|
|
|
ic.parm.setup = chanp->proc->para.setup;
|
|
|
|
ret = chanp->cs->iif.statcallb(&ic);
|
1998-11-15 23:55:28 +00:00
|
|
|
if (chanp->debug & 1)
|
|
|
|
link_debug(chanp, 1, "statcallb ret=%d", ret);
|
1999-07-01 08:12:15 +00:00
|
|
|
|
1997-01-27 16:00:38 +00:00
|
|
|
switch (ret) {
|
1999-07-01 08:12:15 +00:00
|
|
|
case 1: /* OK, someone likes this call */
|
1997-07-27 21:12:21 +00:00
|
|
|
FsmDelTimer(&chanp->drel_timer, 61);
|
1999-07-01 08:12:15 +00:00
|
|
|
FsmChangeState(fi, ST_IN_ALERT_SENT);
|
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st, CC_ALERTING | REQUEST, chanp->proc);
|
|
|
|
break;
|
1999-08-25 20:02:34 +00:00
|
|
|
case 5: /* direct redirect */
|
|
|
|
case 4: /* Proceeding desired */
|
1999-07-01 08:12:15 +00:00
|
|
|
FsmDelTimer(&chanp->drel_timer, 61);
|
|
|
|
FsmChangeState(fi, ST_IN_PROCEED_SEND);
|
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st, CC_PROCEED_SEND | REQUEST, chanp->proc);
|
1999-08-25 20:02:34 +00:00
|
|
|
if (ret == 5)
|
1999-07-01 08:12:15 +00:00
|
|
|
{ chanp->setup = ic.parm.setup;
|
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st, CC_REDIR | REQUEST, chanp->proc);
|
|
|
|
}
|
1997-02-09 00:23:10 +00:00
|
|
|
break;
|
|
|
|
case 2: /* Rejecting Call */
|
|
|
|
break;
|
|
|
|
case 0: /* OK, nobody likes this call */
|
|
|
|
default: /* statcallb problems */
|
1998-05-25 14:08:10 +00:00
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st, CC_IGNORE | REQUEST, chanp->proc);
|
1998-03-07 22:57:08 +00:00
|
|
|
chanp->cs->cardmsg(chanp->cs, MDL_INFO_REL, (void *) (long)chanp->chan);
|
1997-02-09 00:23:10 +00:00
|
|
|
FsmChangeState(fi, ST_NULL);
|
|
|
|
break;
|
1997-01-27 16:00:38 +00:00
|
|
|
}
|
|
|
|
} else {
|
1998-05-25 14:08:10 +00:00
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st, CC_IGNORE | REQUEST, chanp->proc);
|
1998-11-15 23:55:28 +00:00
|
|
|
chanp->cs->cardmsg(chanp->cs, MDL_INFO_REL, (void *) (long)chanp->chan);
|
1997-07-27 21:12:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-10-29 19:02:01 +00:00
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_send_dconnect(struct FsmInst *fi, int event, void *arg)
|
1997-10-29 19:02:01 +00:00
|
|
|
{
|
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
FsmChangeState(fi, ST_IN_WAIT_CONN_ACK);
|
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st, CC_SETUP | RESPONSE, chanp->proc);
|
1997-10-29 19:02:01 +00:00
|
|
|
}
|
|
|
|
|
1997-07-27 21:12:21 +00:00
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_send_alert(struct FsmInst *fi, int event, void *arg)
|
1997-07-27 21:12:21 +00:00
|
|
|
{
|
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
FsmChangeState(fi, ST_IN_ALERT_SENT);
|
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st, CC_ALERTING | REQUEST, chanp->proc);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_send_redir(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-01-27 16:00:38 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st, CC_REDIR | REQUEST, chanp->proc);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-07-27 21:12:21 +00:00
|
|
|
lli_init_bchan_in(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-01-27 16:00:38 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-01-27 16:00:38 +00:00
|
|
|
FsmChangeState(fi, ST_WAIT_BCONN);
|
|
|
|
if (chanp->debug & 1)
|
1998-11-15 23:55:28 +00:00
|
|
|
link_debug(chanp, 0, "STAT_DCONN");
|
1999-07-01 08:12:15 +00:00
|
|
|
HL_LL(chanp, ISDN_STAT_DCONN);
|
1997-01-27 16:00:38 +00:00
|
|
|
chanp->l2_active_protocol = chanp->l2_protocol;
|
|
|
|
chanp->incoming = !0;
|
1997-07-27 21:12:21 +00:00
|
|
|
init_b_st(chanp, !0);
|
1998-05-25 12:58:26 +00:00
|
|
|
chanp->b_st->lli.l4l3(chanp->b_st, DL_ESTABLISH | REQUEST, NULL);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
static void
|
|
|
|
lli_setup_rsp(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
|
|
|
|
if (chanp->leased) {
|
|
|
|
lli_init_bchan_in(fi, event, arg);
|
|
|
|
} else {
|
|
|
|
FsmChangeState(fi, ST_IN_WAIT_CONN_ACK);
|
|
|
|
#ifdef WANT_ALERT
|
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st, CC_ALERTING | REQUEST, chanp->proc);
|
|
|
|
#endif
|
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st, CC_SETUP | RESPONSE, chanp->proc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-03-19 13:18:57 +00:00
|
|
|
/* Call suspend */
|
|
|
|
|
|
|
|
static void
|
|
|
|
lli_suspend(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
|
1998-05-25 14:08:10 +00:00
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st, CC_SUSPEND | REQUEST, chanp->proc);
|
1998-03-19 13:18:57 +00:00
|
|
|
}
|
|
|
|
|
1997-01-21 22:16:39 +00:00
|
|
|
/* Call clearing */
|
|
|
|
|
1996-10-13 20:04:59 +00:00
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_disconnect_req(struct FsmInst *fi, int event, void *arg)
|
1997-01-21 22:16:39 +00:00
|
|
|
{
|
1997-01-27 16:00:38 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-01-27 16:00:38 +00:00
|
|
|
FsmChangeState(fi, ST_WAIT_DRELEASE);
|
1999-07-01 08:12:15 +00:00
|
|
|
chanp->proc->para.cause = 0x10; /* Normal Call Clearing */
|
1998-05-25 14:08:10 +00:00
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st, CC_DISCONNECT | REQUEST, chanp->proc);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_disconnect_reject(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
FsmChangeState(fi, ST_WAIT_DRELEASE);
|
|
|
|
chanp->proc->para.cause = 0x15; /* Call Rejected */
|
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st, CC_DISCONNECT | REQUEST, chanp->proc);
|
1997-01-21 22:16:39 +00:00
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-01-21 22:16:39 +00:00
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_dhup_close(struct FsmInst *fi, int event, void *arg)
|
1997-01-21 22:16:39 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
|
|
|
|
if (chanp->debug & 1)
|
|
|
|
link_debug(chanp, 0, "STAT_DHUP");
|
|
|
|
lli_deliver_cause(chanp);
|
|
|
|
HL_LL(chanp, ISDN_STAT_DHUP);
|
|
|
|
|
|
|
|
lli_close(fi);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_reject_req(struct FsmInst *fi, int event, void *arg)
|
1997-01-21 22:16:39 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
|
|
|
|
#ifndef ALERT_REJECT
|
|
|
|
chanp->proc->para.cause = 0x15; /* Call Rejected */
|
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st, CC_REJECT | REQUEST, chanp->proc);
|
|
|
|
lli_dhup_close(fi, event, arg);
|
|
|
|
#else
|
|
|
|
FsmRestartTimer(&chanp->drel_timer, 40, EV_HANGUP, NULL, 63);
|
|
|
|
FsmChangeState(fi, ST_IN_ALERT_SENT);
|
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st, CC_ALERTING | REQUEST, chanp->proc);
|
|
|
|
#endif
|
1997-01-21 22:16:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-07-27 21:12:21 +00:00
|
|
|
lli_disconn_bchan(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-01-27 16:00:38 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-01-27 16:00:38 +00:00
|
|
|
chanp->data_open = 0;
|
|
|
|
FsmChangeState(fi, ST_WAIT_BRELEASE);
|
1998-05-25 12:58:26 +00:00
|
|
|
chanp->b_st->lli.l4l3(chanp->b_st, DL_RELEASE | REQUEST, NULL);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_start_disc(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-01-27 16:00:38 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
isdn_ctrl ic;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-10-29 19:02:01 +00:00
|
|
|
if (chanp->leased) {
|
|
|
|
ic.command = ISDN_STAT_CAUSE;
|
|
|
|
ic.arg = chanp->chan;
|
|
|
|
sprintf(ic.parm.num, "L0010");
|
|
|
|
chanp->cs->iif.statcallb(&ic);
|
|
|
|
if (chanp->debug & 1)
|
1998-11-15 23:55:28 +00:00
|
|
|
link_debug(chanp, 0, "STAT_DHUP");
|
1999-07-01 08:12:15 +00:00
|
|
|
HL_LL(chanp, ISDN_STAT_DHUP);
|
|
|
|
lli_close(fi);
|
1997-10-29 19:02:01 +00:00
|
|
|
} else {
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_disconnect_req(fi, event, arg);
|
1997-01-21 22:16:39 +00:00
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_rel_b_disc(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
|
|
|
|
release_b_st(chanp);
|
|
|
|
lli_start_disc(fi, event, arg);
|
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
static void
|
|
|
|
lli_bhup_disc(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
|
|
|
|
if (chanp->debug & 1)
|
|
|
|
link_debug(chanp, 0, "STAT_BHUP");
|
|
|
|
HL_LL(chanp, ISDN_STAT_BHUP);
|
|
|
|
|
|
|
|
lli_rel_b_disc(fi, event, arg);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
static void
|
|
|
|
lli_bhup_rel_b(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
|
|
|
|
FsmChangeState(fi, ST_WAIT_DCOMMAND);
|
|
|
|
chanp->data_open = 0;
|
|
|
|
if (chanp->debug & 1)
|
|
|
|
link_debug(chanp, 0, "STAT_BHUP");
|
|
|
|
HL_LL(chanp, ISDN_STAT_BHUP);
|
|
|
|
release_b_st(chanp);
|
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
|
|
|
|
static void
|
1997-07-27 21:12:21 +00:00
|
|
|
lli_release_bchan(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-01-27 16:00:38 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-01-27 16:00:38 +00:00
|
|
|
chanp->data_open = 0;
|
|
|
|
FsmChangeState(fi, ST_WAIT_BREL_DISC);
|
1998-05-25 12:58:26 +00:00
|
|
|
chanp->b_st->lli.l4l3(chanp->b_st, DL_RELEASE | REQUEST, NULL);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
|
1996-10-13 20:04:59 +00:00
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_rel_b_dhup(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
release_b_st(chanp);
|
|
|
|
lli_dhup_close(fi, event, arg);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_bhup_dhup(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
if (chanp->debug & 1)
|
|
|
|
link_debug(chanp, 0, "STAT_BHUP");
|
|
|
|
HL_LL(chanp, ISDN_STAT_BHUP);
|
|
|
|
|
|
|
|
lli_rel_b_dhup(fi, event, arg);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_abort(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
1997-01-27 16:00:38 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
chanp->data_open = 0;
|
|
|
|
chanp->b_st->lli.l4l3(chanp->b_st, DL_RELEASE | REQUEST, NULL);
|
|
|
|
|
|
|
|
lli_bhup_dhup(fi, event, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
lli_release_req(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
|
|
|
|
FsmChangeState(fi, ST_WAIT_D_REL_CNF);
|
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st, CC_RELEASE | REQUEST, chanp->proc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
lli_rel_b_release_req(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
|
|
|
|
release_b_st(chanp);
|
|
|
|
lli_release_req(fi, event, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
lli_bhup_release_req(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
|
|
|
|
if (chanp->debug & 1)
|
|
|
|
link_debug(chanp, 0, "STAT_BHUP");
|
|
|
|
HL_LL(chanp, ISDN_STAT_BHUP);
|
|
|
|
|
|
|
|
lli_rel_b_release_req(fi, event, arg);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
|
1997-01-21 22:16:39 +00:00
|
|
|
/* processing charge info */
|
1996-10-13 20:04:59 +00:00
|
|
|
static void
|
1997-07-27 21:12:21 +00:00
|
|
|
lli_charge_info(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-01-27 16:00:38 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
isdn_ctrl ic;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-07-27 21:12:21 +00:00
|
|
|
ic.driver = chanp->cs->myid;
|
1997-01-27 16:00:38 +00:00
|
|
|
ic.command = ISDN_STAT_CINF;
|
|
|
|
ic.arg = chanp->chan;
|
1997-07-27 21:12:21 +00:00
|
|
|
sprintf(ic.parm.num, "%d", chanp->proc->para.chargeinfo);
|
|
|
|
chanp->cs->iif.statcallb(&ic);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1997-01-21 22:16:39 +00:00
|
|
|
/* error procedures */
|
|
|
|
|
1996-10-13 20:04:59 +00:00
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_dchan_not_ready(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-01-27 16:00:38 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-01-27 16:00:38 +00:00
|
|
|
if (chanp->debug & 1)
|
1999-07-01 08:12:15 +00:00
|
|
|
link_debug(chanp, 0, "STAT_DHUP");
|
|
|
|
HL_LL(chanp, ISDN_STAT_DHUP);
|
1997-01-27 16:00:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_no_setup_rsp(struct FsmInst *fi, int event, void *arg)
|
1997-01-27 16:00:38 +00:00
|
|
|
{
|
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
|
|
|
|
if (chanp->debug & 1)
|
1998-11-15 23:55:28 +00:00
|
|
|
link_debug(chanp, 0, "STAT_DHUP");
|
1999-07-01 08:12:15 +00:00
|
|
|
HL_LL(chanp, ISDN_STAT_DHUP);
|
|
|
|
lli_close(fi);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_error(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
FsmChangeState(fi, ST_WAIT_DRELEASE);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_failure_l(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
|
|
|
isdn_ctrl ic;
|
|
|
|
|
|
|
|
FsmChangeState(fi, ST_NULL);
|
|
|
|
ic.driver = chanp->cs->myid;
|
|
|
|
ic.command = ISDN_STAT_CAUSE;
|
|
|
|
ic.arg = chanp->chan;
|
|
|
|
sprintf(ic.parm.num, "L%02X%02X", 0, 0x2f);
|
|
|
|
chanp->cs->iif.statcallb(&ic);
|
|
|
|
HL_LL(chanp, ISDN_STAT_DHUP);
|
|
|
|
chanp->Flags = 0;
|
|
|
|
chanp->cs->cardmsg(chanp->cs, MDL_INFO_REL, (void *) (long)chanp->chan);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_rel_b_fail(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
release_b_st(chanp);
|
|
|
|
lli_failure_l(fi, event, arg);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_bhup_fail(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
if (chanp->debug & 1)
|
|
|
|
link_debug(chanp, 0, "STAT_BHUP");
|
|
|
|
HL_LL(chanp, ISDN_STAT_BHUP);
|
|
|
|
|
|
|
|
lli_rel_b_fail(fi, event, arg);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
lli_failure_a(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
chanp->data_open = 0;
|
|
|
|
chanp->b_st->lli.l4l3(chanp->b_st, DL_RELEASE | REQUEST, NULL);
|
|
|
|
|
|
|
|
lli_bhup_fail(fi, event, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* *INDENT-OFF* */
|
|
|
|
static struct FsmNode fnlist[] HISAX_INITDATA =
|
|
|
|
{
|
|
|
|
{ST_NULL, EV_DIAL, lli_prep_dialout},
|
|
|
|
{ST_NULL, EV_RESUME, lli_resume},
|
|
|
|
{ST_NULL, EV_SETUP_IND, lli_deliver_call},
|
|
|
|
{ST_NULL, EV_LEASED, lli_leased_in},
|
|
|
|
{ST_OUT_DIAL, EV_SETUP_CNF, lli_init_bchan_out},
|
|
|
|
{ST_OUT_DIAL, EV_HANGUP, lli_disconnect_req},
|
|
|
|
{ST_OUT_DIAL, EV_DISCONNECT_IND, lli_release_req},
|
|
|
|
{ST_OUT_DIAL, EV_RELEASE, lli_dhup_close},
|
|
|
|
{ST_OUT_DIAL, EV_NOSETUP_RSP, lli_no_setup_rsp},
|
|
|
|
{ST_OUT_DIAL, EV_SETUP_ERR, lli_error},
|
|
|
|
{ST_IN_WAIT_LL, EV_LEASED_REL, lli_failure_l},
|
|
|
|
{ST_IN_WAIT_LL, EV_ACCEPTD, lli_setup_rsp},
|
|
|
|
{ST_IN_WAIT_LL, EV_HANGUP, lli_reject_req},
|
|
|
|
{ST_IN_WAIT_LL, EV_DISCONNECT_IND, lli_release_req},
|
|
|
|
{ST_IN_WAIT_LL, EV_RELEASE, lli_dhup_close},
|
|
|
|
{ST_IN_ALERT_SENT, EV_SETUP_CMPL_IND, lli_init_bchan_in},
|
|
|
|
{ST_IN_ALERT_SENT, EV_ACCEPTD, lli_send_dconnect},
|
|
|
|
{ST_IN_ALERT_SENT, EV_HANGUP, lli_disconnect_reject},
|
|
|
|
{ST_IN_ALERT_SENT, EV_DISCONNECT_IND, lli_release_req},
|
|
|
|
{ST_IN_ALERT_SENT, EV_RELEASE, lli_dhup_close},
|
|
|
|
{ST_IN_ALERT_SENT, EV_REDIR, lli_send_redir},
|
|
|
|
{ST_IN_PROCEED_SEND, EV_REDIR, lli_send_redir},
|
|
|
|
{ST_IN_PROCEED_SEND, EV_ALERT, lli_send_alert},
|
|
|
|
{ST_IN_PROCEED_SEND, EV_ACCEPTD, lli_send_dconnect},
|
|
|
|
{ST_IN_PROCEED_SEND, EV_HANGUP, lli_disconnect_reject},
|
|
|
|
{ST_IN_PROCEED_SEND, EV_DISCONNECT_IND, lli_dhup_close},
|
|
|
|
{ST_IN_ALERT_SENT, EV_RELEASE, lli_dhup_close},
|
|
|
|
{ST_IN_WAIT_CONN_ACK, EV_SETUP_CMPL_IND, lli_init_bchan_in},
|
|
|
|
{ST_IN_WAIT_CONN_ACK, EV_HANGUP, lli_disconnect_req},
|
|
|
|
{ST_IN_WAIT_CONN_ACK, EV_DISCONNECT_IND, lli_release_req},
|
|
|
|
{ST_IN_WAIT_CONN_ACK, EV_RELEASE, lli_dhup_close},
|
|
|
|
{ST_IN_WAIT_CONN_ACK, EV_CONNECT_ERR, lli_error},
|
|
|
|
{ST_WAIT_BCONN, EV_BC_EST, lli_go_active},
|
|
|
|
{ST_WAIT_BCONN, EV_BC_REL, lli_rel_b_disc},
|
|
|
|
{ST_WAIT_BCONN, EV_HANGUP, lli_rel_b_disc},
|
|
|
|
{ST_WAIT_BCONN, EV_DISCONNECT_IND, lli_rel_b_release_req},
|
|
|
|
{ST_WAIT_BCONN, EV_RELEASE, lli_rel_b_dhup},
|
|
|
|
{ST_WAIT_BCONN, EV_LEASED_REL, lli_rel_b_fail},
|
|
|
|
{ST_WAIT_BCONN, EV_CINF, lli_charge_info},
|
|
|
|
{ST_ACTIVE, EV_CINF, lli_charge_info},
|
|
|
|
{ST_ACTIVE, EV_BC_REL, lli_bhup_rel_b},
|
|
|
|
{ST_ACTIVE, EV_SUSPEND, lli_suspend},
|
|
|
|
{ST_ACTIVE, EV_HANGUP, lli_disconn_bchan},
|
|
|
|
{ST_ACTIVE, EV_DISCONNECT_IND, lli_release_bchan},
|
|
|
|
{ST_ACTIVE, EV_RELEASE, lli_abort},
|
|
|
|
{ST_ACTIVE, EV_LEASED_REL, lli_failure_a},
|
|
|
|
{ST_WAIT_BRELEASE, EV_BC_REL, lli_bhup_disc},
|
|
|
|
{ST_WAIT_BRELEASE, EV_DISCONNECT_IND, lli_bhup_release_req},
|
|
|
|
{ST_WAIT_BRELEASE, EV_RELEASE, lli_bhup_dhup},
|
|
|
|
{ST_WAIT_BRELEASE, EV_LEASED_REL, lli_bhup_fail},
|
|
|
|
{ST_WAIT_BREL_DISC, EV_BC_REL, lli_bhup_release_req},
|
|
|
|
{ST_WAIT_BREL_DISC, EV_RELEASE, lli_bhup_dhup},
|
|
|
|
{ST_WAIT_DCOMMAND, EV_HANGUP, lli_start_disc},
|
|
|
|
{ST_WAIT_DCOMMAND, EV_DISCONNECT_IND, lli_release_req},
|
|
|
|
{ST_WAIT_DCOMMAND, EV_RELEASE, lli_dhup_close},
|
|
|
|
{ST_WAIT_DCOMMAND, EV_LEASED_REL, lli_failure_l},
|
|
|
|
{ST_WAIT_DRELEASE, EV_RELEASE, lli_dhup_close},
|
|
|
|
{ST_WAIT_DRELEASE, EV_DIAL, lli_dchan_not_ready},
|
|
|
|
/* ETS 300-104 16.1 */
|
|
|
|
{ST_WAIT_D_REL_CNF, EV_RELEASE, lli_dhup_close},
|
|
|
|
{ST_WAIT_D_REL_CNF, EV_DIAL, lli_dchan_not_ready},
|
1996-10-13 20:04:59 +00:00
|
|
|
};
|
1999-07-01 08:12:15 +00:00
|
|
|
/* *INDENT-ON* */
|
1997-01-27 16:00:38 +00:00
|
|
|
|
1997-07-27 21:12:21 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
#define FNCOUNT (sizeof(fnlist)/sizeof(struct FsmNode))
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-11-06 17:13:35 +00:00
|
|
|
HISAX_INITFUNC(void
|
|
|
|
CallcNew(void))
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-01-27 16:00:38 +00:00
|
|
|
callcfsm.state_count = STATE_COUNT;
|
|
|
|
callcfsm.event_count = EVENT_COUNT;
|
|
|
|
callcfsm.strEvent = strEvent;
|
|
|
|
callcfsm.strState = strState;
|
|
|
|
FsmNew(&callcfsm, fnlist, FNCOUNT);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CallcFree(void)
|
|
|
|
{
|
1997-01-27 16:00:38 +00:00
|
|
|
FsmFree(&callcfsm);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-07-27 21:12:21 +00:00
|
|
|
release_b_st(struct Channel *chanp)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-07-27 21:12:21 +00:00
|
|
|
struct PStack *st = chanp->b_st;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
if(test_and_clear_bit(FLG_START_B, &chanp->Flags)) {
|
|
|
|
chanp->bcs->BC_Close(chanp->bcs);
|
|
|
|
switch (chanp->l2_active_protocol) {
|
|
|
|
case (ISDN_PROTO_L2_X75I):
|
|
|
|
releasestack_isdnl2(st);
|
|
|
|
break;
|
|
|
|
case (ISDN_PROTO_L2_HDLC):
|
|
|
|
case (ISDN_PROTO_L2_TRANS):
|
|
|
|
case (ISDN_PROTO_L2_MODEM):
|
1999-08-25 17:00:09 +00:00
|
|
|
case (ISDN_PROTO_L2_FAX):
|
1999-07-01 08:12:15 +00:00
|
|
|
releasestack_transl2(st);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1997-07-27 21:12:21 +00:00
|
|
|
struct Channel
|
1999-07-01 08:12:15 +00:00
|
|
|
*selectfreechannel(struct PStack *st, int bch)
|
1997-03-05 11:28:03 +00:00
|
|
|
{
|
1997-07-27 21:12:21 +00:00
|
|
|
struct IsdnCardState *cs = st->l1.hardware;
|
|
|
|
struct Channel *chanp = st->lli.userdata;
|
|
|
|
int i;
|
1997-03-05 11:28:03 +00:00
|
|
|
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_bit(FLG_TWO_DCHAN, &cs->HW_Flags))
|
1997-07-30 17:13:02 +00:00
|
|
|
i=1;
|
|
|
|
else
|
|
|
|
i=0;
|
1999-07-01 08:12:15 +00:00
|
|
|
|
|
|
|
if (!bch)
|
|
|
|
{ i = 2; /* virtual channel */
|
|
|
|
chanp += 2;
|
|
|
|
}
|
|
|
|
|
1999-07-05 23:51:46 +00:00
|
|
|
while (i < ((bch) ? cs->chanlimit : (2 + MAX_WAITING_CALLS))) {
|
1997-07-30 17:13:02 +00:00
|
|
|
if (chanp->fi.state == ST_NULL)
|
|
|
|
return (chanp);
|
|
|
|
chanp++;
|
|
|
|
i++;
|
1998-11-15 23:55:28 +00:00
|
|
|
}
|
1999-07-05 23:51:46 +00:00
|
|
|
|
|
|
|
if (bch) /* number of channels is limited */
|
|
|
|
{ i = 2; /* virtual channel */
|
|
|
|
chanp = st->lli.userdata;
|
|
|
|
chanp += i;
|
|
|
|
while (i < (2 + MAX_WAITING_CALLS)) {
|
|
|
|
if (chanp->fi.state == ST_NULL)
|
|
|
|
return (chanp);
|
|
|
|
chanp++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
1997-07-27 21:12:21 +00:00
|
|
|
return (NULL);
|
1997-03-05 11:28:03 +00:00
|
|
|
}
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
static void stat_redir_result(struct IsdnCardState *cs, int chan, ulong result)
|
|
|
|
{ isdn_ctrl ic;
|
|
|
|
|
|
|
|
ic.driver = cs->myid;
|
|
|
|
ic.command = ISDN_STAT_REDIR;
|
|
|
|
ic.arg = chan;
|
|
|
|
(ulong)(ic.parm.num[0]) = result;
|
|
|
|
cs->iif.statcallb(&ic);
|
|
|
|
} /* stat_redir_result */
|
1997-10-29 19:02:01 +00:00
|
|
|
|
1996-10-13 20:04:59 +00:00
|
|
|
static void
|
1998-05-25 12:58:26 +00:00
|
|
|
dchan_l3l4(struct PStack *st, int pr, void *arg)
|
1997-01-27 16:00:38 +00:00
|
|
|
{
|
1998-05-25 12:58:26 +00:00
|
|
|
struct l3_process *pc = arg;
|
1999-07-01 08:12:15 +00:00
|
|
|
struct IsdnCardState *cs = st->l1.hardware;
|
1997-07-27 21:12:21 +00:00
|
|
|
struct Channel *chanp;
|
1998-05-25 12:58:26 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
if(!pc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (pr == (CC_SETUP | INDICATION)) {
|
|
|
|
if (!(chanp = selectfreechannel(pc->st, pc->para.bchannel))) {
|
|
|
|
pc->para.cause = 0x11; /* User busy */
|
|
|
|
pc->st->lli.l4l3(pc->st, CC_REJECT | REQUEST, pc);
|
|
|
|
} else {
|
|
|
|
chanp->proc = pc;
|
|
|
|
pc->chan = chanp;
|
1997-07-27 21:12:21 +00:00
|
|
|
FsmEvent(&chanp->fi, EV_SETUP_IND, NULL);
|
|
|
|
}
|
1998-05-25 12:58:26 +00:00
|
|
|
return;
|
1997-07-27 21:12:21 +00:00
|
|
|
}
|
1998-08-13 23:36:54 +00:00
|
|
|
if (!(chanp = pc->chan))
|
|
|
|
return;
|
1998-11-15 23:55:28 +00:00
|
|
|
|
1997-01-27 16:00:38 +00:00
|
|
|
switch (pr) {
|
1998-05-25 14:08:10 +00:00
|
|
|
case (CC_DISCONNECT | INDICATION):
|
1997-02-09 00:23:10 +00:00
|
|
|
FsmEvent(&chanp->fi, EV_DISCONNECT_IND, NULL);
|
|
|
|
break;
|
1998-05-25 14:08:10 +00:00
|
|
|
case (CC_RELEASE | CONFIRM):
|
1999-07-01 08:12:15 +00:00
|
|
|
FsmEvent(&chanp->fi, EV_RELEASE, NULL);
|
1997-02-09 00:23:10 +00:00
|
|
|
break;
|
1998-05-25 14:08:10 +00:00
|
|
|
case (CC_SUSPEND | CONFIRM):
|
1999-07-01 08:12:15 +00:00
|
|
|
FsmEvent(&chanp->fi, EV_RELEASE, NULL);
|
1998-03-19 13:18:57 +00:00
|
|
|
break;
|
1998-05-25 14:08:10 +00:00
|
|
|
case (CC_RESUME | CONFIRM):
|
1998-04-15 16:46:06 +00:00
|
|
|
FsmEvent(&chanp->fi, EV_SETUP_CNF, NULL);
|
|
|
|
break;
|
|
|
|
case (CC_RESUME_ERR):
|
1999-07-01 08:12:15 +00:00
|
|
|
FsmEvent(&chanp->fi, EV_RELEASE, NULL);
|
1998-04-15 16:46:06 +00:00
|
|
|
break;
|
1998-05-25 14:08:10 +00:00
|
|
|
case (CC_RELEASE | INDICATION):
|
1999-07-01 08:12:15 +00:00
|
|
|
FsmEvent(&chanp->fi, EV_RELEASE, NULL);
|
1997-02-09 00:23:10 +00:00
|
|
|
break;
|
1998-05-25 14:08:10 +00:00
|
|
|
case (CC_SETUP_COMPL | INDICATION):
|
1997-02-09 00:23:10 +00:00
|
|
|
FsmEvent(&chanp->fi, EV_SETUP_CMPL_IND, NULL);
|
|
|
|
break;
|
1998-05-25 14:08:10 +00:00
|
|
|
case (CC_SETUP | CONFIRM):
|
1997-02-09 00:23:10 +00:00
|
|
|
FsmEvent(&chanp->fi, EV_SETUP_CNF, NULL);
|
|
|
|
break;
|
1998-05-25 14:08:10 +00:00
|
|
|
case (CC_CHARGE | INDICATION):
|
1997-02-09 00:23:10 +00:00
|
|
|
FsmEvent(&chanp->fi, EV_CINF, NULL);
|
|
|
|
break;
|
1998-05-25 14:08:10 +00:00
|
|
|
case (CC_NOSETUP_RSP):
|
1997-02-09 00:23:10 +00:00
|
|
|
FsmEvent(&chanp->fi, EV_NOSETUP_RSP, NULL);
|
|
|
|
break;
|
|
|
|
case (CC_SETUP_ERR):
|
|
|
|
FsmEvent(&chanp->fi, EV_SETUP_ERR, NULL);
|
|
|
|
break;
|
|
|
|
case (CC_CONNECT_ERR):
|
|
|
|
FsmEvent(&chanp->fi, EV_CONNECT_ERR, NULL);
|
|
|
|
break;
|
|
|
|
case (CC_RELEASE_ERR):
|
1999-07-01 08:12:15 +00:00
|
|
|
FsmEvent(&chanp->fi, EV_RELEASE, NULL);
|
1997-02-09 00:23:10 +00:00
|
|
|
break;
|
1999-07-01 08:12:15 +00:00
|
|
|
case (CC_PROCEED_SEND | INDICATION):
|
1998-05-25 14:08:10 +00:00
|
|
|
case (CC_PROCEEDING | INDICATION):
|
|
|
|
case (CC_ALERTING | INDICATION):
|
1999-07-01 08:12:15 +00:00
|
|
|
case (CC_PROGRESS | INDICATION):
|
|
|
|
case (CC_NOTIFY | INDICATION):
|
1997-07-27 21:12:21 +00:00
|
|
|
break;
|
1999-07-01 08:12:15 +00:00
|
|
|
case (CC_REDIR | INDICATION):
|
|
|
|
stat_redir_result(cs, chanp->chan, pc->redir_result);
|
|
|
|
break;
|
1997-02-09 00:23:10 +00:00
|
|
|
default:
|
1997-10-29 19:02:01 +00:00
|
|
|
if (chanp->debug & 0x800) {
|
1998-11-15 23:55:28 +00:00
|
|
|
HiSax_putstatus(chanp->cs, "Ch",
|
1999-07-09 08:30:08 +00:00
|
|
|
"%d L3->L4 unknown primitiv %#x",
|
1998-11-15 23:55:28 +00:00
|
|
|
chanp->chan, pr);
|
1997-04-13 19:55:21 +00:00
|
|
|
}
|
1997-01-27 16:00:38 +00:00
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1999-09-20 12:13:13 +00:00
|
|
|
static void
|
|
|
|
dummy_pstack(struct PStack *st, int pr, void *arg) {
|
|
|
|
printk(KERN_WARNING"call to dummy_pstack pr=%04x arg %lx\n", pr, (long)arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
init_PStack(struct PStack **stp) {
|
|
|
|
*stp = kmalloc(sizeof(struct PStack), GFP_ATOMIC);
|
|
|
|
(*stp)->next = NULL;
|
|
|
|
(*stp)->l1.l1l2 = dummy_pstack;
|
|
|
|
(*stp)->l1.l1hw = dummy_pstack;
|
|
|
|
(*stp)->l1.l1tei = dummy_pstack;
|
|
|
|
(*stp)->l2.l2tei = dummy_pstack;
|
|
|
|
(*stp)->l2.l2l1 = dummy_pstack;
|
|
|
|
(*stp)->l2.l2l3 = dummy_pstack;
|
|
|
|
(*stp)->l3.l3l2 = dummy_pstack;
|
|
|
|
(*stp)->l3.l3ml3 = dummy_pstack;
|
|
|
|
(*stp)->l3.l3l4 = dummy_pstack;
|
|
|
|
(*stp)->lli.l4l3 = dummy_pstack;
|
|
|
|
(*stp)->ma.layer = dummy_pstack;
|
|
|
|
}
|
|
|
|
|
1996-10-13 20:04:59 +00:00
|
|
|
static void
|
1997-07-27 21:12:21 +00:00
|
|
|
init_d_st(struct Channel *chanp)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1999-09-20 19:49:47 +00:00
|
|
|
struct PStack *st;
|
1997-07-27 21:12:21 +00:00
|
|
|
struct IsdnCardState *cs = chanp->cs;
|
1998-11-15 23:55:28 +00:00
|
|
|
char tmp[16];
|
1997-01-27 16:00:38 +00:00
|
|
|
|
1999-09-20 19:49:47 +00:00
|
|
|
init_PStack(&chanp->d_st);
|
|
|
|
st = chanp->d_st;
|
1999-09-20 12:13:13 +00:00
|
|
|
st->next = NULL;
|
1997-07-27 21:12:21 +00:00
|
|
|
HiSax_addlist(cs, st);
|
|
|
|
setstack_HiSax(st, cs);
|
1997-01-27 16:00:38 +00:00
|
|
|
st->l2.sap = 0;
|
1997-07-27 21:12:21 +00:00
|
|
|
st->l2.tei = -1;
|
1997-10-29 19:02:01 +00:00
|
|
|
st->l2.flag = 0;
|
|
|
|
test_and_set_bit(FLG_MOD128, &st->l2.flag);
|
|
|
|
test_and_set_bit(FLG_LAPD, &st->l2.flag);
|
|
|
|
test_and_set_bit(FLG_ORIG, &st->l2.flag);
|
|
|
|
st->l2.maxlen = MAX_DFRAME_LEN;
|
1997-01-27 16:00:38 +00:00
|
|
|
st->l2.window = 1;
|
1997-07-27 21:12:21 +00:00
|
|
|
st->l2.T200 = 1000; /* 1000 milliseconds */
|
1997-07-30 17:13:02 +00:00
|
|
|
st->l2.N200 = 3; /* try 3 times */
|
1998-08-13 23:36:54 +00:00
|
|
|
st->l2.T203 = 10000; /* 10000 milliseconds */
|
1998-05-25 14:08:10 +00:00
|
|
|
if (test_bit(FLG_TWO_DCHAN, &cs->HW_Flags))
|
1998-11-15 23:55:28 +00:00
|
|
|
sprintf(tmp, "DCh%d Q.921 ", chanp->chan);
|
1998-05-25 14:08:10 +00:00
|
|
|
else
|
1998-11-15 23:55:28 +00:00
|
|
|
sprintf(tmp, "DCh Q.921 ");
|
1997-01-27 16:00:38 +00:00
|
|
|
setstack_isdnl2(st, tmp);
|
1998-05-25 12:58:26 +00:00
|
|
|
setstack_l3dc(st, chanp);
|
1997-07-27 21:12:21 +00:00
|
|
|
st->lli.userdata = chanp;
|
|
|
|
st->lli.l2writewakeup = NULL;
|
1998-05-25 12:58:26 +00:00
|
|
|
st->l3.l3l4 = dchan_l3l4;
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-11-15 23:55:28 +00:00
|
|
|
callc_debug(struct FsmInst *fi, char *fmt, ...)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1998-11-15 23:55:28 +00:00
|
|
|
va_list args;
|
1997-01-27 16:00:38 +00:00
|
|
|
struct Channel *chanp = fi->userdata;
|
1998-11-15 23:55:28 +00:00
|
|
|
char tmp[16];
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1998-11-15 23:55:28 +00:00
|
|
|
va_start(args, fmt);
|
|
|
|
sprintf(tmp, "Ch%d callc ", chanp->chan);
|
|
|
|
VHiSax_putstatus(chanp->cs, tmp, fmt, args);
|
|
|
|
va_end(args);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-07-27 21:12:21 +00:00
|
|
|
init_chan(int chan, struct IsdnCardState *csta)
|
1997-01-27 16:00:38 +00:00
|
|
|
{
|
1997-02-09 00:23:10 +00:00
|
|
|
struct Channel *chanp = csta->channel + chan;
|
1997-01-27 16:00:38 +00:00
|
|
|
|
1997-07-27 21:12:21 +00:00
|
|
|
chanp->cs = csta;
|
|
|
|
chanp->bcs = csta->bcs + chan;
|
1997-01-27 16:00:38 +00:00
|
|
|
chanp->chan = chan;
|
|
|
|
chanp->incoming = 0;
|
|
|
|
chanp->debug = 0;
|
|
|
|
chanp->Flags = 0;
|
|
|
|
chanp->leased = 0;
|
1998-05-25 12:58:26 +00:00
|
|
|
init_PStack(&chanp->b_st);
|
|
|
|
chanp->b_st->l1.delay = DEFAULT_B_DELAY;
|
1997-08-03 14:37:58 +00:00
|
|
|
chanp->fi.fsm = &callcfsm;
|
|
|
|
chanp->fi.state = ST_NULL;
|
|
|
|
chanp->fi.debug = 0;
|
|
|
|
chanp->fi.userdata = chanp;
|
|
|
|
chanp->fi.printdebug = callc_debug;
|
|
|
|
FsmInitTimer(&chanp->fi, &chanp->dial_timer);
|
|
|
|
FsmInitTimer(&chanp->fi, &chanp->drel_timer);
|
1997-10-29 19:02:01 +00:00
|
|
|
if (!chan || test_bit(FLG_TWO_DCHAN, &csta->HW_Flags)) {
|
1997-07-30 17:13:02 +00:00
|
|
|
init_d_st(chanp);
|
|
|
|
} else {
|
|
|
|
chanp->d_st = csta->channel->d_st;
|
|
|
|
}
|
1997-01-27 16:00:38 +00:00
|
|
|
chanp->data_open = 0;
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1997-02-09 00:23:10 +00:00
|
|
|
CallcNewChan(struct IsdnCardState *csta)
|
1999-07-01 08:12:15 +00:00
|
|
|
{ int i;
|
|
|
|
|
1997-02-09 00:23:10 +00:00
|
|
|
chancount += 2;
|
1997-07-27 21:12:21 +00:00
|
|
|
init_chan(0, csta);
|
|
|
|
init_chan(1, csta);
|
1997-02-09 00:23:10 +00:00
|
|
|
printk(KERN_INFO "HiSax: 2 channels added\n");
|
1999-07-01 08:12:15 +00:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_WAITING_CALLS; i++)
|
|
|
|
init_chan(i+2,csta);
|
|
|
|
printk(KERN_INFO "HiSax: MAX_WAITING_CALLS added\n");
|
|
|
|
|
1998-05-25 14:08:10 +00:00
|
|
|
if (test_bit(FLG_PTP, &csta->channel->d_st->l2.flag)) {
|
|
|
|
printk(KERN_INFO "LAYER2 WATCHING ESTABLISH\n");
|
1998-08-13 23:36:54 +00:00
|
|
|
csta->channel->d_st->lli.l4l3(csta->channel->d_st,
|
|
|
|
DL_ESTABLISH | REQUEST, NULL);
|
1998-05-25 14:08:10 +00:00
|
|
|
}
|
1997-02-09 00:23:10 +00:00
|
|
|
return (2);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-07-27 21:12:21 +00:00
|
|
|
release_d_st(struct Channel *chanp)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-07-27 21:12:21 +00:00
|
|
|
struct PStack *st = chanp->d_st;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-07-27 21:12:21 +00:00
|
|
|
if (!st)
|
|
|
|
return;
|
1997-01-27 16:00:38 +00:00
|
|
|
releasestack_isdnl2(st);
|
1997-01-27 23:17:44 +00:00
|
|
|
releasestack_isdnl3(st);
|
1997-01-27 16:00:38 +00:00
|
|
|
HiSax_rmlist(st->l1.hardware, st);
|
1997-07-27 21:12:21 +00:00
|
|
|
kfree(st);
|
|
|
|
chanp->d_st = NULL;
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1997-02-09 00:23:10 +00:00
|
|
|
CallcFreeChan(struct IsdnCardState *csta)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-01-27 16:00:38 +00:00
|
|
|
int i;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-02-09 00:23:10 +00:00
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
FsmDelTimer(&csta->channel[i].drel_timer, 74);
|
|
|
|
FsmDelTimer(&csta->channel[i].dial_timer, 75);
|
1999-07-01 08:12:15 +00:00
|
|
|
if (i || test_bit(FLG_TWO_DCHAN, &csta->HW_Flags))
|
|
|
|
release_d_st(csta->channel + i);
|
|
|
|
if (csta->channel[i].b_st) {
|
|
|
|
release_b_st(csta->channel + i);
|
|
|
|
kfree(csta->channel[i].b_st);
|
|
|
|
csta->channel[i].b_st = NULL;
|
|
|
|
} else
|
1997-07-27 21:12:21 +00:00
|
|
|
printk(KERN_WARNING "CallcFreeChan b_st ch%d allready freed\n", i);
|
1997-10-29 19:02:01 +00:00
|
|
|
if (i || test_bit(FLG_TWO_DCHAN, &csta->HW_Flags)) {
|
1997-07-30 17:13:02 +00:00
|
|
|
release_d_st(csta->channel + i);
|
|
|
|
} else
|
|
|
|
csta->channel[i].d_st = NULL;
|
1997-01-27 23:17:44 +00:00
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-04-06 22:55:52 +00:00
|
|
|
lldata_handler(struct PStack *st, int pr, void *arg)
|
1997-01-27 16:00:38 +00:00
|
|
|
{
|
1997-07-27 21:12:21 +00:00
|
|
|
struct Channel *chanp = (struct Channel *) st->lli.userdata;
|
1997-04-06 22:55:52 +00:00
|
|
|
struct sk_buff *skb = arg;
|
1997-01-27 16:00:38 +00:00
|
|
|
|
|
|
|
switch (pr) {
|
1998-05-25 12:58:26 +00:00
|
|
|
case (DL_DATA | INDICATION):
|
1997-04-06 22:55:52 +00:00
|
|
|
if (chanp->data_open)
|
1997-07-27 21:12:21 +00:00
|
|
|
chanp->cs->iif.rcvcallb_skb(chanp->cs->myid, chanp->chan, skb);
|
1997-04-06 22:55:52 +00:00
|
|
|
else {
|
1999-07-01 08:12:15 +00:00
|
|
|
idev_kfree_skb(skb, FREE_READ);
|
1997-02-09 00:23:10 +00:00
|
|
|
}
|
|
|
|
break;
|
1998-05-25 12:58:26 +00:00
|
|
|
case (DL_ESTABLISH | INDICATION):
|
|
|
|
case (DL_ESTABLISH | CONFIRM):
|
|
|
|
FsmEvent(&chanp->fi, EV_BC_EST, NULL);
|
|
|
|
break;
|
|
|
|
case (DL_RELEASE | INDICATION):
|
|
|
|
case (DL_RELEASE | CONFIRM):
|
|
|
|
FsmEvent(&chanp->fi, EV_BC_REL, NULL);
|
|
|
|
break;
|
1997-02-09 00:23:10 +00:00
|
|
|
default:
|
1999-07-09 08:30:08 +00:00
|
|
|
printk(KERN_WARNING "lldata_handler unknown primitive %#x\n",
|
1997-02-09 00:23:10 +00:00
|
|
|
pr);
|
|
|
|
break;
|
1997-01-27 16:00:38 +00:00
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-04-06 22:55:52 +00:00
|
|
|
lltrans_handler(struct PStack *st, int pr, void *arg)
|
1997-01-27 16:00:38 +00:00
|
|
|
{
|
1997-07-27 21:12:21 +00:00
|
|
|
struct Channel *chanp = (struct Channel *) st->lli.userdata;
|
1997-04-06 22:55:52 +00:00
|
|
|
struct sk_buff *skb = arg;
|
1997-01-27 16:00:38 +00:00
|
|
|
|
|
|
|
switch (pr) {
|
1998-05-25 12:58:26 +00:00
|
|
|
case (PH_DATA | INDICATION):
|
1997-04-06 22:55:52 +00:00
|
|
|
if (chanp->data_open)
|
1997-07-27 21:12:21 +00:00
|
|
|
chanp->cs->iif.rcvcallb_skb(chanp->cs->myid, chanp->chan, skb);
|
1997-04-06 22:55:52 +00:00
|
|
|
else {
|
1998-11-15 23:55:28 +00:00
|
|
|
link_debug(chanp, 0, "channel not open");
|
1999-07-01 08:12:15 +00:00
|
|
|
idev_kfree_skb(skb, FREE_READ);
|
1997-02-09 00:23:10 +00:00
|
|
|
}
|
|
|
|
break;
|
1998-05-25 12:58:26 +00:00
|
|
|
case (PH_ACTIVATE | INDICATION):
|
|
|
|
case (PH_ACTIVATE | CONFIRM):
|
|
|
|
FsmEvent(&chanp->fi, EV_BC_EST, NULL);
|
|
|
|
break;
|
|
|
|
case (PH_DEACTIVATE | INDICATION):
|
|
|
|
case (PH_DEACTIVATE | CONFIRM):
|
|
|
|
FsmEvent(&chanp->fi, EV_BC_REL, NULL);
|
|
|
|
break;
|
1997-02-09 00:23:10 +00:00
|
|
|
default:
|
1999-07-09 08:30:08 +00:00
|
|
|
printk(KERN_WARNING "lltrans_handler unknown primitive %#x\n",
|
1997-02-09 00:23:10 +00:00
|
|
|
pr);
|
|
|
|
break;
|
1997-01-27 16:00:38 +00:00
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-10-29 19:02:01 +00:00
|
|
|
ll_writewakeup(struct PStack *st, int len)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-07-27 21:12:21 +00:00
|
|
|
struct Channel *chanp = st->lli.userdata;
|
1997-01-27 16:00:38 +00:00
|
|
|
isdn_ctrl ic;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-07-27 21:12:21 +00:00
|
|
|
ic.driver = chanp->cs->myid;
|
1997-01-27 16:00:38 +00:00
|
|
|
ic.command = ISDN_STAT_BSENT;
|
|
|
|
ic.arg = chanp->chan;
|
1999-07-01 08:12:15 +00:00
|
|
|
ic.parm.length = len;
|
1997-07-27 21:12:21 +00:00
|
|
|
chanp->cs->iif.statcallb(&ic);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-07-27 21:12:21 +00:00
|
|
|
init_b_st(struct Channel *chanp, int incoming)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-07-27 21:12:21 +00:00
|
|
|
struct PStack *st = chanp->b_st;
|
|
|
|
struct IsdnCardState *cs = chanp->cs;
|
1998-11-15 23:55:28 +00:00
|
|
|
char tmp[16];
|
1997-01-27 16:00:38 +00:00
|
|
|
|
1997-07-27 21:12:21 +00:00
|
|
|
st->l1.hardware = cs;
|
1998-08-13 23:36:54 +00:00
|
|
|
if (chanp->leased)
|
|
|
|
st->l1.bc = chanp->chan & 1;
|
|
|
|
else
|
|
|
|
st->l1.bc = chanp->proc->para.bchannel - 1;
|
1998-05-25 12:58:26 +00:00
|
|
|
switch (chanp->l2_active_protocol) {
|
|
|
|
case (ISDN_PROTO_L2_X75I):
|
|
|
|
case (ISDN_PROTO_L2_HDLC):
|
|
|
|
st->l1.mode = L1_MODE_HDLC;
|
|
|
|
break;
|
|
|
|
case (ISDN_PROTO_L2_TRANS):
|
|
|
|
st->l1.mode = L1_MODE_TRANS;
|
|
|
|
break;
|
|
|
|
case (ISDN_PROTO_L2_MODEM):
|
1999-08-05 20:43:22 +00:00
|
|
|
st->l1.mode = L1_MODE_V32;
|
1998-05-25 12:58:26 +00:00
|
|
|
break;
|
1999-08-25 17:00:09 +00:00
|
|
|
case (ISDN_PROTO_L2_FAX):
|
|
|
|
st->l1.mode = L1_MODE_FAX;
|
|
|
|
break;
|
1998-05-25 12:58:26 +00:00
|
|
|
}
|
1999-08-05 20:43:22 +00:00
|
|
|
chanp->bcs->conmsg = NULL;
|
1997-07-27 21:12:21 +00:00
|
|
|
if (chanp->bcs->BC_SetStack(st, chanp->bcs))
|
1997-01-27 16:00:38 +00:00
|
|
|
return (-1);
|
1997-10-29 19:02:01 +00:00
|
|
|
st->l2.flag = 0;
|
|
|
|
test_and_set_bit(FLG_LAPB, &st->l2.flag);
|
|
|
|
st->l2.maxlen = MAX_DATA_SIZE;
|
|
|
|
if (!incoming)
|
|
|
|
test_and_set_bit(FLG_ORIG, &st->l2.flag);
|
1997-07-27 21:12:21 +00:00
|
|
|
st->l2.T200 = 1000; /* 1000 milliseconds */
|
1997-01-27 16:00:38 +00:00
|
|
|
st->l2.window = 7;
|
1997-07-27 21:12:21 +00:00
|
|
|
st->l2.N200 = 4; /* try 4 times */
|
|
|
|
st->l2.T203 = 5000; /* 5000 milliseconds */
|
1997-02-09 00:23:10 +00:00
|
|
|
st->l3.debug = 0;
|
|
|
|
switch (chanp->l2_active_protocol) {
|
|
|
|
case (ISDN_PROTO_L2_X75I):
|
1998-05-25 14:08:10 +00:00
|
|
|
sprintf(tmp, "Ch%d X.75", chanp->chan);
|
1997-02-09 00:23:10 +00:00
|
|
|
setstack_isdnl2(st, tmp);
|
1998-05-25 12:58:26 +00:00
|
|
|
setstack_l3bc(st, chanp);
|
1997-02-09 00:23:10 +00:00
|
|
|
st->l2.l2l3 = lldata_handler;
|
1997-07-27 21:12:21 +00:00
|
|
|
st->lli.userdata = chanp;
|
|
|
|
st->lli.l1writewakeup = NULL;
|
|
|
|
st->lli.l2writewakeup = ll_writewakeup;
|
1997-02-09 00:23:10 +00:00
|
|
|
st->l2.l2m.debug = chanp->debug & 16;
|
|
|
|
st->l2.debug = chanp->debug & 64;
|
|
|
|
break;
|
|
|
|
case (ISDN_PROTO_L2_HDLC):
|
|
|
|
case (ISDN_PROTO_L2_TRANS):
|
1999-07-01 08:12:15 +00:00
|
|
|
case (ISDN_PROTO_L2_MODEM):
|
1999-08-25 17:00:09 +00:00
|
|
|
case (ISDN_PROTO_L2_FAX):
|
1997-02-09 00:23:10 +00:00
|
|
|
st->l1.l1l2 = lltrans_handler;
|
1997-07-27 21:12:21 +00:00
|
|
|
st->lli.userdata = chanp;
|
|
|
|
st->lli.l1writewakeup = ll_writewakeup;
|
1998-05-25 12:58:26 +00:00
|
|
|
setstack_transl2(st);
|
|
|
|
setstack_l3bc(st, chanp);
|
1997-02-09 00:23:10 +00:00
|
|
|
break;
|
1997-01-27 16:00:38 +00:00
|
|
|
}
|
1999-08-25 17:00:09 +00:00
|
|
|
test_and_set_bit(FLG_START_B, &chanp->Flags);
|
1997-01-27 16:00:38 +00:00
|
|
|
return (0);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1998-05-25 14:08:10 +00:00
|
|
|
static void
|
|
|
|
leased_l4l3(struct PStack *st, int pr, void *arg)
|
|
|
|
{
|
|
|
|
struct Channel *chanp = (struct Channel *) st->lli.userdata;
|
|
|
|
struct sk_buff *skb = arg;
|
|
|
|
|
|
|
|
switch (pr) {
|
|
|
|
case (DL_DATA | REQUEST):
|
1998-11-15 23:55:28 +00:00
|
|
|
link_debug(chanp, 0, "leased line d-channel DATA");
|
1999-07-01 08:12:15 +00:00
|
|
|
idev_kfree_skb(skb, FREE_READ);
|
1998-05-25 14:08:10 +00:00
|
|
|
break;
|
|
|
|
case (DL_ESTABLISH | REQUEST):
|
|
|
|
st->l2.l2l1(st, PH_ACTIVATE | REQUEST, NULL);
|
|
|
|
break;
|
|
|
|
case (DL_RELEASE | REQUEST):
|
|
|
|
break;
|
|
|
|
default:
|
1999-07-09 08:30:08 +00:00
|
|
|
printk(KERN_WARNING "transd_l4l3 unknown primitive %#x\n",
|
1998-05-25 14:08:10 +00:00
|
|
|
pr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
leased_l1l2(struct PStack *st, int pr, void *arg)
|
|
|
|
{
|
|
|
|
struct Channel *chanp = (struct Channel *) st->lli.userdata;
|
|
|
|
struct sk_buff *skb = arg;
|
1999-07-01 08:12:15 +00:00
|
|
|
int i,event = EV_LEASED_REL;
|
1998-05-25 14:08:10 +00:00
|
|
|
|
|
|
|
switch (pr) {
|
|
|
|
case (PH_DATA | INDICATION):
|
1998-11-15 23:55:28 +00:00
|
|
|
link_debug(chanp, 0, "leased line d-channel DATA");
|
1999-07-01 08:12:15 +00:00
|
|
|
idev_kfree_skb(skb, FREE_READ);
|
1998-05-25 14:08:10 +00:00
|
|
|
break;
|
|
|
|
case (PH_ACTIVATE | INDICATION):
|
|
|
|
case (PH_ACTIVATE | CONFIRM):
|
1999-07-01 08:12:15 +00:00
|
|
|
event = EV_LEASED;
|
1998-05-25 14:08:10 +00:00
|
|
|
case (PH_DEACTIVATE | INDICATION):
|
|
|
|
case (PH_DEACTIVATE | CONFIRM):
|
|
|
|
if (test_bit(FLG_TWO_DCHAN, &chanp->cs->HW_Flags))
|
|
|
|
i = 1;
|
|
|
|
else
|
|
|
|
i = 0;
|
|
|
|
while (i < 2) {
|
|
|
|
FsmEvent(&chanp->fi, event, NULL);
|
|
|
|
chanp++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printk(KERN_WARNING
|
1999-07-09 08:30:08 +00:00
|
|
|
"transd_l1l2 unknown primitive %#x\n", pr);
|
1998-05-25 14:08:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-10-13 20:04:59 +00:00
|
|
|
static void
|
1997-02-09 00:23:10 +00:00
|
|
|
distr_debug(struct IsdnCardState *csta, int debugflags)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-01-27 16:00:38 +00:00
|
|
|
int i;
|
1997-02-09 00:23:10 +00:00
|
|
|
struct Channel *chanp = csta->channel;
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
for (i = 0; i < (2 + MAX_WAITING_CALLS) ; i++) {
|
1997-02-09 00:23:10 +00:00
|
|
|
chanp[i].debug = debugflags;
|
|
|
|
chanp[i].fi.debug = debugflags & 2;
|
1997-07-27 21:12:21 +00:00
|
|
|
chanp[i].d_st->l2.l2m.debug = debugflags & 8;
|
1997-10-29 19:02:01 +00:00
|
|
|
chanp[i].b_st->l2.l2m.debug = debugflags & 0x10;
|
|
|
|
chanp[i].d_st->l2.debug = debugflags & 0x20;
|
|
|
|
chanp[i].b_st->l2.debug = debugflags & 0x40;
|
1998-05-25 12:58:26 +00:00
|
|
|
chanp[i].d_st->l3.l3m.debug = debugflags & 0x80;
|
|
|
|
chanp[i].b_st->l3.l3m.debug = debugflags & 0x100;
|
1997-10-29 19:02:01 +00:00
|
|
|
chanp[i].b_st->ma.tei_m.debug = debugflags & 0x200;
|
|
|
|
chanp[i].b_st->ma.debug = debugflags & 0x200;
|
|
|
|
chanp[i].d_st->l1.l1m.debug = debugflags & 0x1000;
|
1998-11-15 23:55:28 +00:00
|
|
|
chanp[i].b_st->l1.l1m.debug = debugflags & 0x2000;
|
1997-01-27 16:00:38 +00:00
|
|
|
}
|
1998-11-15 23:55:28 +00:00
|
|
|
if (debugflags & 4)
|
|
|
|
csta->debug |= DEB_DLOG_HEX;
|
|
|
|
else
|
|
|
|
csta->debug &= ~DEB_DLOG_HEX;
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1998-11-15 23:55:28 +00:00
|
|
|
static char tmpbuf[256];
|
|
|
|
|
1998-03-19 13:18:57 +00:00
|
|
|
static void
|
|
|
|
capi_debug(struct Channel *chanp, capi_msg *cm)
|
|
|
|
{
|
1998-11-15 23:55:28 +00:00
|
|
|
char *t = tmpbuf;
|
1998-03-19 13:18:57 +00:00
|
|
|
|
|
|
|
t += QuickHex(t, (u_char *)cm, (cm->Length>50)? 50: cm->Length);
|
|
|
|
t--;
|
1998-11-15 23:55:28 +00:00
|
|
|
*t= 0;
|
|
|
|
HiSax_putstatus(chanp->cs, "Ch", "%d CAPIMSG %s", chanp->chan, tmpbuf);
|
1998-03-19 13:18:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
lli_got_fac_req(struct Channel *chanp, capi_msg *cm) {
|
|
|
|
if ((cm->para[0] != 3) || (cm->para[1] != 0))
|
|
|
|
return;
|
|
|
|
if (cm->para[2]<3)
|
|
|
|
return;
|
|
|
|
if (cm->para[4] != 0)
|
|
|
|
return;
|
|
|
|
switch(cm->para[3]) {
|
|
|
|
case 4: /* Suspend */
|
1999-10-11 22:16:27 +00:00
|
|
|
strncpy(chanp->setup.phone, &cm->para[5], cm->para[5] +1);
|
|
|
|
FsmEvent(&chanp->fi, EV_SUSPEND, cm);
|
1998-03-19 13:18:57 +00:00
|
|
|
break;
|
1998-04-15 16:46:06 +00:00
|
|
|
case 5: /* Resume */
|
1999-10-11 22:16:27 +00:00
|
|
|
strncpy(chanp->setup.phone, &cm->para[5], cm->para[5] +1);
|
|
|
|
if (chanp->fi.state == ST_NULL) {
|
|
|
|
FsmEvent(&chanp->fi, EV_RESUME, cm);
|
|
|
|
} else {
|
|
|
|
FsmDelTimer(&chanp->dial_timer, 72);
|
|
|
|
FsmAddTimer(&chanp->dial_timer, 80, EV_RESUME, cm, 73);
|
1998-04-15 16:46:06 +00:00
|
|
|
}
|
|
|
|
break;
|
1998-03-19 13:18:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-05-25 12:58:26 +00:00
|
|
|
void
|
|
|
|
lli_got_manufacturer(struct Channel *chanp, struct IsdnCardState *cs, capi_msg *cm) {
|
|
|
|
if ((cs->typ == ISDN_CTYPE_ELSA) || (cs->typ == ISDN_CTYPE_ELSA_PNP) ||
|
|
|
|
(cs->typ == ISDN_CTYPE_ELSA_PCI)) {
|
|
|
|
if (cs->hw.elsa.MFlag) {
|
|
|
|
cs->cardmsg(cs, CARD_AUX_IND, cm->para);
|
|
|
|
}
|
1998-11-15 23:55:28 +00:00
|
|
|
}
|
1998-05-25 12:58:26 +00:00
|
|
|
}
|
|
|
|
|
1999-07-05 23:51:46 +00:00
|
|
|
|
|
|
|
/***************************************************************/
|
|
|
|
/* Limit the available number of channels for the current card */
|
|
|
|
/***************************************************************/
|
|
|
|
static int
|
|
|
|
set_channel_limit(struct IsdnCardState *cs, int chanmax)
|
1999-08-25 17:00:09 +00:00
|
|
|
{
|
|
|
|
isdn_ctrl ic;
|
|
|
|
int i, ii;
|
|
|
|
|
|
|
|
if ((chanmax < 0) || (chanmax > 2))
|
|
|
|
return(-EINVAL);
|
|
|
|
cs->chanlimit = 0;
|
|
|
|
for (ii = 0; ii < 2; ii++) {
|
|
|
|
ic.driver = cs->myid;
|
|
|
|
ic.command = ISDN_STAT_DISCH;
|
|
|
|
ic.arg = ii;
|
|
|
|
if (ii >= chanmax)
|
|
|
|
ic.parm.num[0] = 0; /* disabled */
|
|
|
|
else
|
|
|
|
ic.parm.num[0] = 1; /* enabled */
|
|
|
|
i = cs->iif.statcallb(&ic);
|
|
|
|
if (i) return(-EINVAL);
|
|
|
|
if (ii < chanmax)
|
|
|
|
cs->chanlimit++;
|
|
|
|
}
|
|
|
|
return(0);
|
1999-07-05 23:51:46 +00:00
|
|
|
} /* set_channel_limit */
|
|
|
|
|
1996-10-13 20:04:59 +00:00
|
|
|
int
|
|
|
|
HiSax_command(isdn_ctrl * ic)
|
|
|
|
{
|
1997-02-09 00:23:10 +00:00
|
|
|
struct IsdnCardState *csta = hisax_findcard(ic->driver);
|
1999-07-01 08:12:15 +00:00
|
|
|
struct PStack *st;
|
1997-01-27 16:00:38 +00:00
|
|
|
struct Channel *chanp;
|
|
|
|
int i;
|
1998-08-13 23:36:54 +00:00
|
|
|
u_int num;
|
1997-01-27 16:00:38 +00:00
|
|
|
|
1997-02-09 00:23:10 +00:00
|
|
|
if (!csta) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"HiSax: if_command %d called with invalid driverId %d!\n",
|
|
|
|
ic->command, ic->driver);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
1997-01-27 16:00:38 +00:00
|
|
|
switch (ic->command) {
|
1997-02-09 00:23:10 +00:00
|
|
|
case (ISDN_CMD_SETEAZ):
|
|
|
|
chanp = csta->channel + ic->arg;
|
1997-01-27 16:00:38 +00:00
|
|
|
break;
|
1997-02-09 00:23:10 +00:00
|
|
|
case (ISDN_CMD_SETL2):
|
|
|
|
chanp = csta->channel + (ic->arg & 0xff);
|
1998-11-15 23:55:28 +00:00
|
|
|
if (chanp->debug & 1)
|
|
|
|
link_debug(chanp, 1, "SETL2 card %d %ld",
|
|
|
|
csta->cardnr + 1, ic->arg >> 8);
|
1997-02-09 00:23:10 +00:00
|
|
|
chanp->l2_protocol = ic->arg >> 8;
|
1998-08-20 13:50:42 +00:00
|
|
|
break;
|
|
|
|
case (ISDN_CMD_SETL3):
|
|
|
|
chanp = csta->channel + (ic->arg & 0xff);
|
1998-11-15 23:55:28 +00:00
|
|
|
if (chanp->debug & 1)
|
|
|
|
link_debug(chanp, 1, "SETL3 card %d %ld",
|
|
|
|
csta->cardnr + 1, ic->arg >> 8);
|
1998-08-20 13:50:42 +00:00
|
|
|
chanp->l3_protocol = ic->arg >> 8;
|
1997-01-27 16:00:38 +00:00
|
|
|
break;
|
1997-02-09 00:23:10 +00:00
|
|
|
case (ISDN_CMD_DIAL):
|
|
|
|
chanp = csta->channel + (ic->arg & 0xff);
|
1998-11-15 23:55:28 +00:00
|
|
|
if (chanp->debug & 1)
|
|
|
|
link_debug(chanp, 1, "DIAL %s -> %s (%d,%d)",
|
1997-02-11 01:36:58 +00:00
|
|
|
ic->parm.setup.eazmsn, ic->parm.setup.phone,
|
1998-08-13 23:36:54 +00:00
|
|
|
ic->parm.setup.si1, ic->parm.setup.si2);
|
1997-07-27 21:12:21 +00:00
|
|
|
chanp->setup = ic->parm.setup;
|
|
|
|
if (!strcmp(chanp->setup.eazmsn, "0"))
|
|
|
|
chanp->setup.eazmsn[0] = '\0';
|
1997-02-09 00:23:10 +00:00
|
|
|
/* this solution is dirty and may be change, if
|
|
|
|
* we make a callreference based callmanager */
|
|
|
|
if (chanp->fi.state == ST_NULL) {
|
1997-03-04 23:07:42 +00:00
|
|
|
FsmEvent(&chanp->fi, EV_DIAL, NULL);
|
1997-02-09 00:23:10 +00:00
|
|
|
} else {
|
|
|
|
FsmDelTimer(&chanp->dial_timer, 70);
|
1997-03-04 23:07:42 +00:00
|
|
|
FsmAddTimer(&chanp->dial_timer, 50, EV_DIAL, NULL, 71);
|
1997-01-27 16:00:38 +00:00
|
|
|
}
|
|
|
|
break;
|
1997-02-09 00:23:10 +00:00
|
|
|
case (ISDN_CMD_ACCEPTB):
|
|
|
|
chanp = csta->channel + ic->arg;
|
|
|
|
if (chanp->debug & 1)
|
1998-11-15 23:55:28 +00:00
|
|
|
link_debug(chanp, 1, "ACCEPTB");
|
1997-02-09 00:23:10 +00:00
|
|
|
FsmEvent(&chanp->fi, EV_ACCEPTB, NULL);
|
1997-01-27 16:00:38 +00:00
|
|
|
break;
|
1997-02-09 00:23:10 +00:00
|
|
|
case (ISDN_CMD_ACCEPTD):
|
|
|
|
chanp = csta->channel + ic->arg;
|
|
|
|
if (chanp->debug & 1)
|
1998-11-15 23:55:28 +00:00
|
|
|
link_debug(chanp, 1, "ACCEPTD");
|
1997-02-09 00:23:10 +00:00
|
|
|
FsmEvent(&chanp->fi, EV_ACCEPTD, NULL);
|
1997-01-27 16:00:38 +00:00
|
|
|
break;
|
1997-02-09 00:23:10 +00:00
|
|
|
case (ISDN_CMD_HANGUP):
|
|
|
|
chanp = csta->channel + ic->arg;
|
|
|
|
if (chanp->debug & 1)
|
1998-11-15 23:55:28 +00:00
|
|
|
link_debug(chanp, 1, "HANGUP");
|
1997-02-09 00:23:10 +00:00
|
|
|
FsmEvent(&chanp->fi, EV_HANGUP, NULL);
|
1997-01-27 16:00:38 +00:00
|
|
|
break;
|
1998-03-19 13:18:57 +00:00
|
|
|
case (CAPI_PUT_MESSAGE):
|
1997-02-09 00:23:10 +00:00
|
|
|
chanp = csta->channel + ic->arg;
|
1998-03-19 13:18:57 +00:00
|
|
|
if (chanp->debug & 1)
|
|
|
|
capi_debug(chanp, &ic->parm.cmsg);
|
|
|
|
if (ic->parm.cmsg.Length < 8)
|
|
|
|
break;
|
|
|
|
switch(ic->parm.cmsg.Command) {
|
|
|
|
case CAPI_FACILITY:
|
|
|
|
if (ic->parm.cmsg.Subcommand == CAPI_REQ)
|
|
|
|
lli_got_fac_req(chanp, &ic->parm.cmsg);
|
|
|
|
break;
|
1998-05-25 12:58:26 +00:00
|
|
|
case CAPI_MANUFACTURER:
|
|
|
|
if (ic->parm.cmsg.Subcommand == CAPI_REQ)
|
|
|
|
lli_got_manufacturer(chanp, csta, &ic->parm.cmsg);
|
|
|
|
break;
|
1998-03-19 13:18:57 +00:00
|
|
|
default:
|
1998-05-25 12:58:26 +00:00
|
|
|
break;
|
1997-01-27 16:00:38 +00:00
|
|
|
}
|
|
|
|
break;
|
1997-02-09 00:23:10 +00:00
|
|
|
case (ISDN_CMD_LOCK):
|
|
|
|
HiSax_mod_inc_use_count();
|
|
|
|
#ifdef MODULE
|
1998-11-15 23:55:28 +00:00
|
|
|
if (csta->channel[0].debug & 0x400)
|
1999-07-01 08:12:15 +00:00
|
|
|
HiSax_putstatus(csta, " LOCK ", "modcnt %lx",
|
1998-11-15 23:55:28 +00:00
|
|
|
MOD_USE_COUNT);
|
1997-02-09 00:23:10 +00:00
|
|
|
#endif /* MODULE */
|
|
|
|
break;
|
|
|
|
case (ISDN_CMD_UNLOCK):
|
|
|
|
HiSax_mod_dec_use_count();
|
|
|
|
#ifdef MODULE
|
1998-11-15 23:55:28 +00:00
|
|
|
if (csta->channel[0].debug & 0x400)
|
1999-07-01 08:12:15 +00:00
|
|
|
HiSax_putstatus(csta, " UNLOCK ", "modcnt %lx",
|
1998-11-15 23:55:28 +00:00
|
|
|
MOD_USE_COUNT);
|
1997-02-09 00:23:10 +00:00
|
|
|
#endif /* MODULE */
|
|
|
|
break;
|
|
|
|
case (ISDN_CMD_IOCTL):
|
|
|
|
switch (ic->arg) {
|
|
|
|
case (0):
|
1999-10-14 20:25:29 +00:00
|
|
|
num = *(unsigned int *) ic->parm.num;
|
|
|
|
HiSax_reportcard(csta->cardnr, num);
|
1997-02-09 00:23:10 +00:00
|
|
|
break;
|
|
|
|
case (1):
|
1997-02-11 01:36:58 +00:00
|
|
|
num = *(unsigned int *) ic->parm.num;
|
1997-02-09 00:23:10 +00:00
|
|
|
distr_debug(csta, num);
|
1998-11-15 23:55:28 +00:00
|
|
|
printk(KERN_DEBUG "HiSax: debugging flags card %d set to %x\n",
|
1997-02-09 00:23:10 +00:00
|
|
|
csta->cardnr + 1, num);
|
1998-11-15 23:55:28 +00:00
|
|
|
HiSax_putstatus(csta, "debugging flags ",
|
|
|
|
"card %d set to %x", csta->cardnr + 1, num);
|
1997-02-09 00:23:10 +00:00
|
|
|
break;
|
1998-02-02 13:35:19 +00:00
|
|
|
case (2):
|
1998-11-15 23:55:28 +00:00
|
|
|
num = *(unsigned int *) ic->parm.num;
|
1998-05-25 12:58:26 +00:00
|
|
|
csta->channel[0].b_st->l1.delay = num;
|
|
|
|
csta->channel[1].b_st->l1.delay = num;
|
1998-11-15 23:55:28 +00:00
|
|
|
HiSax_putstatus(csta, "delay ", "card %d set to %d ms",
|
|
|
|
csta->cardnr + 1, num);
|
|
|
|
printk(KERN_DEBUG "HiSax: delay card %d set to %d ms\n",
|
1998-02-02 13:35:19 +00:00
|
|
|
csta->cardnr + 1, num);
|
|
|
|
break;
|
1997-02-09 00:23:10 +00:00
|
|
|
case (3):
|
1997-02-11 01:36:58 +00:00
|
|
|
for (i = 0; i < *(unsigned int *) ic->parm.num; i++)
|
1997-02-09 00:23:10 +00:00
|
|
|
HiSax_mod_dec_use_count();
|
|
|
|
break;
|
|
|
|
case (4):
|
1997-02-11 01:36:58 +00:00
|
|
|
for (i = 0; i < *(unsigned int *) ic->parm.num; i++)
|
1997-02-09 00:23:10 +00:00
|
|
|
HiSax_mod_inc_use_count();
|
|
|
|
break;
|
|
|
|
case (5): /* set card in leased mode */
|
1998-02-09 10:56:02 +00:00
|
|
|
num = *(unsigned int *) ic->parm.num;
|
|
|
|
if ((num <1) || (num > 2)) {
|
1998-11-15 23:55:28 +00:00
|
|
|
HiSax_putstatus(csta, "Set LEASED ",
|
|
|
|
"wrong channel %d", num);
|
|
|
|
printk(KERN_WARNING "HiSax: Set LEASED wrong channel %d\n",
|
1998-02-09 10:56:02 +00:00
|
|
|
num);
|
|
|
|
} else {
|
|
|
|
num--;
|
1998-05-25 12:58:26 +00:00
|
|
|
chanp = csta->channel +num;
|
|
|
|
chanp->leased = 1;
|
1998-11-15 23:55:28 +00:00
|
|
|
HiSax_putstatus(csta, "Card",
|
|
|
|
"%d channel %d set leased mode\n",
|
1998-02-09 10:56:02 +00:00
|
|
|
csta->cardnr + 1, num + 1);
|
1998-05-25 14:08:10 +00:00
|
|
|
chanp->d_st->l1.l1l2 = leased_l1l2;
|
|
|
|
chanp->d_st->lli.l4l3 = leased_l4l3;
|
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st,
|
|
|
|
DL_ESTABLISH | REQUEST, NULL);
|
1998-02-09 10:56:02 +00:00
|
|
|
}
|
1997-02-09 00:23:10 +00:00
|
|
|
break;
|
1997-07-27 21:12:21 +00:00
|
|
|
case (6): /* set B-channel test loop */
|
|
|
|
num = *(unsigned int *) ic->parm.num;
|
|
|
|
if (csta->stlist)
|
1998-05-25 12:58:26 +00:00
|
|
|
csta->stlist->l2.l2l1(csta->stlist,
|
|
|
|
PH_TESTLOOP | REQUEST, (void *) (long)num);
|
1997-07-27 21:12:21 +00:00
|
|
|
break;
|
1998-05-25 14:08:10 +00:00
|
|
|
case (7): /* set card in PTP mode */
|
1998-08-13 23:36:54 +00:00
|
|
|
num = *(unsigned int *) ic->parm.num;
|
1998-05-25 14:08:10 +00:00
|
|
|
if (test_bit(FLG_TWO_DCHAN, &csta->HW_Flags)) {
|
|
|
|
printk(KERN_ERR "HiSax PTP mode only with one TEI possible\n");
|
1998-08-13 23:36:54 +00:00
|
|
|
} else if (num) {
|
1998-05-25 14:08:10 +00:00
|
|
|
test_and_set_bit(FLG_PTP, &csta->channel[0].d_st->l2.flag);
|
|
|
|
test_and_set_bit(FLG_FIXED_TEI, &csta->channel[0].d_st->l2.flag);
|
|
|
|
csta->channel[0].d_st->l2.tei = 0;
|
1998-11-15 23:55:28 +00:00
|
|
|
HiSax_putstatus(csta, "set card ", "in PTP mode");
|
|
|
|
printk(KERN_DEBUG "HiSax: set card in PTP mode\n");
|
1998-08-13 23:36:54 +00:00
|
|
|
printk(KERN_INFO "LAYER2 WATCHING ESTABLISH\n");
|
|
|
|
csta->channel[0].d_st->lli.l4l3(csta->channel[0].d_st,
|
|
|
|
DL_ESTABLISH | REQUEST, NULL);
|
|
|
|
} else {
|
|
|
|
test_and_clear_bit(FLG_PTP, &csta->channel[0].d_st->l2.flag);
|
|
|
|
test_and_clear_bit(FLG_FIXED_TEI, &csta->channel[0].d_st->l2.flag);
|
1998-11-15 23:55:28 +00:00
|
|
|
HiSax_putstatus(csta, "set card ", "in PTMP mode");
|
|
|
|
printk(KERN_DEBUG "HiSax: set card in PTMP mode\n");
|
1998-05-25 14:08:10 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case (8): /* set card in FIXED TEI mode */
|
|
|
|
num = *(unsigned int *) ic->parm.num;
|
|
|
|
chanp = csta->channel + (num & 1);
|
|
|
|
num = num >>1;
|
|
|
|
test_and_set_bit(FLG_FIXED_TEI, &chanp->d_st->l2.flag);
|
|
|
|
chanp->d_st->l2.tei = num;
|
1998-11-15 23:55:28 +00:00
|
|
|
HiSax_putstatus(csta, "set card ", "in FIXED TEI (%d) mode", num);
|
|
|
|
printk(KERN_DEBUG "HiSax: set card in FIXED TEI (%d) mode\n",
|
|
|
|
num);
|
1999-07-25 16:24:04 +00:00
|
|
|
chanp->d_st->lli.l4l3(chanp->d_st,
|
|
|
|
DL_ESTABLISH | REQUEST, NULL);
|
1998-05-25 14:08:10 +00:00
|
|
|
break;
|
1997-02-09 00:23:10 +00:00
|
|
|
#ifdef MODULE
|
|
|
|
case (55):
|
1999-07-01 08:12:15 +00:00
|
|
|
MOD_USE_COUNT = 0;
|
1997-02-09 00:23:10 +00:00
|
|
|
HiSax_mod_inc_use_count();
|
|
|
|
break;
|
|
|
|
#endif /* MODULE */
|
|
|
|
case (11):
|
1998-11-15 23:55:28 +00:00
|
|
|
num = csta->debug & DEB_DLOG_HEX;
|
1997-02-11 01:36:58 +00:00
|
|
|
csta->debug = *(unsigned int *) ic->parm.num;
|
1998-11-15 23:55:28 +00:00
|
|
|
csta->debug |= num;
|
|
|
|
HiSax_putstatus(cards[0].cs, "l1 debugging ",
|
|
|
|
"flags card %d set to %x",
|
|
|
|
csta->cardnr + 1, csta->debug);
|
|
|
|
printk(KERN_DEBUG "HiSax: l1 debugging flags card %d set to %x\n",
|
1997-10-29 19:02:01 +00:00
|
|
|
csta->cardnr + 1, csta->debug);
|
1997-02-09 00:23:10 +00:00
|
|
|
break;
|
|
|
|
case (13):
|
1997-07-27 21:12:21 +00:00
|
|
|
csta->channel[0].d_st->l3.debug = *(unsigned int *) ic->parm.num;
|
|
|
|
csta->channel[1].d_st->l3.debug = *(unsigned int *) ic->parm.num;
|
1998-11-15 23:55:28 +00:00
|
|
|
HiSax_putstatus(cards[0].cs, "l3 debugging ",
|
|
|
|
"flags card %d set to %x\n", csta->cardnr + 1,
|
|
|
|
*(unsigned int *) ic->parm.num);
|
|
|
|
printk(KERN_DEBUG "HiSax: l3 debugging flags card %d set to %x\n",
|
1997-02-11 01:36:58 +00:00
|
|
|
csta->cardnr + 1, *(unsigned int *) ic->parm.num);
|
1997-02-09 00:23:10 +00:00
|
|
|
break;
|
1999-08-25 17:00:09 +00:00
|
|
|
case (10):
|
|
|
|
i = *(unsigned int *) ic->parm.num;
|
1999-07-05 23:51:46 +00:00
|
|
|
return(set_channel_limit(csta, i));
|
1997-02-09 00:23:10 +00:00
|
|
|
default:
|
1999-08-25 17:00:09 +00:00
|
|
|
if (csta->auxcmd)
|
|
|
|
return(csta->auxcmd(csta, ic));
|
1997-02-09 00:23:10 +00:00
|
|
|
printk(KERN_DEBUG "HiSax: invalid ioclt %d\n",
|
|
|
|
(int) ic->arg);
|
|
|
|
return (-EINVAL);
|
1997-01-27 16:00:38 +00:00
|
|
|
}
|
|
|
|
break;
|
1999-07-01 08:12:15 +00:00
|
|
|
|
|
|
|
case (ISDN_CMD_PROCEED):
|
|
|
|
chanp = csta->channel + ic->arg;
|
|
|
|
if (chanp->debug & 1)
|
|
|
|
link_debug(chanp, 1, "PROCEED");
|
|
|
|
FsmEvent(&chanp->fi, EV_PROCEED, NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (ISDN_CMD_ALERT):
|
|
|
|
chanp = csta->channel + ic->arg;
|
|
|
|
if (chanp->debug & 1)
|
|
|
|
link_debug(chanp, 1, "ALERT");
|
|
|
|
FsmEvent(&chanp->fi, EV_ALERT, NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (ISDN_CMD_REDIR):
|
|
|
|
chanp = csta->channel + ic->arg;
|
|
|
|
if (chanp->debug & 1)
|
|
|
|
link_debug(chanp, 1, "REDIR");
|
|
|
|
chanp->setup = ic->parm.setup;
|
|
|
|
FsmEvent(&chanp->fi, EV_REDIR, NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* protocol specific io commands */
|
|
|
|
case (ISDN_CMD_PROT_IO):
|
|
|
|
for (st = csta->stlist; st; st = st->next)
|
|
|
|
if (st->protocol == (ic->arg & 0xFF))
|
|
|
|
return(st->lli.l4l3_proto(st, ic));
|
|
|
|
return(-EINVAL);
|
|
|
|
break;
|
1997-01-27 16:00:38 +00:00
|
|
|
default:
|
1999-08-25 17:00:09 +00:00
|
|
|
if (csta->auxcmd)
|
|
|
|
return(csta->auxcmd(csta, ic));
|
|
|
|
return(-EINVAL);
|
1997-01-27 16:00:38 +00:00
|
|
|
}
|
|
|
|
return (0);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1997-10-10 20:56:50 +00:00
|
|
|
HiSax_writebuf_skb(int id, int chan, int ack, struct sk_buff *skb)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-02-09 00:23:10 +00:00
|
|
|
struct IsdnCardState *csta = hisax_findcard(id);
|
|
|
|
struct Channel *chanp;
|
|
|
|
struct PStack *st;
|
1997-04-06 22:55:52 +00:00
|
|
|
int len = skb->len;
|
|
|
|
unsigned long flags;
|
|
|
|
struct sk_buff *nskb;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-02-09 00:23:10 +00:00
|
|
|
if (!csta) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"HiSax: if_sendbuf called with invalid driverId!\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
chanp = csta->channel + chan;
|
1997-07-27 21:12:21 +00:00
|
|
|
st = chanp->b_st;
|
1996-10-13 20:04:59 +00:00
|
|
|
if (!chanp->data_open) {
|
1998-11-15 23:55:28 +00:00
|
|
|
link_debug(chanp, 1, "writebuf: channel not open");
|
1996-10-13 20:04:59 +00:00
|
|
|
return -EIO;
|
|
|
|
}
|
1997-04-06 22:55:52 +00:00
|
|
|
if (len > MAX_DATA_SIZE) {
|
1998-11-15 23:55:28 +00:00
|
|
|
link_debug(chanp, 1, "writebuf: packet too large (%d bytes)", len);
|
|
|
|
printk(KERN_WARNING "HiSax_writebuf: packet too large (%d bytes) !\n",
|
|
|
|
len);
|
1997-04-06 22:55:52 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
if (len) {
|
1997-07-27 21:12:21 +00:00
|
|
|
if ((len + chanp->bcs->tx_cnt) > MAX_DATA_MEM) {
|
1997-04-06 22:55:52 +00:00
|
|
|
/* Must return 0 here, since this is not an error
|
|
|
|
* but a temporary lack of resources.
|
|
|
|
*/
|
1998-11-15 23:55:28 +00:00
|
|
|
if (chanp->debug & 0x800)
|
|
|
|
link_debug(chanp, 1, "writebuf: no buffers for %d bytes", len);
|
1997-04-06 22:55:52 +00:00
|
|
|
return 0;
|
1999-07-01 08:12:15 +00:00
|
|
|
} else if (chanp->debug & 0x800)
|
|
|
|
link_debug(chanp, 1, "writebuf %d/%d/%d", len, chanp->bcs->tx_cnt,MAX_DATA_MEM);
|
1997-04-06 22:55:52 +00:00
|
|
|
save_flags(flags);
|
|
|
|
cli();
|
|
|
|
nskb = skb_clone(skb, GFP_ATOMIC);
|
|
|
|
if (nskb) {
|
1997-10-29 19:02:01 +00:00
|
|
|
if (!ack)
|
|
|
|
nskb->pkt_type = PACKET_NOACK;
|
1998-05-25 12:58:26 +00:00
|
|
|
if (chanp->l2_active_protocol == ISDN_PROTO_L2_X75I)
|
|
|
|
st->l3.l3l2(st, DL_DATA | REQUEST, nskb);
|
1997-07-27 21:12:21 +00:00
|
|
|
else {
|
|
|
|
chanp->bcs->tx_cnt += len;
|
1998-05-25 12:58:26 +00:00
|
|
|
st->l2.l2l1(st, PH_DATA | REQUEST, nskb);
|
1997-04-13 19:55:21 +00:00
|
|
|
}
|
1999-07-01 08:12:15 +00:00
|
|
|
idev_kfree_skb(skb, FREE_WRITE);
|
1997-04-06 22:55:52 +00:00
|
|
|
} else
|
|
|
|
len = 0;
|
|
|
|
restore_flags(flags);
|
1997-01-27 16:00:38 +00:00
|
|
|
}
|
1997-04-06 22:55:52 +00:00
|
|
|
return (len);
|
1997-01-27 16:00:38 +00:00
|
|
|
}
|