diff options
Diffstat (limited to 'drivers/isdn')
-rw-r--r-- | drivers/isdn/Config.in | 1 | ||||
-rw-r--r-- | drivers/isdn/Makefile | 12 | ||||
-rw-r--r-- | drivers/isdn/hisax/.cvsignore | 1 | ||||
-rw-r--r-- | drivers/isdn/hisax/isdnl1.c | 10 | ||||
-rw-r--r-- | drivers/isdn/isdn_net.c | 2 | ||||
-rw-r--r-- | drivers/isdn/sc/Makefile | 2 | ||||
-rw-r--r-- | drivers/isdn/teles/Makefile | 17 | ||||
-rw-r--r-- | drivers/isdn/teles/buffers.c | 329 | ||||
-rw-r--r-- | drivers/isdn/teles/callc.c | 1453 | ||||
-rw-r--r-- | drivers/isdn/teles/card.c | 1900 | ||||
-rw-r--r-- | drivers/isdn/teles/config.c | 48 | ||||
-rw-r--r-- | drivers/isdn/teles/fsm.c | 156 | ||||
-rw-r--r-- | drivers/isdn/teles/isdnl2.c | 1320 | ||||
-rw-r--r-- | drivers/isdn/teles/isdnl3.c | 673 | ||||
-rw-r--r-- | drivers/isdn/teles/l3_1TR6.c | 538 | ||||
-rw-r--r-- | drivers/isdn/teles/l3_1TR6.h | 160 | ||||
-rw-r--r-- | drivers/isdn/teles/llglue.c | 151 | ||||
-rw-r--r-- | drivers/isdn/teles/mod.c | 160 | ||||
-rw-r--r-- | drivers/isdn/teles/proto.h | 18 | ||||
-rw-r--r-- | drivers/isdn/teles/q931.c | 1155 | ||||
-rw-r--r-- | drivers/isdn/teles/tei.c | 248 | ||||
-rw-r--r-- | drivers/isdn/teles/teles.h | 486 |
22 files changed, 9 insertions, 8831 deletions
diff --git a/drivers/isdn/Config.in b/drivers/isdn/Config.in index af07e9bca..f731a096d 100644 --- a/drivers/isdn/Config.in +++ b/drivers/isdn/Config.in @@ -11,7 +11,6 @@ fi bool 'Support audio via ISDN' CONFIG_ISDN_AUDIO dep_tristate 'ICN 2B and 4B support' CONFIG_ISDN_DRV_ICN $CONFIG_ISDN dep_tristate 'PCBIT-D support' CONFIG_ISDN_DRV_PCBIT $CONFIG_ISDN -dep_tristate 'Teles/NICCY1016PC/Creatix support' CONFIG_ISDN_DRV_TELES $CONFIG_ISDN dep_tristate 'HiSax SiemensChipSet driver support' CONFIG_ISDN_DRV_HISAX $CONFIG_ISDN if [ "$CONFIG_ISDN_DRV_HISAX" != "n" ]; then bool 'HiSax Support for Teles 16.0/8.0' CONFIG_HISAX_16_0 diff --git a/drivers/isdn/Makefile b/drivers/isdn/Makefile index 8ef5d8e39..e88e81735 100644 --- a/drivers/isdn/Makefile +++ b/drivers/isdn/Makefile @@ -1,6 +1,6 @@ SUB_DIRS := MOD_SUB_DIRS := -ALL_SUB_DIRS := icn teles pcbit hisax +ALL_SUB_DIRS := icn pcbit hisax L_OBJS := LX_OBJS := @@ -36,16 +36,6 @@ else endif endif -ifeq ($(CONFIG_ISDN_DRV_TELES),y) - L_OBJS += teles/teles.o - SUB_DIRS += teles - MOD_SUB_DIRS += teles -else - ifeq ($(CONFIG_ISDN_DRV_TELES),m) - MOD_SUB_DIRS += teles - endif -endif - ifeq ($(CONFIG_ISDN_DRV_HISAX),y) L_OBJS += hisax/hisax.o SUB_DIRS += hisax diff --git a/drivers/isdn/hisax/.cvsignore b/drivers/isdn/hisax/.cvsignore new file mode 100644 index 000000000..4671378ae --- /dev/null +++ b/drivers/isdn/hisax/.cvsignore @@ -0,0 +1 @@ +.depend diff --git a/drivers/isdn/hisax/isdnl1.c b/drivers/isdn/hisax/isdnl1.c index cbc91e9d6..ebf0957b5 100644 --- a/drivers/isdn/hisax/isdnl1.c +++ b/drivers/isdn/hisax/isdnl1.c @@ -461,11 +461,11 @@ isac_bh(struct IsdnCardState *sp) if (!sp) return; - if (clear_bit(ISAC_PHCHANGE, &sp->event)) + if (test_and_clear_bit(ISAC_PHCHANGE, &sp->event)) process_new_ph(sp); - if (clear_bit(ISAC_RCVBUFREADY, &sp->event)) + if (test_and_clear_bit(ISAC_RCVBUFREADY, &sp->event)) process_rcv(sp); - if (clear_bit(ISAC_XMTBUFREADY, &sp->event)) + if (test_and_clear_bit(ISAC_XMTBUFREADY, &sp->event)) process_xmt(sp); } @@ -578,9 +578,9 @@ hscx_bh(struct HscxState *hsp) if (!hsp) return; - if (clear_bit(HSCX_RCVBUFREADY, &hsp->event)) + if (test_and_clear_bit(HSCX_RCVBUFREADY, &hsp->event)) hscx_process_rcv(hsp); - if (clear_bit(HSCX_XMTBUFREADY, &hsp->event)) + if (test_and_clear_bit(HSCX_XMTBUFREADY, &hsp->event)) hscx_process_xmt(hsp); } diff --git a/drivers/isdn/isdn_net.c b/drivers/isdn/isdn_net.c index 5d3ab899e..b6b076360 100644 --- a/drivers/isdn/isdn_net.c +++ b/drivers/isdn/isdn_net.c @@ -934,7 +934,7 @@ isdn_net_start_xmit(struct sk_buff *skb, struct device *ndev) return 0; } /* Avoid timer-based retransmission conflicts. */ - if (set_bit(0, (void *) &ndev->tbusy) != 0) + if (test_and_set_bit(0, (void *) &ndev->tbusy) != 0) printk(KERN_WARNING "%s: Transmitter access conflict.\n", ndev->name); diff --git a/drivers/isdn/sc/Makefile b/drivers/isdn/sc/Makefile index 5440cdaff..be0d8b76c 100644 --- a/drivers/isdn/sc/Makefile +++ b/drivers/isdn/sc/Makefile @@ -1,5 +1,5 @@ # -# $Id: Makefile.kernel,v 1.1 1996/11/07 13:07:40 fritz Exp $ +# $Id: Makefile,v 1.2 1997/05/01 08:53:47 davem Exp $ # Copyright (C) 1996 SpellCaster Telecommunications Inc. # # This program is free software; you can redistribute it and/or modify diff --git a/drivers/isdn/teles/Makefile b/drivers/isdn/teles/Makefile deleted file mode 100644 index a252f46ba..000000000 --- a/drivers/isdn/teles/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -L_OBJS := -M_OBJS := -O_OBJS := mod.o card.o config.o buffers.o tei.o isdnl2.o isdnl3.o \ -llglue.o q931.o callc.o fsm.o - -O_TARGET := -ifeq ($(CONFIG_ISDN_DRV_TELES),y) - O_TARGET += teles.o -else - ifeq ($(CONFIG_ISDN_DRV_TELES),m) - O_TARGET += teles.o - M_OBJS += teles.o - endif -endif - -include $(TOPDIR)/Rules.make - diff --git a/drivers/isdn/teles/buffers.c b/drivers/isdn/teles/buffers.c deleted file mode 100644 index 74510a664..000000000 --- a/drivers/isdn/teles/buffers.c +++ /dev/null @@ -1,329 +0,0 @@ -/* $Id: buffers.c,v 1.2 1996/07/04 22:46:20 dm Exp $ - * - * $Log: buffers.c,v $ - * Revision 1.2 1996/07/04 22:46:20 dm - * Merge to 2.0.1 - * - * Revision 1.3 1996/05/31 00:56:53 fritz - * removed cli() from BufPoolAdd, since it is called - * with interrupts off anyway. - * - * Revision 1.2 1996/04/29 22:48:14 fritz - * Removed compatibility-macros. No longer needed. - * - * Revision 1.1 1996/04/13 10:19:28 fritz - * Initial revision - * - * - */ -#define __NO_VERSION__ -#include "teles.h" -#include <linux/mm.h> -#include <linux/malloc.h> - - -void -BufPoolInit(struct BufPool *bp, int order, int bpps, - int maxpages) -{ -#ifdef DEBUG_MAGIC - generateerror - bp->magic = 010167; -#endif - -#if 0 - printk(KERN_DEBUG "BufPoolInit bp %x\n", bp); -#endif - - bp->freelist = NULL; - bp->pageslist = NULL; - bp->pageorder = order; - bp->pagescount = 0; - bp->bpps = bpps; - bp->bufsize = BUFFER_SIZE(order, bpps); - bp->maxpages = maxpages; -} - -int -BufPoolAdd(struct BufPool *bp, int priority) -{ - struct Pages *ptr; - byte *bptr; - int i; - struct BufHeader *bh = NULL, *prev, *first; - -#if 0 - printk(KERN_DEBUG "BufPoolAdd bp %x\n", bp); -#endif - - ptr = (struct Pages *) __get_free_pages(priority, bp->pageorder, 0); - if (!ptr) { - printk(KERN_WARNING "BufPoolAdd couldn't get pages!\n"); - return (-1); - } -#if 0 - printk(KERN_DEBUG "Order %d pages allocated at %x\n", bp->pageorder, ptr); -#endif - - ptr->next = bp->pageslist; - bp->pageslist = ptr; - bp->pagescount++; - - bptr = (byte *) ptr + sizeof(struct Pages *); - - i = bp->bpps; - first = (struct BufHeader *) bptr; - prev = NULL; - while (i--) { - bh = (struct BufHeader *) bptr; -#ifdef DEBUG_MAGIC - bh->magic = 020167; -#endif - bh->next = prev; - prev = bh; - bh->bp = bp; - bptr += PART_SIZE(bp->pageorder, bp->bpps); - } - - first->next = bp->freelist; - bp->freelist = bh; - return (0); -} - -void -BufPoolFree(struct BufPool *bp) -{ - struct Pages *p; - -#if 0 - printk(KERN_DEBUG "BufPoolFree bp %x\n", bp); -#endif - - while (bp->pagescount--) { - p = bp->pageslist->next; - free_pages((unsigned long) bp->pageslist, bp->pageorder); -#if 0 - printk(KERN_DEBUG "Free pages %x order %d\n", bp->pageslist, bp->pageorder); -#endif - bp->pageslist = p; - } -} - -int -BufPoolGet(struct BufHeader **bh, - struct BufPool *bp, int priority, void *heldby, int where) -{ - long flags; - int i; - -#ifdef DEBUG_MAGIC - if (bp->magic != 010167) { - printk(KERN_DEBUG "BufPoolGet: not a BufHeader\n"); - return (-1); - } -#endif - - save_flags(flags); - cli(); - i = 0; - while (!0) { - if (bp->freelist) { - *bh = bp->freelist; - bp->freelist = bp->freelist->next; - (*bh)->heldby = heldby; - (*bh)->where = where; - restore_flags(flags); - return (0); - } - if ((i == 0) && (bp->pagescount < bp->maxpages)) { - if (BufPoolAdd(bp, priority)) { - restore_flags(flags); - return -1; - } - i++; - } else { - *bh = NULL; - restore_flags(flags); - return (-1); - } - } - -} - -void -BufPoolRelease(struct BufHeader *bh) -{ - struct BufPool *bp; - long flags; - -#ifdef DEBUG_MAGIC - if (bh->magic != 020167) { - printk(KERN_DEBUG "BufPoolRelease: not a BufHeader\n"); - printk(KERN_DEBUG "called from %x\n", return_address()); - return; - } -#endif - - bp = bh->bp; - -#ifdef DEBUG_MAGIC - if (bp->magic != 010167) { - printk(KERN_DEBUG "BufPoolRelease: not a BufPool\n"); - return; - } -#endif - - save_flags(flags); - cli(); - bh->next = bp->freelist; - bp->freelist = bh; - restore_flags(flags); -} - -void -BufQueueLink(struct BufQueue *bq, - struct BufHeader *bh) -{ - unsigned long flags; - - save_flags(flags); - cli(); - if (!bq->head) - bq->head = bh; - if (bq->tail) - bq->tail->next = bh; - bq->tail = bh; - bh->next = NULL; - restore_flags(flags); -} - -void -BufQueueLinkFront(struct BufQueue *bq, - struct BufHeader *bh) -{ - unsigned long flags; - - save_flags(flags); - cli(); - bh->next = bq->head; - bq->head = bh; - if (!bq->tail) - bq->tail = bh; - restore_flags(flags); -} - -int -BufQueueUnlink(struct BufHeader **bh, struct BufQueue *bq) -{ - long flags; - - save_flags(flags); - cli(); - - if (bq->head) { - if (bq->tail == bq->head) - bq->tail = NULL; - *bh = bq->head; - bq->head = (*bh)->next; - restore_flags(flags); - return (0); - } else { - restore_flags(flags); - return (-1); - } -} - -void -BufQueueInit(struct BufQueue *bq) -{ -#ifdef DEBUG_MAGIC - bq->magic = 030167; -#endif - bq->head = NULL; - bq->tail = NULL; -} - -void -BufQueueRelease(struct BufQueue *bq) -{ - struct BufHeader *bh; - - while (bq->head) { - BufQueueUnlink(&bh, bq); - BufPoolRelease(bh); - } -} - -int -BufQueueLength(struct BufQueue *bq) -{ - int i = 0; - struct BufHeader *bh; - - bh = bq->head; - while (bh) { - i++; - bh = bh->next; - } - return (i); -} - -void -BufQueueDiscard(struct BufQueue *q, int pr, void *heldby, - int releasetoo) -{ - long flags; - struct BufHeader *sp; - - save_flags(flags); - cli(); - - while (!0) { - sp = q->head; - if (!sp) - break; - if ((sp->primitive == pr) && (sp->heldby == heldby)) { - q->head = sp->next; - if (q->tail == sp) - q->tail = NULL; - if (releasetoo) - BufPoolRelease(sp); - } else - break; - } - - sp = q->head; - if (sp) - while (sp->next) { - if ((sp->next->primitive == pr) && (sp->next->heldby == heldby)) { - if (q->tail == sp->next) - q->tail = sp; - if (releasetoo) - BufPoolRelease(sp->next); - sp->next = sp->next->next; - } else - sp = sp->next; - } - restore_flags(flags); -} - -void -Sfree(byte * ptr) -{ -#if 0 - printk(KERN_DEBUG "Sfree %x\n", ptr); -#endif - kfree(ptr); -} - -byte * -Smalloc(int size, int pr, char *why) -{ - byte *p; - - p = (byte *) kmalloc(size, pr); -#if 0 - printk(KERN_DEBUG "Smalloc %s size %d res %x\n", why, size, p); -#endif - return (p); -} diff --git a/drivers/isdn/teles/callc.c b/drivers/isdn/teles/callc.c deleted file mode 100644 index b065d5670..000000000 --- a/drivers/isdn/teles/callc.c +++ /dev/null @@ -1,1453 +0,0 @@ -/* $Id: callc.c,v 1.16 1997/02/11 01:39:46 keil Exp $ - * - * $Log: callc.c,v $ - * Revision 1.16 1997/02/11 01:39:46 keil - * Changed setup-interface (incoming and outgoing) - * - * Revision 1.15 1996/11/23 11:32:20 keil - * windowsize = 7 X.75 bugfix Thanks to Martin Maurer - * - * Revision 1.14 1996/10/22 23:14:14 fritz - * Changes for compatibility to 2.0.X and 2.1.X kernels. - * - * Revision 1.13 1996/06/24 17:15:55 fritz - * corrected return code of teles_writebuf() - * - * Revision 1.12 1996/06/12 16:15:33 fritz - * Extended user-configurable debugging flags. - * - * Revision 1.11 1996/06/07 12:32:20 fritz - * More changes to support suspend/resume. - * - * Revision 1.10 1996/06/06 21:24:21 fritz - * Started adding support for suspend/resume. - * - * Revision 1.9 1996/05/31 12:23:57 jdenoud - * Jan: added channel open check to teles_writebuf - * - * Revision 1.8 1996/05/31 01:00:38 fritz - * Changed return code of teles_writebuf, when out of memory. - * - * Revision 1.7 1996/05/17 03:40:37 fritz - * General cleanup. - * - * Revision 1.6 1996/05/10 22:42:07 fritz - * Added entry for EV_RELEASE_CNF in ST_OUT (if no D-Channel avail.) - * - * Revision 1.5 1996/05/06 10:16:15 fritz - * Added voice stuff. - * - * Revision 1.4 1996/04/30 22:04:05 isdn4dev - * improved callback Karsten Keil - * - * Revision 1.3 1996/04/30 10:04:19 fritz - * Started voice support. - * Added printk() to debug-switcher for easier - * synchronization between printk()'s and output - * of /dev/isdnctrl. - * - * Revision 1.2 1996/04/20 16:42:29 fritz - * Changed statemachine to allow reject of incoming calls. - * - * Revision 1.1 1996/04/13 10:20:59 fritz - * Initial revision - * - * - */ -#define __NO_VERSION__ -#include "teles.h" - -extern struct IsdnCard cards[]; -extern int nrcards; -extern int drid; -extern isdn_if iif; -extern void teles_mod_dec_use_count(void); -extern void teles_mod_inc_use_count(void); - -static int init_ds(int chan, int incoming); -static void release_ds(int chan); - -static struct Fsm callcfsm = -{NULL, 0, 0}, lcfsm = -{NULL, 0, 0}; - -struct Channel *chanlist; -static int chancount = 0; -unsigned int debugflags = 0; - -#define TMR_DCHAN_EST 2000 - -static void -stat_debug(struct Channel *chanp, char *s) -{ - char tmp[100], tm[32]; - - jiftime(tm, jiffies); - sprintf(tmp, "%s Channel %d HL->LL %s\n", tm, chanp->chan, s); - teles_putstatus(tmp); -} - -enum { - ST_NULL, /* 0 inactive */ - ST_OUT, /* 1 outgoing, awaiting SETUP confirm */ - ST_CLEAR, /* 2 call release, awaiting RELEASE confirm */ - ST_OUT_W, /* 3 outgoing, awaiting d-channel establishment */ - ST_REL_W, /* 4 awaiting d-channel release */ - ST_IN_W, /* 5 incoming, awaiting d-channel establishment */ - ST_IN, /* 6 incoming call received */ - ST_IN_SETUP, /* 7 incoming, SETUP response sent */ - ST_IN_DACT, /* 8 incoming connected, no b-channel prot. */ - ST_OUT_ESTB, /* 10 outgoing connected, awaiting b-channel prot. estbl. */ - ST_ACTIVE, /* 11 active, b channel prot. established */ - ST_BC_HANGUP, /* 12 call clear. (initiator), awaiting b channel prot. rel. */ - ST_PRO_W, /* 13 call clear. (initiator), DISCONNECT req. sent */ - ST_ANT_W, /* 14 call clear. (receiver), awaiting DISCONNECT ind. */ - ST_DISC_BC_HANGUP, /* d channel gone, wait for b channel deactivation */ - ST_OUT_W_HANGUP, /* Outgoing waiting for D-Channel hangup received */ - ST_D_ERR, /* d channel released while active */ -}; - -#define STATE_COUNT (ST_D_ERR+1) - -static char *strState[] = -{ - "ST_NULL", - "ST_OUT", - "ST_CLEAR", - "ST_OUT_W", - "ST_REL_W", - "ST_IN_W", - "ST_IN", - "ST_IN_SETUP", - "ST_IN_DACT", - "ST_OUT_ESTB", - "ST_ACTIVE", - "ST_BC_HANGUP", - "ST_PRO_W", - "ST_ANT_W", - "ST_DISC_BC_HANGUP", - "ST_OUT_W_HANGUP", - "ST_D_ERR", -}; - -enum { - EV_DIAL, /* 0 */ - EV_SETUP_CNF, /* 1 */ - EV_ACCEPTB, /* 2 */ - EV_DISCONNECT_CNF, /* 5 */ - EV_DISCONNECT_IND, /* 6 */ - EV_RELEASE_CNF, /* 7 */ - EV_DLEST, /* 8 */ - EV_DLRL, /* 9 */ - EV_SETUP_IND, /* 10 */ - EV_RELEASE_IND, /* 11 */ - EV_ACCEPTD, /* 12 */ - EV_SETUP_CMPL_IND, /* 13 */ - EV_BC_EST, /* 14 */ - EV_WRITEBUF, /* 15 */ - EV_DATAIN, /* 16 */ - EV_HANGUP, /* 17 */ - EV_BC_REL, /* 18 */ - EV_CINF, /* 19 */ - EV_SUSPEND, /* 20 */ - EV_RESUME, /* 21 */ -}; - -#define EVENT_COUNT (EV_CINF+1) - -static char *strEvent[] = -{ - "EV_DIAL", - "EV_SETUP_CNF", - "EV_ACCEPTB", - "EV_DISCONNECT_CNF", - "EV_DISCONNECT_IND", - "EV_RELEASE_CNF", - "EV_DLEST", - "EV_DLRL", - "EV_SETUP_IND", - "EV_RELEASE_IND", - "EV_ACCEPTD", - "EV_SETUP_CMPL_IND", - "EV_BC_EST", - "EV_WRITEBUF", - "EV_DATAIN", - "EV_HANGUP", - "EV_BC_REL", - "EV_CINF", - "EV_SUSPEND", - "EV_RESUME", -}; - -enum { - ST_LC_NULL, - ST_LC_ACTIVATE_WAIT, - ST_LC_DELAY, - ST_LC_ESTABLISH_WAIT, - ST_LC_CONNECTED, - ST_LC_RELEASE_WAIT, -}; - -#define LC_STATE_COUNT (ST_LC_RELEASE_WAIT+1) - -static char *strLcState[] = -{ - "ST_LC_NULL", - "ST_LC_ACTIVATE_WAIT", - "ST_LC_DELAY", - "ST_LC_ESTABLISH_WAIT", - "ST_LC_CONNECTED", - "ST_LC_RELEASE_WAIT", -}; - -enum { - EV_LC_ESTABLISH, - EV_LC_PH_ACTIVATE, - EV_LC_PH_DEACTIVATE, - EV_LC_DL_ESTABLISH, - EV_LC_TIMER, - EV_LC_DL_RELEASE, - EV_LC_RELEASE, -}; - -#define LC_EVENT_COUNT (EV_LC_RELEASE+1) - -static char *strLcEvent[] = -{ - "EV_LC_ESTABLISH", - "EV_LC_PH_ACTIVATE", - "EV_LC_PH_DEACTIVATE", - "EV_LC_DL_ESTABLISH", - "EV_LC_TIMER", - "EV_LC_DL_RELEASE", - "EV_LC_RELEASE", -}; - -#define LC_D 0 -#define LC_B 1 - -/* - * Dial out - */ -static void -r1(struct FsmInst *fi, int event, void *arg) -{ - isdn_ctrl *ic = arg; - struct Channel *chanp = fi->userdata; - - chanp->para.setup = ic->parm.setup; - if (!strcmp(chanp->para.setup.eazmsn, "0")) - chanp->para.setup.eazmsn[0] = '\0'; - - chanp->l2_active_protocol = chanp->l2_protocol; - chanp->incoming = 0; - chanp->lc_b.l2_start = !0; - - switch (chanp->l2_active_protocol) { - case (ISDN_PROTO_L2_X75I): - chanp->lc_b.l2_establish = !0; - break; - case (ISDN_PROTO_L2_HDLC): - case (ISDN_PROTO_L2_TRANS): - chanp->lc_b.l2_establish = 0; - break; - default: - printk(KERN_WARNING "r1 unknown protocol\n"); - break; - } - - FsmChangeState(fi, ST_OUT_W); - FsmEvent(&chanp->lc_d.lcfi, EV_LC_ESTABLISH, NULL); -} - -static void -ll_hangup(struct Channel *chanp, int bchantoo) -{ - isdn_ctrl ic; - - if (bchantoo) { - if (chanp->debug & 1) - stat_debug(chanp, "STAT_BHUP"); - ic.driver = drid; - ic.command = ISDN_STAT_BHUP; - ic.arg = chanp->chan; - iif.statcallb(&ic); - } - if (chanp->debug & 1) - stat_debug(chanp, "STAT_DHUP"); - ic.driver = drid; - ic.command = ISDN_STAT_DHUP; - ic.arg = chanp->chan; - iif.statcallb(&ic); -} - -static void -r2(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - chanp->is.l4.l4l3(&chanp->is, CC_RELEASE_REQ, NULL); - - FsmChangeState(fi, ST_CLEAR); - ll_hangup(chanp, 0); -} - - -static void -r2_1(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - chanp->is.l4.l4l3(&chanp->is, CC_DISCONNECT_REQ, NULL); - - FsmChangeState(fi, ST_OUT_W_HANGUP); -} - - -static void -r2_2(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - FsmChangeState(fi, ST_REL_W); - FsmEvent(&chanp->lc_d.lcfi, EV_LC_RELEASE, NULL); - ll_hangup(chanp, 0); -} - - -static void -r3(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - FsmEvent(&chanp->lc_d.lcfi, EV_LC_RELEASE, NULL); - FsmChangeState(fi, ST_REL_W); -} - - -static void -r3_1(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - chanp->is.l4.l4l3(&chanp->is,CC_DLRL,NULL); - - FsmEvent(&chanp->lc_d.lcfi, EV_LC_RELEASE, NULL); - FsmChangeState(fi, ST_REL_W); - ll_hangup(chanp, 0); -} - - -static void -r4(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp=fi->userdata; - - chanp->is.l4.l4l3(&chanp->is,CC_DLRL,NULL); - FsmChangeState(fi, ST_NULL); -} - -static void -r5(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - chanp->para.callref = chanp->outcallref; - - chanp->outcallref++; - if (chanp->outcallref == 128) - chanp->outcallref = 64; - - chanp->is.l4.l4l3(&chanp->is, CC_SETUP_REQ, NULL); - - FsmChangeState(fi, ST_OUT); -} - -static void -r6(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - FsmChangeState(fi, ST_IN_W); - FsmEvent(&chanp->lc_d.lcfi, EV_LC_ESTABLISH, NULL); -} - -static void -r7(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - isdn_ctrl ic; - - /* - * Report incoming calls only once to linklevel, use octet 3 of - * channel identification information element. (it's value - * is copied to chanp->para.bchannel in l3s12(), file isdnl3.c) - */ - if (((chanp->chan & 1) + 1) & chanp->para.bchannel) { - chanp->is.l4.l4l3(&chanp->is, CC_ALERTING_REQ, NULL); - FsmChangeState(fi, ST_IN); - if (chanp->debug & 1) - stat_debug(chanp, "STAT_ICALL"); - ic.driver = drid; - ic.command = ISDN_STAT_ICALL; - ic.arg = chanp->chan; - /* - * No need to return "unknown" for calls without OAD, - * cause that's handled in linklevel now (replaced by '0') - */ - ic.parm.setup = chanp->para.setup; - iif.statcallb(&ic); - } else { - chanp->is.l4.l4l3(&chanp->is,CC_DLRL,NULL); - FsmEvent(&chanp->lc_d.lcfi, EV_LC_RELEASE, NULL); - FsmChangeState(fi, ST_REL_W); - } -} - -static void -r8(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - FsmChangeState(fi, ST_IN_SETUP); - chanp->is.l4.l4l3(&chanp->is, CC_SETUP_RSP, NULL); - -} - -static void -r9(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - FsmChangeState(fi, ST_IN_DACT); - - chanp->l2_active_protocol = chanp->l2_protocol; - chanp->incoming = !0; - chanp->lc_b.l2_start = 0; - - switch (chanp->l2_active_protocol) { - case (ISDN_PROTO_L2_X75I): - chanp->lc_b.l2_establish = !0; - break; - case (ISDN_PROTO_L2_HDLC): - case (ISDN_PROTO_L2_TRANS): - chanp->lc_b.l2_establish = 0; - break; - default: - printk(KERN_WARNING "r9 unknown protocol\n"); - break; - } - - init_ds(chanp->chan, !0); - - FsmEvent(&chanp->lc_b.lcfi, EV_LC_ESTABLISH, NULL); -} - -static void -r10(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - FsmChangeState(fi, ST_OUT_ESTB); - - init_ds(chanp->chan, 0); - FsmEvent(&chanp->lc_b.lcfi, EV_LC_ESTABLISH, NULL); - -} - -static void -r12(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - isdn_ctrl ic; - - FsmChangeState(fi, ST_ACTIVE); - chanp->data_open = !0; - - if (chanp->debug & 1) - stat_debug(chanp, "STAT_DCONN"); - ic.driver = drid; - ic.command = ISDN_STAT_DCONN; - ic.arg = chanp->chan; - iif.statcallb(&ic); - - if (chanp->debug & 1) - stat_debug(chanp, "STAT_BCONN"); - ic.driver = drid; - ic.command = ISDN_STAT_BCONN; - ic.arg = chanp->chan; - iif.statcallb(&ic); -} - -static void -r15(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - chanp->data_open = 0; - FsmChangeState(fi, ST_BC_HANGUP); - FsmEvent(&chanp->lc_b.lcfi, EV_LC_RELEASE, NULL); -} - -static void -r16(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - release_ds(chanp->chan); - - FsmChangeState(fi, ST_PRO_W); - chanp->is.l4.l4l3(&chanp->is, CC_DISCONNECT_REQ, NULL); -} - -static void -r17(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - chanp->data_open = 0; - release_ds(chanp->chan); - - FsmChangeState(fi, ST_ANT_W); -} - - -static void -r17_1(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - chanp->data_open = 0; - release_ds(chanp->chan); - - chanp->is.l4.l4l3(&chanp->is,CC_DLRL,NULL); - - FsmEvent(&chanp->lc_d.lcfi,EV_LC_RELEASE,NULL); - - FsmChangeState(fi, ST_NULL); - - ll_hangup(chanp,!0); -} - -static void -r18(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - FsmChangeState(fi, ST_REL_W); - FsmEvent(&chanp->lc_d.lcfi, EV_LC_RELEASE, NULL); - - ll_hangup(chanp, !0); -} - -static void -r19(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - FsmChangeState(fi, ST_CLEAR); - - chanp->is.l4.l4l3(&chanp->is, CC_RELEASE_REQ, NULL); - - ll_hangup(chanp, !0); -} - -static void -r20(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - chanp->is.l4.l4l3(&chanp->is,CC_DLRL,NULL); - - FsmEvent(&chanp->lc_d.lcfi,EV_LC_RELEASE,NULL); - - FsmChangeState(fi, ST_NULL); - - ll_hangup(chanp, 0); -} - - -static void -r21(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - chanp->data_open = 0; - FsmChangeState(fi, ST_DISC_BC_HANGUP); - FsmEvent(&chanp->lc_b.lcfi, EV_LC_RELEASE, NULL); -} - -static void -r22(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - release_ds(chanp->chan); - - FsmChangeState(fi, ST_CLEAR); - - chanp->is.l4.l4l3(&chanp->is, CC_RELEASE_REQ, NULL); - - ll_hangup(chanp, !0); -} - -static void -r23(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - release_ds(chanp->chan); - - FsmChangeState(fi, ST_PRO_W); - chanp->is.l4.l4l3(&chanp->is, CC_DISCONNECT_REQ, NULL); -} - -static void -r23_1(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - release_ds(chanp->chan); - - chanp->is.l4.l4l3(&chanp->is, CC_DLRL,NULL); - - FsmEvent(&chanp->lc_d.lcfi, EV_LC_RELEASE,NULL); - - FsmChangeState(fi, ST_NULL); - - ll_hangup(chanp,!0); -} - -static void -r24(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - chanp->data_open = 0; - FsmChangeState(fi, ST_D_ERR); - FsmEvent(&chanp->lc_b.lcfi, EV_LC_RELEASE, NULL); -} - -static void -r25(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - - release_ds(chanp->chan); - - FsmChangeState(fi, ST_NULL); - - ll_hangup(chanp, !0); -} - -static void -r26(struct FsmInst *fi, int event, void *arg) -{ - struct Channel *chanp = fi->userdata; - isdn_ctrl ic; - - - ic.driver = drid; - ic.command = ISDN_STAT_CINF; - ic.arg = chanp->chan; - sprintf(ic.parm.num, "%d", chanp->para.chargeinfo); - iif.statcallb(&ic); -} - - - -static struct FsmNode fnlist[] = -{ - {ST_NULL, EV_DIAL, r1}, - {ST_OUT_W, EV_DLEST, r5}, - {ST_OUT_W, EV_DLRL, r20}, - {ST_OUT_W, EV_RELEASE_CNF, r2_2 }, - {ST_OUT, EV_DISCONNECT_IND, r2}, - {ST_OUT, EV_SETUP_CNF, r10}, - {ST_OUT, EV_HANGUP, r2_1}, - {ST_OUT, EV_RELEASE_IND, r20}, - {ST_OUT, EV_RELEASE_CNF, r20}, - {ST_OUT, EV_DLRL, r2_2}, - {ST_OUT_W_HANGUP, EV_RELEASE_IND, r2_2}, - {ST_OUT_W_HANGUP, EV_DLRL, r20}, - {ST_CLEAR, EV_RELEASE_CNF, r3}, - {ST_CLEAR, EV_DLRL, r20}, - {ST_REL_W, EV_DLRL, r4}, - {ST_NULL, EV_SETUP_IND, r6}, - {ST_IN_W, EV_DLEST, r7}, - {ST_IN_W, EV_DLRL, r3_1}, - {ST_IN, EV_DLRL, r3_1}, - {ST_IN, EV_HANGUP, r2_1}, - {ST_IN, EV_RELEASE_IND, r2_2}, - {ST_IN, EV_RELEASE_CNF, r2_2}, - {ST_IN, EV_ACCEPTD, r8}, - {ST_IN_SETUP, EV_HANGUP, r2_1}, - {ST_IN_SETUP, EV_SETUP_CMPL_IND, r9}, - {ST_IN_SETUP, EV_RELEASE_IND, r2_2}, - {ST_IN_SETUP, EV_DISCONNECT_IND, r2}, - {ST_IN_SETUP, EV_DLRL, r20}, - {ST_OUT_ESTB, EV_BC_EST, r12}, - {ST_OUT_ESTB, EV_BC_REL, r23}, - {ST_OUT_ESTB, EV_DLRL, r23_1}, - {ST_IN_DACT, EV_BC_EST, r12}, - {ST_IN_DACT, EV_BC_REL, r17}, - {ST_IN_DACT, EV_DLRL, r17_1}, - {ST_ACTIVE, EV_HANGUP, r15}, - {ST_ACTIVE, EV_BC_REL, r17}, - {ST_ACTIVE, EV_DISCONNECT_IND, r21}, - {ST_ACTIVE, EV_DLRL, r24}, - {ST_ACTIVE, EV_CINF, r26}, - {ST_ACTIVE, EV_RELEASE_IND, r17}, - {ST_BC_HANGUP, EV_BC_REL, r16}, - {ST_BC_HANGUP, EV_DISCONNECT_IND, r21}, - {ST_PRO_W, EV_RELEASE_IND, r18}, - {ST_ANT_W, EV_DISCONNECT_IND, r19}, - {ST_DISC_BC_HANGUP, EV_BC_REL, r22}, - {ST_D_ERR, EV_BC_REL, r25}, -}; - -#define FNCOUNT (sizeof(fnlist)/sizeof(struct FsmNode)) - -static void -lc_r1(struct FsmInst *fi, int event, void *arg) -{ - struct LcFsm *lf = fi->userdata; - - FsmChangeState(fi, ST_LC_ACTIVATE_WAIT); - FsmAddTimer(&lf->act_timer, 1000, EV_LC_TIMER, NULL, 50); - lf->st->ma.manl1(lf->st, PH_ACTIVATE, NULL); - -} - -static void -lc_r6(struct FsmInst *fi, int event, void *arg) -{ - struct LcFsm *lf = fi->userdata; - - FsmDelTimer(&lf->act_timer, 50); - FsmChangeState(fi, ST_LC_DELAY); - FsmAddTimer(&lf->act_timer, 40, EV_LC_TIMER, NULL, 51); -} - -static void -lc_r2(struct FsmInst *fi, int event, void *arg) -{ - struct LcFsm *lf = fi->userdata; - - if (lf->l2_establish) { - FsmChangeState(fi, ST_LC_ESTABLISH_WAIT); - if (lf->l2_start) - lf->st->ma.manl2(lf->st, DL_ESTABLISH, NULL); - } else { - FsmChangeState(fi, ST_LC_CONNECTED); - lf->lccall(lf, LC_ESTABLISH, NULL); - } -} - -static void -lc_r3(struct FsmInst *fi, int event, void *arg) -{ - struct LcFsm *lf = fi->userdata; - - FsmChangeState(fi, ST_LC_CONNECTED); - lf->lccall(lf, LC_ESTABLISH, NULL); -} - -static void -lc_r4(struct FsmInst *fi, int event, void *arg) -{ - struct LcFsm *lf = fi->userdata; - - if (lf->l2_establish) { - FsmChangeState(fi, ST_LC_RELEASE_WAIT); - lf->st->ma.manl2(lf->st, DL_RELEASE, NULL); - } else { - FsmChangeState(fi, ST_LC_NULL); - lf->st->ma.manl1(lf->st, PH_DEACTIVATE, NULL); - lf->lccall(lf, LC_RELEASE, NULL); - } -} - -static void -lc_r5(struct FsmInst *fi, int event, void *arg) -{ - struct LcFsm *lf = fi->userdata; - - FsmChangeState(fi, ST_LC_NULL); - lf->st->ma.manl1(lf->st, PH_DEACTIVATE, NULL); - lf->lccall(lf, LC_RELEASE, NULL); -} - -static struct FsmNode LcFnList[] = -{ - {ST_LC_NULL, EV_LC_ESTABLISH, lc_r1}, - {ST_LC_ACTIVATE_WAIT, EV_LC_PH_ACTIVATE, lc_r6}, - {ST_LC_DELAY, EV_LC_TIMER, lc_r2}, - {ST_LC_ESTABLISH_WAIT, EV_LC_DL_ESTABLISH, lc_r3}, - {ST_LC_CONNECTED, EV_LC_RELEASE, lc_r4}, - {ST_LC_CONNECTED, EV_LC_DL_RELEASE, lc_r5}, - {ST_LC_RELEASE_WAIT, EV_LC_DL_RELEASE, lc_r5}, - {ST_LC_ACTIVATE_WAIT, EV_LC_TIMER, lc_r5}, - {ST_LC_ESTABLISH_WAIT, EV_LC_DL_RELEASE, lc_r5}, -}; - -#define LC_FN_COUNT (sizeof(LcFnList)/sizeof(struct FsmNode)) - -void -CallcNew(void) -{ - callcfsm.state_count = STATE_COUNT; - callcfsm.event_count = EVENT_COUNT; - callcfsm.strEvent = strEvent; - callcfsm.strState = strState; - FsmNew(&callcfsm, fnlist, FNCOUNT); - - lcfsm.state_count = LC_STATE_COUNT; - lcfsm.event_count = LC_EVENT_COUNT; - lcfsm.strEvent = strLcEvent; - lcfsm.strState = strLcState; - FsmNew(&lcfsm, LcFnList, LC_FN_COUNT); -} - -void -CallcFree(void) -{ - FsmFree(&lcfsm); - FsmFree(&callcfsm); -} - -static void -release_ds(int chan) -{ - struct PStack *st = &chanlist[chan].ds; - struct IsdnCardState *sp; - struct HscxState *hsp; - - sp = st->l1.hardware; - hsp = sp->hs + chanlist[chan].hscx; - - close_hscxstate(hsp); - - switch (chanlist[chan].l2_active_protocol) { - case (ISDN_PROTO_L2_X75I): - releasestack_isdnl2(st); - break; - case (ISDN_PROTO_L2_HDLC): - case (ISDN_PROTO_L2_TRANS): - releasestack_transl2(st); - break; - } -} - -static void -cc_l1man(struct PStack *st, int pr, void *arg) -{ - struct Channel *chanp = (struct Channel *) st->l4.userdata; - - switch (pr) { - case (PH_ACTIVATE): - FsmEvent(&chanp->lc_d.lcfi, EV_LC_PH_ACTIVATE, NULL); - break; - case (PH_DEACTIVATE): - FsmEvent(&chanp->lc_d.lcfi, EV_LC_PH_DEACTIVATE, NULL); - break; - } -} - -static void -cc_l2man(struct PStack *st, int pr, void *arg) -{ - struct Channel *chanp = (struct Channel *) st->l4.userdata; - - switch (pr) { - case (DL_ESTABLISH): - FsmEvent(&chanp->lc_d.lcfi, EV_LC_DL_ESTABLISH, NULL); - break; - case (DL_RELEASE): - FsmEvent(&chanp->lc_d.lcfi, EV_LC_DL_RELEASE, NULL); - break; - } -} - -static void -dcc_l1man(struct PStack *st, int pr, void *arg) -{ - struct Channel *chanp = (struct Channel *) st->l4.userdata; - - switch (pr) { - case (PH_ACTIVATE): - FsmEvent(&chanp->lc_b.lcfi, EV_LC_PH_ACTIVATE, NULL); - break; - case (PH_DEACTIVATE): - FsmEvent(&chanp->lc_b.lcfi, EV_LC_PH_DEACTIVATE, NULL); - break; - } -} - -static void -dcc_l2man(struct PStack *st, int pr, void *arg) -{ - struct Channel *chanp = (struct Channel *) st->l4.userdata; - - switch (pr) { - case (DL_ESTABLISH): - FsmEvent(&chanp->lc_b.lcfi, EV_LC_DL_ESTABLISH, NULL); - break; - case (DL_RELEASE): - FsmEvent(&chanp->lc_b.lcfi, EV_LC_DL_RELEASE, NULL); - break; - } -} - -static void -ll_handler(struct PStack *st, int pr, - struct BufHeader *ibh) -{ - struct Channel *chanp = (struct Channel *) st->l4.userdata; - - switch (pr) { - case (CC_DISCONNECT_IND): - FsmEvent(&chanp->fi, EV_DISCONNECT_IND, NULL); - break; - case (CC_RELEASE_CNF): - FsmEvent(&chanp->fi, EV_RELEASE_CNF, NULL); - break; - case (CC_SETUP_IND): - FsmEvent(&chanp->fi, EV_SETUP_IND, NULL); - break; - case (CC_RELEASE_IND): - FsmEvent(&chanp->fi, EV_RELEASE_IND, NULL); - break; - case (CC_SETUP_COMPLETE_IND): - FsmEvent(&chanp->fi, EV_SETUP_CMPL_IND, NULL); - break; - case (CC_SETUP_CNF): - FsmEvent(&chanp->fi, EV_SETUP_CNF, NULL); - break; - case (CC_INFO_CHARGE): - FsmEvent(&chanp->fi, EV_CINF, NULL); - break; - } -} - -static void -init_is(int chan, unsigned int ces) -{ - struct PStack *st = &(chanlist[chan].is); - struct IsdnCardState *sp = chanlist[chan].sp; - char tmp[128]; - - setstack_teles(st, sp); - - st->l2.sap = 0; - - st->l2.tei = 255; - - st->l2.ces = ces; - st->l2.extended = !0; - st->l2.laptype = LAPD; - st->l2.window = 1; - st->l2.orig = !0; - st->l2.t200 = 1000; /* 1000 milliseconds */ - if (st->protocol == ISDN_PTYPE_1TR6) { - st->l2.n200 = 3; /* try 3 times */ - st->l2.t203 = 10000; /* 10000 milliseconds */ - } else { - st->l2.n200 = 4; /* try 4 times */ - st->l2.t203 = 5000; /* 5000 milliseconds */ - } - - sprintf(tmp, "Channel %d q.921", chan); - setstack_isdnl2(st, tmp); - setstack_isdnl3(st); - st->l2.debug = 2; - st->l3.debug = 2; - st->l2.debug = 0xff; - st->l3.debug = 0xff; - st->l4.userdata = chanlist + chan; - st->l4.l2writewakeup = NULL; - - st->l3.l3l4 = ll_handler; - st->l1.l1man = cc_l1man; - st->l2.l2man = cc_l2man; - - st->pa = &chanlist[chan].para; - teles_addlist(sp, st); -} - -static void -callc_debug(struct FsmInst *fi, char *s) -{ - char str[80], tm[32]; - struct Channel *chanp = fi->userdata; - - jiftime(tm, jiffies); - sprintf(str, "%s Channel %d callc %s\n", tm, chanp->chan, s); - teles_putstatus(str); -} - -static void -lc_debug(struct FsmInst *fi, char *s) -{ - char str[256], tm[32]; - struct LcFsm *lf = fi->userdata; - - jiftime(tm, jiffies); - sprintf(str, "%s Channel %d lc %s\n", tm, lf->ch->chan, s); - teles_putstatus(str); -} - -static void -dlc_debug(struct FsmInst *fi, char *s) -{ - char str[256], tm[32]; - struct LcFsm *lf = fi->userdata; - - jiftime(tm, jiffies); - sprintf(str, "%s Channel %d dlc %s\n", tm, lf->ch->chan, s); - teles_putstatus(str); -} - -static void -lccall_d(struct LcFsm *lf, int pr, void *arg) -{ - struct Channel *chanp = lf->ch; - - switch (pr) { - case (LC_ESTABLISH): - FsmEvent(&chanp->fi, EV_DLEST, NULL); - break; - case (LC_RELEASE): - FsmEvent(&chanp->fi, EV_DLRL, NULL); - break; - } -} - -static void -lccall_b(struct LcFsm *lf, int pr, void *arg) -{ - struct Channel *chanp = lf->ch; - - switch (pr) { - case (LC_ESTABLISH): - FsmEvent(&chanp->fi, EV_BC_EST, NULL); - break; - case (LC_RELEASE): - FsmEvent(&chanp->fi, EV_BC_REL, NULL); - break; - } -} - -static void -init_chan(int chan, int cardnr, int hscx, - unsigned int ces) -{ - struct IsdnCard *card = cards + cardnr; - struct Channel *chanp = chanlist + chan; - - chanp->sp = card->sp; - chanp->hscx = hscx; - chanp->chan = chan; - chanp->incoming = 0; - chanp->debug = 0; - init_is(chan, ces); - - chanp->fi.fsm = &callcfsm; - chanp->fi.state = ST_NULL; - chanp->fi.debug = 0; - chanp->fi.userdata = chanp; - chanp->fi.printdebug = callc_debug; - - chanp->lc_d.lcfi.fsm = &lcfsm; - chanp->lc_d.lcfi.state = ST_LC_NULL; - chanp->lc_d.lcfi.debug = 0; - chanp->lc_d.lcfi.userdata = &chanp->lc_d; - chanp->lc_d.lcfi.printdebug = lc_debug; - chanp->lc_d.type = LC_D; - chanp->lc_d.ch = chanp; - chanp->lc_d.st = &chanp->is; - chanp->lc_d.l2_establish = !0; - chanp->lc_d.l2_start = !0; - chanp->lc_d.lccall = lccall_d; - FsmInitTimer(&chanp->lc_d.lcfi, &chanp->lc_d.act_timer); - - chanp->lc_b.lcfi.fsm = &lcfsm; - chanp->lc_b.lcfi.state = ST_LC_NULL; - chanp->lc_b.lcfi.debug = 0; - chanp->lc_b.lcfi.userdata = &chanp->lc_b; - chanp->lc_b.lcfi.printdebug = dlc_debug; - chanp->lc_b.type = LC_B; - chanp->lc_b.ch = chanp; - chanp->lc_b.st = &chanp->ds; - chanp->lc_b.l2_establish = !0; - chanp->lc_b.l2_start = !0; - chanp->lc_b.lccall = lccall_b; - FsmInitTimer(&chanp->lc_b.lcfi, &chanp->lc_b.act_timer); - - chanp->outcallref = 64; - chanp->data_open = 0; -} - -int -CallcNewChan(void) -{ - int i, ces, c; - - chancount = 0; - for (i = 0; i < nrcards; i++) - if (cards[i].sp) - chancount += 2; - - chanlist = (struct Channel *) Smalloc(sizeof(struct Channel) * - chancount, GFP_KERNEL, "chanlist"); - - c = 0; - ces = randomces(); - for (i = 0; i < nrcards; i++) - if (cards[i].sp) { - init_chan(c++, i, 1, ces++); - ces %= 0xffff; - init_chan(c++, i, 0, ces++); - ces %= 0xffff; - } - printk(KERN_INFO "channels %d\n", chancount); - return (chancount); - -} - -static void -release_is(int chan) -{ - struct PStack *st = &chanlist[chan].is; - - releasestack_isdnl2(st); - teles_rmlist(st->l1.hardware, st); - BufQueueRelease(&st->l2.i_queue); -} - -void -CallcFreeChan(void) -{ - int i; - - for (i = 0; i < chancount; i++) - release_is(i); - Sfree((void *) chanlist); -} - -static void -lldata_handler(struct PStack *st, int pr, - void *arg) -{ - struct Channel *chanp = (struct Channel *) st->l4.userdata; - byte *ptr; - int size; - struct BufHeader *ibh = arg; - - switch (pr) { - case (DL_DATA): - if (chanp->data_open) { - ptr = DATAPTR(ibh); - ptr += chanp->ds.l2.ihsize; - size = ibh->datasize - chanp->ds.l2.ihsize; - iif.rcvcallb(drid, chanp->chan, ptr, size); - } - BufPoolRelease(ibh); - break; - default: - printk(KERN_WARNING "lldata_handler unknown primitive\n"); - break; - } -} - -static void -lltrans_handler(struct PStack *st, int pr, - struct BufHeader *ibh) -{ - struct Channel *chanp = (struct Channel *) st->l4.userdata; - byte *ptr; - - switch (pr) { - case (PH_DATA): - if (chanp->data_open) { - ptr = DATAPTR(ibh); - iif.rcvcallb(drid, chanp->chan, ptr, ibh->datasize); - } - BufPoolRelease(ibh); - break; - default: - printk(KERN_WARNING "lltrans_handler unknown primitive\n"); - break; - } -} - -static void -ll_writewakeup(struct PStack *st) -{ - struct Channel *chanp = st->l4.userdata; - isdn_ctrl ic; - - ic.driver = drid; - ic.command = ISDN_STAT_BSENT; - ic.arg = chanp->chan; - iif.statcallb(&ic); -} - -static int -init_ds(int chan, int incoming) -{ - struct PStack *st = &(chanlist[chan].ds); - struct IsdnCardState *sp = (struct IsdnCardState *) - chanlist[chan].is.l1.hardware; - struct HscxState *hsp = sp->hs + chanlist[chan].hscx; - char tmp[128]; - - st->l1.hardware = sp; - - hsp->mode = 2; - hsp->transbufsize = 4000; - - if (setstack_hscx(st, hsp)) - return (-1); - - st->l2.extended = 0; - st->l2.laptype = LAPB; - st->l2.orig = !incoming; - st->l2.t200 = 1000; /* 1000 milliseconds */ - st->l2.window = 7; - st->l2.n200 = 4; /* try 4 times */ - st->l2.t203 = 5000; /* 5000 milliseconds */ - - st->l2.debug = 0xff; - st->l3.debug = 0xff; - switch (chanlist[chan].l2_active_protocol) { - case (ISDN_PROTO_L2_X75I): - sprintf(tmp, "Channel %d x.75", chan); - setstack_isdnl2(st, tmp); - st->l2.l2l3 = lldata_handler; - st->l1.l1man = dcc_l1man; - st->l2.l2man = dcc_l2man; - st->l4.userdata = chanlist + chan; - st->l4.l1writewakeup = NULL; - st->l4.l2writewakeup = ll_writewakeup; - st->l2.l2m.debug = debugflags & 16; - st->ma.manl2(st, MDL_NOTEIPROC, NULL); - st->l1.hscxmode = 2; /* Packet-Mode ? */ - st->l1.hscxchannel = chanlist[chan].para.bchannel - 1; - break; - case (ISDN_PROTO_L2_HDLC): - st->l1.l1l2 = lltrans_handler; - st->l1.l1man = dcc_l1man; - st->l4.userdata = chanlist + chan; - st->l4.l1writewakeup = ll_writewakeup; - st->l1.hscxmode = 2; - st->l1.hscxchannel = chanlist[chan].para.bchannel - 1; - break; - case (ISDN_PROTO_L2_TRANS): - st->l1.l1l2 = lltrans_handler; - st->l1.l1man = dcc_l1man; - st->l4.userdata = chanlist + chan; - st->l4.l1writewakeup = ll_writewakeup; - st->l1.hscxmode = 1; - st->l1.hscxchannel = chanlist[chan].para.bchannel - 1; - break; - } - - return (0); - -} - -static void -channel_report(int i) -{ -} - -static void -command_debug(struct Channel *chanp, char *s) -{ - char tmp[64], tm[32]; - - jiftime(tm, jiffies); - sprintf(tmp, "%s Channel %d LL->HL %s\n", tm, chanp->chan, s); - teles_putstatus(tmp); -} - -static void -distr_debug(void) -{ - int i; - - for (i = 0; i < chancount; i++) { - chanlist[i].debug = debugflags & 1; - chanlist[i].fi.debug = debugflags & 2; - chanlist[i].is.l2.l2m.debug = debugflags & 8; - chanlist[i].ds.l2.l2m.debug = debugflags & 16; - } - for (i = 0; i < nrcards; i++) - if (cards[i].sp) { - cards[i].sp->dlogflag = debugflags & 4; - cards[i].sp->debug = debugflags & 32; - } -} - -int -teles_command(isdn_ctrl * ic) -{ - struct Channel *chanp; - char tmp[64]; - int i; - unsigned int num; - - switch (ic->command) { - case (ISDN_CMD_SETEAZ): - chanp = chanlist + ic->arg; - if (chanp->debug & 1) - command_debug(chanp, "SETEAZ"); - return (0); - case (ISDN_CMD_DIAL): - chanp = chanlist + (ic->arg & 0xff); - if (chanp->debug & 1) { - sprintf(tmp, "DIAL %s -> %s (%d,%d)", - ic->parm.setup.eazmsn, ic->parm.setup.phone, - ic->parm.setup.si1, ic->parm.setup.si2); - command_debug(chanp, tmp); - } - FsmEvent(&chanp->fi, EV_DIAL, ic); - return (0); - case (ISDN_CMD_ACCEPTB): - chanp = chanlist + ic->arg; - if (chanp->debug & 1) - command_debug(chanp, "ACCEPTB"); - FsmEvent(&chanp->fi, EV_ACCEPTB, NULL); - break; - case (ISDN_CMD_ACCEPTD): - chanp = chanlist + ic->arg; - if (chanp->debug & 1) - command_debug(chanp, "ACCEPTD"); - FsmEvent(&chanp->fi, EV_ACCEPTD, NULL); - break; - case (ISDN_CMD_HANGUP): - chanp = chanlist + ic->arg; - if (chanp->debug & 1) - command_debug(chanp, "HANGUP"); - FsmEvent(&chanp->fi, EV_HANGUP, NULL); - break; - case (ISDN_CMD_SUSPEND): - chanp = chanlist + ic->arg; - if (chanp->debug & 1) { - sprintf(tmp, "SUSPEND %s", ic->parm.num); - command_debug(chanp, tmp); - } - FsmEvent(&chanp->fi, EV_SUSPEND, ic); - break; - case (ISDN_CMD_RESUME): - chanp = chanlist + ic->arg; - if (chanp->debug & 1) { - sprintf(tmp, "RESUME %s", ic->parm.num); - command_debug(chanp, tmp); - } - FsmEvent(&chanp->fi, EV_RESUME, ic); - break; - case (ISDN_CMD_LOCK): - teles_mod_inc_use_count(); - break; - case (ISDN_CMD_UNLOCK): - teles_mod_dec_use_count(); - break; - case (ISDN_CMD_IOCTL): - switch (ic->arg) { - case (0): - for (i = 0; i < nrcards; i++) - if (cards[i].sp) - teles_reportcard(i); - for (i = 0; i < chancount; i++) - channel_report(i); - break; - case (1): - debugflags = *(unsigned int *) ic->parm.num; - distr_debug(); - sprintf(tmp, "debugging flags set to %x\n", debugflags); - teles_putstatus(tmp); - printk(KERN_DEBUG "%s", tmp); - break; - case (2): - num = *(unsigned int *) ic->parm.num; - i = num >> 8; - if (i >= chancount) - break; - chanp = chanlist + i; - chanp->impair = num & 0xff; - if (chanp->debug & 1) { - sprintf(tmp, "IMPAIR %x", chanp->impair); - command_debug(chanp, tmp); - } - break; - } - break; - case (ISDN_CMD_SETL2): - chanp = chanlist + (ic->arg & 0xff); - if (chanp->debug & 1) { - sprintf(tmp, "SETL2 %ld", ic->arg >> 8); - command_debug(chanp, tmp); - } - chanp->l2_protocol = ic->arg >> 8; - break; - default: - break; - } - - return (0); -} - -int -teles_writebuf(int id, int chan, const u_char * buf, int count, int user) -{ - struct Channel *chanp = chanlist + chan; - struct PStack *st = &chanp->ds; - struct BufHeader *ibh; - int err, i; - byte *ptr; - - if (!chanp->data_open) { - printk(KERN_DEBUG "teles_writebuf: channel not open\n"); - return -EIO; - } - - err = BufPoolGet(&ibh, st->l1.sbufpool, GFP_ATOMIC, st, 21); - if (err) - /* Must return 0 here, since this is not an error - * but a temporary lack of resources. - */ - return 0; - - ptr = DATAPTR(ibh); - if (chanp->lc_b.l2_establish) - i = st->l2.ihsize; - else - i = 0; - - if ((count+i) > BUFFER_SIZE(HSCX_SBUF_ORDER, HSCX_SBUF_BPPS)) { - printk(KERN_WARNING "teles_writebuf: packet too large!\n"); - return (-EINVAL); - } - - ptr += i; - - if (user) - copy_from_user(ptr, buf, count); - else - memcpy(ptr, buf, count); - ibh->datasize = count + i; - - if (chanp->data_open) { - if (chanp->lc_b.l2_establish) - chanp->ds.l3.l3l2(&chanp->ds, DL_DATA, ibh); - else - chanp->ds.l2.l2l1(&chanp->ds, PH_DATA, ibh); - return (count); - } else { - BufPoolRelease(ibh); - return (0); - } - -} diff --git a/drivers/isdn/teles/card.c b/drivers/isdn/teles/card.c deleted file mode 100644 index 2ada8a29d..000000000 --- a/drivers/isdn/teles/card.c +++ /dev/null @@ -1,1900 +0,0 @@ -/* $Id: card.c,v 1.16 1996/10/22 23:14:16 fritz Exp $ - * - * card.c low level stuff for the Teles S0 isdn card - * - * Author Jan den Ouden - * - * Beat Doebeli log all D channel traffic - * - * $Log: card.c,v $ - * Revision 1.16 1996/10/22 23:14:16 fritz - * Changes for compatibility to 2.0.X and 2.1.X kernels. - * - * Revision 1.15 1996/09/29 19:41:56 fritz - * Bugfix: ignore unknown frames. - * - * Revision 1.14 1996/09/23 01:53:49 fritz - * Bugfix: discard unknown frames (non-EDSS1 and non-1TR6). - * - * Revision 1.13 1996/07/18 11:21:24 jdenoud - * Use small buffers for incoming audio data - * - * Revision 1.12 1996/06/24 17:16:52 fritz - * Added check for misconfigured membase. - * - * Revision 1.11 1996/06/14 03:30:37 fritz - * Added recovery from EXIR 40 interrupt. - * Some cleanup. - * - * Revision 1.10 1996/06/11 14:57:20 hipp - * minor changes to ensure, that SKBs are sent in the right order - * - * Revision 1.9 1996/06/06 14:42:09 fritz - * Bugfix: forgot hsp-> in last change. - * - * Revision 1.7 1996/05/31 01:02:21 fritz - * Cosmetic changes. - * - * Revision 1.6 1996/05/26 14:58:10 fritz - * Bugfix: Did not show port correctly, when no card found. - * - * Revision 1.5 1996/05/17 03:45:02 fritz - * Made error messages more clearly. - * Bugfix: Only 31 bytes of 32-byte audio frames - * have been transfered to upper layers. - * - * Revision 1.4 1996/05/06 10:17:57 fritz - * Added voice-send stuff - * (Not reporting EXIR when in voice-mode, since it's normal). - * - * Revision 1.3 1996/04/30 22:02:40 isdn4dev - * Bugfixes for 16.3 - * -improved IO allocation - * -fix second B channel problem - * -correct ph_command patch - * - * Revision 1.2 1996/04/30 10:00:59 fritz - * Bugfix: Added ph_command(8) for 16.3. - * Bugfix: Ports did not get registered correctly - * when using a 16.3. - * Started voice support. - * Some experimental changes of waitforXFW(). - * - * Revision 1.1 1996/04/13 10:22:42 fritz - * Initial revision - * - * - */ - -#define __NO_VERSION__ -#include "teles.h" -#include "proto.h" - -#define INCLUDE_INLINE_FUNCS -#include <linux/tqueue.h> -#include <linux/interrupt.h> - -#undef DCHAN_VERBOSE - -extern void tei_handler(struct PStack *st, byte pr, - struct BufHeader *ibh); -extern struct IsdnCard cards[]; -extern int nrcards; - -#define byteout(addr,val) outb_p(val,addr) -#define bytein(addr) inb_p(addr) - -static inline byte -readisac_0(byte * cardm, byte offset) -{ - return readb(cardm + 0x100 + ((offset & 1) ? 0x1ff : 0) + offset); -} - -static inline byte -readisac_3(int iobase, byte offset) -{ - return (bytein(iobase - 0x420 + offset)); -} - -#define READISAC(mbase,ibase,ofs) \ - ((mbase)?readisac_0(mbase,ofs):readisac_3(ibase,ofs)) - -static inline void -writeisac_0(byte * cardm, byte offset, byte value) -{ - writeb(value, cardm + 0x100 + ((offset & 1) ? 0x1ff : 0) + offset); -} - -static inline void -writeisac_3(int iobase, byte offset, byte value) -{ - byteout(iobase - 0x420 + offset, value); -} - -#define WRITEISAC(mbase,ibase,ofs,val) \ - ((mbase)?writeisac_0(mbase,ofs,val):writeisac_3(ibase,ofs,val)) - -static inline void -readisac_s(int iobase, byte offset, byte * dest, int count) -{ - insb(iobase - 0x420 + offset, dest, count); -} - -static inline void -writeisac_s(int iobase, byte offset, byte * src, int count) -{ - outsb(iobase - 0x420 + offset, src, count); -} - -static inline byte -readhscx_0(byte * base, byte hscx, byte offset) -{ - return readb(base + 0x180 + ((offset & 1) ? 0x1FF : 0) + - ((hscx & 1) ? 0x40 : 0) + offset); -} - -static inline byte -readhscx_3(int iobase, byte hscx, byte offset) -{ - return (bytein(iobase - (hscx ? 0x820 : 0xc20) + offset)); -} - -#define READHSCX(mbase,ibase,hscx,ofs) \ - ((mbase)?readhscx_0(mbase,hscx,ofs):readhscx_3(ibase,hscx,ofs)) - -static inline void -writehscx_0(byte * base, byte hscx, byte offset, byte data) -{ - writeb(data, base + 0x180 + ((offset & 1) ? 0x1FF : 0) + - ((hscx & 1) ? 0x40 : 0) + offset); -} - -static inline void -writehscx_3(int iobase, byte hscx, byte offset, byte data) -{ - byteout(iobase - (hscx ? 0x820 : 0xc20) + offset, data); -} - -static inline void -readhscx_s(int iobase, byte hscx, byte offset, byte * dest, int count) -{ - insb(iobase - (hscx ? 0x820 : 0xc20) + offset, dest, count); -} - -static inline void -writehscx_s(int iobase, byte hscx, byte offset, byte * src, int count) -{ - outsb(iobase - (hscx ? 0x820 : 0xc20) + offset, src, count); -} - -#define ISAC_MASK 0x20 -#define ISAC_ISTA 0x20 -#define ISAC_STAR 0x21 -#define ISAC_CMDR 0x21 -#define ISAC_EXIR 0x24 - -#define ISAC_RBCH 0x2a - -#define ISAC_ADF2 0x39 -#define ISAC_SPCR 0x30 -#define ISAC_ADF1 0x38 -#define ISAC_CIX0 0x31 -#define ISAC_STCR 0x37 -#define ISAC_MODE 0x22 -#define ISAC_RSTA 0x27 -#define ISAC_RBCL 0x25 -#define ISAC_TIMR 0x23 -#define ISAC_SQXR 0x3b - -#define HSCX_ISTA 0x20 -#define HSCX_CCR1 0x2f -#define HSCX_CCR2 0x2c -#define HSCX_TSAR 0x31 -#define HSCX_TSAX 0x30 -#define HSCX_XCCR 0x32 -#define HSCX_RCCR 0x33 -#define HSCX_MODE 0x22 -#define HSCX_CMDR 0x21 -#define HSCX_EXIR 0x24 -#define HSCX_XAD1 0x24 -#define HSCX_XAD2 0x25 -#define HSCX_RAH2 0x27 -#define HSCX_RSTA 0x27 -#define HSCX_TIMR 0x23 -#define HSCX_STAR 0x21 -#define HSCX_RBCL 0x25 -#define HSCX_XBCH 0x2d -#define HSCX_VSTR 0x2e -#define HSCX_RLCR 0x2e -#define HSCX_MASK 0x20 - -static inline void -waitforCEC_0(byte * base, byte hscx) -{ - long to = 10; - - while ((readhscx_0(base, hscx, HSCX_STAR) & 0x04) && to) { - udelay(5); - to--; - } - if (!to) - printk(KERN_WARNING "waitforCEC timeout\n"); -} - -static inline void -waitforCEC_3(int iobase, byte hscx) -{ - long to = 10; - - while ((readhscx_3(iobase, hscx, HSCX_STAR) & 0x04) && to) { - udelay(5); - to--; - } - if (!to) - printk(KERN_WARNING "waitforCEC timeout\n"); -} - -static inline void -waitforXFW_0(byte * base, byte hscx) -{ - long to = 20; - - while ((!(readhscx_0(base, hscx, HSCX_STAR) & 0x44)==0x40) && to) { - udelay(5); - to--; - } - if (!to) - printk(KERN_WARNING "waitforXFW timeout\n"); -} - -static inline void -waitforXFW_3(int iobase, byte hscx) -{ - long to = 20; - - while ((!(readhscx_3(iobase, hscx, HSCX_STAR) & 0x44)==0x40) && to) { - udelay(5); - to--; - } - if (!to) - printk(KERN_WARNING "waitforXFW timeout\n"); -} - -static inline void -writehscxCMDR_0(byte * base, byte hscx, byte data) -{ - long flags; - - save_flags(flags); - cli(); - waitforCEC_0(base, hscx); - writehscx_0(base, hscx, HSCX_CMDR, data); - restore_flags(flags); -} - -static inline void -writehscxCMDR_3(int iobase, byte hscx, byte data) -{ - long flags; - - save_flags(flags); - cli(); - waitforCEC_3(iobase, hscx); - writehscx_3(iobase, hscx, HSCX_CMDR, data); - restore_flags(flags); -} - -#define WRITEHSCX_CMDR(mbase,ibase,hscx,data) \ - ((mbase)?writehscxCMDR_0(mbase,hscx,data):writehscxCMDR_3(ibase,hscx,data)) - -/* - * fast interrupt here - */ - -#define ISAC_RCVBUFREADY 0 -#define ISAC_XMTBUFREADY 1 -#define ISAC_PHCHANGE 2 - -#define HSCX_RCVBUFREADY 0 -#define HSCX_XMTBUFREADY 1 - -void -teles_hscxreport(struct IsdnCardState *sp, int hscx) -{ - printk(KERN_DEBUG "HSCX %d\n", hscx); - if (sp->membase) { - printk(KERN_DEBUG " ISTA %x\n", readhscx_0(sp->membase, - hscx, HSCX_ISTA)); - printk(KERN_DEBUG " STAR %x\n", readhscx_0(sp->membase, - hscx, HSCX_STAR)); - printk(KERN_DEBUG " EXIR %x\n", readhscx_0(sp->membase, - hscx, HSCX_EXIR)); - } else { - printk(KERN_DEBUG " ISTA %x\n", readhscx_3(sp->iobase, - hscx, HSCX_ISTA)); - printk(KERN_DEBUG " STAR %x\n", readhscx_3(sp->iobase, - hscx, HSCX_STAR)); - printk(KERN_DEBUG " EXIR %x\n", readhscx_3(sp->iobase, - hscx, HSCX_EXIR)); - } -} - -void -teles_report(struct IsdnCardState *sp) -{ - printk(KERN_DEBUG "ISAC\n"); - if (sp->membase) { - printk(KERN_DEBUG " ISTA %x\n", readisac_0(sp->membase, - ISAC_ISTA)); - printk(KERN_DEBUG " STAR %x\n", readisac_0(sp->membase, - ISAC_STAR)); - printk(KERN_DEBUG " EXIR %x\n", readisac_0(sp->membase, - ISAC_EXIR)); - } else { - printk(KERN_DEBUG " ISTA %x\n", readisac_3(sp->iobase, - ISAC_ISTA)); - printk(KERN_DEBUG " STAR %x\n", readisac_3(sp->iobase, - ISAC_STAR)); - printk(KERN_DEBUG " EXIR %x\n", readisac_3(sp->iobase, - ISAC_EXIR)); - } - teles_hscxreport(sp, 0); - teles_hscxreport(sp, 1); -} - -/* - * HSCX stuff goes here - */ - -static void -hscx_sched_event(struct HscxState *hsp, int event) -{ - hsp->event |= 1 << event; - queue_task_irq_off(&hsp->tqueue, &tq_immediate); - mark_bh(IMMEDIATE_BH); -} - -static void -hscx_empty_fifo(struct HscxState *hsp, int count) -{ - byte *ptr; - struct BufHeader *ibh = hsp->rcvibh; - - if (hsp->sp->debug) - printk(KERN_DEBUG "hscx_empty_fifo\n"); - - if (hsp->rcvptr + count > BUFFER_SIZE(HSCX_RBUF_ORDER, - HSCX_RBUF_BPPS)) { - printk(KERN_WARNING - "hscx_empty_fifo: incoming packet too large\n"); - WRITEHSCX_CMDR(hsp->membase, hsp->iobase, hsp->hscx, 0x80); - return; - } - ptr = DATAPTR(ibh); - ptr += hsp->rcvptr; - - hsp->rcvptr += count; - if (hsp->membase) { - while (count--) - *ptr++ = readhscx_0(hsp->membase, hsp->hscx, 0x0); - writehscxCMDR_0(hsp->membase, hsp->hscx, 0x80); - } else { - readhscx_s(hsp->iobase, hsp->hscx, 0x3e, ptr, count); - writehscxCMDR_3(hsp->iobase, hsp->hscx, 0x80); - } -} - -static void -hscx_fill_fifo(struct HscxState *hsp) -{ - struct BufHeader *ibh; - int more, count; - byte *ptr; - - if (hsp->sp->debug) - printk(KERN_DEBUG "hscx_fill_fifo\n"); - - ibh = hsp->xmtibh; - if (!ibh) - return; - - count = ibh->datasize - hsp->sendptr; - if (count <= 0) - return; - - more = (hsp->mode == 1)?1:0; - if (count > 32) { - more = !0; - count = 32; - } - ptr = DATAPTR(ibh); - ptr += hsp->sendptr; - hsp->sendptr += count; - -#ifdef BCHAN_VERBOSE - { - int i; - printk(KERN_DEBUG "hscx_fill_fifo "); - for (i = 0; i < count; i++) - printk(" %2x", ptr[i]); - printk("\n"); - } -#endif - if (hsp->membase) { - waitforXFW_0(hsp->membase, hsp->hscx); - while (count--) - writehscx_0(hsp->membase, hsp->hscx, 0x0, *ptr++); - writehscxCMDR_0(hsp->membase, hsp->hscx, more ? 0x8 : 0xa); - } else { - waitforXFW_3(hsp->iobase, hsp->hscx); - writehscx_s(hsp->iobase, hsp->hscx, 0x3e, ptr, count); - writehscxCMDR_3(hsp->iobase, hsp->hscx, more ? 0x8 : 0xa); - } -} - -static inline void -hscx_interrupt(struct IsdnCardState *sp, byte val, byte hscx) -{ - byte r; - struct HscxState *hsp = sp->hs + hscx; - int count, err; - - if (!hsp->init) - return; - - if (val & 0x80) { /* RME */ - - r = READHSCX(hsp->membase, sp->iobase, hsp->hscx, HSCX_RSTA); - if ((r & 0xf0) != 0xa0) { - if (!r & 0x80) - printk(KERN_WARNING - "Teles: HSCX invalid frame\n"); - if ((r & 0x40) && hsp->mode) - printk(KERN_WARNING "Teles: HSCX RDO mode=%d\n",hsp->mode); - if (!r & 0x20) - printk(KERN_WARNING "Teles: HSCX CRC error\n"); - if (hsp->rcvibh) - BufPoolRelease(hsp->rcvibh); - hsp->rcvibh = NULL; - WRITEHSCX_CMDR(hsp->membase, hsp->iobase, hsp->hscx, - 0x80); - goto afterRME; - } - if (!hsp->rcvibh) - if (BufPoolGet(&hsp->rcvibh, &hsp->rbufpool, - GFP_ATOMIC, (void *) 1, 1)) { - printk(KERN_WARNING - "HSCX RME out of buffers at %ld\n", - jiffies); - WRITEHSCX_CMDR(hsp->membase, hsp->iobase, - hsp->hscx, 0x80); - goto afterRME; - } else - hsp->rcvptr = 0; - - count = READHSCX(hsp->membase, sp->iobase, hsp->hscx, - HSCX_RBCL) & 0x1f; - if (count == 0) - count = 32; - hscx_empty_fifo(hsp, count); - hsp->rcvibh->datasize = hsp->rcvptr - 1; - BufQueueLink(&hsp->rq, hsp->rcvibh); - hsp->rcvibh = NULL; - hscx_sched_event(hsp, HSCX_RCVBUFREADY); - } - afterRME: - if (val & 0x40) { /* RPF */ - if (!hsp->rcvibh) { - if (hsp->mode == 1) - err=BufPoolGet(&hsp->rcvibh, &hsp->smallpool, - GFP_ATOMIC, (void *)1, 2); - else - err=BufPoolGet(&hsp->rcvibh, &hsp->rbufpool, - GFP_ATOMIC, (void *)1, 2); - - if (err) { - printk(KERN_WARNING - "HSCX RPF out of buffers at %ld\n", - jiffies); - WRITEHSCX_CMDR(hsp->membase, hsp->iobase, - hsp->hscx, 0x80); - goto afterRPF; - } else - hsp->rcvptr = 0; - } - - hscx_empty_fifo(hsp, 32); - if (hsp->mode == 1) { - /* receive audio data */ - hsp->rcvibh->datasize = hsp->rcvptr; - BufQueueLink(&hsp->rq, hsp->rcvibh); - hsp->rcvibh = NULL; - hscx_sched_event(hsp, HSCX_RCVBUFREADY); - } - - } - afterRPF: - if (val & 0x10) { /* XPR */ - if (hsp->xmtibh) - if (hsp->xmtibh->datasize > hsp->sendptr) { - hscx_fill_fifo(hsp); - goto afterXPR; - } else { - if (hsp->releasebuf) - BufPoolRelease(hsp->xmtibh); - hsp->sendptr = 0; - if (hsp->st->l4.l1writewakeup) - hsp->st->l4.l1writewakeup(hsp->st); - hsp->xmtibh = NULL; - } - if (!BufQueueUnlink(&hsp->xmtibh, &hsp->sq)) { - hsp->releasebuf = !0; - hscx_fill_fifo(hsp); - } else - hscx_sched_event(hsp, HSCX_XMTBUFREADY); - } - afterXPR: -} - -/* - * ISAC stuff goes here - */ - -static void -isac_sched_event(struct IsdnCardState *sp, int event) -{ - sp->event |= 1 << event; - queue_task_irq_off(&sp->tqueue, &tq_immediate); - mark_bh(IMMEDIATE_BH); -} - -static void -empty_fifo(struct IsdnCardState *sp, int count) -{ - byte *ptr; - struct BufHeader *ibh = sp->rcvibh; - - if (sp->debug) - printk(KERN_DEBUG "empty_fifo\n"); - - if (sp->rcvptr >= 3072) { - printk(KERN_WARNING "empty_fifo rcvptr %d\n", sp->rcvptr); - return; - } - ptr = DATAPTR(ibh); - ptr += sp->rcvptr; - sp->rcvptr += count; - - if (sp->membase) { -#ifdef DCHAN_VERBOSE - printk(KERN_DEBUG "empty_fifo "); - while (count--) { - *ptr = readisac_0(sp->membase, 0x0); - printk("%2x ", *ptr); - ptr++; - } - printk("\n"); -#else - while (count--) - *ptr++ = readisac_0(sp->membase, 0x0); -#endif - writeisac_0(sp->membase, ISAC_CMDR, 0x80); - } else { -#ifdef DCHAN_VERBOSE - int i; - printk(KERN_DEBUG "empty_fifo "); - readisac_s(sp->iobase, 0x3e, ptr, count); - for (i = 0; i < count; i++) - printk("%2x ", ptr[i]); - printk("\n"); -#else - readisac_s(sp->iobase, 0x3e, ptr, count); -#endif - writeisac_3(sp->iobase, ISAC_CMDR, 0x80); - } -} - -static void -fill_fifo(struct IsdnCardState *sp) -{ - struct BufHeader *ibh; - int count, more; - byte *ptr; - - if (sp->debug) - printk(KERN_DEBUG "fill_fifo\n"); - - ibh = sp->xmtibh; - if (!ibh) - return; - - count = ibh->datasize - sp->sendptr; - if (count <= 0) - return; - if (count >= 3072) - return; - - more = 0; - if (count > 32) { - more = !0; - count = 32; - } - ptr = DATAPTR(ibh); - ptr += sp->sendptr; - sp->sendptr += count; - - if (sp->membase) { -#ifdef DCHAN_VERBOSE - printk(KERN_DEBUG "fill_fifo "); - while (count--) { - writeisac_0(sp->membase, 0x0, *ptr); - printk("%2x ", *ptr); - ptr++; - } - printk("\n"); -#else - while (count--) - writeisac_0(sp->membase, 0x0, *ptr++); -#endif - writeisac_0(sp->membase, ISAC_CMDR, more ? 0x8 : 0xa); - } else { -#ifdef DCHAN_VERBOSE - int i; - writeisac_s(sp->iobase, 0x3e, ptr, count); - printk(KERN_DEBUG "fill_fifo "); - for (i = 0; i < count; i++) - printk("%2x ", ptr[i]); - printk("\n"); -#else - writeisac_s(sp->iobase, 0x3e, ptr, count); -#endif - writeisac_3(sp->iobase, ISAC_CMDR, more ? 0x8 : 0xa); - } -} - -static int -act_wanted(struct IsdnCardState *sp) -{ - struct PStack *st; - - st = sp->stlist; - while (st) - if (st->l1.act_state) - return (!0); - else - st = st->next; - return (0); -} - -static void -ph_command(struct IsdnCardState *sp, unsigned int command) -{ - printk(KERN_DEBUG "ph_command %d\n", command); - WRITEISAC(sp->membase, sp->iobase, ISAC_CIX0, (command << 2) | 3); -} - -static void -isac_new_ph(struct IsdnCardState *sp) -{ - int enq; - - enq = act_wanted(sp); - - switch (sp->ph_state) { - case (0): - case (6): - if (enq) - ph_command(sp, 0); - else - ph_command(sp, 15); - break; - case (7): - if (enq) - ph_command(sp, 9); - break; - case (12): - ph_command(sp, 8); - sp->ph_active = 5; - isac_sched_event(sp, ISAC_PHCHANGE); - if (!sp->xmtibh) - if (!BufQueueUnlink(&sp->xmtibh, &sp->sq)) - sp->sendptr = 0; - if (sp->xmtibh) - fill_fifo(sp); - break; - case (13): - ph_command(sp, 9); - sp->ph_active = 5; - isac_sched_event(sp, ISAC_PHCHANGE); - if (!sp->xmtibh) - if (!BufQueueUnlink(&sp->xmtibh, &sp->sq)) - sp->sendptr = 0; - if (sp->xmtibh) - fill_fifo(sp); - break; - case (4): - case (8): - break; - default: - sp->ph_active = 0; - break; - } -} - -static void -teles_interrupt(int intno, void *dev_id, struct pt_regs *regs) -{ - byte val, r, exval; - struct IsdnCardState *sp; - unsigned int count; - struct HscxState *hsp; - - sp = (struct IsdnCardState *) irq2dev_map[intno]; - - if (!sp) { - printk(KERN_WARNING "Teles: Spurious interrupt!\n"); - return; - } - val = READHSCX(sp->membase, sp->iobase, 1, HSCX_ISTA); - - if (val & 0x01) { - hsp = sp->hs + 1; - exval = READHSCX(sp->membase, sp->iobase, 1, HSCX_EXIR); - if (exval == 0x40) { - if (hsp->mode == 1) - hscx_fill_fifo(hsp); - else { - /* Here we lost an TX interrupt, so - * restart transmitting the whole frame. - */ - hsp->sendptr = 0; - WRITEHSCX_CMDR(hsp->membase, hsp->iobase, - hsp->hscx, 0x01); - printk(KERN_DEBUG "HSCX B EXIR %x\n", exval); - } - } else - printk(KERN_WARNING "HSCX B EXIR %x\n", exval); - } - if (val & 0xf8) { - if (sp->debug) - printk(KERN_DEBUG "HSCX B interrupt %x\n", val); - hscx_interrupt(sp, val, 1); - } - if (val & 0x02) { - hsp = sp->hs; - exval = READHSCX(sp->membase, sp->iobase, 0, HSCX_EXIR); - if (exval == 0x40) { - if (hsp->mode == 1) - hscx_fill_fifo(hsp); - else { - /* Here we lost an TX interrupt, so - * restart transmitting the whole frame. - */ - hsp->sendptr = 0; - WRITEHSCX_CMDR(hsp->membase, hsp->iobase, - hsp->hscx, 0x01); - printk(KERN_DEBUG "HSCX A EXIR %x\n", exval); - } - } else - printk(KERN_WARNING "HSCX A EXIR %x\n", exval); - } - if (val & 0x04) { - val = READHSCX(sp->membase, sp->iobase, 0, HSCX_ISTA); - if (sp->debug) - printk(KERN_DEBUG "HSCX A interrupt %x\n", - val); - hscx_interrupt(sp, val, 0); - } - - val = READISAC(sp->membase, sp->iobase, ISAC_ISTA); - - if (sp->debug) - printk(KERN_DEBUG "ISAC interrupt %x\n", val); - - if (val & 0x80) { /* RME */ - - r = READISAC(sp->membase, sp->iobase, ISAC_RSTA); - if ((r & 0x70) != 0x20) { - if (r & 0x40) - printk(KERN_WARNING "Teles: ISAC RDO\n"); - if (!r & 0x20) - printk(KERN_WARNING "Teles: ISAC CRC error\n"); - if (sp->rcvibh) - BufPoolRelease(sp->rcvibh); - sp->rcvibh = NULL; - WRITEISAC(sp->membase, sp->iobase, ISAC_CMDR, 0x80); - goto afterRME; - } - if (!sp->rcvibh) - if (BufPoolGet(&(sp->rcvibh), &(sp->rbufpool), - GFP_ATOMIC, - (void *) 1, 3)) { - printk(KERN_WARNING - "ISAC RME out of buffers!\n"); - WRITEISAC(sp->membase, sp->iobase, - ISAC_CMDR, 0x80); - goto afterRME; - } else - sp->rcvptr = 0; - - count = READISAC(sp->membase, sp->iobase, ISAC_RBCL) & 0x1f; - if (count == 0) - count = 32; - empty_fifo(sp, count); - sp->rcvibh->datasize = sp->rcvptr; - BufQueueLink(&(sp->rq), sp->rcvibh); - sp->rcvibh = NULL; - isac_sched_event(sp, ISAC_RCVBUFREADY); - } - afterRME: - if (val & 0x40) { /* RPF */ - if (!sp->rcvibh) - if (BufPoolGet(&(sp->rcvibh), &(sp->rbufpool), - GFP_ATOMIC, - (void *) 1, 4)) { - printk(KERN_WARNING - "ISAC RME out of buffers!\n"); - WRITEISAC(sp->membase, sp->iobase, - ISAC_CMDR, 0x80); - goto afterRPF; - } else - sp->rcvptr = 0; - empty_fifo(sp, 32); - } - afterRPF: - if (val & 0x20) { - } - if (val & 0x10) { /* XPR */ - if (sp->xmtibh) - if (sp->xmtibh->datasize > sp->sendptr) { - fill_fifo(sp); - goto afterXPR; - } else { - if (sp->releasebuf) - BufPoolRelease(sp->xmtibh); - sp->xmtibh = NULL; - sp->sendptr = 0; - } - if (!BufQueueUnlink(&sp->xmtibh, &sp->sq)) { - sp->releasebuf = !0; - fill_fifo(sp); - } else - isac_sched_event(sp, ISAC_XMTBUFREADY); - } - afterXPR: - if (val & 0x04) { /* CISQ */ - sp->ph_state = (READISAC(sp->membase, sp->iobase, ISAC_CIX0) - >> 2) & 0xf; - printk(KERN_DEBUG "l1state %d\n", sp->ph_state); - isac_new_ph(sp); - } - if (sp->membase) { - writeisac_0(sp->membase, ISAC_MASK, 0xFF); - writehscx_0(sp->membase, 0, HSCX_MASK, 0xFF); - writehscx_0(sp->membase, 1, HSCX_MASK, 0xFF); - writeisac_0(sp->membase, ISAC_MASK, 0x0); - writehscx_0(sp->membase, 0, HSCX_MASK, 0x0); - writehscx_0(sp->membase, 1, HSCX_MASK, 0x0); - } else { - writeisac_3(sp->iobase, ISAC_MASK, 0xFF); - writehscx_3(sp->iobase, 0, HSCX_MASK, 0xFF); - writehscx_3(sp->iobase, 1, HSCX_MASK, 0xFF); - writeisac_3(sp->iobase, ISAC_MASK, 0x0); - writehscx_3(sp->iobase, 0, HSCX_MASK, 0x0); - writehscx_3(sp->iobase, 1, HSCX_MASK, 0x0); - } -} - -/* - * soft interrupt - */ - -static void -act_ivated(struct IsdnCardState *sp) -{ - struct PStack *st; - - st = sp->stlist; - while (st) { - if (st->l1.act_state == 1) { - st->l1.act_state = 2; - st->l1.l1man(st, PH_ACTIVATE, NULL); - } - st = st->next; - } -} - -static void -process_new_ph(struct IsdnCardState *sp) -{ - if (sp->ph_active == 5) - act_ivated(sp); -} - -static void -process_xmt(struct IsdnCardState *sp) -{ - struct PStack *stptr; - - if (sp->xmtibh) - return; - - stptr = sp->stlist; - while (stptr != NULL) - if (stptr->l1.requestpull) { - stptr->l1.requestpull = 0; - stptr->l1.l1l2(stptr, PH_PULL_ACK, NULL); - break; - } else - stptr = stptr->next; -} - -static void -process_rcv(struct IsdnCardState *sp) -{ - struct BufHeader *ibh, *cibh; - struct PStack *stptr; - byte *ptr; - int found, broadc; - char tmp[64]; - - while (!BufQueueUnlink(&ibh, &sp->rq)) { - stptr = sp->stlist; - ptr = DATAPTR(ibh); - broadc = (ptr[1] >> 1) == 127; - - if (broadc && sp->dlogflag && (!(ptr[0] >> 2))) - dlogframe(sp, ptr + 3, ibh->datasize - 3, - "Q.931 frame network->user broadcast"); - - if (broadc) { - while (stptr != NULL) { - if ((ptr[0] >> 2) == stptr->l2.sap) - if (!BufPoolGet(&cibh, &sp->rbufpool, GFP_ATOMIC, - (void *) 1, 5)) { - memcpy(DATAPTR(cibh), DATAPTR(ibh), ibh->datasize); - cibh->datasize = ibh->datasize; - stptr->l1.l1l2(stptr, PH_DATA, cibh); - } else - printk(KERN_WARNING "isdn broadcast buffer shortage\n"); - stptr = stptr->next; - } - BufPoolRelease(ibh); - } else { - found = 0; - while (stptr != NULL) - if (((ptr[0] >> 2) == stptr->l2.sap) && - ((ptr[1] >> 1) == stptr->l2.tei)) { - stptr->l1.l1l2(stptr, PH_DATA, ibh); - found = !0; - break; - } else - stptr = stptr->next; - if (!found) { - /* BD 10.10.95 - * Print out D-Channel msg not processed - * by isdn4linux - */ - - if ((!(ptr[0] >> 2)) && (!(ptr[2] & 0x01))) { - sprintf(tmp, "Q.931 frame network->user with tei %d (not for us)", ptr[1] >> 1); - dlogframe(sp, ptr + 4, ibh->datasize - 4, tmp); - } - BufPoolRelease(ibh); - } - } - - } - -} - -static void -isac_bh(struct IsdnCardState *sp) -{ - if (!sp) - return; - - if (clear_bit(ISAC_PHCHANGE, &sp->event)) - process_new_ph(sp); - if (clear_bit(ISAC_RCVBUFREADY, &sp->event)) - process_rcv(sp); - if (clear_bit(ISAC_XMTBUFREADY, &sp->event)) - process_xmt(sp); -} - - -static void -hscx_process_xmt(struct HscxState *hsp) -{ - struct PStack *st = hsp->st; - - if (hsp->xmtibh) - return; - - if (st->l1.requestpull) { - st->l1.requestpull = 0; - st->l1.l1l2(st, PH_PULL_ACK, NULL); - } - if (!hsp->active) - if ((!hsp->xmtibh) && (!hsp->sq.head)) - modehscx(hsp, 0, 0); -} - -static void -hscx_process_rcv(struct HscxState *hsp) -{ - struct BufHeader *ibh; - -#ifdef DEBUG_MAGIC - if (hsp->magic != 301270) { - printk(KERN_DEBUG "hscx_process_rcv magic not 301270\n"); - return; - } -#endif - while (!BufQueueUnlink(&ibh, &hsp->rq)) { - hsp->st->l1.l1l2(hsp->st, PH_DATA, ibh); - } -} - -static void -hscx_bh(struct HscxState *hsp) -{ - - if (!hsp) - return; - - if (clear_bit(HSCX_RCVBUFREADY, &hsp->event)) - hscx_process_rcv(hsp); - if (clear_bit(HSCX_XMTBUFREADY, &hsp->event)) - hscx_process_xmt(hsp); - -} - -/* - * interrupt stuff ends here - */ - -static void -restart_ph(struct IsdnCardState *sp) -{ - switch (sp->ph_active) { - case (0): - if (sp->ph_state == 6) - ph_command(sp, 0); - else - ph_command(sp, 1); - sp->ph_active = 1; - break; - } -} - -static void -initisac(byte * cardmem, int iobase) -{ - if (cardmem) { - writeisac_0(cardmem, ISAC_MASK, 0xff); - writeisac_0(cardmem, ISAC_ADF2, 0x0); - writeisac_0(cardmem, ISAC_SPCR, 0xa); - writeisac_0(cardmem, ISAC_ADF1, 0x2); - writeisac_0(cardmem, ISAC_STCR, 0x70); - writeisac_0(cardmem, ISAC_MODE, 0xc9); - writeisac_0(cardmem, ISAC_CMDR, 0x41); - writeisac_0(cardmem, ISAC_CIX0, (1 << 2) | 3); - } else { - writeisac_3(iobase, ISAC_MASK, 0xff); - writeisac_3(iobase, ISAC_ADF2, 0x80); - writeisac_3(iobase, ISAC_SQXR, 0x2f); - writeisac_3(iobase, ISAC_SPCR, 0x00); - writeisac_3(iobase, ISAC_ADF1, 0x02); - writeisac_3(iobase, ISAC_STCR, 0x70); - writeisac_3(iobase, ISAC_MODE, 0xc9); - writeisac_3(iobase, ISAC_TIMR, 0x00); - writeisac_3(iobase, ISAC_ADF1, 0x00); - writeisac_3(iobase, ISAC_CMDR, 0x41); - writeisac_3(iobase, ISAC_CIX0, (1 << 2) | 3); - } -} - -static int -checkcard(int cardnr) -{ - int timout; - byte cfval, val; - struct IsdnCard *card = cards + cardnr; - - if (card->membase) - if ((unsigned long)card->membase < 0x10000) { - (unsigned long)card->membase <<= 4; - printk(KERN_INFO - "Teles membase configured DOSish, assuming 0x%lx\n", - (unsigned long)card->membase); - } - if (!card->iobase) { - if (card->membase) { - printk(KERN_NOTICE - "Teles 8 assumed, mem: %lx irq: %d proto: %s\n", - (long) card->membase, card->interrupt, - (card->protocol == ISDN_PTYPE_1TR6) ? - "1TR6" : "EDSS1"); - printk(KERN_INFO "HSCX version A:%x B:%x\n", - readhscx_0(card->membase, 0, HSCX_VSTR) & 0xf, - readhscx_0(card->membase, 1, HSCX_VSTR) & 0xf); - } - } else { - switch (card->iobase) { - case 0x180: - case 0x280: - case 0x380: - card->iobase |= 0xc00; - break; - } - if (card->membase) { /* 16.0 */ - if (check_region(card->iobase, 8)) { - printk(KERN_WARNING - "teles: ports %x-%x already in use\n", - card->iobase, - card->iobase + 8 ); - return -1; - } - } else { /* 16.3 */ - if (check_region(card->iobase, 16)) { - printk(KERN_WARNING - "teles: 16.3 ports %x-%x already in use\n", - card->iobase, - card->iobase + 16 ); - return -1; - } - if (check_region((card->iobase - 0xc00) , 32)) { - printk(KERN_WARNING - "teles: 16.3 ports %x-%x already in use\n", - card->iobase - 0xc00, - card->iobase - 0xc00 + 32); - return -1; - } - if (check_region((card->iobase - 0x800) , 32)) { - printk(KERN_WARNING - "teles: 16.3 ports %x-%x already in use\n", - card->iobase - 0x800, - card->iobase - 0x800 + 32); - return -1; - } - if (check_region((card->iobase - 0x400) , 32)) { - printk(KERN_WARNING - "teles: 16.3 ports %x-%x already in use\n", - card->iobase - 0x400, - card->iobase - 0x400 + 32); - return -1; - } - } - switch (card->interrupt) { - case 2: - cfval = 0x00; - break; - case 3: - cfval = 0x02; - break; - case 4: - cfval = 0x04; - break; - case 5: - cfval = 0x06; - break; - case 10: - cfval = 0x08; - break; - case 11: - cfval = 0x0A; - break; - case 12: - cfval = 0x0C; - break; - case 15: - cfval = 0x0E; - break; - default: - cfval = 0x00; - break; - } - if (card->membase) { - cfval |= (((unsigned int) card->membase >> 9) & 0xF0); - } - if (bytein(card->iobase + 0) != 0x51) { - printk(KERN_INFO "XXX Byte at %x is %x\n", - card->iobase + 0, - bytein(card->iobase + 0)); - return -2; - } - if (bytein(card->iobase + 1) != 0x93) { - printk(KERN_INFO "XXX Byte at %x is %x\n", - card->iobase + 1, - bytein(card->iobase + 1)); - return -2; - } - val = bytein(card->iobase + 2); /* 0x1e=without AB - * 0x1f=with AB - * 0x1c 16.3 ??? - */ - if (val != 0x1c && val != 0x1e && val != 0x1f) { - printk(KERN_INFO "XXX Byte at %x is %x\n", - card->iobase + 2, - bytein(card->iobase + 2)); - return -2; - } - if (card->membase) { /* 16.0 */ - request_region(card->iobase, 8, "teles 16.0"); - } else { - request_region(card->iobase, 16, "teles 16.3"); - request_region(card->iobase - 0xC00, 32, "teles HSCX0"); - request_region(card->iobase - 0x800, 32, "teles HSCX1"); - request_region(card->iobase - 0x400, 32, "teles ISAC"); - } - cli(); - timout = jiffies + (HZ / 10) + 1; - byteout(card->iobase + 4, cfval); - sti(); - while (jiffies <= timout); - - cli(); - timout = jiffies + (HZ / 10) + 1; - byteout(card->iobase + 4, cfval | 1); - sti(); - while (jiffies <= timout); - - if (card->membase) - printk(KERN_NOTICE - "Teles 16.0 found, io: %x mem: %lx irq: %d proto: %s\n", - card->iobase, (long) card->membase, - card->interrupt, - (card->protocol == ISDN_PTYPE_1TR6) ? - "1TR6" : "EDSS1"); - else - printk(KERN_NOTICE - "Teles 16.3 found, io: %x irq: %d proto: %s\n", - card->iobase, card->interrupt, - (card->protocol == ISDN_PTYPE_1TR6) ? - "1TR6" : "EDSS1"); - printk(KERN_INFO "HSCX version A:%x B:%x\n", - READHSCX(card->membase, card->iobase, 0, - HSCX_VSTR) & 0xf, - READHSCX(card->membase, card->iobase, 1, - HSCX_VSTR) & 0xf); - - } - if (card->membase) { - cli(); - timout = jiffies + (HZ / 5) + 1; - writeb(0, card->membase + 0x80); - sti(); - while (jiffies <= timout); - - cli(); - writeb(1, card->membase + 0x80); - timout = jiffies + (HZ / 5) + 1; - sti(); - while (jiffies <= timout); - } - return (0); -} - -void -modehscx(struct HscxState *hs, int mode, - int ichan) -{ - struct IsdnCardState *sp = hs->sp; - int hscx = hs->hscx; - - printk(KERN_DEBUG "modehscx hscx %d mode %d ichan %d\n", - hscx, mode, ichan); - - hs->mode = mode; - if (sp->membase) { - /* What's that ??? KKeil */ - if (hscx == 0) - ichan = 1 - ichan; /* raar maar waar... */ - writehscx_0(sp->membase, hscx, HSCX_CCR1, 0x85); - writehscx_0(sp->membase, hscx, HSCX_XAD1, 0xFF); - writehscx_0(sp->membase, hscx, HSCX_XAD2, 0xFF); - writehscx_0(sp->membase, hscx, HSCX_RAH2, 0xFF); - writehscx_0(sp->membase, hscx, HSCX_XBCH, 0x0); - - switch (mode) { - case (0): - writehscx_0(sp->membase, hscx, HSCX_CCR2, 0x30); - writehscx_0(sp->membase, hscx, HSCX_TSAX, 0xff); - writehscx_0(sp->membase, hscx, HSCX_TSAR, 0xff); - writehscx_0(sp->membase, hscx, HSCX_XCCR, 7); - writehscx_0(sp->membase, hscx, HSCX_RCCR, 7); - writehscx_0(sp->membase, hscx, HSCX_MODE, 0x84); - break; - case (1): - if (ichan == 0) { - writehscx_0(sp->membase, hscx, HSCX_CCR2, 0x30); - writehscx_0(sp->membase, hscx, HSCX_TSAX, 0x7); - writehscx_0(sp->membase, hscx, HSCX_TSAR, 0x7); - writehscx_0(sp->membase, hscx, HSCX_XCCR, 7); - writehscx_0(sp->membase, hscx, HSCX_RCCR, 7); - } else { - writehscx_0(sp->membase, hscx, HSCX_CCR2, 0x30); - writehscx_0(sp->membase, hscx, HSCX_TSAX, 0x3); - writehscx_0(sp->membase, hscx, HSCX_TSAR, 0x3); - writehscx_0(sp->membase, hscx, HSCX_XCCR, 7); - writehscx_0(sp->membase, hscx, HSCX_RCCR, 7); - } - writehscx_0(sp->membase, hscx, HSCX_MODE, 0xe4); - writehscx_0(sp->membase, hscx, HSCX_CMDR, 0x41); - break; - case (2): - if (ichan == 0) { - writehscx_0(sp->membase, hscx, HSCX_CCR2, 0x30); - writehscx_0(sp->membase, hscx, HSCX_TSAX, 0x7); - writehscx_0(sp->membase, hscx, HSCX_TSAR, 0x7); - writehscx_0(sp->membase, hscx, HSCX_XCCR, 7); - writehscx_0(sp->membase, hscx, HSCX_RCCR, 7); - } else { - writehscx_0(sp->membase, hscx, HSCX_CCR2, 0x30); - writehscx_0(sp->membase, hscx, HSCX_TSAX, 0x3); - writehscx_0(sp->membase, hscx, HSCX_TSAR, 0x3); - writehscx_0(sp->membase, hscx, HSCX_XCCR, 7); - writehscx_0(sp->membase, hscx, HSCX_RCCR, 7); - } - writehscx_0(sp->membase, hscx, HSCX_MODE, 0x8c); - writehscx_0(sp->membase, hscx, HSCX_CMDR, 0x41); - break; - } - writehscx_0(sp->membase, hscx, HSCX_ISTA, 0x00); - } else { - writehscx_3(sp->iobase, hscx, HSCX_CCR1, 0x85); - writehscx_3(sp->iobase, hscx, HSCX_XAD1, 0xFF); - writehscx_3(sp->iobase, hscx, HSCX_XAD2, 0xFF); - writehscx_3(sp->iobase, hscx, HSCX_RAH2, 0xFF); - writehscx_3(sp->iobase, hscx, HSCX_XBCH, 0x00); - writehscx_3(sp->iobase, hscx, HSCX_RLCR, 0x00); - - switch (mode) { - case (0): - writehscx_3(sp->iobase, hscx, HSCX_CCR2, 0x30); - writehscx_3(sp->iobase, hscx, HSCX_TSAX, 0xff); - writehscx_3(sp->iobase, hscx, HSCX_TSAR, 0xff); - writehscx_3(sp->iobase, hscx, HSCX_XCCR, 7); - writehscx_3(sp->iobase, hscx, HSCX_RCCR, 7); - writehscx_3(sp->iobase, hscx, HSCX_MODE, 0x84); - break; - case (1): - if (ichan == 0) { - writehscx_3(sp->iobase, hscx, HSCX_CCR2, 0x30); - writehscx_3(sp->iobase, hscx, HSCX_TSAX, 0x2f); - writehscx_3(sp->iobase, hscx, HSCX_TSAR, 0x2f); - writehscx_3(sp->iobase, hscx, HSCX_XCCR, 7); - writehscx_3(sp->iobase, hscx, HSCX_RCCR, 7); - } else { - writehscx_3(sp->iobase, hscx, HSCX_CCR2, 0x30); - writehscx_3(sp->iobase, hscx, HSCX_TSAX, 0x3); - writehscx_3(sp->iobase, hscx, HSCX_TSAR, 0x3); - writehscx_3(sp->iobase, hscx, HSCX_XCCR, 7); - writehscx_3(sp->iobase, hscx, HSCX_RCCR, 7); - } - writehscx_3(sp->iobase, hscx, HSCX_MODE, 0xe4); - writehscx_3(sp->iobase, hscx, HSCX_CMDR, 0x41); - break; - case (2): - if (ichan == 0) { - writehscx_3(sp->iobase, hscx, HSCX_CCR2, 0x30); - writehscx_3(sp->iobase, hscx, HSCX_TSAX, 0x2f); - writehscx_3(sp->iobase, hscx, HSCX_TSAR, 0x2f); - writehscx_3(sp->iobase, hscx, HSCX_XCCR, 7); - writehscx_3(sp->iobase, hscx, HSCX_RCCR, 7); - } else { - writehscx_3(sp->iobase, hscx, HSCX_CCR2, 0x30); - writehscx_3(sp->iobase, hscx, HSCX_TSAX, 0x3); - writehscx_3(sp->iobase, hscx, HSCX_TSAR, 0x3); - writehscx_3(sp->iobase, hscx, HSCX_XCCR, 7); - writehscx_3(sp->iobase, hscx, HSCX_RCCR, 7); - } - writehscx_3(sp->iobase, hscx, HSCX_MODE, 0x8c); - writehscx_3(sp->iobase, hscx, HSCX_CMDR, 0x41); - break; - } - writehscx_3(sp->iobase, hscx, HSCX_ISTA, 0x00); - } -} - -void -teles_addlist(struct IsdnCardState *sp, - struct PStack *st) -{ - st->next = sp->stlist; - sp->stlist = st; -} - -void -teles_rmlist(struct IsdnCardState *sp, - struct PStack *st) -{ - struct PStack *p; - - if (sp->stlist == st) - sp->stlist = st->next; - else { - p = sp->stlist; - while (p) - if (p->next == st) { - p->next = st->next; - return; - } else - p = p->next; - } -} - - -static void -teles_l2l1(struct PStack *st, int pr, - struct BufHeader *ibh) -{ - struct IsdnCardState *sp = (struct IsdnCardState *) - st->l1.hardware; - - - switch (pr) { - case (PH_DATA): - if (sp->xmtibh) - BufQueueLink(&sp->sq, ibh); - else { - sp->xmtibh = ibh; - sp->sendptr = 0; - sp->releasebuf = !0; - fill_fifo(sp); - } - break; - case (PH_DATA_PULLED): - if (sp->xmtibh) { - printk(KERN_DEBUG "teles_l2l1: this shouldn't happen\n"); - break; - } - sp->xmtibh = ibh; - sp->sendptr = 0; - sp->releasebuf = 0; - fill_fifo(sp); - break; - case (PH_REQUEST_PULL): - if (!sp->xmtibh) { - st->l1.requestpull = 0; - st->l1.l1l2(st, PH_PULL_ACK, NULL); - } else - st->l1.requestpull = !0; - break; - } -} - -static void -check_ph_act(struct IsdnCardState *sp) -{ - struct PStack *st = sp->stlist; - - while (st) { - if (st->l1.act_state) - return; - st = st->next; - } - sp->ph_active = 0; -} - -static void -teles_manl1(struct PStack *st, int pr, - void *arg) -{ - struct IsdnCardState *sp = (struct IsdnCardState *) - st->l1.hardware; - long flags; - - switch (pr) { - case (PH_ACTIVATE): - save_flags(flags); - cli(); - if (sp->ph_active == 5) { - st->l1.act_state = 2; - restore_flags(flags); - st->l1.l1man(st, PH_ACTIVATE, NULL); - } else { - st->l1.act_state = 1; - if (sp->ph_active == 0) - restart_ph(sp); - restore_flags(flags); - } - break; - case (PH_DEACTIVATE): - st->l1.act_state = 0; - check_ph_act(sp); - break; - } -} - -static void -teles_l2l1discardq(struct PStack *st, int pr, - void *heldby, int releasetoo) -{ - struct IsdnCardState *sp = (struct IsdnCardState *) st->l1.hardware; - -#ifdef DEBUG_MAGIC - if (sp->magic != 301271) { - printk(KERN_DEBUG "isac_discardq magic not 301271\n"); - return; - } -#endif - - BufQueueDiscard(&sp->sq, pr, heldby, releasetoo); -} - -void -setstack_teles(struct PStack *st, struct IsdnCardState *sp) -{ - st->l1.hardware = sp; - st->l1.sbufpool = &(sp->sbufpool); - st->l1.rbufpool = &(sp->rbufpool); - st->l1.smallpool = &(sp->smallpool); - st->protocol = sp->teistack->protocol; - - setstack_tei(st); - - st->l1.stlistp = &(sp->stlist); - st->l1.act_state = 0; - st->l2.l2l1 = teles_l2l1; - st->l2.l2l1discardq = teles_l2l1discardq; - st->ma.manl1 = teles_manl1; - st->l1.requestpull = 0; -} - -void -init_hscxstate(struct IsdnCardState *sp, - int hscx) -{ - struct HscxState *hsp = sp->hs + hscx; - - hsp->sp = sp; - hsp->hscx = hscx; - hsp->membase = sp->membase; - hsp->iobase = sp->iobase; - - hsp->tqueue.next = 0; - hsp->tqueue.sync = 0; - hsp->tqueue.routine = (void *) (void *) hscx_bh; - hsp->tqueue.data = hsp; - - hsp->inuse = 0; - hsp->init = 0; - hsp->active = 0; - -#ifdef DEBUG_MAGIC - hsp->magic = 301270; -#endif -} - -void -initcard(int cardnr) -{ - struct IsdnCardState *sp; - struct IsdnCard *card = cards + cardnr; - - sp = (struct IsdnCardState *) - Smalloc(sizeof(struct IsdnCardState), GFP_KERNEL, - "struct IsdnCardState"); - - sp->membase = card->membase; - sp->iobase = card->iobase; - sp->cardnr = cardnr; - - BufPoolInit(&sp->sbufpool, ISAC_SBUF_ORDER, ISAC_SBUF_BPPS, - ISAC_SBUF_MAXPAGES); - BufPoolInit(&sp->rbufpool, ISAC_RBUF_ORDER, ISAC_RBUF_BPPS, - ISAC_RBUF_MAXPAGES); - BufPoolInit(&sp->smallpool, ISAC_SMALLBUF_ORDER, ISAC_SMALLBUF_BPPS, - ISAC_SMALLBUF_MAXPAGES); - - sp->dlogspace = Smalloc(4096, GFP_KERNEL, "dlogspace"); - - initisac(card->membase, card->iobase); - - sp->rcvibh = NULL; - sp->rcvptr = 0; - sp->xmtibh = NULL; - sp->sendptr = 0; - sp->event = 0; - sp->tqueue.next = 0; - sp->tqueue.sync = 0; - sp->tqueue.routine = (void *) (void *) isac_bh; - sp->tqueue.data = sp; - - BufQueueInit(&sp->rq); - BufQueueInit(&sp->sq); - - sp->stlist = NULL; - - sp->ph_active = 0; - - sp->dlogflag = 0; - sp->debug = 0; - - sp->releasebuf = 0; -#ifdef DEBUG_MAGIC - sp->magic = 301271; -#endif - - cards[sp->cardnr].sp = sp; - - init_hscxstate(sp, 0); - init_hscxstate(sp, 1); - - modehscx(sp->hs, 0, 0); - modehscx(sp->hs + 1, 0, 0); - - WRITEISAC(sp->membase, sp->iobase, ISAC_MASK, 0x0); -} - -static int -get_irq(int cardnr) -{ - struct IsdnCard *card = cards + cardnr; - long flags; - - save_flags(flags); - cli(); - if (request_irq(card->interrupt, &teles_interrupt, - SA_INTERRUPT, "teles", NULL)) { - printk(KERN_WARNING "Teles couldn't get interrupt %d\n", - card->interrupt); - restore_flags(flags); - return (!0); - } - irq2dev_map[card->interrupt] = (void *) card->sp; - restore_flags(flags); - return (0); -} - -static void -release_irq(int cardnr) -{ - struct IsdnCard *card = cards + cardnr; - - irq2dev_map[card->interrupt] = NULL; - free_irq(card->interrupt, NULL); -} - -void -close_hscxstate(struct HscxState *hs) -{ - modehscx(hs, 0, 0); - hs->inuse = 0; - - if (hs->init) { - BufPoolFree(&hs->smallpool); - BufPoolFree(&hs->rbufpool); - BufPoolFree(&hs->sbufpool); - } - hs->init = 0; -} - -void -closecard(int cardnr) -{ - struct IsdnCardState *sp = cards[cardnr].sp; - - cards[cardnr].sp = NULL; - - Sfree(sp->dlogspace); - - BufPoolFree(&sp->smallpool); - BufPoolFree(&sp->rbufpool); - BufPoolFree(&sp->sbufpool); - - close_hscxstate(sp->hs + 1); - close_hscxstate(sp->hs); - - if (cards[cardnr].iobase) - if (cards[cardnr].membase) { /* 16.0 */ - release_region(cards[cardnr].iobase, 8); - } else { - release_region(cards[cardnr].iobase, 16); - release_region(cards[cardnr].iobase - 0xC00, 32); - release_region(cards[cardnr].iobase - 0x800, 32); - release_region(cards[cardnr].iobase - 0x400, 32); - } - - Sfree((void *) sp); -} - -void -teles_shiftcards(int idx) -{ - int i; - - for (i = idx; i < 15; i++) - memcpy(&cards[i],&cards[i+1],sizeof(cards[i])); -} - -int -teles_inithardware(void) -{ - int foundcards = 0; - int i = 0; - - while (i < nrcards) { - if (!cards[i].protocol) - break; - switch (checkcard(i)) { - case (0): - initcard(i); - if (get_irq(i)) { - closecard(i); - teles_shiftcards(i); - } else { - foundcards++; - i++; - } - break; - case (-1): - teles_shiftcards(i); - break; - case (-2): - release_region(cards[i].iobase, 8); - printk(KERN_WARNING "NO Teles card found at 0x%x!\n", cards[i].iobase); - teles_shiftcards(i); - break; - } - } - return foundcards; -} - -void -teles_closehardware(void) -{ - int i; - - for (i = 0; i < nrcards; i++) - if (cards[i].sp) { - release_irq(i); - closecard(i); - } -} - -static void -hscx_l2l1(struct PStack *st, int pr, - struct BufHeader *ibh) -{ - struct IsdnCardState *sp = (struct IsdnCardState *) - st->l1.hardware; - struct HscxState *hsp = sp->hs + st->l1.hscx; - long flags; - - switch (pr) { - case (PH_DATA): - save_flags(flags); - cli(); - if (hsp->xmtibh) { - BufQueueLink(&hsp->sq, ibh); - restore_flags(flags); - } - else { - restore_flags(flags); - hsp->xmtibh = ibh; - hsp->sendptr = 0; - hsp->releasebuf = !0; - hscx_fill_fifo(hsp); - } - break; - case (PH_DATA_PULLED): - if (hsp->xmtibh) { - printk(KERN_DEBUG "hscx_l2l1: this shouldn't happen\n"); - break; - } - hsp->xmtibh = ibh; - hsp->sendptr = 0; - hsp->releasebuf = 0; - hscx_fill_fifo(hsp); - break; - case (PH_REQUEST_PULL): - if (!hsp->xmtibh) { - st->l1.requestpull = 0; - st->l1.l1l2(st, PH_PULL_ACK, NULL); - } else - st->l1.requestpull = !0; - break; - } - -} - -extern struct IsdnBuffers *tracebuf; - -static void -hscx_l2l1discardq(struct PStack *st, int pr, void *heldby, - int releasetoo) -{ - struct IsdnCardState *sp = (struct IsdnCardState *) - st->l1.hardware; - struct HscxState *hsp = sp->hs + st->l1.hscx; - -#ifdef DEBUG_MAGIC - if (hsp->magic != 301270) { - printk(KERN_DEBUG "hscx_discardq magic not 301270\n"); - return; - } -#endif - - BufQueueDiscard(&hsp->sq, pr, heldby, releasetoo); -} - -static int -open_hscxstate(struct IsdnCardState *sp, - int hscx) -{ - struct HscxState *hsp = sp->hs + hscx; - - if (!hsp->init) { - BufPoolInit(&hsp->sbufpool, HSCX_SBUF_ORDER, HSCX_SBUF_BPPS, - HSCX_SBUF_MAXPAGES); - BufPoolInit(&hsp->rbufpool, HSCX_RBUF_ORDER, HSCX_RBUF_BPPS, - HSCX_RBUF_MAXPAGES); - BufPoolInit(&hsp->smallpool, HSCX_SMALLBUF_ORDER, HSCX_SMALLBUF_BPPS, - HSCX_SMALLBUF_MAXPAGES); - } - hsp->init = !0; - - BufQueueInit(&hsp->rq); - BufQueueInit(&hsp->sq); - - hsp->releasebuf = 0; - hsp->rcvibh = NULL; - hsp->xmtibh = NULL; - hsp->rcvptr = 0; - hsp->sendptr = 0; - hsp->event = 0; - return (0); -} - -static void -hscx_manl1(struct PStack *st, int pr, - void *arg) -{ - struct IsdnCardState *sp = (struct IsdnCardState *) - st->l1.hardware; - struct HscxState *hsp = sp->hs + st->l1.hscx; - - switch (pr) { - case (PH_ACTIVATE): - hsp->active = !0; - modehscx(hsp, st->l1.hscxmode, st->l1.hscxchannel); - st->l1.l1man(st, PH_ACTIVATE, NULL); - break; - case (PH_DEACTIVATE): - if (!hsp->xmtibh) - modehscx(hsp, 0, 0); - - hsp->active = 0; - break; - } -} - -int -setstack_hscx(struct PStack *st, struct HscxState *hs) -{ - if (open_hscxstate(st->l1.hardware, hs->hscx)) - return (-1); - - st->l1.hscx = hs->hscx; - st->l2.l2l1 = hscx_l2l1; - st->ma.manl1 = hscx_manl1; - st->l2.l2l1discardq = hscx_l2l1discardq; - - st->l1.sbufpool = &hs->sbufpool; - st->l1.rbufpool = &hs->rbufpool; - st->l1.smallpool = &hs->smallpool; - st->l1.act_state = 0; - st->l1.requestpull = 0; - - hs->st = st; - return (0); -} - -void -teles_reportcard(int cardnr) -{ - printk(KERN_DEBUG "teles_reportcard\n"); -} diff --git a/drivers/isdn/teles/config.c b/drivers/isdn/teles/config.c deleted file mode 100644 index 1a9d2d873..000000000 --- a/drivers/isdn/teles/config.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $Id: config.c,v 1.1 1996/04/13 10:23:11 fritz Exp $ - * - * $Log: config.c,v $ - * Revision 1.1 1996/04/13 10:23:11 fritz - * Initial revision - * - * - */ -#define __NO_VERSION__ -#include <linux/types.h> -#include <linux/stddef.h> -#include <linux/timer.h> -#include "teles.h" - -/* - * This structure array contains one entry per card. An entry looks - * like this: - * - * { membase,irq,portbase,protocol,NULL } - * - * protocol can be either ISDN_PTYPE_EURO or ISDN_PTYPE_1TR6 - * - * Cards which don't have an io port (Teles 8 bit cards for - * example) can be entered with io port 0x0 - * - * For the Teles 16.3, membase has to be set to 0. - * - */ - -struct IsdnCard cards[] = -{ - {(byte *) 0xd0000, 15, 0xd80, ISDN_PTYPE_EURO, NULL}, /* example */ - {NULL, 0, 0, 0, NULL}, - {NULL, 0, 0, 0, NULL}, - {NULL, 0, 0, 0, NULL}, - {NULL, 0, 0, 0, NULL}, - {NULL, 0, 0, 0, NULL}, - {NULL, 0, 0, 0, NULL}, - {NULL, 0, 0, 0, NULL}, - {NULL, 0, 0, 0, NULL}, - {NULL, 0, 0, 0, NULL}, - {NULL, 0, 0, 0, NULL}, - {NULL, 0, 0, 0, NULL}, - {NULL, 0, 0, 0, NULL}, - {NULL, 0, 0, 0, NULL}, - {NULL, 0, 0, 0, NULL}, - {NULL, 0, 0, 0, NULL}, -}; diff --git a/drivers/isdn/teles/fsm.c b/drivers/isdn/teles/fsm.c deleted file mode 100644 index 4d651e73e..000000000 --- a/drivers/isdn/teles/fsm.c +++ /dev/null @@ -1,156 +0,0 @@ -/* $Id: fsm.c,v 1.3 1997/02/16 01:04:12 fritz Exp $ - * - * $Log: fsm.c,v $ - * Revision 1.3 1997/02/16 01:04:12 fritz - * Bugfix: Changed timer handling caused hang with 2.1.X - * - * Revision 1.2 1996/04/29 22:49:57 fritz - * Removed compatibility-macros. - * - * Revision 1.1 1996/04/13 10:23:41 fritz - * Initial revision - * - * - */ -#define __NO_VERSION__ -#include "teles.h" - -void -FsmNew(struct Fsm *fsm, - struct FsmNode *fnlist, int fncount) -{ - int i; - - fsm->jumpmatrix = (int *) Smalloc(4L * fsm->state_count * fsm->event_count, - GFP_KERNEL, "Fsm jumpmatrix"); - memset(fsm->jumpmatrix, 0, 4L * fsm->state_count * fsm->event_count); - - for (i = 0; i < fncount; i++) - fsm->jumpmatrix[fsm->state_count * fnlist[i].event + - fnlist[i].state] = (int) fnlist[i].routine; -} - -void -FsmFree(struct Fsm *fsm) -{ - Sfree((void *) fsm->jumpmatrix); -} - -int -FsmEvent(struct FsmInst *fi, int event, void *arg) -{ - void (*r) (struct FsmInst *, int, void *); - char str[80]; - - r = (void (*)) fi->fsm->jumpmatrix[fi->fsm->state_count * event + fi->state]; - if (r) { - if (fi->debug) { - sprintf(str, "State %s Event %s", - fi->fsm->strState[fi->state], - fi->fsm->strEvent[event]); - fi->printdebug(fi, str); - } - r(fi, event, arg); - return (0); - } else { - if (fi->debug) { - sprintf(str, "State %s Event %s no routine", - fi->fsm->strState[fi->state], - fi->fsm->strEvent[event]); - fi->printdebug(fi, str); - } - return (!0); - } -} - -void -FsmChangeState(struct FsmInst *fi, int newstate) -{ - char str[80]; - - fi->state = newstate; - if (fi->debug) { - sprintf(str, "ChangeState %s", - fi->fsm->strState[newstate]); - fi->printdebug(fi, str); - } -} - -static void -FsmExpireTimer(struct FsmTimer *ft) -{ - FsmEvent(ft->fi, ft->event, ft->arg); -} - -void -FsmInitTimer(struct FsmInst *fi, struct FsmTimer *ft) -{ - ft->fi = fi; - ft->tl.function = (void *) FsmExpireTimer; - ft->tl.data = (long) ft; - init_timer(&ft->tl); -} - -void -FsmDelTimer(struct FsmTimer *ft, int where) -{ -#if 0 - if (ft->fi->debug) { - sprintf(str, "FsmDelTimer %lx %d", ft, where); - ft->fi->printdebug(ft->fi, str); - } -#endif - - del_timer(&ft->tl); -} - -int -FsmAddTimer(struct FsmTimer *ft, - int millisec, int event, void *arg, int where) -{ - -#if 0 - if (ft->fi->debug) { - sprintf(str, "FsmAddTimer %lx %d %d", ft, millisec, where); - ft->fi->printdebug(ft->fi, str); - } -#endif - - if (ft->tl.next || ft->tl.prev) { - printk(KERN_WARNING "FsmAddTimer: timer already active!\n"); - return -1; - } - init_timer(&ft->tl); - ft->event = event; - ft->arg = arg; - ft->tl.expires = jiffies + (millisec * HZ) / 1000; - add_timer(&ft->tl); - return 0; -} - -int -FsmTimerRunning(struct FsmTimer *ft) -{ - return (ft->tl.next != NULL); -} - -void -jiftime(char *s, long mark) -{ - s += 8; - - *s-- = '\0'; - *s-- = mark % 10 + '0'; - mark /= 10; - *s-- = mark % 10 + '0'; - mark /= 10; - *s-- = '.'; - *s-- = mark % 10 + '0'; - mark /= 10; - *s-- = mark % 6 + '0'; - mark /= 6; - *s-- = ':'; - *s-- = mark % 10 + '0'; - mark /= 10; - *s-- = mark % 10 + '0'; -} diff --git a/drivers/isdn/teles/isdnl2.c b/drivers/isdn/teles/isdnl2.c deleted file mode 100644 index 98171aa7d..000000000 --- a/drivers/isdn/teles/isdnl2.c +++ /dev/null @@ -1,1320 +0,0 @@ -/* $Id: isdnl2.c,v 1.3 1996/11/23 11:32:57 keil Exp $ - * - * $Log: isdnl2.c,v $ - * Revision 1.3 1996/11/23 11:32:57 keil - * X.75 bugfixies; Thanks to Martin Maurer - * - * Revision 1.2 1996/05/17 03:46:15 fritz - * General cleanup. - * - * Revision 1.1 1996/04/13 10:24:16 fritz - * Initial revision - * - * - */ -#define __NO_VERSION__ -#include "teles.h" - -#define TIMER_1 2000 - -static void l2m_debug(struct FsmInst *fi, char *s); - -struct Fsm l2fsm = -{NULL, 0, 0}; - -enum { - ST_L2_1, - ST_L2_3, - ST_L2_4, - ST_L2_5, - ST_L2_6, - ST_L2_7, - ST_L2_8, -}; - -#define L2_STATE_COUNT (ST_L2_8+1) - -static char *strL2State[] = -{ - "ST_L2_1", - "ST_L2_3", - "ST_L2_4", - "ST_L2_5", - "ST_L2_6", - "ST_L2_7", - "ST_L2_8", -}; - -enum { - EV_L2_UI, - EV_L2_SABMX, - EV_L2_UA, - EV_L2_DISC, - EV_L2_I, - EV_L2_RR, - EV_L2_REJ, - EV_L2_FRMR, - EV_L2_DL_DATA, - EV_L2_DL_ESTABLISH, - EV_L2_MDL_ASSIGN, - EV_L2_DL_UNIT_DATA, - EV_L2_DL_RELEASE, - EV_L2_MDL_NOTEIPROC, - EV_L2_T200, - EV_L2_ACK_PULL, - EV_L2_T203, - EV_L2_RNR, -}; - -#define L2_EVENT_COUNT (EV_L2_RNR+1) - -static char *strL2Event[] = -{ - "EV_L2_UI", - "EV_L2_SABMX", - "EV_L2_UA", - "EV_L2_DISC", - "EV_L2_I", - "EV_L2_RR", - "EV_L2_REJ", - "EV_L2_FRMR", - "EV_L2_DL_DATA", - "EV_L2_DL_ESTABLISH", - "EV_L2_MDL_ASSIGN", - "EV_L2_DL_UNIT_DATA", - "EV_L2_DL_RELEASE", - "EV_L2_MDL_NOTEIPROC", - "EV_L2_T200", - "EV_L2_ACK_PULL", - "EV_L2_T203", - "EV_L2_RNR", -}; - -int errcount = 0; - -static int l2addrsize(struct Layer2 *tsp); - -static int -cansend(struct PStack *st) -{ - int p1; - - p1 = (st->l2.va + st->l2.window) % (st->l2.extended ? 128 : 8); - return (st->l2.vs != p1); -} - -static void -discard_i_queue(struct PStack *st) -{ - struct BufHeader *ibh; - - while (!BufQueueUnlink(&ibh, &st->l2.i_queue)) - BufPoolRelease(ibh); -} - -int -l2headersize(struct Layer2 *tsp, int UI) -{ - return ((tsp->extended && (!UI) ? 2 : 1) + (tsp->laptype == LAPD ? 2 : 1)); -} - -int -l2addrsize(struct Layer2 *tsp) -{ - return (tsp->laptype == LAPD ? 2 : 1); -} - -static int -sethdraddr(struct Layer2 *tsp, - struct BufHeader *ibh, int rsp) -{ - byte *ptr = DATAPTR(ibh); - int crbit; - - if (tsp->laptype == LAPD) { - crbit = rsp; - if (!tsp->orig) - crbit = !crbit; - *ptr++ = (tsp->sap << 2) | (crbit ? 2 : 0); - *ptr++ = (tsp->tei << 1) | 1; - return (2); - } else { - crbit = rsp; - if (tsp->orig) - crbit = !crbit; - if (crbit) - *ptr++ = 1; - else - *ptr++ = 3; - return (1); - } -} - -static void -enqueue_ui(struct PStack *st, - struct BufHeader *ibh) -{ - st->l2.l2l1(st, PH_DATA, ibh); -} - -static void -enqueue_super(struct PStack *st, - struct BufHeader *ibh) -{ - st->l2.l2l1(st, PH_DATA, ibh); -} - -static int -legalnr(struct PStack *st, int nr) -{ - struct Layer2 *l2 = &st->l2; - int lnr, lvs; - - lvs = (l2->vs >= l2->va) ? l2->vs : (l2->vs + l2->extended ? 128 : 8); - lnr = (nr >= l2->va) ? nr : (nr + l2->extended ? 128 : 8); - return (lnr <= lvs); -} - -static void -setva(struct PStack *st, int nr) -{ - struct Layer2 *l2 = &st->l2; - - if (l2->va != nr) { - while (l2->va != nr) { - l2->va = (l2->va + 1) % (l2->extended ? 128 : 8); - BufPoolRelease(l2->windowar[l2->sow]); - l2->sow = (l2->sow + 1) % l2->window; - } - if (st->l4.l2writewakeup) - st->l4.l2writewakeup(st); - } -} - -static void -l2s1(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - - st->l2.l2tei(st, MDL_ASSIGN, (void *)st->l2.ces); - FsmChangeState(fi, ST_L2_3); -} - -static void -l2s2(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - struct BufHeader *ibh = arg; - - byte *ptr; - int i; - - i = sethdraddr(&(st->l2), ibh, 0); - ptr = DATAPTR(ibh); - ptr += i; - *ptr = 0x3; - - enqueue_ui(st, ibh); -} - -static void -l2s3(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - struct BufHeader *ibh = arg; - - st->l2.l2l3(st, DL_UNIT_DATA, ibh); -} - -static void -establishlink(struct FsmInst *fi) -{ - struct PStack *st = fi->userdata; - struct BufHeader *ibh; - int i; - byte *ptr; - - FsmChangeState(fi, ST_L2_5); - st->l2.rc = 0; - - if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 1)) - if (st->l2.l2m.debug) - l2m_debug(&st->l2.l2m, "FAT 1"); - - - if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 15)) - return; - i = sethdraddr(&st->l2, ibh, 0); - ptr = DATAPTR(ibh); - ptr += i; - if (st->l2.extended) - *ptr = 0x7f; - else - *ptr = 0x3f; - ibh->datasize = i + 1; - - enqueue_super(st, ibh); -} - -static void -l2s11(struct FsmInst *fi, int event, void *arg) -{ - establishlink(fi); -} - -static void -l2s13(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - struct Channel *chanp = st->l4.userdata; - byte *ptr; - struct BufHeader *ibh; - int i; - - FsmChangeState(fi, ST_L2_6); - - FsmDelTimer(&st->l2.t203_timer, 1); - if (st->l2.t200_running) { - FsmDelTimer(&st->l2.t200_timer, 2); - st->l2.t200_running = 0; - } - st->l2.rc = 0; - if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 2)) - if (st->l2.l2m.debug) - l2m_debug(&st->l2.l2m, "FAT 2"); - - - if ((chanp->impair == 2) && (st->l2.laptype == LAPB)) - goto nodisc; - - if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 9)) - return; - i = sethdraddr(&(st->l2), ibh, 0); - ptr = DATAPTR(ibh); - ptr += i; - *ptr = 0x53; - ibh->datasize = i + 1; - enqueue_super(st, ibh); - - nodisc: - discard_i_queue(st); -} - -static void -l2s12(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - struct BufHeader *ibh = arg; - byte *ptr; - int i; - - BufPoolRelease(ibh); - st->l2.vs = 0; - st->l2.va = 0; - st->l2.vr = 0; - st->l2.sow = 0; - FsmChangeState(fi, ST_L2_7); - if (FsmAddTimer(&st->l2.t203_timer, st->l2.t203, EV_L2_T203, NULL, 3)) - if (st->l2.l2m.debug) - l2m_debug(&st->l2.l2m, "FAT 3"); - - st->l2.l2man(st, DL_ESTABLISH, NULL); - - if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 10)) - return; - i = sethdraddr(&(st->l2), ibh, !0); - ptr = DATAPTR(ibh); - ptr += i; - *ptr = 0x73; - ibh->datasize = i + 1; - enqueue_super(st, ibh); - -} - -static void -l2s14(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - struct BufHeader *ibh = arg; - struct Channel *chanp = st->l4.userdata; - byte *ptr; - int i, p; - - ptr = DATAPTR(ibh); - ptr += l2addrsize(&(st->l2)); - p = (*ptr) & 0x10; - BufPoolRelease(ibh); - - FsmChangeState(fi, ST_L2_4); - - FsmDelTimer(&st->l2.t203_timer, 3); - if (st->l2.t200_running) { - FsmDelTimer(&st->l2.t200_timer, 4); - st->l2.t200_running = 0; - } - if ((chanp->impair == 1) && (st->l2.laptype == LAPB)) - goto noresponse; - - if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 11)) - return; - i = sethdraddr(&(st->l2), ibh, 0); - ptr = DATAPTR(ibh); - ptr += i; - *ptr = 0x63 | (p ? 0x10 : 0x0); - ibh->datasize = i + 1; - enqueue_super(st, ibh); - - noresponse: - st->l2.l2man(st, DL_RELEASE, NULL); - -} - -static void -l2s5(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - struct BufHeader *ibh = arg; - int f; - byte *data; - - data = DATAPTR(ibh); - data += l2addrsize(&(st->l2)); - - f = *data & 0x10; - BufPoolRelease(ibh); - - if (f) { - st->l2.vs = 0; - st->l2.va = 0; - st->l2.vr = 0; - st->l2.sow = 0; - FsmChangeState(fi, ST_L2_7); - - FsmDelTimer(&st->l2.t200_timer, 5); - if (FsmAddTimer(&st->l2.t203_timer, st->l2.t203, EV_L2_T203, NULL, 4)) - if (st->l2.l2m.debug) - l2m_debug(&st->l2.l2m, "FAT 4"); - - - st->l2.l2man(st, DL_ESTABLISH, NULL); - } -} - -static void -l2s15(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - struct BufHeader *ibh = arg; - int f; - byte *data; - - data = DATAPTR(ibh); - data += l2addrsize(&st->l2); - - f = *data & 0x10; - BufPoolRelease(ibh); - - if (f) { - FsmDelTimer(&st->l2.t200_timer, 6); - FsmChangeState(fi, ST_L2_4); - st->l2.l2man(st, DL_RELEASE, NULL); - } -} - -static void -l2s6(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - struct Channel *chanp = st->l4.userdata; - struct BufHeader *ibh = arg; - int p, i, seq, rsp; - byte *ptr; - struct Layer2 *l2; - - l2 = &st->l2; - ptr = DATAPTR(ibh); - - if (l2->laptype == LAPD) { - rsp = ptr[0] & 0x2; - if (l2->orig) - rsp = !rsp; - } else { - rsp = ptr[0] == 0x3; - if (l2->orig) - rsp = !rsp; - } - - ptr += l2addrsize(l2); - - if (l2->extended) { - p = (ptr[1] & 0x1) == 0x1; - seq = ptr[1] >> 1; - } else { - p = (ptr[0] & 0x10); - seq = (ptr[0] >> 5) & 0x7; - } - BufPoolRelease(ibh); - - if ((chanp->impair == 4) && (st->l2.laptype == LAPB)) - goto noresp; - - if ((!rsp) && p) { - if (!BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 12)) { - i = sethdraddr(l2, ibh, !0); - ptr = DATAPTR(ibh); - ptr += i; - - if (l2->extended) { - *ptr++ = 0x1; - *ptr++ = (l2->vr << 1) | (p ? 1 : 0); - i += 2; - } else { - *ptr++ = (l2->vr << 5) | 0x1 | (p ? 0x10 : 0x0); - i += 1; - } - ibh->datasize = i; - enqueue_super(st, ibh); - } - } - noresp: - if (legalnr(st, seq)) - if (seq == st->l2.vs) { - setva(st, seq); - FsmDelTimer(&st->l2.t200_timer, 7); - st->l2.t200_running = 0; - FsmDelTimer(&st->l2.t203_timer, 8); - if (FsmAddTimer(&st->l2.t203_timer, st->l2.t203, EV_L2_T203, NULL, 5)) - if (st->l2.l2m.debug) - l2m_debug(&st->l2.l2m, "FAT 5"); - - if (st->l2.i_queue.head) - st->l2.l2l1(st, PH_REQUEST_PULL, NULL); - } else if (st->l2.va != seq) { - setva(st, seq); - FsmDelTimer(&st->l2.t200_timer, 9); - if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 6)) - if (st->l2.l2m.debug) - l2m_debug(&st->l2.l2m, "FAT 6"); - - if (st->l2.i_queue.head) - st->l2.l2l1(st, PH_REQUEST_PULL, NULL); - } -} - -static void -l2s7(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - struct BufHeader *ibh = arg; - int i; - byte *ptr; - struct IsdnCardState *sp = st->l1.hardware; - char str[64]; - - i = sethdraddr(&st->l2, ibh, 0); - ptr = DATAPTR(ibh); - - if (st->l2.laptype == LAPD) - if (sp->dlogflag) { - sprintf(str, "Q.931 frame user->network tei %d", st->l2.tei); - dlogframe(sp, ptr + st->l2.ihsize, ibh->datasize - st->l2.ihsize, - str); - } - BufQueueLink(&st->l2.i_queue, ibh); - - st->l2.l2l1(st, PH_REQUEST_PULL, NULL); -} - -static void -l2s8(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - struct Channel *chanp = st->l4.userdata; - struct BufHeader *ibh = arg; - byte *ptr; - struct BufHeader *ibh2; - struct IsdnCardState *sp = st->l1.hardware; - struct Layer2 *l2 = &(st->l2); - int i, p, seq, nr, wasok; - char str[64]; - - ptr = DATAPTR(ibh); - ptr += l2addrsize(l2); - if (l2->extended) { - p = (ptr[1] & 0x1) == 0x1; - seq = ptr[0] >> 1; - nr = (ptr[1] >> 1) & 0x7f; - } else { - p = (ptr[0] & 0x10); - seq = (ptr[0] >> 1) & 0x7; - nr = (ptr[0] >> 5) & 0x7; - } - - if (l2->vr == seq) { - wasok = !0; - - l2->vr = (l2->vr + 1) % (l2->extended ? 128 : 8); - l2->rejexp = 0; - - ptr = DATAPTR(ibh); - if (st->l2.laptype == LAPD) - if (sp->dlogflag) { - sprintf(str, "Q.931 frame network->user tei %d", st->l2.tei); - dlogframe(st->l1.hardware, ptr + l2->ihsize, - ibh->datasize - l2->ihsize, str); - } - label8_1: - if ((chanp->impair == 3) && (st->l2.laptype == LAPB)) - goto noRR; - - if (!BufPoolGet(&ibh2, st->l1.smallpool, GFP_ATOMIC, (void *) st, 13)) { - i = sethdraddr(&(st->l2), ibh2, !0); - ptr = DATAPTR(ibh2); - ptr += i; - - if (l2->extended) { - *ptr++ = 0x1; - *ptr++ = (l2->vr << 1) | (p ? 1 : 0); - i += 2; - } else { - *ptr++ = (l2->vr << 5) | 0x1 | (p ? 0x10 : 0x0); - i += 1; - } - ibh2->datasize = i; - enqueue_super(st, ibh2); - noRR: - } - } else { - /* n(s)!=v(r) */ - wasok = 0; - BufPoolRelease(ibh); - if (st->l2.rejexp) { - if (p) - goto label8_1; - } else { - st->l2.rejexp = !0; - if (!BufPoolGet(&ibh2, st->l1.smallpool, GFP_ATOMIC, (void *) st, 14)) { - i = sethdraddr(&(st->l2), ibh2, p); - ptr = DATAPTR(ibh2); - ptr += i; - - if (l2->extended) { - *ptr++ = 0x9; - *ptr++ = (l2->vr << 1) | (p ? 1 : 0); - i += 2; - } else { - *ptr++ = (l2->vr << 5) | 0x9 | (p ? 0x10 : 0x0); - i += 1; - } - ibh2->datasize = i; - enqueue_super(st, ibh2); - } - } - } - - if (legalnr(st, nr)) - if (nr == st->l2.vs) { - setva(st, nr); - FsmDelTimer(&st->l2.t200_timer, 10); - st->l2.t200_running = 0; - FsmDelTimer(&st->l2.t203_timer, 11); - if (FsmAddTimer(&st->l2.t203_timer, st->l2.t203, EV_L2_T203, NULL, 7)) - if (st->l2.l2m.debug) - l2m_debug(&st->l2.l2m, "FAT 5"); - - if (st->l2.i_queue.head) - st->l2.l2l1(st, PH_REQUEST_PULL, NULL); - } else if (nr != st->l2.va) { - setva(st, nr); - FsmDelTimer(&st->l2.t200_timer, 12); - if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 8)) - if (st->l2.l2m.debug) - l2m_debug(&st->l2.l2m, "FAT 6"); - - if (st->l2.i_queue.head) - st->l2.l2l1(st, PH_REQUEST_PULL, NULL); - } - if (wasok) - st->l2.l2l3(st, DL_DATA, ibh); - -} - -static void -l2s17(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - - st->l2.tei = (int) arg; - establishlink(fi); -} - -static void -enquiry_response(struct PStack *st) -{ - struct BufHeader *ibh2; - int i; - byte *ptr; - struct Layer2 *l2; - - l2 = &st->l2; - if (!BufPoolGet(&ibh2, st->l1.smallpool, GFP_ATOMIC, (void *) st, 16)) { - i = sethdraddr(&(st->l2), ibh2, !0); - ptr = DATAPTR(ibh2); - ptr += i; - - if (l2->extended) { - *ptr++ = 0x1; - *ptr++ = (l2->vr << 1) | 0x1; - i += 2; - } else { - *ptr++ = (l2->vr << 5) | 0x1 | 0x10; - i += 1; - } - ibh2->datasize = i; - enqueue_super(st, ibh2); - } -} - -static void -invoke_retransmission(struct PStack *st, int nr) -{ - struct Layer2 *l2 = &st->l2; - int p1; - - if (l2->vs != nr) { - while (l2->vs != nr) { - - l2->vs = l2->vs - 1; - if (l2->vs < 0) - l2->vs += l2->extended ? 128 : 8; - - p1 = l2->vs - l2->va; - if (p1 < 0) - p1 += l2->extended ? 128 : 8; - p1 = (p1 + l2->sow) % l2->window; - - BufQueueLinkFront(&l2->i_queue, l2->windowar[p1]); - } - st->l2.l2l1(st, PH_REQUEST_PULL, NULL); - } -} - -static void -l2s16(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - struct BufHeader *ibh = arg; - int p, seq, rsp; - byte *ptr; - struct Layer2 *l2; - - l2 = &(st->l2); - ptr = DATAPTR(ibh); - - if (l2->laptype == LAPD) { - rsp = ptr[0] & 0x2; - if (l2->orig) - rsp = !rsp; - } else { - rsp = ptr[0] == 0x3; - if (l2->orig) - rsp = !rsp; - } - - - ptr += l2addrsize(l2); - - if (l2->extended) { - p = (ptr[1] & 0x1) == 0x1; - seq = ptr[1] >> 1; - } else { - p = (ptr[0] & 0x10); - seq = (ptr[0] >> 5) & 0x7; - } - BufPoolRelease(ibh); - - if ((!rsp) && p) - enquiry_response(st); - - if (!legalnr(st, seq)) - return; - - setva(st, seq); - invoke_retransmission(st, seq); - -} - -static void -l2s19(struct FsmInst *fi, int event, void *arg) -{ - FsmChangeState(fi, ST_L2_4); -} - -static void -l2s20(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - int i; - struct BufHeader *ibh; - byte *ptr; - - if (st->l2.rc == st->l2.n200) { - FsmChangeState(fi, ST_L2_4); - st->l2.l2man(st, DL_RELEASE, NULL); - } else { - st->l2.rc++; - - if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 9)) - if (st->l2.l2m.debug) - l2m_debug(&st->l2.l2m, "FAT 7"); - - if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 15)) - return; - - i = sethdraddr(&st->l2, ibh, 0); - ptr = DATAPTR(ibh); - ptr += i; - if (st->l2.extended) - *ptr = 0x7f; - else - *ptr = 0x3f; - ibh->datasize = i + 1; - enqueue_super(st, ibh); - } -} - -static void -l2s21(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - struct Channel *chanp = st->l4.userdata; - int i; - struct BufHeader *ibh; - byte *ptr; - - if (st->l2.rc == st->l2.n200) { - FsmChangeState(fi, ST_L2_4); - st->l2.l2man(st, DL_RELEASE, NULL); - } else { - st->l2.rc++; - - if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 10)) - if (st->l2.l2m.debug) - l2m_debug(&st->l2.l2m, "FAT 8"); - - - if ((chanp->impair == 2) && (st->l2.laptype == LAPB)) - goto nodisc; - - if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 15)) - return; - - i = sethdraddr(&st->l2, ibh, 0); - ptr = DATAPTR(ibh); - ptr += i; - *ptr = 0x53; - ibh->datasize = i + 1; - enqueue_super(st, ibh); - nodisc: - - } -} - -static void -l2s22(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - struct BufHeader *ibh; - struct Layer2 *l2 = &st->l2; - byte *ptr; - int p1; - - if (!cansend(st)) - return; - - if (BufQueueUnlink(&ibh, &l2->i_queue)) - return; - - - p1 = l2->vs - l2->va; - if (p1 < 0) - p1 += l2->extended ? 128 : 8; - p1 = (p1 + l2->sow) % l2->window; - l2->windowar[p1] = ibh; - - ptr = DATAPTR(ibh); - ptr += l2addrsize(l2); - - if (l2->extended) { - *ptr++ = l2->vs << 1; - *ptr++ = (l2->vr << 1) | 0x1; - l2->vs = (l2->vs + 1) % 128; - } else { - *ptr++ = (l2->vr << 5) | (l2->vs << 1); - l2->vs = (l2->vs + 1) % 8; - } - - st->l2.l2l1(st, PH_DATA_PULLED, ibh); - - if (!st->l2.t200_running) { - FsmDelTimer(&st->l2.t203_timer, 13); - if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 11)) - if (st->l2.l2m.debug) - l2m_debug(&st->l2.l2m, "FAT 9"); - - st->l2.t200_running = !0; - } - if (l2->i_queue.head && cansend(st)) - st->l2.l2l1(st, PH_REQUEST_PULL, NULL); - -} - -static void -transmit_enquiry(struct PStack *st) -{ - struct BufHeader *ibh; - byte *ptr; - - if (!BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 12)) { - ptr = DATAPTR(ibh); - ptr += sethdraddr(&st->l2, ibh, 0); - - if (st->l2.extended) { - *ptr++ = 0x1; - *ptr++ = (st->l2.vr << 1) | 1; - } else { - *ptr++ = (st->l2.vr << 5) | 0x11; - } - ibh->datasize = ptr - DATAPTR(ibh); - enqueue_super(st, ibh); - if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 12)) - if (st->l2.l2m.debug) - l2m_debug(&st->l2.l2m, "FAT 10"); - - st->l2.t200_running = !0; - } -} - -static void -l2s23(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - - st->l2.t200_running = 0; - - st->l2.rc = 1; - FsmChangeState(fi, ST_L2_8); - transmit_enquiry(st); -} - -static void -l2s24(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - struct BufHeader *ibh = arg; - int p, seq, rsp; - byte *ptr; - struct Layer2 *l2; - - l2 = &st->l2; - ptr = DATAPTR(ibh); - - if (l2->laptype == LAPD) { - rsp = ptr[0] & 0x2; - if (l2->orig) - rsp = !rsp; - } else { - rsp = ptr[0] == 0x3; - if (l2->orig) - rsp = !rsp; - } - - - ptr += l2addrsize(l2); - - if (l2->extended) { - p = (ptr[1] & 0x1) == 0x1; - seq = ptr[1] >> 1; - } else { - p = (ptr[0] & 0x10); - seq = (ptr[0] >> 5) & 0x7; - } - BufPoolRelease(ibh); - - if (rsp && p) { - if (legalnr(st, seq)) { - FsmChangeState(fi, ST_L2_7); - setva(st, seq); - if (st->l2.t200_running) { - FsmDelTimer(&st->l2.t200_timer, 14); - st->l2.t200_running = 0; - } - if (FsmAddTimer(&st->l2.t203_timer, st->l2.t203, EV_L2_T203, NULL, 13)) - if (st->l2.l2m.debug) - l2m_debug(&st->l2.l2m, "FAT 11"); - - invoke_retransmission(st, seq); - } - } else { - if (!rsp && p) - enquiry_response(st); - if (legalnr(st, seq)) { - setva(st, seq); - } - } -} - -static void -l2s25(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - - st->l2.rc = 0; - FsmChangeState(fi, ST_L2_8); - transmit_enquiry(st); -} - -static void -l2s26(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - - if (st->l2.rc == st->l2.n200) { - l2s13(fi, event, NULL); - } else { - st->l2.rc++; - transmit_enquiry(st); - } -} - -static void -l2s27(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - struct BufHeader *ibh = arg; - byte *ptr; - int i, p, est; - - ptr = DATAPTR(ibh); - ptr += l2addrsize(&st->l2); - - if (st->l2.extended) - p = ptr[1] & 0x1; - else - p = ptr[0] & 0x10; - - BufPoolRelease(ibh); - - if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 10)) - return; - i = sethdraddr(&st->l2, ibh, 0); - ptr = DATAPTR(ibh); - ptr += i; - *ptr = 0x63 | p; - ibh->datasize = i + 1; - enqueue_super(st, ibh); - - if (st->l2.vs != st->l2.va) { - discard_i_queue(st); - est = !0; - } else - est = 0; - - FsmDelTimer(&st->l2.t200_timer, 15); - st->l2.t200_running = 0; - - if (FsmAddTimer(&st->l2.t203_timer, st->l2.t203, EV_L2_T203, NULL, 3)) - if (st->l2.l2m.debug) - l2m_debug(&st->l2.l2m, "FAT 12"); - - st->l2.vs = 0; - st->l2.va = 0; - st->l2.vr = 0; - st->l2.sow = 0; - - - if (est) - st->l2.l2man(st, DL_ESTABLISH, NULL); - -} - -static void -l2s28(struct FsmInst *fi, int event, void *arg) -{ - struct PStack *st = fi->userdata; - struct BufHeader *ibh = arg; - byte *ptr; - char tmp[64]; - - ptr = DATAPTR(ibh); - ptr += l2addrsize(&st->l2); - ptr++; - - if (st->l2.l2m.debug) { - if (st->l2.extended) - sprintf(tmp, "FRMR information %2x %2x %2x %2x %2x", - ptr[0], ptr[1], ptr[2], ptr[3], ptr[4]); - else - sprintf(tmp, "FRMR information %2x %2x %2x", - ptr[0], ptr[1], ptr[2]); - - l2m_debug(&st->l2.l2m, tmp); - } - BufPoolRelease(ibh); -} - -static int -IsUI(byte * data, int ext) -{ - return ((data[0] & 0xef) == 0x3); -} - -static int -IsUA(byte * data, int ext) -{ - return ((data[0] & 0xef) == 0x63); -} - -static int -IsDISC(byte * data, int ext) -{ - return ((data[0] & 0xef) == 0x43); -} - -static int -IsRR(byte * data, int ext) -{ - if (ext) - return (data[0] == 0x1); - else - return ((data[0] & 0xf) == 1); -} - -static int -IsI(byte * data, int ext) -{ - return ((data[0] & 0x1) == 0x0); -} - -static int -IsSABMX(byte * data, int ext) -{ - return (ext ? data[0] == 0x7f : data[0] == 0x3f); -} - -static int -IsREJ(byte * data, int ext) -{ - return (ext ? data[0] == 0x9 : (data[0] & 0xf) == 0x9); -} - -static int -IsFRMR(byte * data, int ext) -{ - return ((data[0] & 0xef) == 0x87); -} - -static int -IsRNR(byte * data, int ext) -{ - if (ext) - return (data[0] == 0x5); - else - return ((data[0] & 0xf) == 5); -} - -static struct FsmNode L2FnList[] = -{ - {ST_L2_1, EV_L2_DL_ESTABLISH, l2s1}, - {ST_L2_1, EV_L2_MDL_NOTEIPROC, l2s19}, - {ST_L2_3, EV_L2_MDL_ASSIGN, l2s17}, - {ST_L2_4, EV_L2_DL_UNIT_DATA, l2s2}, - {ST_L2_4, EV_L2_DL_ESTABLISH, l2s11}, - {ST_L2_7, EV_L2_DL_UNIT_DATA, l2s2}, - {ST_L2_7, EV_L2_DL_DATA, l2s7}, - {ST_L2_7, EV_L2_DL_RELEASE, l2s13}, - {ST_L2_7, EV_L2_ACK_PULL, l2s22}, - {ST_L2_8, EV_L2_DL_RELEASE, l2s13}, - - {ST_L2_1, EV_L2_UI, l2s3}, - {ST_L2_4, EV_L2_UI, l2s3}, - {ST_L2_4, EV_L2_SABMX, l2s12}, - {ST_L2_5, EV_L2_UA, l2s5}, - {ST_L2_6, EV_L2_UA, l2s15}, - {ST_L2_7, EV_L2_UI, l2s3}, - {ST_L2_7, EV_L2_DISC, l2s14}, - {ST_L2_7, EV_L2_I, l2s8}, - {ST_L2_7, EV_L2_RR, l2s6}, - {ST_L2_7, EV_L2_REJ, l2s16}, - {ST_L2_7, EV_L2_SABMX, l2s27}, - {ST_L2_7, EV_L2_FRMR, l2s28}, - {ST_L2_8, EV_L2_RR, l2s24}, - {ST_L2_8, EV_L2_DISC, l2s14}, - {ST_L2_8, EV_L2_FRMR, l2s28}, - - {ST_L2_5, EV_L2_T200, l2s20}, - {ST_L2_6, EV_L2_T200, l2s21}, - {ST_L2_7, EV_L2_T200, l2s23}, - {ST_L2_7, EV_L2_T203, l2s25}, - {ST_L2_8, EV_L2_T200, l2s26}, -}; - -#define L2_FN_COUNT (sizeof(L2FnList)/sizeof(struct FsmNode)) - -static void -isdnl2_l1l2(struct PStack *st, int pr, struct BufHeader *arg) -{ - struct BufHeader *ibh; - byte *datap; - int ret = !0; - - switch (pr) { - case (PH_DATA): - - ibh = arg; - datap = DATAPTR(ibh); - datap += l2addrsize(&st->l2); - - if (IsI(datap, st->l2.extended)) - ret = FsmEvent(&st->l2.l2m, EV_L2_I, ibh); - else if (IsRR(datap, st->l2.extended)) - ret = FsmEvent(&st->l2.l2m, EV_L2_RR, ibh); - else if (IsUI(datap, st->l2.extended)) - ret = FsmEvent(&st->l2.l2m, EV_L2_UI, ibh); - else if (IsSABMX(datap, st->l2.extended)) - ret = FsmEvent(&st->l2.l2m, EV_L2_SABMX, ibh); - else if (IsUA(datap, st->l2.extended)) - ret = FsmEvent(&st->l2.l2m, EV_L2_UA, ibh); - else if (IsDISC(datap, st->l2.extended)) - ret = FsmEvent(&st->l2.l2m, EV_L2_DISC, ibh); - else if (IsREJ(datap, st->l2.extended)) - ret = FsmEvent(&st->l2.l2m, EV_L2_REJ, ibh); - else if (IsFRMR(datap, st->l2.extended)) - ret = FsmEvent(&st->l2.l2m, EV_L2_FRMR, ibh); - else if (IsRNR(datap, st->l2.extended)) - ret = FsmEvent(&st->l2.l2m, EV_L2_RNR, ibh); - - if (ret) - BufPoolRelease(ibh); - - break; - case (PH_PULL_ACK): - FsmEvent(&st->l2.l2m, EV_L2_ACK_PULL, arg); - break; - } -} - -static void -isdnl2_l3l2(struct PStack *st, int pr, - void *arg) -{ - switch (pr) { - case (DL_DATA): - if (FsmEvent(&st->l2.l2m, EV_L2_DL_DATA, arg)) - BufPoolRelease((struct BufHeader *) arg); - break; - case (DL_UNIT_DATA): - if (FsmEvent(&st->l2.l2m, EV_L2_DL_UNIT_DATA, arg)) - BufPoolRelease((struct BufHeader *) arg); - break; - } -} - -static void -isdnl2_manl2(struct PStack *st, int pr, - void *arg) -{ - switch (pr) { - case (DL_ESTABLISH): - FsmEvent(&st->l2.l2m, EV_L2_DL_ESTABLISH, arg); - break; - case (DL_RELEASE): - FsmEvent(&st->l2.l2m, EV_L2_DL_RELEASE, arg); - break; - case (MDL_NOTEIPROC): - FsmEvent(&st->l2.l2m, EV_L2_MDL_NOTEIPROC, NULL); - break; - } -} - -static void -isdnl2_teil2(struct PStack *st, int pr, - void *arg) -{ - switch (pr) { - case (MDL_ASSIGN): - FsmEvent(&st->l2.l2m, EV_L2_MDL_ASSIGN, arg); - break; - } -} - -void -releasestack_isdnl2(struct PStack *st) -{ - FsmDelTimer(&st->l2.t200_timer, 15); - FsmDelTimer(&st->l2.t203_timer, 16); -} - -static void -l2m_debug(struct FsmInst *fi, char *s) -{ - struct PStack *st = fi->userdata; - char tm[32], str[256]; - - jiftime(tm, jiffies); - sprintf(str, "%s %s %s\n", tm, st->l2.debug_id, s); - teles_putstatus(str); -} - - -void -setstack_isdnl2(struct PStack *st, char *debug_id) -{ - st->l1.l1l2 = isdnl2_l1l2; - st->l3.l3l2 = isdnl2_l3l2; - st->ma.manl2 = isdnl2_manl2; - st->ma.teil2 = isdnl2_teil2; - - st->l2.uihsize = l2headersize(&st->l2, !0); - st->l2.ihsize = l2headersize(&st->l2, 0); - BufQueueInit(&(st->l2.i_queue)); - st->l2.rejexp = 0; - st->l2.debug = 1; - - st->l2.l2m.fsm = &l2fsm; - st->l2.l2m.state = ST_L2_1; - st->l2.l2m.debug = 0; - st->l2.l2m.userdata = st; - st->l2.l2m.printdebug = l2m_debug; - strcpy(st->l2.debug_id, debug_id); - - FsmInitTimer(&st->l2.l2m, &st->l2.t200_timer); - FsmInitTimer(&st->l2.l2m, &st->l2.t203_timer); - st->l2.t200_running = 0; -} - -void -setstack_transl2(struct PStack *st) -{ -} - -void -releasestack_transl2(struct PStack *st) -{ -} - -void -Isdnl2New(void) -{ - l2fsm.state_count = L2_STATE_COUNT; - l2fsm.event_count = L2_EVENT_COUNT; - l2fsm.strEvent = strL2Event; - l2fsm.strState = strL2State; - FsmNew(&l2fsm, L2FnList, L2_FN_COUNT); -} - -void -Isdnl2Free(void) -{ - FsmFree(&l2fsm); -} diff --git a/drivers/isdn/teles/isdnl3.c b/drivers/isdn/teles/isdnl3.c deleted file mode 100644 index 3bfb47255..000000000 --- a/drivers/isdn/teles/isdnl3.c +++ /dev/null @@ -1,673 +0,0 @@ -/* $Id: isdnl3.c,v 1.13 1997/02/16 12:12:51 fritz Exp $ - * - * $Log: isdnl3.c,v $ - * Revision 1.13 1997/02/16 12:12:51 fritz - * Bugfix: SI2 was nont initialized on incoming calls. - * - * Revision 1.12 1997/02/11 01:39:20 keil - * Changed setup-interface (incoming and outgoing) - * - * Revision 1.11 1996/09/29 19:41:58 fritz - * Bugfix: ignore unknown frames. - * - * Revision 1.10 1996/09/25 18:32:43 keil - * response for STATUS_ENQ message added - * - * Revision 1.9 1996/06/06 14:22:27 fritz - * Changed level of "non-digital call..." message, since - * with audio support, this is quite normal. - * - * Revision 1.8 1996/06/03 20:35:04 fritz - * Fixed typos. - * - * Revision 1.7 1996/06/03 20:03:39 fritz - * Fixed typos. - * - * Revision 1.6 1996/05/21 11:33:50 keil - * Adding SETUP_ACKNOWLEDGE as answer of a SETUP message. - * - * Revision 1.5 1996/05/18 01:37:16 fritz - * Added spelling corrections and some minor changes - * to stay in sync with kernel. - * - * Revision 1.4 1996/05/17 03:46:16 fritz - * General cleanup. - * - * Revision 1.3 1996/04/30 21:57:53 isdn4dev - * remove some debugging code, improve callback Karsten Keil - * - * Revision 1.2 1996/04/20 16:45:05 fritz - * Changed to report all incoming calls to Linklevel, not just those - * with Service 7. - * Misc. typos - * - * Revision 1.1 1996/04/13 10:24:45 fritz - * Initial revision - * - * - */ -#define __NO_VERSION__ -#define P_1TR6 -#include "teles.h" -#include "l3_1TR6.h" -#define DEBUG_1TR6 0 - -static void -i_down(struct PStack *st, - struct BufHeader *ibh) -{ - st->l3.l3l2(st, DL_DATA, ibh); -} - -static void -newl3state(struct PStack *st, int state) -{ - st->l3.state = state; - if (DEBUG_1TR6 > 4) - printk(KERN_INFO "isdnl3: bc:%d cr:%x new state %d\n", - st->pa->bchannel, st->pa->callref, state); - -} - -static void -l3_message(struct PStack *st, int mt) -{ - struct BufHeader *dibh; - byte *p; - int size; - - BufPoolGet(&dibh, st->l1.sbufpool, GFP_ATOMIC, (void *) st, 18); - p = DATAPTR(dibh); - p += st->l2.ihsize; - size = st->l2.ihsize; - - *p++ = 0x8; - *p++ = 0x1; - *p++ = st->l3.callref; - *p++ = mt; - size += 4; - - dibh->datasize = size; - i_down(st, dibh); -} - -static void -l3s3(struct PStack *st, byte pr, void *arg) -{ - l3_message(st, MT_RELEASE); - newl3state(st, 19); -} - -static void -l3s4(struct PStack *st, byte pr, void *arg) -{ - struct BufHeader *ibh = arg; - - BufPoolRelease(ibh); - newl3state(st, 0); - st->l3.l3l4(st, CC_RELEASE_CNF, NULL); -} - -static void -l3s4_1(struct PStack *st, byte pr, void *arg) -{ - struct BufHeader *ibh = arg; - - BufPoolRelease(ibh); - newl3state(st, 19); - l3_message(st, MT_RELEASE); - st->l3.l3l4(st, CC_RELEASE_CNF, NULL); -} - -static void -l3s5(struct PStack *st, byte pr, - void *arg) -{ - struct BufHeader *dibh; - byte *p; - char *teln; - - st->l3.callref = st->pa->callref; - BufPoolGet(&dibh, st->l1.sbufpool, GFP_ATOMIC, (void *) st, 19); - p = DATAPTR(dibh); - p += st->l2.ihsize; - - *p++ = 0x8; - *p++ = 0x1; - *p++ = st->l3.callref; - *p++ = MT_SETUP; - *p++ = 0xa1; - - /* - * Set Bearer Capability, Map info from 1TR6-convention to EDSS1 - */ - switch (st->pa->setup.si1) { - case 1: /* Telephony */ - *p++ = 0x4; /* BC-IE-code */ - *p++ = 0x3; /* Length */ - *p++ = 0x90; /* Coding Std. national, 3.1 kHz audio */ - *p++ = 0x90; /* Circuit-Mode 64kbps */ - *p++ = 0xa3; /* A-Law Audio */ - break; - case 5: /* Datatransmission 64k, BTX */ - case 7: /* Datatransmission 64k */ - default: - *p++ = 0x4; /* BC-IE-code */ - *p++ = 0x2; /* Length */ - *p++ = 0x88; /* Coding Std. nat., unrestr. dig. Inform. */ - *p++ = 0x90; /* Packet-Mode 64kbps */ - break; - } - /* - * What about info2? Mapping to High-Layer-Compatibility? - */ - if (st->pa->setup.eazmsn[0] != '\0') { - *p++ = 0x6c; - *p++ = strlen(st->pa->setup.eazmsn) + 1; - /* Classify as AnyPref. */ - *p++ = 0x81; /* Ext = '1'B, Type = '000'B, Plan = '0001'B. */ - teln = st->pa->setup.eazmsn; - while (*teln) - *p++ = *teln++ & 0x7f; - } - *p++ = 0x70; - *p++ = strlen(st->pa->setup.phone) + 1; - /* Classify as AnyPref. */ - *p++ = 0x81; /* Ext = '1'B, Type = '000'B, Plan = '0001'B. */ - - teln = st->pa->setup.phone; - while (*teln) - *p++ = *teln++ & 0x7f; - - - dibh->datasize = p - DATAPTR(dibh); - - newl3state(st, 1); - i_down(st, dibh); - -} - -static void -l3s6(struct PStack *st, byte pr, void *arg) -{ - byte *p; - struct BufHeader *ibh = arg; - - p = DATAPTR(ibh); - if ((p = findie(p + st->l2.ihsize, ibh->datasize - st->l2.ihsize, - 0x18, 0))) { - st->pa->bchannel = p[2] & 0x3; - } else - printk(KERN_WARNING "octect 3 not found\n"); - - BufPoolRelease(ibh); - newl3state(st, 3); - st->l3.l3l4(st, CC_PROCEEDING_IND, NULL); -} - -static void -l3s7(struct PStack *st, byte pr, void *arg) -{ - struct BufHeader *ibh = arg; - - BufPoolRelease(ibh); - newl3state(st, 12); - st->l3.l3l4(st, CC_DISCONNECT_IND, NULL); -} - -static void -l3s8(struct PStack *st, byte pr, void *arg) -{ - struct BufHeader *ibh = arg; - - BufPoolRelease(ibh); - st->l3.l3l4(st, CC_SETUP_CNF, NULL); - newl3state(st, 10); -} - -static void -l3s11(struct PStack *st, byte pr, void *arg) -{ - struct BufHeader *ibh = arg; - - BufPoolRelease(ibh); - newl3state(st, 4); - st->l3.l3l4(st, CC_ALERTING_IND, NULL); -} - -static void -l3s12(struct PStack *st, byte pr, void *arg) -{ - byte *p; - int bcfound = 0; - struct BufHeader *ibh = arg; - - p = DATAPTR(ibh); - p += st->l2.uihsize; - st->pa->callref = getcallref(p); - st->l3.callref = 0x80 + st->pa->callref; - - /* - * Channel Identification - */ - p = DATAPTR(ibh); - if ((p = findie(p + st->l2.uihsize, ibh->datasize - st->l2.uihsize, - 0x18, 0))) { - st->pa->bchannel = p[2] & 0x3; - bcfound++ ; - } else - printk(KERN_WARNING "l3s12: Channel ident not found\n"); - - p = DATAPTR(ibh); - if (st->protocol == ISDN_PTYPE_1TR6) { - if ((p = findie(p + st->l2.uihsize, ibh->datasize - st->l2.uihsize, 0x01, 6))) { - st->pa->setup.si1 = p[2]; - st->pa->setup.si2 = p[3]; - } else - printk(KERN_WARNING "l3s12(1TR6): ServiceIndicator not found\n"); - } else { - /* - * Bearer Capabilities - */ - if ((p = findie(p + st->l2.uihsize, ibh->datasize - st->l2.uihsize, 0x04, 0))) { - st->pa->setup.si2 = 0; - switch (p[2] & 0x1f) { - case 0x00: - /* Speech */ - case 0x10: - /* 3.1 Khz audio */ - st->pa->setup.si1 = 1; - break; - case 0x08: - /* Unrestricted digital information */ - st->pa->setup.si1 = 7; - break; - case 0x09: - /* Restricted digital information */ - st->pa->setup.si1 = 2; - break; - case 0x11: - /* Unrestr. digital information with tones/announcements */ - st->pa->setup.si1 = 3; - break; - case 0x18: - /* Video */ - st->pa->setup.si1 = 4; - break; - default: - st->pa->setup.si1 = 0; - } - } else - printk(KERN_WARNING "l3s12: Bearer capabilities not found\n"); - } - - p = DATAPTR(ibh); - if ((p = findie(p + st->l2.uihsize, ibh->datasize - st->l2.uihsize, - 0x70, 0))) - iecpy(st->pa->setup.eazmsn, p, 1); - else - strcpy(st->pa->setup.eazmsn, ""); - - p = DATAPTR(ibh); - if ((p = findie(p + st->l2.uihsize, ibh->datasize - st->l2.uihsize, - 0x6c, 0))) { - st->pa->setup.plan = p[2]; - if (st->protocol == ISDN_PTYPE_1TR6) { - iecpy(st->pa->setup.phone, p, 1); - } else { - st->pa->setup.screen = p[3]; - iecpy(st->pa->setup.phone, p, 2); - } - } else - strcpy(st->pa->setup.phone, ""); - BufPoolRelease(ibh); - - if (bcfound) { - if (st->pa->setup.si1 != 7) { - printk(KERN_DEBUG "non-digital call: %s -> %s\n", - st->pa->setup.phone, - st->pa->setup.eazmsn); - } - newl3state(st, 6); - st->l3.l3l4(st, CC_SETUP_IND, NULL); - } -} - -static void -l3s13(struct PStack *st, byte pr, void *arg) -{ - newl3state(st, 0); -} - -static void -l3s16(struct PStack *st, byte pr, - void *arg) -{ - st->l3.callref = 0x80 + st->pa->callref; - l3_message(st, MT_CONNECT); - newl3state(st, 8); -} - -static void -l3s17(struct PStack *st, byte pr, void *arg) -{ - struct BufHeader *ibh = arg; - - BufPoolRelease(ibh); - st->l3.l3l4(st, CC_SETUP_COMPLETE_IND, NULL); - newl3state(st, 10); -} - -static void -l3s18(struct PStack *st, byte pr, void *arg) -{ - struct BufHeader *dibh; - byte *p; - int size; - - BufPoolGet(&dibh, st->l1.sbufpool, GFP_ATOMIC, (void *) st, 20); - p = DATAPTR(dibh); - p += st->l2.ihsize; - size = st->l2.ihsize; - - *p++ = 0x8; - *p++ = 0x1; - *p++ = st->l3.callref; - *p++ = MT_DISCONNECT; - size += 4; - - *p++ = IE_CAUSE; - *p++ = 0x2; - *p++ = 0x80; - *p++ = 0x90; - size += 4; - - dibh->datasize = size; - i_down(st, dibh); - - newl3state(st, 11); -} - -static void -l3s19(struct PStack *st, byte pr, void *arg) -{ - struct BufHeader *ibh = arg; - - BufPoolRelease(ibh); - newl3state(st, 0); - l3_message(st, MT_RELEASE_COMPLETE); - st->l3.l3l4(st, CC_RELEASE_IND, NULL); -} - -static void -l3s20(struct PStack *st, byte pr, - void *arg) -{ - l3_message(st, MT_ALERTING); - newl3state(st, 7); -} - -static void -l3s21(struct PStack *st, byte pr, void *arg) -{ - struct BufHeader *dibh=arg; - byte *p; - int size; - - BufPoolRelease(dibh); - - BufPoolGet(&dibh, st->l1.sbufpool, GFP_ATOMIC, (void *) st, 20); - p = DATAPTR(dibh); - p += st->l2.ihsize; - size = st->l2.ihsize; - - *p++ = 0x8; - *p++ = 0x1; - *p++ = st->l3.callref; - *p++ = MT_STATUS; - size += 4; - - *p++ = IE_CAUSE; - *p++ = 0x2; - *p++ = 0x80; - *p++ = 0x9E; /* answer status enquire */ - size += 4; - - *p++ = 0x14; /* CallState */ - *p++ = 0x1; - *p++ = st->l3.state & 0x3f; /* ISO L3 CallState */ - size += 3; - - dibh->datasize = size; - i_down(st, dibh); - -} - -struct stateentry { - int state; - byte primitive; - void (*rout) (struct PStack *, byte, void *); -}; - -static struct stateentry downstatelist[] = -{ - {0,CC_SETUP_REQ,l3s5}, - {1,CC_DISCONNECT_REQ,l3s18}, - {1,CC_RELEASE_REQ,l3s3}, - {1,CC_DLRL,l3s13}, - {3,CC_DISCONNECT_REQ,l3s18}, - {3,CC_RELEASE_REQ,l3s3}, - {3,CC_DLRL,l3s13}, - {4,CC_RELEASE_REQ,l3s3}, - {4,CC_DISCONNECT_REQ,l3s18}, - {4,CC_DLRL,l3s13}, - {6,CC_RELEASE_REQ,l3s3}, - {6,CC_DISCONNECT_REQ,l3s18}, - {6,CC_ALERTING_REQ,l3s20}, - {6,CC_DLRL,l3s13}, - {7,CC_RELEASE_REQ,l3s3}, - {7,CC_SETUP_RSP,l3s16}, - {7,CC_DLRL,l3s13}, - {8,CC_RELEASE_REQ,l3s3}, - {8,CC_DISCONNECT_REQ,l3s18}, - {8,CC_DLRL,l3s13}, - {10,CC_DISCONNECT_REQ,l3s18}, - {10,CC_RELEASE_REQ,l3s3}, - {10,CC_DLRL,l3s13}, - {11,CC_RELEASE_REQ,l3s3}, - {12,CC_RELEASE_REQ,l3s3}, - {19,CC_DLRL,l3s13}, -}; - -static int downsllen = sizeof(downstatelist) / -sizeof(struct stateentry); - -static struct stateentry datastatelist[] = -{ - {0,MT_STATUS_ENQUIRY,l3s21}, - {0,MT_SETUP,l3s12}, - {1,MT_STATUS_ENQUIRY,l3s21}, - {1,MT_CALL_PROCEEDING,l3s6}, - {1,MT_SETUP_ACKNOWLEDGE,l3s6}, - {1,MT_RELEASE_COMPLETE,l3s4}, - {1,MT_RELEASE,l3s19}, - {1,MT_DISCONNECT,l3s7}, - {3,MT_STATUS_ENQUIRY,l3s21}, - {3,MT_DISCONNECT,l3s7}, - {3,MT_CONNECT,l3s8}, - {3,MT_ALERTING,l3s11}, - {3,MT_RELEASE,l3s19}, - {3,MT_RELEASE_COMPLETE,l3s4}, - {4,MT_STATUS_ENQUIRY,l3s21}, - {4,MT_CONNECT,l3s8}, - {4,MT_DISCONNECT,l3s7}, - {4,MT_RELEASE,l3s19}, - {4,MT_RELEASE_COMPLETE,l3s4}, - {8,MT_STATUS_ENQUIRY,l3s21}, - {6,MT_SETUP,l3s12}, - {8,MT_STATUS_ENQUIRY,l3s21}, - {7,MT_RELEASE,l3s19}, - {7,MT_RELEASE_COMPLETE,l3s4_1}, - {7,MT_DISCONNECT,l3s7}, - {8,MT_STATUS_ENQUIRY,l3s21}, - {8,MT_RELEASE,l3s19}, - {8,MT_CONNECT_ACKNOWLEDGE,l3s17}, - {8,MT_DISCONNECT,l3s7}, - {8,MT_RELEASE_COMPLETE,l3s4_1}, - {10,MT_STATUS_ENQUIRY,l3s21}, - {10,MT_DISCONNECT,l3s7}, - {10,MT_RELEASE,l3s19}, - {10,MT_RELEASE_COMPLETE,l3s4_1}, - {11,MT_STATUS_ENQUIRY,l3s21}, - {11,MT_RELEASE,l3s19}, - {11,MT_RELEASE_COMPLETE,l3s4}, - {19,MT_STATUS_ENQUIRY,l3s21}, - {19,MT_RELEASE_COMPLETE,l3s4}, -}; - -static int datasllen = sizeof(datastatelist) / -sizeof(struct stateentry); - -#ifdef P_1TR6 -#include "l3_1TR6.c" -#endif - -static void -l3up(struct PStack *st, - int pr, void *arg) -{ - int i, mt, size; - byte *ptr; - struct BufHeader *ibh = arg; - - if (pr == DL_DATA) { - ptr = DATAPTR(ibh); - ptr += st->l2.ihsize; - size = ibh->datasize - st->l2.ihsize; - mt = ptr[3]; - switch (ptr[0]) { -#ifdef P_1TR6 - case PROTO_DIS_N0: - BufPoolRelease(ibh); - break; - case PROTO_DIS_N1: - for (i = 0; i < datasl_1tr6t_len; i++) - if ((st->l3.state == datastatelist_1tr6t[i].state) && - (mt == datastatelist_1tr6t[i].primitive)) - break; - if (i == datasl_1tr6t_len) { - BufPoolRelease(ibh); - if (DEBUG_1TR6 > 0) - printk(KERN_INFO "isdnl3up unhandled 1tr6 state %d MT %x\n", - st->l3.state, mt); - } else - datastatelist_1tr6t[i].rout(st, pr, ibh); - break; -#endif - case PROTO_EURO: /* E-DSS1 */ - for (i = 0; i < datasllen; i++) - if ((st->l3.state == datastatelist[i].state) && - (mt == datastatelist[i].primitive)) - break; - if (i == datasllen) { - BufPoolRelease(ibh); - if (DEBUG_1TR6 > 0) - printk(KERN_INFO "isdnl3up unhandled E-DSS1 state %d MT %x\n", - st->l3.state, mt); - } else - datastatelist[i].rout(st, pr, ibh); - break; - default: - BufPoolRelease(ibh); - break; - } - } else if (pr == DL_UNIT_DATA) { - ptr = DATAPTR(ibh); - ptr += st->l2.uihsize; - size = ibh->datasize - st->l2.uihsize; - mt = ptr[3]; - switch (ptr[0]) { -#ifdef P_1TR6 - case PROTO_DIS_N0: - BufPoolRelease(ibh); - break; - case PROTO_DIS_N1: - for (i = 0; i < datasl_1tr6t_len; i++) - if ((st->l3.state == datastatelist_1tr6t[i].state) && - (mt == datastatelist_1tr6t[i].primitive)) - break; - if (i == datasl_1tr6t_len) { - if (DEBUG_1TR6 > 0) { - printk(KERN_INFO "isdnl3up unhandled 1tr6 state %d MT %x\n" - ,st->l3.state, mt); - } - BufPoolRelease(ibh); - } else - datastatelist_1tr6t[i].rout(st, pr, ibh); - break; -#endif - case PROTO_EURO: /* E-DSS1 */ - for (i = 0; i < datasllen; i++) - if ((st->l3.state == datastatelist[i].state) && - (mt == datastatelist[i].primitive)) - break; - if (i == datasllen) { - BufPoolRelease(ibh); - if (DEBUG_1TR6 > 0) - printk(KERN_INFO "isdnl3up unhandled E-DSS1 state %d MT %x\n", - st->l3.state, mt); - } else - datastatelist[i].rout(st, pr, ibh); - break; - default: - BufPoolRelease(ibh); - break; - } - } -} - -static void -l3down(struct PStack *st, - int pr, void *arg) -{ - int i; - struct BufHeader *ibh = arg; - - switch (st->protocol) { -#ifdef P_1TR6 - case ISDN_PTYPE_1TR6: - for (i = 0; i < downsl_1tr6t_len; i++) - if ((st->l3.state == downstatelist_1tr6t[i].state) && - (pr == downstatelist_1tr6t[i].primitive)) - break; - if (i == downsl_1tr6t_len) { - if (DEBUG_1TR6 > 0) { - printk(KERN_INFO "isdnl3down unhandled 1tr6 state %d primitive %x\n", st->l3.state, pr); - } - } else - downstatelist_1tr6t[i].rout(st, pr, ibh); - break; -#endif - default: - for (i = 0; i < downsllen; i++) - if ((st->l3.state == downstatelist[i].state) && - (pr == downstatelist[i].primitive)) - break; - if (i == downsllen) { - if (DEBUG_1TR6 > 0) { - printk(KERN_INFO "isdnl3down unhandled E-DSS1 state %d primitive %x\n", st->l3.state, pr); - } - } else - downstatelist[i].rout(st, pr, ibh); - } -} - -void -setstack_isdnl3(struct PStack *st) -{ - st->l4.l4l3 = l3down; - st->l2.l2l3 = l3up; - st->l3.state = 0; - st->l3.callref = 0; - st->l3.debug = 0; -} diff --git a/drivers/isdn/teles/l3_1TR6.c b/drivers/isdn/teles/l3_1TR6.c deleted file mode 100644 index 8566a14d4..000000000 --- a/drivers/isdn/teles/l3_1TR6.c +++ /dev/null @@ -1,538 +0,0 @@ -/* $Id: l3_1TR6.c,v 1.7 1997/02/11 01:38:55 keil Exp $ - * - * $Log: l3_1TR6.c,v $ - * Revision 1.7 1997/02/11 01:38:55 keil - * Changed setup-interface (incoming and outgoing) - * - * Revision 1.6 1996/09/25 18:34:57 keil - * missing states in 1TR6 Statemachine added - * - * Revision 1.5 1996/09/23 01:53:51 fritz - * Bugfix: discard unknown frames (non-EDSS1 and non-1TR6). - * - * Revision 1.4 1996/06/06 14:22:28 fritz - * Changed level of "non-digital call..." message, since - * with audio support, this is quite normal. - * - * Revision 1.3 1996/04/30 21:54:42 isdn4dev - * SPV, callback , remove some debugging code Karsten Keil - * - * Revision 1.2 1996/04/20 16:47:23 fritz - * Changed statemachine to allow reject of an incoming call. - * Report all incoming calls, not just those with Service = 7. - * Misc. typos - * - * Revision 1.1 1996/04/13 10:25:16 fritz - * Initial revision - * - * - */ - -#include "proto.h" - -static void -l3_1TR6_message(struct PStack *st, int mt, int pd) -{ - struct BufHeader *dibh; - byte *p; - - BufPoolGet(&dibh, st->l1.sbufpool, GFP_ATOMIC, (void *) st, 18); - p = DATAPTR(dibh); - p += st->l2.ihsize; - - *p++ = pd; - *p++ = 0x1; - *p++ = st->l3.callref; - *p++ = mt; - - dibh->datasize = p - DATAPTR(dibh); - i_down(st, dibh); -} - -static void -l3_1tr6_setup(struct PStack *st, byte pr, void *arg) -{ - struct BufHeader *dibh; - byte *p; - char *teln; - - st->l3.callref = st->pa->callref; - BufPoolGet(&dibh, st->l1.sbufpool, GFP_ATOMIC, (void *) st, 19); - p = DATAPTR(dibh); - p += st->l2.ihsize; - - *p++ = PROTO_DIS_N1; - *p++ = 0x1; - *p++ = st->l3.callref; - *p++ = MT_N1_SETUP; - - if ('S' == (st->pa->setup.phone[0] & 0x5f)) { /* SPV ??? */ - /* NSF SPV */ - *p++ = WE0_netSpecFac; - *p++ = 4; /* Laenge */ - *p++ = 0; - *p++ = FAC_SPV; /* SPV */ - *p++ = st->pa->setup.si1; /* 0 for all Services */ - *p++ = st->pa->setup.si2; /* 0 for all Services */ - *p++ = WE0_netSpecFac; - *p++ = 4; /* Laenge */ - *p++ = 0; - *p++ = FAC_Activate; /* aktiviere SPV (default) */ - *p++ = st->pa->setup.si1; /* 0 for all Services */ - *p++ = st->pa->setup.si2; /* 0 for all Services */ - } - if (st->pa->setup.eazmsn[0]) { - *p++ = WE0_origAddr; - *p++ = strlen(st->pa->setup.eazmsn) + 1; - /* Classify as AnyPref. */ - *p++ = 0x81; /* Ext = '1'B, Type = '000'B, Plan = '0001'B. */ - teln = st->pa->setup.eazmsn; - while (*teln) - *p++ = *teln++ & 0x7f; - } - *p++ = WE0_destAddr; - teln = st->pa->setup.phone; - if ('S' != (st->pa->setup.phone[0] & 0x5f)) { /* Keine SPV ??? */ - *p++ = strlen(st->pa->setup.phone) + 1; - st->pa->spv = 0; - } else { /* SPV */ - *p++ = strlen(st->pa->setup.phone); - teln++; /* skip S */ - st->pa->spv = 1; - } - /* Classify as AnyPref. */ - *p++ = 0x81; /* Ext = '1'B, Type = '000'B, Plan = '0001'B. */ - while (*teln) - *p++ = *teln++ & 0x7f; - - *p++ = WE_Shift_F6; - /* Codesatz 6 fuer Service */ - *p++ = WE6_serviceInd; - *p++ = 2; /* len=2 info,info2 */ - *p++ = st->pa->setup.si1; - *p++ = st->pa->setup.si2; - - dibh->datasize = p - DATAPTR(dibh); - - newl3state(st, 1); - i_down(st, dibh); - -} - -static void -l3_1tr6_tu_setup(struct PStack *st, byte pr, void *arg) -{ - byte *p; - struct BufHeader *ibh = arg; - - p = DATAPTR(ibh); - p += st->l2.uihsize; - st->pa->callref = getcallref(p); - st->l3.callref = 0x80 + st->pa->callref; - - /* Channel Identification */ - p = DATAPTR(ibh); - if ((p = findie(p + st->l2.uihsize, ibh->datasize - st->l2.uihsize, - WE0_chanID, 0))) { - st->pa->bchannel = p[2] & 0x3; - } else - printk(KERN_INFO "l3tu_setup: Channel ident not found\n"); - - p = DATAPTR(ibh); - - if ((p = findie(p + st->l2.uihsize, ibh->datasize - st->l2.uihsize, WE6_serviceInd, 6))) { - st->pa->setup.si1 = p[2]; - st->pa->setup.si2 = p[3]; - } else - printk(KERN_INFO "l3s12(1TR6): ServiceIndicator not found\n"); - - p = DATAPTR(ibh); - if ((p = findie(p + st->l2.uihsize, ibh->datasize - st->l2.uihsize, - WE0_destAddr, 0))) - iecpy(st->pa->setup.eazmsn, p, 1); - else - strcpy(st->pa->setup.eazmsn, ""); - - p = DATAPTR(ibh); - if ((p = findie(p + st->l2.uihsize, ibh->datasize - st->l2.uihsize, - WE0_origAddr, 0))) { - iecpy(st->pa->setup.phone, p, 1); - } else - strcpy(st->pa->setup.phone, ""); - - p = DATAPTR(ibh); - st->pa->spv = 0; - if ((p = findie(p + st->l2.uihsize, ibh->datasize - st->l2.uihsize, - WE0_netSpecFac, 0))) { - if ((FAC_SPV == p[3]) || (FAC_Activate == p[3])) - st->pa->spv = 1; - } - BufPoolRelease(ibh); - - /* Signal all services, linklevel takes care of Service-Indicator */ - if (st->pa->setup.si1 != 7) { - printk(KERN_DEBUG "non-digital call: %s -> %s\n", - st->pa->setup.phone, - st->pa->setup.eazmsn); - } - newl3state(st, 6); - st->l3.l3l4(st, CC_SETUP_IND, NULL); -} - -static void -l3_1tr6_tu_setup_ack(struct PStack *st, byte pr, void *arg) -{ - byte *p; - struct BufHeader *ibh = arg; - - p = DATAPTR(ibh); - if ((p = findie(p + st->l2.ihsize, ibh->datasize - st->l2.ihsize, - WE0_chanID, 0))) { - st->pa->bchannel = p[2] & 0x3; - } else - printk(KERN_INFO "octect 3 not found\n"); - - - BufPoolRelease(ibh); - newl3state(st, 2); -} - -static void -l3_1tr6_tu_call_sent(struct PStack *st, byte pr, void *arg) -{ - byte *p; - struct BufHeader *ibh = arg; - - p = DATAPTR(ibh); - if ((p = findie(p + st->l2.ihsize, ibh->datasize - st->l2.ihsize, - WE0_chanID, 0))) { - st->pa->bchannel = p[2] & 0x3; - } else - printk(KERN_INFO "octect 3 not found\n"); - - BufPoolRelease(ibh); - newl3state(st, 3); - st->l3.l3l4(st, CC_PROCEEDING_IND, NULL); -} - -static void -l3_1tr6_tu_alert(struct PStack *st, byte pr, void *arg) -{ - byte *p; - struct BufHeader *ibh = arg; - - - p = DATAPTR(ibh); - if ((p = findie(p + st->l2.ihsize, ibh->datasize - st->l2.ihsize, - WE6_statusCalled, 6))) { - if (DEBUG_1TR6 > 2) - printk(KERN_INFO "status called %x\n", p[2]); - } else if (DEBUG_1TR6 > 0) - printk(KERN_INFO "statusCalled not found\n"); - - BufPoolRelease(ibh); - newl3state(st, 4); - st->l3.l3l4(st, CC_ALERTING_IND, NULL); -} - -static void -l3_1tr6_tu_info(struct PStack *st, byte pr, void *arg) -{ - byte *p; - int i,tmpcharge=0; - char a_charge[8]; - struct BufHeader *ibh = arg; - - p = DATAPTR(ibh); - if ((p = findie(p + st->l2.ihsize, ibh->datasize - st->l2.ihsize, - WE6_chargingInfo, 6))) { - iecpy(a_charge, p, 1); - for (i = 0; i < strlen (a_charge); i++) { - tmpcharge *= 10; - tmpcharge += a_charge[i] & 0xf; - } - if (tmpcharge > st->pa->chargeinfo) { - st->pa->chargeinfo = tmpcharge; - st->l3.l3l4 (st, CC_INFO_CHARGE, NULL); - } - if (DEBUG_1TR6 > 2) - printk(KERN_INFO "chargingInfo %d\n", st->pa->chargeinfo); - } else if (DEBUG_1TR6 > 2) - printk(KERN_INFO "chargingInfo not found\n"); - - BufPoolRelease(ibh); -} - -static void -l3_1tr6_tu_info_s2(struct PStack *st, byte pr, void *arg) -{ - byte *p; - int i; - struct BufHeader *ibh = arg; - - if (DEBUG_1TR6 > 4) { - p = DATAPTR(ibh); - for (i = 0; i < ibh->datasize; i++) { - printk(KERN_INFO "Info DATA %x\n", p[i]); - } - } - BufPoolRelease(ibh); -} - -static void -l3_1tr6_tu_connect(struct PStack *st, byte pr, void *arg) -{ - struct BufHeader *ibh = arg; - - st->pa->chargeinfo=0; - BufPoolRelease(ibh); - st->l3.l3l4(st, CC_SETUP_CNF, NULL); - newl3state(st, 10); -} - -static void -l3_1tr6_tu_rel(struct PStack *st, byte pr, void *arg) -{ - struct BufHeader *ibh = arg; - - BufPoolRelease(ibh); - l3_1TR6_message(st, MT_N1_REL_ACK, PROTO_DIS_N1); - st->l3.l3l4(st, CC_RELEASE_IND, NULL); - newl3state(st, 0); -} - -static void -l3_1tr6_tu_rel_ack(struct PStack *st, byte pr, void *arg) -{ - struct BufHeader *ibh = arg; - - BufPoolRelease(ibh); - newl3state(st, 0); - st->l3.l3l4(st, CC_RELEASE_CNF, NULL); -} - -static void -l3_1tr6_tu_disc(struct PStack *st, byte pr, void *arg) -{ - struct BufHeader *ibh = arg; - byte *p; - int i,tmpcharge=0; - char a_charge[8]; - - p = DATAPTR(ibh); - if ((p = findie(p + st->l2.ihsize, ibh->datasize - st->l2.ihsize, - WE6_chargingInfo, 6))) { - iecpy(a_charge, p, 1); - for (i = 0; i < strlen (a_charge); i++) { - tmpcharge *= 10; - tmpcharge += a_charge[i] & 0xf; - } - if (tmpcharge > st->pa->chargeinfo) { - st->pa->chargeinfo = tmpcharge; - st->l3.l3l4 (st, CC_INFO_CHARGE, NULL); - } - if (DEBUG_1TR6 > 2) - printk(KERN_INFO "chargingInfo %d\n", st->pa->chargeinfo); - } else if (DEBUG_1TR6 > 2) - printk(KERN_INFO "chargingInfo not found\n"); - - p = DATAPTR(ibh); - if ((p = findie(p + st->l2.ihsize, ibh->datasize - st->l2.ihsize, - WE0_cause, 0))) { - if (p[1] > 0) { - st->pa->cause = p[2]; - } else { - st->pa->cause = 0; - } - if (DEBUG_1TR6 > 1) - printk(KERN_INFO "Cause %x\n", st->pa->cause); - } else if (DEBUG_1TR6 > 0) - printk(KERN_INFO "Cause not found\n"); - - BufPoolRelease(ibh); - newl3state(st, 12); - st->l3.l3l4(st, CC_DISCONNECT_IND, NULL); -} - - -static void -l3_1tr6_tu_connect_ack(struct PStack *st, byte pr, void *arg) -{ - struct BufHeader *ibh = arg; - - BufPoolRelease(ibh); - st->pa->chargeinfo = 0; - st->l3.l3l4(st, CC_SETUP_COMPLETE_IND, NULL); - newl3state(st, 10); -} - -static void -l3_1tr6_alert(struct PStack *st, byte pr, - void *arg) -{ - l3_1TR6_message(st, MT_N1_ALERT, PROTO_DIS_N1); - newl3state(st, 7); -} - -static void -l3_1tr6_conn(struct PStack *st, byte pr, - void *arg) -{ - struct BufHeader *dibh; - byte *p; - - st->l3.callref = 0x80 + st->pa->callref; - - BufPoolGet(&dibh, st->l1.sbufpool, GFP_ATOMIC, (void *) st, 20); - p = DATAPTR(dibh); - p += st->l2.ihsize; - - *p++ = PROTO_DIS_N1; - *p++ = 0x1; - *p++ = st->l3.callref; - *p++ = MT_N1_CONN; - - if (st->pa->spv) { /* SPV ??? */ - /* NSF SPV */ - *p++ = WE0_netSpecFac; - *p++ = 4; /* Laenge */ - *p++ = 0; - *p++ = FAC_SPV; /* SPV */ - *p++ = st->pa->setup.si1; - *p++ = st->pa->setup.si2; - *p++ = WE0_netSpecFac; - *p++ = 4; /* Laenge */ - *p++ = 0; - *p++ = FAC_Activate; /* aktiviere SPV */ - *p++ = st->pa->setup.si1; - *p++ = st->pa->setup.si2; - } - dibh->datasize = p - DATAPTR(dibh); - - i_down(st, dibh); - - newl3state(st, 8); -} - -static void -l3_1tr6_reset(struct PStack *st, byte pr, void *arg) -{ - newl3state(st, 0); -} - -static void -l3_1tr6_disconn_req(struct PStack *st, byte pr, void *arg) -{ - struct BufHeader *dibh; - byte *p; - byte rejflg; - - BufPoolGet(&dibh, st->l1.sbufpool, GFP_ATOMIC, (void *) st, 21); - p = DATAPTR(dibh); - p += st->l2.ihsize; - - *p++ = PROTO_DIS_N1; - *p++ = 0x1; - *p++ = st->l3.callref; - *p++ = MT_N1_DISC; - - if (st->l3.state == 7) { - rejflg = 1; - *p++ = WE0_cause; /* Anruf abweisen */ - *p++ = 0x01; /* Laenge = 1 */ - *p++ = CAUSE_CallRejected; - } else { - rejflg = 0; - *p++ = WE0_cause; - *p++ = 0x0; /* Laenge = 0 normales Ausloesen */ - } - - dibh->datasize = p - DATAPTR(dibh); - - i_down(st, dibh); - - newl3state(st, 11); -} - -static void -l3_1tr6_rel_req(struct PStack *st, byte pr, void *arg) -{ - l3_1TR6_message(st, MT_N1_REL, PROTO_DIS_N1); - newl3state(st, 19); -} - -static struct stateentry downstatelist_1tr6t[] = -{ - {0, CC_SETUP_REQ, l3_1tr6_setup}, - {1, CC_DISCONNECT_REQ, l3_1tr6_disconn_req}, - {1, CC_RELEASE_REQ, l3_1tr6_rel_req}, - {1, CC_DLRL, l3_1tr6_reset}, - {2, CC_DISCONNECT_REQ, l3_1tr6_disconn_req}, - {2, CC_RELEASE_REQ, l3_1tr6_rel_req}, - {2, CC_DLRL, l3_1tr6_reset}, - {3, CC_DISCONNECT_REQ, l3_1tr6_disconn_req}, - {3, CC_RELEASE_REQ, l3_1tr6_rel_req}, - {3, CC_DLRL, l3_1tr6_reset}, - {4, CC_DISCONNECT_REQ, l3_1tr6_disconn_req}, - {4, CC_RELEASE_REQ, l3_1tr6_rel_req}, - {4, CC_DLRL, l3_1tr6_reset}, - {6, CC_REJECT_REQ, l3_1tr6_reset}, - {6, CC_RELEASE_REQ, l3_1tr6_rel_req}, - {6, CC_SETUP_RSP, l3_1tr6_conn}, - {6, CC_ALERTING_REQ, l3_1tr6_alert}, - {6, CC_DLRL, l3_1tr6_reset}, - {7, CC_SETUP_RSP, l3_1tr6_conn}, - {7, CC_RELEASE_REQ, l3_1tr6_rel_req}, - {7, CC_DISCONNECT_REQ, l3_1tr6_disconn_req}, - {7, CC_DLRL, l3_1tr6_reset}, - {8, CC_DISCONNECT_REQ, l3_1tr6_disconn_req}, - {8, CC_RELEASE_REQ, l3_1tr6_rel_req}, - {8, CC_DLRL, l3_1tr6_reset}, - {10, CC_DISCONNECT_REQ, l3_1tr6_disconn_req}, - {10, CC_RELEASE_REQ, l3_1tr6_rel_req}, - {10, CC_DLRL, l3_1tr6_reset}, - {12, CC_RELEASE_REQ, l3_1tr6_rel_req}, - {12, CC_DLRL, l3_1tr6_reset}, - {19, CC_DLRL, l3_1tr6_reset}, -}; - -static int downsl_1tr6t_len = sizeof(downstatelist_1tr6t) / -sizeof(struct stateentry); - -static struct stateentry datastatelist_1tr6t[] = -{ - {0, MT_N1_SETUP, l3_1tr6_tu_setup}, - {0, MT_N1_REL, l3_1tr6_tu_rel}, - {1, MT_N1_SETUP_ACK, l3_1tr6_tu_setup_ack}, - {1, MT_N1_CALL_SENT, l3_1tr6_tu_call_sent}, - {1, MT_N1_REL, l3_1tr6_tu_rel}, - {1, MT_N1_DISC, l3_1tr6_tu_disc}, - {2, MT_N1_CALL_SENT, l3_1tr6_tu_call_sent}, - {2, MT_N1_ALERT, l3_1tr6_tu_alert}, - {2, MT_N1_CONN, l3_1tr6_tu_connect}, - {2, MT_N1_REL, l3_1tr6_tu_rel}, - {2, MT_N1_DISC, l3_1tr6_tu_disc}, - {2, MT_N1_INFO, l3_1tr6_tu_info_s2}, - {3, MT_N1_ALERT, l3_1tr6_tu_alert}, - {3, MT_N1_CONN, l3_1tr6_tu_connect}, - {3, MT_N1_REL, l3_1tr6_tu_rel}, - {3, MT_N1_DISC, l3_1tr6_tu_disc}, - {4, MT_N1_ALERT, l3_1tr6_tu_alert}, - {4, MT_N1_CONN, l3_1tr6_tu_connect}, - {4, MT_N1_REL, l3_1tr6_tu_rel}, - {4, MT_N1_DISC, l3_1tr6_tu_disc}, - {7, MT_N1_REL, l3_1tr6_tu_rel}, - {7, MT_N1_DISC, l3_1tr6_tu_disc}, - {8, MT_N1_REL, l3_1tr6_tu_rel}, - {8, MT_N1_DISC, l3_1tr6_tu_disc}, - {8, MT_N1_CONN_ACK, l3_1tr6_tu_connect_ack}, - {10, MT_N1_REL, l3_1tr6_tu_rel}, - {10, MT_N1_DISC, l3_1tr6_tu_disc}, - {10, MT_N1_INFO, l3_1tr6_tu_info}, - {11, MT_N1_REL, l3_1tr6_tu_rel}, - {12, MT_N1_REL, l3_1tr6_tu_rel}, - {19, MT_N1_REL_ACK, l3_1tr6_tu_rel_ack} -}; - -static int datasl_1tr6t_len = sizeof(datastatelist_1tr6t) / -sizeof(struct stateentry); diff --git a/drivers/isdn/teles/l3_1TR6.h b/drivers/isdn/teles/l3_1TR6.h deleted file mode 100644 index e3b538e26..000000000 --- a/drivers/isdn/teles/l3_1TR6.h +++ /dev/null @@ -1,160 +0,0 @@ -/* $Id: l3_1TR6.h,v 1.4 1996/09/23 01:53:52 fritz Exp $ - * - * $Log: l3_1TR6.h,v $ - * Revision 1.4 1996/09/23 01:53:52 fritz - * Bugfix: discard unknown frames (non-EDSS1 and non-1TR6). - * - * Revision 1.3 1996/04/30 21:53:48 isdn4dev - * Bugs, SPV, Logging in q931.c Karsten Keil - * - * Revision 1.1 1996/04/13 10:25:42 fritz - * Initial revision - * - * - */ -#ifndef l3_1TR6 -#define l3_1TR6 - -/* - * MsgType N0 - */ -#define MT_N0_REG_IND 0x61 -#define MT_N0_CANC_IND 0x62 -#define MT_N0_FAC_STA 0x63 -#define MT_N0_STA_ACK 0x64 -#define MT_N0_STA_REJ 0x65 -#define MT_N0_FAC_INF 0x66 -#define MT_N0_INF_ACK 0x67 -#define MT_N0_INF_REJ 0x68 -#define MT_N0_CLOSE 0x75 -#define MT_N0_CLO_ACK 0x77 - - -/* - * MsgType N1 - */ - -#define MT_N1_ESC 0x00 -#define MT_N1_ALERT 0x01 -#define MT_N1_CALL_SENT 0x02 -#define MT_N1_CONN 0x07 -#define MT_N1_CONN_ACK 0x0F -#define MT_N1_SETUP 0x05 -#define MT_N1_SETUP_ACK 0x0D -#define MT_N1_RES 0x26 -#define MT_N1_RES_ACK 0x2E -#define MT_N1_RES_REJ 0x22 -#define MT_N1_SUSP 0x25 -#define MT_N1_SUSP_ACK 0x2D -#define MT_N1_SUSP_REJ 0x21 -#define MT_N1_USER_INFO 0x20 -#define MT_N1_DET 0x40 -#define MT_N1_DISC 0x45 -#define MT_N1_REL 0x4D -#define MT_N1_REL_ACK 0x5A -#define MT_N1_CANC_ACK 0x6E -#define MT_N1_CANC_REJ 0x67 -#define MT_N1_CON_CON 0x69 -#define MT_N1_FAC 0x60 -#define MT_N1_FAC_ACK 0x68 -#define MT_N1_FAC_CAN 0x66 -#define MT_N1_FAC_REG 0x64 -#define MT_N1_FAC_REJ 0x65 -#define MT_N1_INFO 0x6D -#define MT_N1_REG_ACK 0x6C -#define MT_N1_REG_REJ 0x6F -#define MT_N1_STAT 0x63 - - - -/* - * W Elemente - */ - -#define WE_Shift_F0 0x90 -#define WE_Shift_F6 0x96 -#define WE_Shift_OF0 0x98 -#define WE_Shift_OF6 0x9E - -#define WE0_cause 0x08 -#define WE0_connAddr 0x0C -#define WE0_callID 0x10 -#define WE0_chanID 0x18 -#define WE0_netSpecFac 0x20 -#define WE0_display 0x28 -#define WE0_keypad 0x2C -#define WE0_origAddr 0x6C -#define WE0_destAddr 0x70 -#define WE0_userInfo 0x7E - -#define WE0_moreData 0xA0 -#define WE0_congestLevel 0xB0 - -#define WE6_serviceInd 0x01 -#define WE6_chargingInfo 0x02 -#define WE6_date 0x03 -#define WE6_facSelect 0x05 -#define WE6_facStatus 0x06 -#define WE6_statusCalled 0x07 -#define WE6_addTransAttr 0x08 - -/* - * FacCodes - */ -#define FAC_Sperre 0x01 -#define FAC_Sperre_All 0x02 -#define FAC_Sperre_Fern 0x03 -#define FAC_Sperre_Intl 0x04 -#define FAC_Sperre_Interk 0x05 - -#define FAC_Forward1 0x02 -#define FAC_Forward2 0x03 -#define FAC_Konferenz 0x06 -#define FAC_GrabBchan 0x0F -#define FAC_Reactivate 0x10 -#define FAC_Konferenz3 0x11 -#define FAC_Dienstwechsel1 0x12 -#define FAC_Dienstwechsel2 0x13 -#define FAC_NummernIdent 0x14 -#define FAC_GBG 0x15 -#define FAC_DisplayUebergeben 0x17 -#define FAC_DisplayUmgeleitet 0x1A -#define FAC_Unterdruecke 0x1B -#define FAC_Deactivate 0x1E -#define FAC_Activate 0x1D -#define FAC_SPV 0x1F -#define FAC_Rueckwechsel 0x23 -#define FAC_Umleitung 0x24 - -/* - * Cause codes - */ -#define CAUSE_InvCRef 0x01 -#define CAUSE_BearerNotImpl 0x03 -#define CAUSE_CIDunknown 0x07 -#define CAUSE_CIDinUse 0x08 -#define CAUSE_NoChans 0x0A -#define CAUSE_FacNotImpl 0x10 -#define CAUSE_FacNotSubscr 0x11 -#define CAUSE_OutgoingBarred 0x20 -#define CAUSE_UserAccessBusy 0x21 -#define CAUSE_NegativeGBG 0x22 -#define CAUSE_UnknownGBG 0x23 -#define CAUSE_NoSPVknown 0x25 -#define CAUSE_DestNotObtain 0x35 -#define CAUSE_NumberChanged 0x38 -#define CAUSE_OutOfOrder 0x39 -#define CAUSE_NoUserResponse 0x3A -#define CAUSE_UserBusy 0x3B -#define CAUSE_IncomingBarred 0x3D -#define CAUSE_CallRejected 0x3E -#define CAUSE_NetworkCongestion 0x59 -#define CAUSE_RemoteUser 0x5A -#define CAUSE_LocalProcErr 0x70 -#define CAUSE_RemoteProcErr 0x71 -#define CAUSE_RemoteUserSuspend 0x72 -#define CAUSE_RemoteUserResumed 0x73 -#define CAUSE_UserInfoDiscarded 0x7F - - -#endif diff --git a/drivers/isdn/teles/llglue.c b/drivers/isdn/teles/llglue.c deleted file mode 100644 index 7e32c2f4f..000000000 --- a/drivers/isdn/teles/llglue.c +++ /dev/null @@ -1,151 +0,0 @@ -/* $Id: llglue.c,v 1.7 1996/10/22 23:14:17 fritz Exp $ - * - * $Log: llglue.c,v $ - * Revision 1.7 1996/10/22 23:14:17 fritz - * Changes for compatibility to 2.0.X and 2.1.X kernels. - * - * Revision 1.6 1996/06/03 20:03:39 fritz - * Fixed typos. - * - * Revision 1.5 1996/05/31 00:58:47 fritz - * Errata: Reverted change from rev 1.4. - * - * Revision 1.4 1996/05/26 14:59:57 fritz - * Bugfix: maxbufsize had been set without respect to possible X.75 header. - * - * Revision 1.3 1996/05/01 14:19:57 fritz - * Added ISDN_FEATURE_L2_TRANS - * - * Revision 1.2 1996/04/29 23:01:46 fritz - * Added driverId and channel to readstatus(). - * - * Revision 1.1 1996/04/13 10:26:29 fritz - * Initial revision - * - * - */ -#define __NO_VERSION__ -#include "teles.h" -#include <linux/malloc.h> -#include <linux/timer.h> - - -extern struct Channel *chanlist; -int drid; -char *teles_id = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; - -isdn_if iif; - -#define TELES_STATUS_BUFSIZE 4096 -static byte *teles_status_buf = NULL; -static byte *teles_status_read = NULL; -static byte *teles_status_write = NULL; -static byte *teles_status_end = NULL; - -int -teles_readstatus(byte * buf, int len, int user, int id, int channel) -{ - int count; - byte *p; - - for (p = buf, count = 0; count < len; p++, count++) { - if (user) - put_user(*teles_status_read++, p); - else - *p++ = *teles_status_read++; - if (teles_status_read > teles_status_end) - teles_status_read = teles_status_buf; - } - return count; -} - -void -teles_putstatus(char *buf) -{ - long flags; - int len, count, i; - byte *p; - isdn_ctrl ic; - - save_flags(flags); - cli(); - count = 0; - len = strlen(buf); - for (p = buf, i = len; i > 0; i--, p++) { - *teles_status_write++ = *p; - if (teles_status_write > teles_status_end) - teles_status_write = teles_status_buf; - count++; - } - restore_flags(flags); - if (count) { - ic.command = ISDN_STAT_STAVAIL; - ic.driver = drid; - ic.arg = count; - iif.statcallb(&ic); - } -} - - -int -ll_init(void) -{ - isdn_ctrl ic; - - teles_status_buf = Smalloc(TELES_STATUS_BUFSIZE, - GFP_KERNEL, "teles_status_buf"); - if (!teles_status_buf) { - printk(KERN_ERR "teles: Could not allocate status-buffer\n"); - return (-EIO); - } else { - teles_status_read = teles_status_buf; - teles_status_write = teles_status_buf; - teles_status_end = teles_status_buf + TELES_STATUS_BUFSIZE - 1; - } - - iif.channels = CallcNewChan(); - iif.maxbufsize = BUFFER_SIZE(HSCX_SBUF_ORDER, HSCX_SBUF_BPPS); - iif.features = - ISDN_FEATURE_L2_X75I | - ISDN_FEATURE_L2_HDLC | - ISDN_FEATURE_L2_TRANS | - ISDN_FEATURE_L3_TRANS | - ISDN_FEATURE_P_1TR6 | - ISDN_FEATURE_P_EURO; - - iif.command = teles_command; - iif.writebuf = teles_writebuf; - iif.writecmd = NULL; - iif.readstat = teles_readstatus; - strncpy(iif.id, teles_id, sizeof(iif.id) - 1); - - register_isdn(&iif); - drid = iif.channels; - - ic.driver = drid; - ic.command = ISDN_STAT_RUN; - iif.statcallb(&ic); - return 0; -} - -void -ll_stop(void) -{ - isdn_ctrl ic; - - ic.command = ISDN_STAT_STOP; - ic.driver = drid; - iif.statcallb(&ic); - - CallcFreeChan(); -} - -void -ll_unload(void) -{ - isdn_ctrl ic; - - ic.command = ISDN_STAT_UNLOAD; - ic.driver = drid; - iif.statcallb(&ic); -} diff --git a/drivers/isdn/teles/mod.c b/drivers/isdn/teles/mod.c deleted file mode 100644 index d5486bd4b..000000000 --- a/drivers/isdn/teles/mod.c +++ /dev/null @@ -1,160 +0,0 @@ -/* $Id: mod.c,v 1.3 1997/02/14 12:23:31 fritz Exp $ - * - * $Log: mod.c,v $ - * Revision 1.3 1997/02/14 12:23:31 fritz - * Added support for new insmod parameter handling. - * - * Revision 1.2 1997/02/10 11:45:14 fritz - * More changes for Kernel 2.1.X compatibility. - * - * Revision 1.1 1996/04/13 10:27:02 fritz - * Initial revision - * - * - */ -#include "teles.h" - -extern struct IsdnCard cards[]; -extern char *teles_id; - -int nrcards; - -typedef struct { - byte *membase; - int interrupt; - unsigned int iobase; - unsigned int protocol; -} io_type; - -io_type io[] = -{ - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, -}; - -#ifdef MODULE -#if (LINUX_VERSION_CODE > 0x020111) -MODULE_PARM(io, "1-64i"); -MODULE_PARM(teles_id, "s"); -#endif -#endif - -void -teles_mod_dec_use_count(void) -{ - MOD_DEC_USE_COUNT; -} - -void -teles_mod_inc_use_count(void) -{ - MOD_INC_USE_COUNT; -} - -#ifdef MODULE -#define teles_init init_module -#else -void teles_setup(char *str, int *ints) -{ - int i, j, argc; - static char sid[20]; - - argc = ints[0]; - i = 0; - j = 1; - while (argc && (i<16)) { - if (argc) { - io[i].iobase = ints[j]; - j++; argc--; - } - if (argc) { - io[i].interrupt = ints[j]; - j++; argc--; - } - if (argc) { - io[i].membase = (byte *)ints[j]; - j++; argc--; - } - if (argc) { - io[i].protocol = ints[j]; - j++; argc--; - } - i++; - } - if (strlen(str)) { - strcpy(sid,str); - teles_id = sid; - } -} -#endif - -int -teles_init(void) -{ - int i; - - nrcards = 0; - for (i = 0; i < 16; i++) { - if (io[i].protocol) { - cards[i].membase = io[i].membase; - cards[i].interrupt = io[i].interrupt; - cards[i].iobase = io[i].iobase; - cards[i].protocol = io[i].protocol; - } - } - for (i = 0; i < 16; i++) - if (cards[i].protocol) - nrcards++; - printk(KERN_DEBUG "teles: Total %d card%s defined\n", - nrcards, (nrcards > 1) ? "s" : ""); - if (teles_inithardware()) { - /* Install only, if at least one card found */ - Isdnl2New(); - TeiNew(); - CallcNew(); - ll_init(); - - /* No symbols to export, hide all symbols */ - -#ifdef MODULE -#if (LINUX_VERSION_CODE < 0x020111) - register_symtab(NULL); -#else - EXPORT_NO_SYMBOLS; -#endif - printk(KERN_NOTICE "Teles module installed\n"); -#endif - return (0); - } else - return -EIO; -} - -#ifdef MODULE -void -cleanup_module(void) -{ - - ll_stop(); - TeiFree(); - Isdnl2Free(); - CallcFree(); - teles_closehardware(); - ll_unload(); - printk(KERN_NOTICE "Teles module removed\n"); - -} -#endif diff --git a/drivers/isdn/teles/proto.h b/drivers/isdn/teles/proto.h deleted file mode 100644 index 0d7ae8ef4..000000000 --- a/drivers/isdn/teles/proto.h +++ /dev/null @@ -1,18 +0,0 @@ -/* $Id: proto.h,v 1.1 1996/09/23 01:53:52 fritz Exp $ - * - * not much now - just the l3 proto discriminator - * - * $Log: proto.h,v $ - * Revision 1.1 1996/09/23 01:53:52 fritz - * Bugfix: discard unknown frames (non-EDSS1 and non-1TR6). - * - */ - -#ifndef PROTO_H -#define PROTO_H - -#define PROTO_EURO 0x08 -#define PROTO_DIS_N0 0x40 -#define PROTO_DIS_N1 0x41 - -#endif diff --git a/drivers/isdn/teles/q931.c b/drivers/isdn/teles/q931.c deleted file mode 100644 index c9f5fa692..000000000 --- a/drivers/isdn/teles/q931.c +++ /dev/null @@ -1,1155 +0,0 @@ -/* $Id: q931.c,v 1.6 1996/09/23 01:53:53 fritz Exp $ - * - * q931.c code to decode ITU Q.931 call control messages - * - * Author Jan den Ouden - * - * Changelog - * - * Pauline Middelink general improvements - * - * Beat Doebeli cause texts, display information element - * - * Karsten Keil cause texts, display information element for 1TR6 - * - * - * $Log: q931.c,v $ - * Revision 1.6 1996/09/23 01:53:53 fritz - * Bugfix: discard unknown frames (non-EDSS1 and non-1TR6). - * - * Revision 1.5 1996/06/03 20:03:40 fritz - * Fixed typos. - * - * Revision 1.4 1996/05/17 03:46:17 fritz - * General cleanup. - * - * Revision 1.3 1996/04/30 22:06:50 isdn4dev - * logging 1TR6 messages correctly Karsten Keil - * - * Revision 1.2 1996/04/20 16:48:19 fritz - * Misc. typos - * - * Revision 1.1 1996/04/13 10:27:49 fritz - * Initial revision - * - * - */ - - -#define __NO_VERSION__ -#include "teles.h" -#include "proto.h" -#include "l3_1TR6.h" - -byte * -findie(byte * p, int size, byte ie, int wanted_set) -{ - int l, codeset, maincodeset; - byte *pend = p + size; - - /* skip protocol discriminator, callref and message type */ - p++; - l = (*p++) & 0xf; - p += l; - p++; - codeset = 0; - maincodeset = 0; - /* while there are bytes left... */ - while (p < pend) { - if ((*p & 0xf0) == 0x90) { - codeset = *p & 0x07; - if (!(*p & 0x08)) - maincodeset = codeset; - } - if (*p & 0x80) - p++; - else { - if (codeset == wanted_set) { - if (*p == ie) - return (p); - if (*p > ie) - return (NULL); - } - p++; - l = *p++; - p += l; - codeset = maincodeset; - } - } - return (NULL); -} - -void -iecpy(byte * dest, byte * iestart, int ieoffset) -{ - byte *p; - int l; - - p = iestart + ieoffset + 2; - l = iestart[1] - ieoffset; - while (l--) - *dest++ = *p++; - *dest++ = '\0'; -} - -int -getcallref(byte * p) -{ - p++; /* prot discr */ - p++; /* callref length */ - return (*p); /* assuming one-byte callref */ -} - -/* - * According to Table 4-2/Q.931 - */ -static -struct MessageType { - byte nr; - char *descr; -} mtlist[] = { - - { - 0x1, "ALERTING" - }, - { - 0x2, "CALL PROCEEDING" - }, - { - 0x7, "CONNECT" - }, - { - 0xf, "CONNECT ACKNOWLEDGE" - }, - { - 0x3, "PROGRESS" - }, - { - 0x5, "SETUP" - }, - { - 0xd, "SETUP ACKNOWLEDGE" - }, - { - 0x26, "RESUME" - }, - { - 0x2e, "RESUME ACKNOWLEDGE" - }, - { - 0x22, "RESUME REJECT" - }, - { - 0x25, "SUSPEND" - }, - { - 0x2d, "SUSPEND ACKNOWLEDGE" - }, - { - 0x21, "SUSPEND REJECT" - }, - { - 0x20, "USER INFORMATION" - }, - { - 0x45, "DISCONNECT" - }, - { - 0x4d, "RELEASE" - }, - { - 0x5a, "RELEASE COMPLETE" - }, - { - 0x46, "RESTART" - }, - { - 0x4e, "RESTART ACKNOWLEDGE" - }, - { - 0x60, "SEGMENT" - }, - { - 0x79, "CONGESTION CONTROL" - }, - { - 0x7b, "INFORMATION" - }, - { - 0x62, "FACILITY" - }, - { - 0x6e, "NOTIFY" - }, - { - 0x7d, "STATUS" - }, - { - 0x75, "STATUS ENQUIRY" - } -}; - -#define MTSIZE sizeof(mtlist)/sizeof(struct MessageType) - -static -struct MessageType mt_n0[] = -{ - {MT_N0_REG_IND, "REGister INDication"}, - {MT_N0_CANC_IND, "CANCel INDication"}, - {MT_N0_FAC_STA, "FACility STAtus"}, - {MT_N0_STA_ACK, "STAtus ACKnowledge"}, - {MT_N0_STA_REJ, "STAtus REJect"}, - {MT_N0_FAC_INF, "FACility INFormation"}, - {MT_N0_INF_ACK, "INFormation ACKnowledge"}, - {MT_N0_INF_REJ, "INFormation REJect"}, - {MT_N0_CLOSE, "CLOSE"}, - {MT_N0_CLO_ACK, "CLOse ACKnowledge"} -}; - -int mt_n0_len = (sizeof(mt_n0) / sizeof(struct MessageType)); - -static -struct MessageType mt_n1[] = -{ - {MT_N1_ESC, "ESCape"}, - {MT_N1_ALERT, "ALERT"}, - {MT_N1_CALL_SENT, "CALL SENT"}, - {MT_N1_CONN, "CONNect"}, - {MT_N1_CONN_ACK, "CONNect ACKnowledge"}, - {MT_N1_SETUP, "SETUP"}, - {MT_N1_SETUP_ACK, "SETUP ACKnowledge"}, - {MT_N1_RES, "RESume"}, - {MT_N1_RES_ACK, "RESume ACKnowledge"}, - {MT_N1_RES_REJ, "RESume REJect"}, - {MT_N1_SUSP, "SUSPend"}, - {MT_N1_SUSP_ACK, "SUSPend ACKnowledge"}, - {MT_N1_SUSP_REJ, "SUSPend REJect"}, - {MT_N1_USER_INFO, "USER INFO"}, - {MT_N1_DET, "DETach"}, - {MT_N1_DISC, "DISConnect"}, - {MT_N1_REL, "RELease"}, - {MT_N1_REL_ACK, "RELease ACKnowledge"}, - {MT_N1_CANC_ACK, "CANCel ACKnowledge"}, - {MT_N1_CANC_REJ, "CANCel REJect"}, - {MT_N1_CON_CON, "CONgestion CONtrol"}, - {MT_N1_FAC, "FACility"}, - {MT_N1_FAC_ACK, "FACility ACKnowledge"}, - {MT_N1_FAC_CAN, "FACility CANcel"}, - {MT_N1_FAC_REG, "FACility REGister"}, - {MT_N1_FAC_REJ, "FACility REJect"}, - {MT_N1_INFO, "INFOrmation"}, - {MT_N1_REG_ACK, "REGister ACKnowledge"}, - {MT_N1_REG_REJ, "REGister REJect"}, - {MT_N1_STAT, "STATus"} -}; - -int mt_n1_len = (sizeof(mt_n1) / sizeof(struct MessageType)); - -static struct MessageType fac_1tr6[] = -{ - {FAC_Sperre, "Sperre"}, - {FAC_Forward1, "Forward 1"}, - {FAC_Forward2, "Forward 2"}, - {FAC_Konferenz, "Konferenz"}, - {FAC_GrabBchan, "Grab Bchannel"}, - {FAC_Reactivate, "Reactivate"}, - {FAC_Konferenz3, "Dreier Konferenz"}, - {FAC_Dienstwechsel1, "Einseitiger Dienstwechsel"}, - {FAC_Dienstwechsel2, "Zweiseitiger Dienstwechsel"}, - {FAC_NummernIdent, "Rufnummer-Identifizierung"}, - {FAC_GBG, "GBG"}, - {FAC_DisplayUebergeben, "Display Uebergeben"}, - {FAC_DisplayUmgeleitet, "Display Umgeleitet"}, - {FAC_Unterdruecke, "Unterdruecke Rufnummer"}, - {FAC_Deactivate, "Deactivate"}, - {FAC_Activate, "Activate"}, - {FAC_SPV, "SPV"}, - {FAC_Rueckwechsel, "Rueckwechsel"}, - {FAC_Umleitung, "Umleitung"} -}; -int fac_1tr6_len = (sizeof(fac_1tr6) / sizeof(struct MessageType)); - - - -static int -prbits(char *dest, byte b, int start, int len) -{ - char *dp = dest; - - b = b << (8 - start); - while (len--) { - if (b & 0x80) - *dp++ = '1'; - else - *dp++ = '0'; - b = b << 1; - } - return (dp - dest); -} - -static -byte * -skipext(byte * p) -{ - while (!(*p++ & 0x80)); - return (p); -} - -/* - * Cause Values According to Q.850 - * edescr: English description - * ddescr: German description used by Swissnet II (Swiss Telecom - * not yet written... - */ - -static -struct CauseValue { - byte nr; - char *edescr; - char *ddescr; -} cvlist[] = { - - { - 0x01, "Unallocated (unassigned) number", "Nummer nicht zugeteilt" - }, - { - 0x02, "No route to specified transit network", "" - }, - { - 0x03, "No route to destination", "" - }, - { - 0x04, "Send special information tone", "" - }, - { - 0x05, "Misdialled trunk prefix", "" - }, - { - 0x06, "Channel unacceptable", "Kanal nicht akzeptierbar" - }, - { - 0x07, "Channel awarded and being delivered in an established channel", "" - }, - { - 0x08, "Preemption", "" - }, - { - 0x09, "Preemption - circuit reserved for reuse", "" - }, - { - 0x10, "Normal call clearing", "Normale Ausloesung" - }, - { - 0x11, "User busy", "TNB besetzt" - }, - { - 0x12, "No user responding", "" - }, - { - 0x13, "No answer from user (user alerted)", "" - }, - { - 0x14, "Subscriber absent", "" - }, - { - 0x15, "Call rejected", "" - }, - { - 0x16, "Number changed", "" - }, - { - 0x1a, "non-selected user clearing", "" - }, - { - 0x1b, "Destination out of order", "" - }, - { - 0x1c, "Invalid number format (address incomplete)", "" - }, - { - 0x1d, "Facility rejected", "" - }, - { - 0x1e, "Response to Status enquiry", "" - }, - { - 0x1f, "Normal, unspecified", "" - }, - { - 0x22, "No circuit/channel available", "" - }, - { - 0x26, "Network out of order", "" - }, - { - 0x27, "Permanent frame mode connection out-of-service", "" - }, - { - 0x28, "Permanent frame mode connection operational", "" - }, - { - 0x29, "Temporary failure", "" - }, - { - 0x2a, "Switching equipment congestion", "" - }, - { - 0x2b, "Access information discarded", "" - }, - { - 0x2c, "Requested circuit/channel not available", "" - }, - { - 0x2e, "Precedence call blocked", "" - }, - { - 0x2f, "Resource unavailable, unspecified", "" - }, - { - 0x31, "Quality of service unavailable", "" - }, - { - 0x32, "Requested facility not subscribed", "" - }, - { - 0x35, "Outgoing calls barred within CUG", "" - }, - { - 0x37, "Incoming calls barred within CUG", "" - }, - { - 0x39, "Bearer capability not authorized", "" - }, - { - 0x3a, "Bearer capability not presently available", "" - }, - { - 0x3e, "Inconsistency in designated outgoing access information and subscriber class ", " " - }, - { - 0x3f, "Service or option not available, unspecified", "" - }, - { - 0x41, "Bearer capability not implemented", "" - }, - { - 0x42, "Channel type not implemented", "" - }, - { - 0x43, "Requested facility not implemented", "" - }, - { - 0x44, "Only restricted digital information bearer capability is available", "" - }, - { - 0x4f, "Service or option not implemented", "" - }, - { - 0x51, "Invalid call reference value", "" - }, - { - 0x52, "Identified channel does not exist", "" - }, - { - 0x53, "A suspended call exists, but this call identity does not", "" - }, - { - 0x54, "Call identity in use", "" - }, - { - 0x55, "No call suspended", "" - }, - { - 0x56, "Call having the requested call identity has been cleared", "" - }, - { - 0x57, "User not member of CUG", "" - }, - { - 0x58, "Incompatible destination", "" - }, - { - 0x5a, "Non-existent CUG", "" - }, - { - 0x5b, "Invalid transit network selection", "" - }, - { - 0x5f, "Invalid message, unspecified", "" - }, - { - 0x60, "Mandatory information element is missing", "" - }, - { - 0x61, "Message type non-existent or not implemented", "" - }, - { - 0x62, "Message not compatible with call state or message type non-existent or not implemented ", " " - }, - { - 0x63, "Information element/parameter non-existent or not implemented", "" - }, - { - 0x64, "Invalid information element contents", "" - }, - { - 0x65, "Message not compatible with call state", "" - }, - { - 0x66, "Recovery on timer expiry", "" - }, - { - 0x67, "Parameter non-existent or not implemented - passed on", "" - }, - { - 0x6e, "Message with unrecognized parameter discarded", "" - }, - { - 0x6f, "Protocol error, unspecified", "" - }, - { - 0x7f, "Interworking, unspecified", "" - }, -}; - -#define CVSIZE sizeof(cvlist)/sizeof(struct CauseValue) - -static -int -prcause(char *dest, byte * p) -{ - byte *end; - char *dp = dest; - int i, cause; - - end = p + p[1] + 1; - p += 2; - dp += sprintf(dp, " coding "); - dp += prbits(dp, *p, 7, 2); - dp += sprintf(dp, " location "); - dp += prbits(dp, *p, 4, 4); - *dp++ = '\n'; - p = skipext(p); - - cause = 0x7f & *p++; - - /* locate cause value */ - for (i = 0; i < CVSIZE; i++) - if (cvlist[i].nr == cause) - break; - - /* display cause value if it exists */ - if (i == CVSIZE) - dp += sprintf(dp, "Unknown cause type %x!\n", cause); - else - dp += sprintf(dp, " cause value %x : %s \n", cause, cvlist[i].edescr); - - while (!0) { - if (p > end) - break; - dp += sprintf(dp, " diag attribute %d ", *p++ & 0x7f); - dp += sprintf(dp, " rej %d ", *p & 0x7f); - if (*p & 0x80) { - *dp++ = '\n'; - break; - } else - dp += sprintf(dp, " av %d\n", (*++p) & 0x7f); - } - return (dp - dest); - -} - -static -struct MessageType cause_1tr6[] = -{ - {CAUSE_InvCRef, "Invalid Call Reference"}, - {CAUSE_BearerNotImpl, "Bearer Service Not Implemented"}, - {CAUSE_CIDunknown, "Caller Identity unknown"}, - {CAUSE_CIDinUse, "Caller Identity in Use"}, - {CAUSE_NoChans, "No Channels available"}, - {CAUSE_FacNotImpl, "Facility Not Implemented"}, - {CAUSE_FacNotSubscr, "Facility Not Subscribed"}, - {CAUSE_OutgoingBarred, "Outgoing calls barred"}, - {CAUSE_UserAccessBusy, "User Access Busy"}, - {CAUSE_NegativeGBG, "Negative GBG"}, - {CAUSE_UnknownGBG, "Unknown GBG"}, - {CAUSE_NoSPVknown, "No SPV known"}, - {CAUSE_DestNotObtain, "Destination not obtainable"}, - {CAUSE_NumberChanged, "Number changed"}, - {CAUSE_OutOfOrder, "Out Of Order"}, - {CAUSE_NoUserResponse, "No User Response"}, - {CAUSE_UserBusy, "User Busy"}, - {CAUSE_IncomingBarred, "Incoming Barred"}, - {CAUSE_CallRejected, "Call Rejected"}, - {CAUSE_NetworkCongestion, "Network Congestion"}, - {CAUSE_RemoteUser, "Remote User initiated"}, - {CAUSE_LocalProcErr, "Local Procedure Error"}, - {CAUSE_RemoteProcErr, "Remote Procedure Error"}, - {CAUSE_RemoteUserSuspend, "Remote User Suspend"}, - {CAUSE_RemoteUserResumed, "Remote User Resumed"}, - {CAUSE_UserInfoDiscarded, "User Info Discarded"} -}; - -int cause_1tr6_len = (sizeof(cause_1tr6) / sizeof(struct MessageType)); - -static int -prcause_1tr6(char *dest, byte * p) -{ - char *dp = dest; - int i, cause; - - p++; - if (0 == *p) { - dp += sprintf(dp, " OK (cause length=0)\n"); - return (dp - dest); - } else if (*p > 1) { - dp += sprintf(dp, " coding "); - dp += prbits(dp, p[2], 7, 2); - dp += sprintf(dp, " location "); - dp += prbits(dp, p[2], 4, 4); - *dp++ = '\n'; - } - p++; - cause = 0x7f & *p; - - /* locate cause value */ - for (i = 0; i < cause_1tr6_len; i++) - if (cause_1tr6[i].nr == cause) - break; - - /* display cause value if it exists */ - if (i == cause_1tr6_len) - dp += sprintf(dp, "Unknown cause type %x!\n", cause); - else - dp += sprintf(dp, " cause value %x : %s \n", cause, cause_1tr6[i].descr); - - return (dp - dest); - -} - -static int -prchident(char *dest, byte * p) { - char *dp = dest; - - p += 2; - dp += sprintf(dp, " octet 3 "); - dp += prbits(dp, *p, 8, 8); - *dp++ = '\n'; - return (dp - dest); -} - -static int -prcalled(char *dest, byte * p) { - int l; - char *dp = dest; - - p++; - l = *p++ - 1; - dp += sprintf(dp, " octet 3 "); - dp += prbits(dp, *p++, 8, 8); - *dp++ = '\n'; - dp += sprintf(dp, " number digits "); - while (l--) - *dp++ = *p++; - *dp++ = '\n'; - return (dp - dest); -} -static int -prcalling(char *dest, byte * p) { - int l; - char *dp = dest; - - p++; - l = *p++ - 1; - dp += sprintf(dp, " octet 3 "); - dp += prbits(dp, *p, 8, 8); - *dp++ = '\n'; - if (!(*p & 0x80)) { - dp += sprintf(dp, " octet 3a "); - dp += prbits(dp, *++p, 8, 8); - *dp++ = '\n'; - l--; - }; - p++; - - dp += sprintf(dp, " number digits "); - while (l--) - *dp++ = *p++; - *dp++ = '\n'; - return (dp - dest); -} - -static -int -prbearer(char *dest, byte * p) -{ - char *dp = dest, ch; - - p += 2; - dp += sprintf(dp, " octet 3 "); - dp += prbits(dp, *p++, 8, 8); - *dp++ = '\n'; - dp += sprintf(dp, " octet 4 "); - dp += prbits(dp, *p, 8, 8); - *dp++ = '\n'; - if ((*p++ & 0x1f) == 0x18) { - dp += sprintf(dp, " octet 4.1 "); - dp += prbits(dp, *p++, 8, 8); - *dp++ = '\n'; - } - /* check for user information layer 1 */ - if ((*p & 0x60) == 0x20) { - ch = ' '; - do { - dp += sprintf(dp, " octet 5%c ", ch); - dp += prbits(dp, *p, 8, 8); - *dp++ = '\n'; - if (ch == ' ') - ch = 'a'; - else - ch++; - } - while (!(*p++ & 0x80)); - } - /* check for user information layer 2 */ - if ((*p & 0x60) == 0x40) { - dp += sprintf(dp, " octet 6 "); - dp += prbits(dp, *p++, 8, 8); - *dp++ = '\n'; - } - /* check for user information layer 3 */ - if ((*p & 0x60) == 0x60) { - dp += sprintf(dp, " octet 7 "); - dp += prbits(dp, *p++, 8, 8); - *dp++ = '\n'; - } - return (dp - dest); -} - -static int -general(char *dest, byte * p) { - char *dp = dest; - char ch = ' '; - int l, octet = 3; - - p++; - l = *p++; - /* Iterate over all octets in the information element */ - while (l--) { - dp += sprintf(dp, " octet %d%c ", octet, ch); - dp += prbits(dp, *p++, 8, 8); - *dp++ = '\n'; - - /* last octet in group? */ - if (*p & 0x80) { - octet++; - ch = ' '; - } else if (ch == ' ') - ch = 'a'; - else - ch++; - } - return (dp - dest); -} - -static int -prcharge(char *dest, byte * p) { - char *dp = dest; - int l; - - p++; - l = *p++ - 1; - dp += sprintf(dp, " GEA "); - dp += prbits(dp, *p++, 8, 8); - dp += sprintf(dp, " Anzahl: "); - /* Iterate over all octets in the * information element */ - while (l--) - *dp++ = *p++; - *dp++ = '\n'; - return (dp - dest); -} -static int -prtext(char *dest, byte * p) { - char *dp = dest; - int l; - - p++; - l = *p++; - dp += sprintf(dp, " "); - /* Iterate over all octets in the * information element */ - while (l--) - *dp++ = *p++; - *dp++ = '\n'; - return (dp - dest); -} -static int -display(char *dest, byte * p) { - char *dp = dest; - char ch = ' '; - int l, octet = 3; - - p++; - l = *p++; - /* Iterate over all octets in the * display-information element */ - dp += sprintf(dp, " \""); - while (l--) { - dp += sprintf(dp, "%c", *p++); - - /* last octet in group? */ - if (*p & 0x80) { - octet++; - ch = ' '; - } else if (ch == ' ') - ch = 'a'; - - else - ch++; - } - *dp++ = '\"'; - *dp++ = '\n'; - return (dp - dest); -} - -int -prfacility(char *dest, byte * p) -{ - char *dp = dest; - int l, l2; - - p++; - l = *p++; - dp += sprintf(dp, " octet 3 "); - dp += prbits(dp, *p++, 8, 8); - dp += sprintf(dp, "\n"); - l -= 1; - - while (l > 0) { - dp += sprintf(dp, " octet 4 "); - dp += prbits(dp, *p++, 8, 8); - dp += sprintf(dp, "\n"); - dp += sprintf(dp, " octet 5 %d\n", l2 = *p++ & 0x7f); - l -= 2; - dp += sprintf(dp, " contents "); - while (l2--) { - dp += sprintf(dp, "%2x ", *p++); - l--; - } - dp += sprintf(dp, "\n"); - } - - return (dp - dest); -} - -static -struct InformationElement { - byte nr; - char *descr; - int (*f) (char *, byte *); -} ielist[] = { - - { - 0x00, "Segmented message", general - }, - { - 0x04, "Bearer capability", prbearer - }, - { - 0x08, "Cause", prcause - }, - { - 0x10, "Call identity", general - }, - { - 0x14, "Call state", general - }, - { - 0x18, "Channel identification", prchident - }, - { - 0x1c, "Facility", prfacility - }, - { - 0x1e, "Progress indicator", general - }, - { - 0x20, "Network-specific facilities", general - }, - { - 0x27, "Notification indicator", general - }, - { - 0x28, "Display", display - }, - { - 0x29, "Date/Time", general - }, - { - 0x2c, "Keypad facility", general - }, - { - 0x34, "Signal", general - }, - { - 0x40, "Information rate", general - }, - { - 0x42, "End-to-end delay", general - }, - { - 0x43, "Transit delay selection and indication", general - }, - { - 0x44, "Packet layer binary parameters", general - }, - { - 0x45, "Packet layer window size", general - }, - { - 0x46, "Packet size", general - }, - { - 0x47, "Closed user group", general - }, - { - 0x4a, "Reverse charge indication", general - }, - { - 0x6c, "Calling party number", prcalling - }, - { - 0x6d, "Calling party subaddress", general - }, - { - 0x70, "Called party number", prcalled - }, - { - 0x71, "Called party subaddress", general - }, - { - 0x74, "Redirecting number", general - }, - { - 0x78, "Transit network selection", general - }, - { - 0x79, "Restart indicator", general - }, - { - 0x7c, "Low layer compatibility", general - }, - { - 0x7d, "High layer compatibility", general - }, - { - 0x7e, "User-user", general - }, - { - 0x7f, "Escape for extension", general - }, -}; - - -#define IESIZE sizeof(ielist)/sizeof(struct InformationElement) - -static struct InformationElement we_0[] = -{ - {WE0_cause, "Cause", prcause_1tr6}, - {WE0_connAddr, "Connecting Address", prcalled}, - {WE0_callID, "Call IDentity", general}, - {WE0_chanID, "Channel IDentity", general}, - {WE0_netSpecFac, "Network Specific Facility", general}, - {WE0_display, "Display", general}, - {WE0_keypad, "Keypad", general}, - {WE0_origAddr, "Origination Address", prcalled}, - {WE0_destAddr, "Destination Address", prcalled}, - {WE0_userInfo, "User Info", general} -}; - -static int we_0_len = (sizeof(we_0) / sizeof(struct InformationElement)); - -static struct InformationElement we_6[] = -{ - {WE6_serviceInd, "Service Indicator", general}, - {WE6_chargingInfo, "Charging Information", prcharge}, - {WE6_date, "Date", prtext}, - {WE6_facSelect, "Facility Select", general}, - {WE6_facStatus, "Facility Status", general}, - {WE6_statusCalled, "Status Called", general}, - {WE6_addTransAttr, "Additional Transmission Attributes", general} -}; -static int we_6_len = (sizeof(we_6) / sizeof(struct InformationElement)); - -void -dlogframe(struct IsdnCardState *sp, byte * buf, int size, char *comment) { - byte *bend = buf + size; - char *dp; - int i, cs = 0, cs_old = 0, cs_fest = 0; - - /* display header */ - dp = sp->dlogspace; - dp += sprintf(dp, "%s\n", comment); - - { - byte *p = buf; - dp += sprintf(dp, "hex: "); - while (p < bend) - dp += sprintf(dp, "%02x ", *p++); - dp += sprintf(dp, "\n"); - teles_putstatus(sp->dlogspace); - dp = sp->dlogspace; - } - if ((0xfe & buf[0]) == PROTO_DIS_N0) { /* 1TR6 */ - /* locate message type */ - if (buf[0] == PROTO_DIS_N0) { /* N0 */ - for (i = 0; i < mt_n0_len; i++) - if (mt_n0[i].nr == buf[3]) - break; - /* display message type iff it exists */ - if (i == mt_n0_len) - dp += sprintf(dp, "Unknown message type N0 %x!\n", buf[3]); - else - dp += sprintf(dp, "call reference %d size %d message type %s\n", - buf[2], size, mt_n0[i].descr); - } else { /* N1 */ - for (i = 0; i < mt_n1_len; i++) - if (mt_n1[i].nr == buf[3]) - break; - /* display message type iff it exists */ - if (i == mt_n1_len) - dp += sprintf(dp, "Unknown message type N1 %x!\n", buf[3]); - else - dp += sprintf(dp, "call reference %d size %d message type %s\n", - buf[2], size, mt_n1[i].descr); - } - - /* display each information element */ - buf += 4; - while (buf < bend) { - /* Is it a single octet information element? */ - if (*buf & 0x80) { - switch ((*buf >> 4) & 7) { - case 1: - dp += sprintf(dp, " Shift %x\n", *buf & 0xf); - cs_old = cs; - cs = *buf & 7; - cs_fest = *buf & 8; - break; - case 3: - dp += sprintf(dp, " Congestion level %x\n", *buf & 0xf); - break; - case 2: - if (*buf == 0xa0) { - dp += sprintf(dp, " More data\n"); - break; - } - if (*buf == 0xa1) { - dp += sprintf(dp, " Sending complete\n"); - } - break; - /* fall through */ - default: - dp += sprintf(dp, " Reserved %x\n", *buf); - break; - } - buf++; - continue; - } - /* No, locate it in the table */ - if (cs == 0) { - for (i = 0; i < we_0_len; i++) - if (*buf == we_0[i].nr) - break; - - /* When found, give appropriate msg */ - if (i != we_0_len) { - dp += sprintf(dp, " %s\n", we_0[i].descr); - dp += we_0[i].f(dp, buf); - } else - dp += sprintf(dp, " Codeset %d attribute %x attribute size %d\n", cs, *buf, buf[1]); - } else if (cs == 6) { - for (i = 0; i < we_6_len; i++) - if (*buf == we_6[i].nr) - break; - - /* When found, give appropriate msg */ - if (i != we_6_len) { - dp += sprintf(dp, " %s\n", we_6[i].descr); - dp += we_6[i].f(dp, buf); - } else - dp += sprintf(dp, " Codeset %d attribute %x attribute size %d\n", cs, *buf, buf[1]); - } else - dp += sprintf(dp, " Unknown Codeset %d attribute %x attribute size %d\n", cs, *buf, buf[1]); - /* Skip to next element */ - if (cs_fest == 8) { - cs = cs_old; - cs_old = 0; - cs_fest = 0; - } - buf += buf[1] + 2; - } - } else if (buf[0]==PROTO_EURO) { /* EURO */ - /* locate message type */ - for (i = 0; i < MTSIZE; i++) - if (mtlist[i].nr == buf[3]) - break; - - /* display message type iff it exists */ - if (i == MTSIZE) - dp += sprintf(dp, "Unknown message type %x!\n", buf[3]); - else - dp += sprintf(dp, "call reference %d size %d message type %s\n", - buf[2], size, mtlist[i].descr); - - /* display each information element */ - buf += 4; - while (buf < bend) { - /* Is it a single octet information element? */ - if (*buf & 0x80) { - switch ((*buf >> 4) & 7) { - case 1: - dp += sprintf(dp, " Shift %x\n", *buf & 0xf); - break; - case 3: - dp += sprintf(dp, " Congestion level %x\n", *buf & 0xf); - break; - case 5: - dp += sprintf(dp, " Repeat indicator %x\n", *buf & 0xf); - break; - case 2: - if (*buf == 0xa0) { - dp += sprintf(dp, " More data\n"); - break; - } - if (*buf == 0xa1) { - dp += sprintf(dp, " Sending complete\n"); - } - break; - /* fall through */ - default: - dp += sprintf(dp, " Reserved %x\n", *buf); - break; - } - buf++; - continue; - } - /* No, locate it in the table */ - for (i = 0; i < IESIZE; i++) - if (*buf == ielist[i].nr) - break; - - /* When not found, give appropriate msg */ - if (i != IESIZE) { - dp += sprintf(dp, " %s\n", ielist[i].descr); - dp += ielist[i].f(dp, buf); - } else - dp += sprintf(dp, " attribute %x attribute size %d\n", *buf, buf[1]); - - /* Skip to next element */ - buf += buf[1] + 2; - } - } - else dp += sprintf(dp,"Unnown frame type %.2x, ignored\n",buf[0]); - - dp += sprintf(dp, "\n"); - teles_putstatus(sp->dlogspace); -} diff --git a/drivers/isdn/teles/tei.c b/drivers/isdn/teles/tei.c deleted file mode 100644 index 3ab9f3646..000000000 --- a/drivers/isdn/teles/tei.c +++ /dev/null @@ -1,248 +0,0 @@ -/* $Id: tei.c,v 1.1 1996/04/13 10:28:25 fritz Exp $ - * - * $Log: tei.c,v $ - * Revision 1.1 1996/04/13 10:28:25 fritz - * Initial revision - * - * - */ -#define __NO_VERSION__ -#include "teles.h" - -extern struct IsdnCard cards[]; -extern int nrcards; - -static struct PStack * -findces(struct PStack *st, int ces) -{ - struct PStack *ptr = *(st->l1.stlistp); - - while (ptr) - if (ptr->l2.ces == ces) - return (ptr); - else - ptr = ptr->next; - return (NULL); -} - -static struct PStack * -findtei(struct PStack *st, int tei) -{ - struct PStack *ptr = *(st->l1.stlistp); - - if (tei == 127) - return (NULL); - - while (ptr) - if (ptr->l2.tei == tei) - return (ptr); - else - ptr = ptr->next; - return (NULL); -} - -void -tei_handler(struct PStack *st, - byte pr, struct BufHeader *ibh) -{ - byte *bp; - unsigned int tces; - struct PStack *otsp, *ptr; - unsigned int data; - - if (st->l2.debug) - printk(KERN_DEBUG "teihandler %d\n", pr); - - switch (pr) { - case (MDL_ASSIGN): - data = (unsigned int) ibh; - BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 6); - if (!ibh) - return; - bp = DATAPTR(ibh); - bp += st->l2.uihsize; - bp[0] = 0xf; - bp[1] = data >> 8; - bp[2] = data & 0xff; - bp[3] = 0x1; - bp[4] = 0xff; - ibh->datasize = 8; - st->l3.l3l2(st, DL_UNIT_DATA, ibh); - break; - case (DL_UNIT_DATA): - bp = DATAPTR(ibh); - bp += 3; - if (bp[0] != 0xf) - break; - switch (bp[3]) { - case (2): - tces = (bp[1] << 8) | bp[2]; - BufPoolRelease(ibh); - if (st->l3.debug) - printk(KERN_DEBUG "tei identity assigned for %d=%d\n", tces, - bp[4] >> 1); - if ((otsp = findces(st, tces))) - otsp->ma.teil2(otsp, MDL_ASSIGN, - (void *)(bp[4] >> 1)); - break; - case (4): - if (st->l3.debug) - printk(KERN_DEBUG "checking identity for %d\n", bp[4] >> 1); - if (bp[4] >> 1 == 0x7f) { - BufPoolRelease(ibh); - ptr = *(st->l1.stlistp); - while (ptr) { - if ((ptr->l2.tei & 0x7f) != 0x7f) { - if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 7)) - break; - bp = DATAPTR(ibh); - bp += 3; - bp[0] = 0xf; - bp[1] = ptr->l2.ces >> 8; - bp[2] = ptr->l2.ces & 0xff; - bp[3] = 0x5; - bp[4] = (ptr->l2.tei << 1) | 1; - ibh->datasize = 8; - st->l3.l3l2(st, DL_UNIT_DATA, ibh); - } - ptr = ptr->next; - } - } else { - otsp = findtei(st, bp[4] >> 1); - BufPoolRelease(ibh); - if (!otsp) - break; - if (st->l3.debug) - printk(KERN_DEBUG "ces is %d\n", otsp->l2.ces); - if (BufPoolGet(&ibh, st->l1.smallpool, GFP_ATOMIC, (void *) st, 7)) - break; - bp = DATAPTR(ibh); - bp += 3; - bp[0] = 0xf; - bp[1] = otsp->l2.ces >> 8; - bp[2] = otsp->l2.ces & 0xff; - bp[3] = 0x5; - bp[4] = (otsp->l2.tei << 1) | 1; - ibh->datasize = 8; - st->l3.l3l2(st, DL_UNIT_DATA, ibh); - } - break; - default: - BufPoolRelease(ibh); - if (st->l3.debug) - printk(KERN_DEBUG "tei message unknown %d ai %d\n", bp[3], bp[4] >> 1); - } - break; - default: - printk(KERN_WARNING "tei handler unknown primitive %d\n", pr); - break; - } -} - -unsigned int -randomces(void) -{ - int x = jiffies & 0xffff; - - return (x); -} - -static void -tei_man(struct PStack *sp, int i, void *v) -{ - printk(KERN_DEBUG "tei_man\n"); -} - -static void -tei_l2tei(struct PStack *st, int pr, void *arg) -{ - struct IsdnCardState *sp = st->l1.hardware; - - tei_handler(sp->teistack, pr, arg); -} - -void -setstack_tei(struct PStack *st) -{ - st->l2.l2tei = tei_l2tei; -} - -static void -init_tei(struct IsdnCardState *sp, int protocol) -{ - struct PStack *st; - char tmp[128]; - -#define DIRTY_HACK_AGAINST_SIGSEGV - - st = (struct PStack *) Smalloc(sizeof(struct PStack), GFP_KERNEL, - "struct PStack"); - -#ifdef DIRTY_HACK_AGAINST_SIGSEGV - sp->teistack = st; /* struct is not initialized yet */ - sp->teistack->protocol = protocol; /* struct is not initialized yet */ -#endif /* DIRTY_HACK_AGAINST_SIGSEGV */ - - - setstack_teles(st, sp); - - st->l2.extended = !0; - st->l2.laptype = LAPD; - st->l2.window = 1; - st->l2.orig = !0; - st->protocol = protocol; - -/* - * the following is not necessary for tei mng. (broadcast only) - */ - - st->l2.t200 = 500; /* 500 milliseconds */ - st->l2.n200 = 4; /* try 4 times */ - - st->l2.sap = 63; - st->l2.tei = 127; - - sprintf(tmp, "Card %d tei ", sp->cardnr); - setstack_isdnl2(st, tmp); - st->l2.debug = 0; - st->l3.debug = 0; - - st->ma.manl2(st, MDL_NOTEIPROC, NULL); - - st->l2.l2l3 = (void *) tei_handler; - st->l1.l1man = tei_man; - st->l2.l2man = tei_man; - st->l4.l2writewakeup = NULL; - - teles_addlist(sp, st); - sp->teistack = st; -} - -static void -release_tei(struct IsdnCardState *sp) -{ - struct PStack *st = sp->teistack; - - teles_rmlist(sp, st); - Sfree((void *) st); -} - -void -TeiNew(void) -{ - int i; - - for (i = 0; i < nrcards; i++) - if (cards[i].sp) - init_tei(cards[i].sp, cards[i].protocol); -} - -void -TeiFree(void) -{ - int i; - - for (i = 0; i < nrcards; i++) - if (cards[i].sp) - release_tei(cards[i].sp); -} diff --git a/drivers/isdn/teles/teles.h b/drivers/isdn/teles/teles.h deleted file mode 100644 index 339e52d4e..000000000 --- a/drivers/isdn/teles/teles.h +++ /dev/null @@ -1,486 +0,0 @@ -/* $Id: teles.h,v 1.3 1997/02/11 01:40:36 keil Exp $ - * - * $Log: teles.h,v $ - * Revision 1.3 1997/02/11 01:40:36 keil - * New Param structure - * - * Revision 1.2 1996/04/30 21:52:04 isdn4dev - * SPV for 1TR6 - Karsten - * - * Revision 1.1 1996/04/13 10:29:00 fritz - * Initial revision - * - * - */ -#include <linux/module.h> -#include <linux/version.h> -#include <linux/errno.h> -#include <linux/fs.h> -#include <linux/major.h> -#include <asm/segment.h> -#include <asm/io.h> -#include <linux/delay.h> -#include <linux/kernel.h> -#include <linux/signal.h> -#include <linux/malloc.h> -#include <linux/mm.h> -#include <linux/mman.h> -#include <linux/ioport.h> -#include <linux/timer.h> -#include <linux/wait.h> -#include <linux/isdnif.h> -#include <linux/tty.h> - -#define PH_ACTIVATE 1 -#define PH_DATA 2 -#define PH_DEACTIVATE 3 - -#define MDL_ASSIGN 4 -#define DL_UNIT_DATA 5 -#define SC_STARTUP 6 -#define CC_ESTABLISH 7 -#define DL_ESTABLISH 8 -#define DL_DATA 9 -#define CC_S_STATUS_ENQ 10 - -#define CC_CONNECT 15 -#define CC_CONNECT_ACKNOWLEDGE 16 -#define CO_EOF 17 -#define SC_DISCONNECT 18 -#define CO_DTMF 19 -#define DL_RELEASE 20 - -#define CO_ALARM 22 -#define CC_REJECT 23 - -#define CC_SETUP_REQ 24 -#define CC_SETUP_CNF 25 -#define CC_SETUP_IND 26 -#define CC_SETUP_RSP 27 -#define CC_SETUP_COMPLETE_IND 28 - -#define CC_DISCONNECT_REQ 29 -#define CC_DISCONNECT_IND 30 - -#define CC_RELEASE_CNF 31 -#define CC_RELEASE_IND 32 -#define CC_RELEASE_REQ 33 - -#define CC_REJECT_REQ 34 - -#define CC_PROCEEDING_IND 35 - -#define CC_DLRL 36 -#define CC_DLEST 37 - -#define CC_ALERTING_REQ 38 -#define CC_ALERTING_IND 39 - -#define DL_STOP 40 -#define DL_START 41 - -#define MDL_NOTEIPROC 46 - -#define LC_ESTABLISH 47 -#define LC_RELEASE 48 - -#define PH_REQUEST_PULL 49 -#define PH_PULL_ACK 50 -#define PH_DATA_PULLED 51 -#define CC_INFO_CHARGE 52 - -/* - * Message-Types - */ - -#define MT_ALERTING 0x01 -#define MT_CALL_PROCEEDING 0x02 -#define MT_CONNECT 0x07 -#define MT_CONNECT_ACKNOWLEDGE 0x0f -#define MT_PROGRESS 0x03 -#define MT_SETUP 0x05 -#define MT_SETUP_ACKNOWLEDGE 0x0d -#define MT_RESUME 0x26 -#define MT_RESUME_ACKNOWLEDGE 0x2e -#define MT_RESUME_REJECT 0x22 -#define MT_SUSPEND 0x25 -#define MT_SUSPEND_ACKNOWLEDGE 0x2d -#define MT_SUSPEND_REJECT 0x21 -#define MT_USER_INFORMATION 0x20 -#define MT_DISCONNECT 0x45 -#define MT_RELEASE 0x4d -#define MT_RELEASE_COMPLETE 0x5a -#define MT_RESTART 0x46 -#define MT_RESTART_ACKNOWLEDGE 0x4e -#define MT_SEGMENT 0x60 -#define MT_CONGESTION_CONTROL 0x79 -#define MT_INFORMATION 0x7b -#define MT_FACILITY 0x62 -#define MT_NOTIFY 0x6e -#define MT_STATUS 0x7d -#define MT_STATUS_ENQUIRY 0x75 - -#define IE_CAUSE 0x08 - -struct HscxIoctlArg { - int channel; - int mode; - int transbufsize; -}; - -#ifdef __KERNEL__ - -#undef DEBUG_MAGIC - -#define HSCX_SBUF_ORDER 1 -#define HSCX_SBUF_BPPS 2 -#define HSCX_SBUF_MAXPAGES 3 - -#define HSCX_RBUF_ORDER 1 -#define HSCX_RBUF_BPPS 2 -#define HSCX_RBUF_MAXPAGES 3 - -#define HSCX_SMALLBUF_ORDER 0 -#define HSCX_SMALLBUF_BPPS 40 -#define HSCX_SMALLBUF_MAXPAGES 1 - -#define ISAC_SBUF_ORDER 0 -#define ISAC_SBUF_BPPS 16 -#define ISAC_SBUF_MAXPAGES 1 - -#define ISAC_RBUF_ORDER 0 -#define ISAC_RBUF_BPPS 16 -#define ISAC_RBUF_MAXPAGES 1 - -#define ISAC_SMALLBUF_ORDER 0 -#define ISAC_SMALLBUF_BPPS 40 -#define ISAC_SMALLBUF_MAXPAGES 1 - -#define byte unsigned char - -#define MAX_WINDOW 8 - -byte *Smalloc(int size, int pr, char *why); -void Sfree(byte * ptr); - -/* - * Statemachine - */ -struct Fsm { - int *jumpmatrix; - int state_count, event_count; - char **strEvent, **strState; -}; - -struct FsmInst { - struct Fsm *fsm; - int state; - int debug; - void *userdata; - int userint; - void (*printdebug) (struct FsmInst *, char *); -}; - -struct FsmNode { - int state, event; - void (*routine) (struct FsmInst *, int, void *); -}; - -struct FsmTimer { - struct FsmInst *fi; - struct timer_list tl; - int event; - void *arg; -}; - -struct BufHeader { -#ifdef DEBUG_MAGIC - int magic; -#endif - struct BufHeader *next; - struct BufPool *bp; - int datasize; - byte primitive, where; - void *heldby; -}; - -struct Pages { - struct Pages *next; -}; - -struct BufPool { -#ifdef DEBUG_MAGIC - int magic; -#endif - struct BufHeader *freelist; - struct Pages *pageslist; - int pageorder; - int pagescount; - int bpps; - int bufsize; - int maxpages; -}; - -struct BufQueue { -#ifdef DEBUG_MAGIC - int magic; -#endif - struct BufHeader *head, *tail; -}; - -struct Layer1 { - void *hardware; - int hscx; - struct BufPool *sbufpool, *rbufpool, *smallpool; - struct PStack **stlistp; - int act_state; - void (*l1l2) (struct PStack *, int, struct BufHeader *); - void (*l1man) (struct PStack *, int, void *); - int hscxmode, hscxchannel, requestpull; -}; - -struct Layer2 { - int sap, tei, ces; - int extended, laptype; - int uihsize, ihsize; - int vs, va, vr; - struct BufQueue i_queue; - int window, orig; - int rejexp; - int debug; - struct BufHeader *windowar[MAX_WINDOW]; - int sow; - struct FsmInst l2m; - void (*l2l1) (struct PStack *, int, struct BufHeader *); - void (*l2l1discardq) (struct PStack *, int, void *, int); - void (*l2man) (struct PStack *, int, void *); - void (*l2l3) (struct PStack *, int, void *); - void (*l2tei) (struct PStack *, int, void *); - struct FsmTimer t200_timer, t203_timer; - int t200, n200, t203; - int rc, t200_running; - char debug_id[32]; -}; - -struct Layer3 { - void (*l3l4) (struct PStack *, int, struct BufHeader *); - void (*l3l2) (struct PStack *, int, void *); - int state, callref; - int debug; -}; - -struct Layer4 { - void (*l4l3) (struct PStack *, int, void *); - void *userdata; - void (*l1writewakeup) (struct PStack *); - void (*l2writewakeup) (struct PStack *); -}; - -struct Management { - void (*manl1) (struct PStack *, int, void *); - void (*manl2) (struct PStack *, int, void *); - void (*teil2) (struct PStack *, int, void *); -}; - -struct Param { - int cause; - int bchannel; - int callref; /* TEI-Number */ - setup_parm setup; /* from isdnif.h numbers and Serviceindicator */ - int chargeinfo; /* Charge Info - only for 1tr6 in - * the moment - */ - int spv; /* SPV Flag */ -}; - -struct PStack { - struct PStack *next; - struct Layer1 l1; - struct Layer2 l2; - struct Layer3 l3; - struct Layer4 l4; - struct Management ma; - struct Param *pa; - int protocol; /* EDSS1 or 1TR6 */ -}; - -struct HscxState { - byte *membase; - int iobase; - int inuse, init, active; - struct BufPool sbufpool, rbufpool, smallpool; - struct IsdnCardState *sp; - int hscx, mode; - int transbufsize, receive; - struct BufHeader *rcvibh, *xmtibh; - int rcvptr, sendptr; - struct PStack *st; - struct tq_struct tqueue; - int event; - struct BufQueue rq, sq; - int releasebuf; -#ifdef DEBUG_MAGIC - int magic; /* 301270 */ -#endif -}; - -struct IsdnCardState { -#ifdef DEBUG_MAGIC - int magic; -#endif - byte *membase; - int iobase; - struct BufPool sbufpool, rbufpool, smallpool; - struct PStack *stlist; - struct BufHeader *xmtibh, *rcvibh; - int rcvptr, sendptr; - int event; - struct tq_struct tqueue; - int ph_active; - struct BufQueue rq, sq; - - int cardnr, ph_state; - struct PStack *teistack; - struct HscxState hs[2]; - - int dlogflag; - char *dlogspace; - int debug; - int releasebuf; -}; - -struct IsdnCard { - byte *membase; - int interrupt; - unsigned int iobase; - int protocol; /* EDSS1 or 1TR6 */ - struct IsdnCardState *sp; -}; - -#define DATAPTR(x) ((byte *)x+sizeof(struct BufHeader)) - -#define LAPD 0 -#define LAPB 1 - -void BufPoolInit(struct BufPool *bp, int order, int bpps, - int maxpages); -int BufPoolAdd(struct BufPool *bp, int priority); -void BufPoolFree(struct BufPool *bp); -int BufPoolGet(struct BufHeader **bh, - struct BufPool *bp, int priority, void *heldby, int where); -void BufPoolRelease(struct BufHeader *bh); -void BufQueueLink(struct BufQueue *bq, - struct BufHeader *bh); -int BufQueueUnlink(struct BufHeader **bh, struct BufQueue *bq); -void BufQueueInit(struct BufQueue *bq); -void BufQueueRelease(struct BufQueue *bq); -void BufQueueDiscard(struct BufQueue *q, int pr, void *heldby, - int releasetoo); -int BufQueueLength(struct BufQueue *bq); -void BufQueueLinkFront(struct BufQueue *bq, - struct BufHeader *bh); - -void l2down(struct PStack *st, - byte pr, struct BufHeader *ibh); -void l2up(struct PStack *st, - byte pr, struct BufHeader *ibh); -void acceptph(struct PStack *st, - struct BufHeader *ibh); -void setstack_isdnl2(struct PStack *st, char *debug_id); -int teles_inithardware(void); -void teles_closehardware(void); - -void setstack_teles(struct PStack *st, struct IsdnCardState *sp); -unsigned int randomces(void); -void setstack_isdnl3(struct PStack *st); -void teles_addlist(struct IsdnCardState *sp, - struct PStack *st); -void releasestack_isdnl2(struct PStack *st); -void teles_rmlist(struct IsdnCardState *sp, - struct PStack *st); -void newcallref(struct PStack *st); - -int ll_init(void); -void ll_stop(void), ll_unload(void); -int setstack_hscx(struct PStack *st, struct HscxState *hs); -void modehscx(struct HscxState *hs, int mode, int ichan); -byte *findie(byte * p, int size, byte ie, int wanted_set); -int getcallref(byte * p); - -void FsmNew(struct Fsm *fsm, - struct FsmNode *fnlist, int fncount); -void FsmFree(struct Fsm *fsm); -int FsmEvent(struct FsmInst *fi, - int event, void *arg); -void FsmChangeState(struct FsmInst *fi, - int newstate); -void FsmInitTimer(struct FsmInst *fi, struct FsmTimer *ft); -int FsmAddTimer(struct FsmTimer *ft, - int millisec, int event, void *arg, int where); -void FsmDelTimer(struct FsmTimer *ft, int where); -int FsmTimerRunning(struct FsmTimer *ft); -void jiftime(char *s, long mark); - -void CallcNew(void); -void CallcFree(void); -int CallcNewChan(void); -void CallcFreeChan(void); -int teles_command(isdn_ctrl * ic); -int teles_writebuf(int id, int chan, const u_char * buf, int count, int user); -void teles_putstatus(char *buf); -void teles_reportcard(int cardnr); -int ListLength(struct BufHeader *ibh); -void dlogframe(struct IsdnCardState *sp, byte * p, int size, char *comment); -void iecpy(byte * dest, byte * iestart, int ieoffset); -void setstack_transl2(struct PStack *st); -void releasestack_transl2(struct PStack *st); -void close_hscxstate(struct HscxState *); -void setstack_tei(struct PStack *st); - -struct LcFsm { - struct FsmInst lcfi; - int type; - struct Channel *ch; - void (*lccall) (struct LcFsm *, int, void *); - struct PStack *st; - int l2_establish; - int l2_start; - struct FsmTimer act_timer; - char debug_id[32]; -}; - -struct Channel { - struct PStack ds, is; - struct IsdnCardState *sp; - int hscx; - int chan; - int incoming; - struct FsmInst fi; - struct LcFsm lc_d, lc_b; - struct Param para; - int debug; -#ifdef DEBUG_MAGIC - int magic; /* 301272 */ -#endif - int l2_protocol, l2_active_protocol; - int l2_primitive, l2_headersize; - int data_open; - int outcallref; - int impair; -}; - -#define PART_SIZE(order,bpps) (( (PAGE_SIZE<<order) -\ - sizeof(void *))/bpps) -#define BUFFER_SIZE(order,bpps) (PART_SIZE(order,bpps)-\ - sizeof(struct BufHeader)) - -#endif - -void Isdnl2New(void); -void Isdnl2Free(void); -void TeiNew(void); -void TeiFree(void); - - - - |