1996-10-13 20:04:59 +00:00
|
|
|
/* $Id$
|
1997-02-09 00:29:11 +00:00
|
|
|
|
1998-11-15 23:55:28 +00:00
|
|
|
* Author Karsten Keil (keil@isdn4linux.de)
|
1996-10-13 20:04:59 +00:00
|
|
|
* based on the teles driver from Jan den Ouden
|
|
|
|
*
|
1998-11-15 23:55:28 +00:00
|
|
|
* This file is (c) under GNU PUBLIC LICENSE
|
|
|
|
* For changes and modifications please read
|
|
|
|
* ../../../Documentation/isdn/HiSax.cert
|
|
|
|
*
|
1996-10-13 20:04:59 +00:00
|
|
|
* Thanks to Jan den Ouden
|
|
|
|
* Fritz Elfert
|
|
|
|
*
|
|
|
|
* $Log$
|
1999-08-25 16:52:04 +00:00
|
|
|
* Revision 2.19 1999/08/05 20:40:26 keil
|
|
|
|
* Fix interlayer communication
|
|
|
|
*
|
1999-08-05 20:40:26 +00:00
|
|
|
* Revision 2.18 1999/07/21 14:46:16 keil
|
|
|
|
* changes from EICON certification
|
|
|
|
*
|
1999-07-21 14:46:28 +00:00
|
|
|
* Revision 2.17 1999/07/01 08:11:50 keil
|
|
|
|
* Common HiSax version for 2.0, 2.1, 2.2 and 2.3 kernel
|
|
|
|
*
|
1999-07-01 08:12:15 +00:00
|
|
|
* Revision 2.16 1998/11/15 23:55:01 keil
|
|
|
|
* changes from 2.0
|
|
|
|
*
|
1998-11-15 23:55:28 +00:00
|
|
|
* Revision 2.15 1998/08/13 23:36:42 keil
|
|
|
|
* HiSax 3.1 - don't work stable with current LinkLevel
|
|
|
|
*
|
1998-08-13 23:36:54 +00:00
|
|
|
* Revision 2.14 1998/06/19 15:19:18 keil
|
|
|
|
* fix LAPB tx_cnt for none I-frames
|
|
|
|
*
|
1998-06-19 15:19:18 +00:00
|
|
|
* Revision 2.13 1998/06/18 23:17:20 keil
|
|
|
|
* LAPB bugfix
|
|
|
|
*
|
1998-06-18 23:17:20 +00:00
|
|
|
* Revision 2.12 1998/05/25 14:10:12 keil
|
|
|
|
* HiSax 3.0
|
|
|
|
* X.75 and leased are working again.
|
|
|
|
*
|
1998-05-25 14:10:20 +00:00
|
|
|
* Revision 2.11 1998/05/25 12:58:08 keil
|
|
|
|
* HiSax golden code from certification, Don't use !!!
|
|
|
|
* No leased lines, no X75, but many changes.
|
|
|
|
*
|
1998-04-27 13:23:32 +00:00
|
|
|
* Revision 2.9 1998/04/10 10:35:30 paul
|
|
|
|
* fixed (silly?) warnings from egcs on Alpha.
|
|
|
|
*
|
1998-04-10 10:35:30 +00:00
|
|
|
* Revision 2.8 1998/03/07 22:57:04 tsbogend
|
|
|
|
* made HiSax working on Linux/Alpha
|
|
|
|
*
|
1998-03-07 22:57:08 +00:00
|
|
|
* Revision 2.7 1998/02/12 23:07:47 keil
|
|
|
|
* change for 2.1.86 (removing FREE_READ/FREE_WRITE from [dev]_kfree_skb()
|
|
|
|
*
|
1998-02-12 23:08:50 +00:00
|
|
|
* Revision 2.6 1998/02/02 13:36:15 keil
|
|
|
|
* bugfix X.75 win calculation
|
|
|
|
*
|
1998-02-02 13:36:15 +00:00
|
|
|
* Revision 2.5 1997/11/06 17:09:22 keil
|
|
|
|
* New 2.1 init code
|
|
|
|
*
|
1997-11-06 17:13:35 +00:00
|
|
|
* Revision 2.4 1997/10/29 19:02:01 keil
|
|
|
|
* new LL interface
|
|
|
|
*
|
1997-10-29 19:02:01 +00:00
|
|
|
* Revision 2.3 1997/10/01 09:21:39 fritz
|
|
|
|
* Removed old compatibility stuff for 2.0.X kernels.
|
|
|
|
* From now on, this code is for 2.1.X ONLY!
|
|
|
|
* Old stuff is still in the separate branch.
|
|
|
|
*
|
1997-10-01 09:22:21 +00:00
|
|
|
* Revision 2.2 1997/07/31 11:49:05 keil
|
1998-05-25 12:58:26 +00:00
|
|
|
* Error handling for no TEI assign
|
1997-10-01 09:22:21 +00:00
|
|
|
*
|
1997-07-31 11:49:05 +00:00
|
|
|
* Revision 2.1 1997/07/27 21:34:38 keil
|
|
|
|
* cosmetics
|
|
|
|
*
|
1997-07-27 21:34:38 +00:00
|
|
|
* Revision 2.0 1997/06/26 11:07:29 keil
|
|
|
|
* New q.921 and X.75 Layer2
|
|
|
|
*
|
1996-10-13 20:04:59 +00:00
|
|
|
*
|
1997-06-26 11:07:29 +00:00
|
|
|
* Old log removed KKe
|
1996-10-13 20:04:59 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
#define __NO_VERSION__
|
|
|
|
#include "hisax.h"
|
1996-12-08 19:51:51 +00:00
|
|
|
#include "isdnl2.h"
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-02-09 00:29:11 +00:00
|
|
|
const char *l2_revision = "$Revision$";
|
1997-01-21 22:23:42 +00:00
|
|
|
|
1998-11-15 23:55:28 +00:00
|
|
|
static void l2m_debug(struct FsmInst *fi, char *fmt, ...);
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-07-27 21:34:38 +00:00
|
|
|
static
|
1997-02-09 00:29:11 +00:00
|
|
|
struct Fsm l2fsm =
|
1997-05-06 09:38:13 +00:00
|
|
|
{NULL, 0, 0, NULL, NULL};
|
1996-10-13 20:04:59 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
ST_L2_1,
|
1997-06-26 11:07:29 +00:00
|
|
|
ST_L2_2,
|
1996-10-13 20:04:59 +00:00
|
|
|
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)
|
|
|
|
|
1997-02-09 00:29:11 +00:00
|
|
|
static char *strL2State[] =
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
|
|
|
"ST_L2_1",
|
1997-06-26 11:07:29 +00:00
|
|
|
"ST_L2_2",
|
1996-10-13 20:04:59 +00:00
|
|
|
"ST_L2_3",
|
|
|
|
"ST_L2_4",
|
|
|
|
"ST_L2_5",
|
|
|
|
"ST_L2_6",
|
|
|
|
"ST_L2_7",
|
|
|
|
"ST_L2_8",
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
EV_L2_UI,
|
1999-07-01 08:12:15 +00:00
|
|
|
EV_L2_SABME,
|
1996-10-13 20:04:59 +00:00
|
|
|
EV_L2_DISC,
|
1997-06-26 11:07:29 +00:00
|
|
|
EV_L2_DM,
|
|
|
|
EV_L2_UA,
|
1996-10-13 20:04:59 +00:00
|
|
|
EV_L2_FRMR,
|
1997-06-26 11:07:29 +00:00
|
|
|
EV_L2_SUPER,
|
|
|
|
EV_L2_I,
|
1996-10-13 20:04:59 +00:00
|
|
|
EV_L2_DL_DATA,
|
1997-06-26 11:07:29 +00:00
|
|
|
EV_L2_ACK_PULL,
|
|
|
|
EV_L2_DL_UNIT_DATA,
|
1999-07-01 08:12:15 +00:00
|
|
|
EV_L2_DL_ESTABLISH_REQ,
|
|
|
|
EV_L2_DL_RELEASE_REQ,
|
1996-10-13 20:04:59 +00:00
|
|
|
EV_L2_MDL_ASSIGN,
|
1997-01-04 13:47:06 +00:00
|
|
|
EV_L2_MDL_REMOVE,
|
1997-07-31 11:49:05 +00:00
|
|
|
EV_L2_MDL_ERROR,
|
1997-10-29 19:02:01 +00:00
|
|
|
EV_L1_DEACTIVATE,
|
1996-10-13 20:04:59 +00:00
|
|
|
EV_L2_T200,
|
|
|
|
EV_L2_T203,
|
1999-07-01 08:12:15 +00:00
|
|
|
EV_L2_SET_OWN_BUSY,
|
|
|
|
EV_L2_CLEAR_OWN_BUSY,
|
|
|
|
EV_L2_FRAME_ERROR,
|
1996-10-13 20:04:59 +00:00
|
|
|
};
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
#define L2_EVENT_COUNT (EV_L2_FRAME_ERROR+1)
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-02-09 00:29:11 +00:00
|
|
|
static char *strL2Event[] =
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
|
|
|
"EV_L2_UI",
|
1999-07-01 08:12:15 +00:00
|
|
|
"EV_L2_SABME",
|
1996-10-13 20:04:59 +00:00
|
|
|
"EV_L2_DISC",
|
1997-06-26 11:07:29 +00:00
|
|
|
"EV_L2_DM",
|
|
|
|
"EV_L2_UA",
|
1996-10-13 20:04:59 +00:00
|
|
|
"EV_L2_FRMR",
|
1997-06-26 11:07:29 +00:00
|
|
|
"EV_L2_SUPER",
|
|
|
|
"EV_L2_I",
|
1996-10-13 20:04:59 +00:00
|
|
|
"EV_L2_DL_DATA",
|
1997-06-26 11:07:29 +00:00
|
|
|
"EV_L2_ACK_PULL",
|
|
|
|
"EV_L2_DL_UNIT_DATA",
|
1999-07-01 08:12:15 +00:00
|
|
|
"EV_L2_DL_ESTABLISH_REQ",
|
|
|
|
"EV_L2_DL_RELEASE_REQ",
|
1996-10-13 20:04:59 +00:00
|
|
|
"EV_L2_MDL_ASSIGN",
|
1997-01-04 13:47:06 +00:00
|
|
|
"EV_L2_MDL_REMOVE",
|
1997-07-31 11:49:05 +00:00
|
|
|
"EV_L2_MDL_ERROR",
|
1997-10-29 19:02:01 +00:00
|
|
|
"EV_L1_DEACTIVATE",
|
1996-10-13 20:04:59 +00:00
|
|
|
"EV_L2_T200",
|
|
|
|
"EV_L2_T203",
|
1999-07-01 08:12:15 +00:00
|
|
|
"EV_L2_SET_OWN_BUSY",
|
|
|
|
"EV_L2_CLEAR_OWN_BUSY",
|
|
|
|
"EV_L2_FRAME_ERROR",
|
1996-10-13 20:04:59 +00:00
|
|
|
};
|
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
static int l2addrsize(struct Layer2 *l2);
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-21 14:46:28 +00:00
|
|
|
static void
|
|
|
|
set_peer_busy(struct Layer2 *l2) {
|
|
|
|
test_and_set_bit(FLG_PEER_BUSY, &l2->flag);
|
|
|
|
if (skb_queue_len(&l2->i_queue) || skb_queue_len(&l2->ui_queue))
|
|
|
|
test_and_set_bit(FLG_L2BLOCK, &l2->flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clear_peer_busy(struct Layer2 *l2) {
|
|
|
|
if (test_and_clear_bit(FLG_PEER_BUSY, &l2->flag))
|
|
|
|
test_and_clear_bit(FLG_L2BLOCK, &l2->flag);
|
|
|
|
}
|
|
|
|
|
1997-04-06 22:59:59 +00:00
|
|
|
static void
|
|
|
|
InitWin(struct Layer2 *l2)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_WINDOW; i++)
|
|
|
|
l2->windowar[i] = NULL;
|
|
|
|
}
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
static int
|
|
|
|
freewin1(struct Layer2 *l2)
|
1997-04-06 22:59:59 +00:00
|
|
|
{
|
|
|
|
int i, cnt = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_WINDOW; i++) {
|
|
|
|
if (l2->windowar[i]) {
|
|
|
|
cnt++;
|
1999-07-01 08:12:15 +00:00
|
|
|
idev_kfree_skb(l2->windowar[i], FREE_WRITE);
|
1997-04-06 22:59:59 +00:00
|
|
|
l2->windowar[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
1999-07-01 08:12:15 +00:00
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
freewin(struct PStack *st)
|
|
|
|
{
|
|
|
|
freewin1(&st->l2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ReleaseWin(struct Layer2 *l2)
|
|
|
|
{
|
|
|
|
int cnt;
|
|
|
|
|
|
|
|
if((cnt = freewin1(l2)))
|
1997-04-06 22:59:59 +00:00
|
|
|
printk(KERN_WARNING "isdl2 freed %d skbuffs in release\n", cnt);
|
|
|
|
}
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
inline unsigned int
|
1996-10-13 20:04:59 +00:00
|
|
|
cansend(struct PStack *st)
|
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
unsigned int p1;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
if(test_bit(FLG_MOD128, &st->l2.flag))
|
|
|
|
p1 = (st->l2.vs - st->l2.va) % 128;
|
|
|
|
else
|
|
|
|
p1 = (st->l2.vs - st->l2.va) % 8;
|
1997-10-29 19:02:01 +00:00
|
|
|
return ((p1 < st->l2.window) && !test_bit(FLG_PEER_BUSY, &st->l2.flag));
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
inline void
|
|
|
|
clear_exception(struct Layer2 *l2)
|
|
|
|
{
|
1997-10-29 19:02:01 +00:00
|
|
|
test_and_clear_bit(FLG_ACK_PEND, &l2->flag);
|
|
|
|
test_and_clear_bit(FLG_REJEXC, &l2->flag);
|
|
|
|
test_and_clear_bit(FLG_OWN_BUSY, &l2->flag);
|
1999-07-21 14:46:28 +00:00
|
|
|
clear_peer_busy(l2);
|
1997-06-26 11:07:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline int
|
|
|
|
l2headersize(struct Layer2 *l2, int ui)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-10-29 19:02:01 +00:00
|
|
|
return (((test_bit(FLG_MOD128, &l2->flag) && (!ui)) ? 2 : 1) +
|
|
|
|
(test_bit(FLG_LAPD, &l2->flag) ? 2 : 1));
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
inline int
|
|
|
|
l2addrsize(struct Layer2 *l2)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-10-29 19:02:01 +00:00
|
|
|
return (test_bit(FLG_LAPD, &l2->flag) ? 2 : 1);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-06-26 11:07:29 +00:00
|
|
|
sethdraddr(struct Layer2 *l2, u_char * header, int rsp)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-04-06 22:59:59 +00:00
|
|
|
u_char *ptr = header;
|
1997-06-26 11:07:29 +00:00
|
|
|
int crbit = rsp;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_bit(FLG_LAPD, &l2->flag)) {
|
1997-06-26 11:07:29 +00:00
|
|
|
*ptr++ = (l2->sap << 2) | (rsp ? 2 : 0);
|
|
|
|
*ptr++ = (l2->tei << 1) | 1;
|
1996-10-13 20:04:59 +00:00
|
|
|
return (2);
|
|
|
|
} else {
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_bit(FLG_ORIG, &l2->flag))
|
1996-10-13 20:04:59 +00:00
|
|
|
crbit = !crbit;
|
|
|
|
if (crbit)
|
|
|
|
*ptr++ = 1;
|
|
|
|
else
|
|
|
|
*ptr++ = 3;
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-06-19 15:19:18 +00:00
|
|
|
inline static void
|
1996-10-13 20:04:59 +00:00
|
|
|
enqueue_super(struct PStack *st,
|
1997-04-06 22:59:59 +00:00
|
|
|
struct sk_buff *skb)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1998-06-19 15:19:18 +00:00
|
|
|
if (test_bit(FLG_LAPB, &st->l2.flag))
|
|
|
|
st->l1.bcs->tx_cnt += skb->len;
|
1998-05-25 12:58:26 +00:00
|
|
|
st->l2.l2l1(st, PH_DATA | REQUEST, skb);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1998-06-19 15:19:18 +00:00
|
|
|
#define enqueue_ui(a, b) enqueue_super(a, b)
|
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
inline int
|
1999-07-01 08:12:15 +00:00
|
|
|
IsUI(u_char * data)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-06-26 11:07:29 +00:00
|
|
|
return ((data[0] & 0xef) == UI);
|
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
inline int
|
1999-07-01 08:12:15 +00:00
|
|
|
IsUA(u_char * data)
|
1997-06-26 11:07:29 +00:00
|
|
|
{
|
|
|
|
return ((data[0] & 0xef) == UA);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1997-10-29 19:02:01 +00:00
|
|
|
inline int
|
1999-07-01 08:12:15 +00:00
|
|
|
IsDM(u_char * data)
|
1997-10-29 19:02:01 +00:00
|
|
|
{
|
|
|
|
return ((data[0] & 0xef) == DM);
|
|
|
|
}
|
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
inline int
|
1999-07-01 08:12:15 +00:00
|
|
|
IsDISC(u_char * data)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-06-26 11:07:29 +00:00
|
|
|
return ((data[0] & 0xef) == DISC);
|
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
inline int
|
1999-07-01 08:12:15 +00:00
|
|
|
IsRR(u_char * data, struct PStack *st)
|
1997-06-26 11:07:29 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
if (test_bit(FLG_MOD128, &st->l2.flag))
|
1997-06-26 11:07:29 +00:00
|
|
|
return (data[0] == RR);
|
|
|
|
else
|
|
|
|
return ((data[0] & 0xf) == 1);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1998-08-13 23:36:54 +00:00
|
|
|
inline int
|
1999-07-01 08:12:15 +00:00
|
|
|
IsSFrame(u_char * data, struct PStack *st)
|
1998-08-13 23:36:54 +00:00
|
|
|
{
|
|
|
|
register u_char d = *data;
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
if (!test_bit(FLG_MOD128, &st->l2.flag))
|
1998-08-13 23:36:54 +00:00
|
|
|
d &= 0xf;
|
|
|
|
return(((d & 0xf3) == 1) && ((d & 0x0c) != 0x0c));
|
|
|
|
}
|
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
inline int
|
1999-07-01 08:12:15 +00:00
|
|
|
IsSABME(u_char * data, struct PStack *st)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-06-26 11:07:29 +00:00
|
|
|
u_char d = data[0] & ~0x10;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
return (test_bit(FLG_MOD128, &st->l2.flag) ? d == SABME : d == SABM);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
inline int
|
1999-07-01 08:12:15 +00:00
|
|
|
IsREJ(u_char * data, struct PStack *st)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
return (test_bit(FLG_MOD128, &st->l2.flag) ? data[0] == REJ : (data[0] & 0xf) == REJ);
|
1997-06-26 11:07:29 +00:00
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
inline int
|
1999-07-01 08:12:15 +00:00
|
|
|
IsFRMR(u_char * data)
|
1997-06-26 11:07:29 +00:00
|
|
|
{
|
|
|
|
return ((data[0] & 0xef) == FRMR);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int
|
1999-07-01 08:12:15 +00:00
|
|
|
IsRNR(u_char * data, struct PStack *st)
|
1997-06-26 11:07:29 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
return (test_bit(FLG_MOD128, &st->l2.flag) ? data[0] == RNR : (data[0] & 0xf) == RNR);
|
1997-06-26 11:07:29 +00:00
|
|
|
}
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
int
|
|
|
|
iframe_error(struct PStack *st, struct sk_buff *skb)
|
1997-06-26 11:07:29 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
int i = l2addrsize(&st->l2) + (test_bit(FLG_MOD128, &st->l2.flag) ? 1 : 0);
|
|
|
|
int rsp = *skb->data & 0x2;
|
1997-06-26 11:07:29 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
if (test_bit(FLG_ORIG, &st->l2.flag))
|
|
|
|
rsp = !rsp;
|
|
|
|
|
|
|
|
if (rsp)
|
|
|
|
return 'L';
|
|
|
|
|
|
|
|
|
|
|
|
if (skb->len <= i)
|
|
|
|
return 'N';
|
|
|
|
|
|
|
|
if ((skb->len - i) > st->l2.maxlen)
|
|
|
|
return 'O';
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
super_error(struct PStack *st, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
if (skb->len != l2addrsize(&st->l2) +
|
|
|
|
(test_bit(FLG_MOD128, &st->l2.flag) ? 2 : 1))
|
|
|
|
return 'N';
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
unnum_error(struct PStack *st, struct sk_buff *skb, int wantrsp)
|
|
|
|
{
|
|
|
|
int rsp = (*skb->data & 0x2) >> 1;
|
|
|
|
if (test_bit(FLG_ORIG, &st->l2.flag))
|
|
|
|
rsp = !rsp;
|
|
|
|
|
|
|
|
if (rsp != wantrsp)
|
|
|
|
return 'L';
|
|
|
|
|
|
|
|
if (skb->len != l2addrsize(&st->l2) + 1)
|
|
|
|
return 'N';
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
UI_error(struct PStack *st, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
int rsp = *skb->data & 0x2;
|
|
|
|
if (test_bit(FLG_ORIG, &st->l2.flag))
|
|
|
|
rsp = !rsp;
|
|
|
|
|
|
|
|
if (rsp)
|
|
|
|
return 'L';
|
|
|
|
|
|
|
|
if (skb->len > st->l2.maxlen + l2addrsize(&st->l2) + 1)
|
|
|
|
return 'O';
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
FRMR_error(struct PStack *st, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
int headers = l2addrsize(&st->l2) + 1;
|
|
|
|
u_char *datap = skb->data + headers;
|
|
|
|
int rsp = *skb->data & 0x2;
|
|
|
|
|
|
|
|
if (test_bit(FLG_ORIG, &st->l2.flag))
|
|
|
|
rsp = !rsp;
|
|
|
|
|
|
|
|
if (!rsp)
|
|
|
|
return 'L';
|
|
|
|
|
|
|
|
if (test_bit(FLG_MOD128, &st->l2.flag)) {
|
|
|
|
if (skb->len < headers + 5)
|
|
|
|
return 'N';
|
|
|
|
else
|
|
|
|
l2m_debug(&st->l2.l2m, "FRMR information %2x %2x %2x %2x %2x",
|
|
|
|
datap[0], datap[1], datap[2],
|
|
|
|
datap[3], datap[4]);
|
|
|
|
} else {
|
|
|
|
if (skb->len < headers + 3)
|
|
|
|
return 'N';
|
|
|
|
else
|
|
|
|
l2m_debug(&st->l2.l2m, "FRMR information %2x %2x %2x",
|
|
|
|
datap[0], datap[1], datap[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int
|
|
|
|
legalnr(struct PStack *st, unsigned int nr)
|
|
|
|
{
|
|
|
|
struct Layer2 *l2 = &st->l2;
|
|
|
|
|
|
|
|
if(test_bit(FLG_MOD128, &l2->flag))
|
|
|
|
return ((nr - l2->va) % 128) <= ((l2->vs - l2->va) % 128);
|
|
|
|
else
|
|
|
|
return ((nr - l2->va) % 8) <= ((l2->vs - l2->va) % 8);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
setva(struct PStack *st, unsigned int nr)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-06-26 11:07:29 +00:00
|
|
|
struct Layer2 *l2 = &st->l2;
|
1997-10-29 19:02:01 +00:00
|
|
|
int len;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
while (l2->va != nr) {
|
1999-07-01 08:12:15 +00:00
|
|
|
(l2->va)++;
|
|
|
|
if(test_bit(FLG_MOD128, &l2->flag))
|
|
|
|
l2->va %= 128;
|
|
|
|
else
|
|
|
|
l2->va %= 8;
|
1997-10-29 19:02:01 +00:00
|
|
|
len = l2->windowar[l2->sow]->len;
|
|
|
|
if (PACKET_NOACK == l2->windowar[l2->sow]->pkt_type)
|
|
|
|
len = -1;
|
1999-07-01 08:12:15 +00:00
|
|
|
idev_kfree_skb(l2->windowar[l2->sow], FREE_WRITE);
|
1997-06-26 11:07:29 +00:00
|
|
|
l2->windowar[l2->sow] = NULL;
|
|
|
|
l2->sow = (l2->sow + 1) % l2->window;
|
1997-10-29 19:02:01 +00:00
|
|
|
if (st->lli.l2writewakeup && (len >=0))
|
|
|
|
st->lli.l2writewakeup(st, len);
|
1997-06-26 11:07:29 +00:00
|
|
|
}
|
1997-04-06 22:59:59 +00:00
|
|
|
}
|
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
static void
|
1997-04-06 22:59:59 +00:00
|
|
|
send_uframe(struct PStack *st, u_char cmd, u_char cr)
|
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
|
|
|
u_char tmp[MAX_HEADER_LEN];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
i = sethdraddr(&st->l2, tmp, cr);
|
|
|
|
tmp[i++] = cmd;
|
|
|
|
if (!(skb = alloc_skb(i, GFP_ATOMIC))) {
|
1997-05-06 09:38:13 +00:00
|
|
|
printk(KERN_WARNING "isdl2 can't alloc sbbuff for send_uframe\n");
|
1997-04-06 22:59:59 +00:00
|
|
|
return;
|
|
|
|
}
|
1999-07-01 08:12:15 +00:00
|
|
|
SET_SKB_FREE(skb);
|
1997-04-06 22:59:59 +00:00
|
|
|
memcpy(skb_put(skb, i), tmp, i);
|
|
|
|
enqueue_super(st, skb);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
inline u_char
|
|
|
|
get_PollFlag(struct PStack * st, struct sk_buff * skb)
|
|
|
|
{
|
|
|
|
return (skb->data[l2addrsize(&(st->l2))] & 0x10);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
FreeSkb(struct sk_buff *skb)
|
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
idev_kfree_skb(skb, FREE_READ);
|
1997-06-26 11:07:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline u_char
|
|
|
|
get_PollFlagFree(struct PStack *st, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
u_char PF;
|
|
|
|
|
|
|
|
PF = get_PollFlag(st, skb);
|
|
|
|
FreeSkb(skb);
|
|
|
|
return (PF);
|
|
|
|
}
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
inline void
|
|
|
|
start_t200(struct PStack *st, int i)
|
|
|
|
{
|
|
|
|
FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, i);
|
|
|
|
test_and_set_bit(FLG_T200_RUN, &st->l2.flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
restart_t200(struct PStack *st, int i)
|
|
|
|
{
|
|
|
|
FsmRestartTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, i);
|
|
|
|
test_and_set_bit(FLG_T200_RUN, &st->l2.flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
stop_t200(struct PStack *st, int i)
|
|
|
|
{
|
|
|
|
if(test_and_clear_bit(FLG_T200_RUN, &st->l2.flag))
|
|
|
|
FsmDelTimer(&st->l2.t200, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
st5_dl_release_l2l3(struct PStack *st)
|
|
|
|
{
|
|
|
|
int pr;
|
|
|
|
|
|
|
|
if(test_and_clear_bit(FLG_PEND_REL, &st->l2.flag))
|
|
|
|
pr = DL_RELEASE | CONFIRM;
|
|
|
|
else
|
|
|
|
pr = DL_RELEASE | INDICATION;
|
|
|
|
|
|
|
|
st->l2.l2l3(st, pr, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
lapb_dl_release_l2l3(struct PStack *st, int f)
|
|
|
|
{
|
|
|
|
if (test_bit(FLG_LAPB, &st->l2.flag))
|
|
|
|
st->l2.l2l1(st, PH_DEACTIVATE | REQUEST, NULL);
|
|
|
|
st->l2.l2l3(st, DL_RELEASE | f, NULL);
|
|
|
|
}
|
|
|
|
|
1996-10-13 20:04:59 +00:00
|
|
|
static void
|
|
|
|
establishlink(struct FsmInst *fi)
|
|
|
|
{
|
1997-02-09 00:29:11 +00:00
|
|
|
struct PStack *st = fi->userdata;
|
1997-04-06 22:59:59 +00:00
|
|
|
u_char cmd;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
clear_exception(&st->l2);
|
1996-10-13 20:04:59 +00:00
|
|
|
st->l2.rc = 0;
|
1997-10-29 19:02:01 +00:00
|
|
|
cmd = (test_bit(FLG_MOD128, &st->l2.flag) ? SABME : SABM) | 0x10;
|
1997-06-26 11:07:29 +00:00
|
|
|
send_uframe(st, cmd, CMD);
|
1997-07-27 21:34:38 +00:00
|
|
|
FsmDelTimer(&st->l2.t203, 1);
|
1999-07-01 08:12:15 +00:00
|
|
|
restart_t200(st, 1);
|
|
|
|
test_and_clear_bit(FLG_PEND_REL, &st->l2.flag);
|
|
|
|
freewin(st);
|
1997-06-26 11:07:29 +00:00
|
|
|
FsmChangeState(fi, ST_L2_5);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
l2_mdl_error_ua(struct FsmInst *fi, int event, void *arg)
|
1997-06-26 11:07:29 +00:00
|
|
|
{
|
|
|
|
struct sk_buff *skb = arg;
|
|
|
|
struct PStack *st = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
if (get_PollFlagFree(st, skb))
|
|
|
|
st->ma.layer(st, MDL_ERROR | INDICATION, (void *) 'C');
|
|
|
|
else
|
|
|
|
st->ma.layer(st, MDL_ERROR | INDICATION, (void *) 'D');
|
1997-06-26 11:07:29 +00:00
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
l2_mdl_error_dm(struct FsmInst *fi, int event, void *arg)
|
1997-06-26 11:07:29 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
struct sk_buff *skb = arg;
|
1997-06-26 11:07:29 +00:00
|
|
|
struct PStack *st = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
if (get_PollFlagFree(st, skb))
|
|
|
|
st->ma.layer(st, MDL_ERROR | INDICATION, (void *) 'B');
|
|
|
|
else {
|
|
|
|
st->ma.layer(st, MDL_ERROR | INDICATION, (void *) 'E');
|
1998-08-13 23:36:54 +00:00
|
|
|
establishlink(fi);
|
1999-07-01 08:12:15 +00:00
|
|
|
test_and_clear_bit(FLG_L3_INIT, &st->l2.flag);
|
1998-08-13 23:36:54 +00:00
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
l2_st8_mdl_error_dm(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct sk_buff *skb = arg;
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
|
|
|
if (get_PollFlagFree(st, skb))
|
|
|
|
st->ma.layer(st, MDL_ERROR | INDICATION, (void *) 'B');
|
|
|
|
else {
|
|
|
|
st->ma.layer(st, MDL_ERROR | INDICATION, (void *) 'E');
|
|
|
|
}
|
|
|
|
establishlink(fi);
|
|
|
|
test_and_clear_bit(FLG_L3_INIT, &st->l2.flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_go_st3(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
FsmChangeState(fi, ST_L2_3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_mdl_assign(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
|
|
|
FsmChangeState(fi, ST_L2_3);
|
|
|
|
st->l2.l2tei(st, MDL_ASSIGN | INDICATION, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_queue_ui_assign(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
struct sk_buff *skb = arg;
|
|
|
|
|
|
|
|
skb_queue_tail(&st->l2.ui_queue, skb);
|
|
|
|
FsmChangeState(fi, ST_L2_2);
|
|
|
|
st->l2.l2tei(st, MDL_ASSIGN | INDICATION, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_queue_ui(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
struct sk_buff *skb = arg;
|
|
|
|
|
|
|
|
skb_queue_tail(&st->l2.ui_queue, skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tx_ui(struct PStack *st)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-06-26 11:07:29 +00:00
|
|
|
struct sk_buff *skb;
|
|
|
|
u_char header[MAX_HEADER_LEN];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
i = sethdraddr(&(st->l2), header, CMD);
|
|
|
|
header[i++] = UI;
|
|
|
|
while ((skb = skb_dequeue(&st->l2.ui_queue))) {
|
|
|
|
memcpy(skb_push(skb, i), header, i);
|
|
|
|
enqueue_ui(st, skb);
|
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
l2_send_ui(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-02-09 00:29:11 +00:00
|
|
|
struct PStack *st = fi->userdata;
|
1997-06-26 11:07:29 +00:00
|
|
|
struct sk_buff *skb = arg;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
skb_queue_tail(&st->l2.ui_queue, skb);
|
1999-07-01 08:12:15 +00:00
|
|
|
tx_ui(st);
|
1997-06-26 11:07:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_got_ui(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
struct sk_buff *skb = arg;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
skb_pull(skb, l2headersize(&st->l2, 1));
|
1999-07-01 08:12:15 +00:00
|
|
|
st->l2.l2l3(st, DL_UNIT_DATA | INDICATION, skb);
|
|
|
|
/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
* in states 1-3 for broadcast
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
static void
|
|
|
|
l2_establish(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
establishlink(fi);
|
1997-10-29 19:02:01 +00:00
|
|
|
test_and_set_bit(FLG_L3_INIT, &st->l2.flag);
|
1997-06-26 11:07:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
l2_discard_i_setl3(struct FsmInst *fi, int event, void *arg)
|
1997-06-26 11:07:29 +00:00
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1998-05-25 12:58:26 +00:00
|
|
|
discard_queue(&st->l2.i_queue);
|
1999-07-01 08:12:15 +00:00
|
|
|
test_and_set_bit(FLG_L3_INIT, &st->l2.flag);
|
|
|
|
test_and_clear_bit(FLG_PEND_REL, &st->l2.flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_l3_reestablish(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
|
|
|
discard_queue(&st->l2.i_queue);
|
|
|
|
establishlink(fi);
|
|
|
|
test_and_set_bit(FLG_L3_INIT, &st->l2.flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_release(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
|
|
|
st->l2.l2l3(st, DL_RELEASE | CONFIRM, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_pend_rel(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
|
|
|
test_and_set_bit(FLG_PEND_REL, &st->l2.flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_disconnect(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
|
|
|
discard_queue(&st->l2.i_queue);
|
|
|
|
freewin(st);
|
1997-06-26 11:07:29 +00:00
|
|
|
FsmChangeState(fi, ST_L2_6);
|
|
|
|
st->l2.rc = 0;
|
|
|
|
send_uframe(st, DISC | 0x10, CMD);
|
1997-07-27 21:34:38 +00:00
|
|
|
FsmDelTimer(&st->l2.t203, 1);
|
1999-07-01 08:12:15 +00:00
|
|
|
restart_t200(st, 2);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
l2_start_multi(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-02-09 00:29:11 +00:00
|
|
|
struct PStack *st = fi->userdata;
|
1997-04-06 22:59:59 +00:00
|
|
|
struct sk_buff *skb = arg;
|
1999-07-01 08:12:15 +00:00
|
|
|
|
|
|
|
send_uframe(st, UA | get_PollFlagFree(st, skb), RSP);
|
|
|
|
|
|
|
|
clear_exception(&st->l2);
|
|
|
|
st->l2.vs = 0;
|
|
|
|
st->l2.va = 0;
|
|
|
|
st->l2.vr = 0;
|
|
|
|
st->l2.sow = 0;
|
|
|
|
FsmChangeState(fi, ST_L2_7);
|
|
|
|
FsmAddTimer(&st->l2.t203, st->l2.T203, EV_L2_T203, NULL, 3);
|
|
|
|
|
|
|
|
st->l2.l2l3(st, DL_ESTABLISH | INDICATION, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_send_UA(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
struct sk_buff *skb = arg;
|
|
|
|
|
|
|
|
send_uframe(st, UA | get_PollFlagFree(st, skb), RSP);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_send_DM(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
struct sk_buff *skb = arg;
|
|
|
|
|
|
|
|
send_uframe(st, DM | get_PollFlagFree(st, skb), RSP);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_restart_multi(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
struct sk_buff *skb = arg;
|
|
|
|
int est = 0, state;
|
1997-04-06 22:59:59 +00:00
|
|
|
|
|
|
|
state = fi->state;
|
1999-07-01 08:12:15 +00:00
|
|
|
|
|
|
|
send_uframe(st, UA | get_PollFlagFree(st, skb), RSP);
|
|
|
|
|
|
|
|
st->ma.layer(st, MDL_ERROR | INDICATION, (void *) 'F');
|
|
|
|
|
|
|
|
if (st->l2.vs != st->l2.va) {
|
|
|
|
discard_queue(&st->l2.i_queue);
|
|
|
|
est = 1;
|
1997-06-26 11:07:29 +00:00
|
|
|
}
|
1999-07-01 08:12:15 +00:00
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
clear_exception(&st->l2);
|
1996-10-13 20:04:59 +00:00
|
|
|
st->l2.vs = 0;
|
|
|
|
st->l2.va = 0;
|
|
|
|
st->l2.vr = 0;
|
|
|
|
st->l2.sow = 0;
|
1997-06-26 11:07:29 +00:00
|
|
|
FsmChangeState(fi, ST_L2_7);
|
1999-07-01 08:12:15 +00:00
|
|
|
stop_t200(st, 3);
|
1998-05-25 14:10:20 +00:00
|
|
|
FsmRestartTimer(&st->l2.t203, st->l2.T203, EV_L2_T203, NULL, 3);
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
if (est)
|
|
|
|
st->l2.l2l3(st, DL_ESTABLISH | INDICATION, NULL);
|
|
|
|
|
|
|
|
if ((ST_L2_7==state) || (ST_L2_8 == state))
|
|
|
|
if (skb_queue_len(&st->l2.i_queue) && cansend(st))
|
|
|
|
st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_stop_multi(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
struct sk_buff *skb = arg;
|
|
|
|
|
|
|
|
FsmChangeState(fi, ST_L2_4);
|
|
|
|
FsmDelTimer(&st->l2.t203, 3);
|
|
|
|
stop_t200(st, 4);
|
|
|
|
|
|
|
|
send_uframe(st, UA | get_PollFlagFree(st, skb), RSP);
|
|
|
|
|
|
|
|
discard_queue(&st->l2.i_queue);
|
|
|
|
freewin(st);
|
|
|
|
lapb_dl_release_l2l3(st, INDICATION);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_connected(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
struct sk_buff *skb = arg;
|
|
|
|
int pr=-1;
|
|
|
|
|
|
|
|
if (!get_PollFlag(st, skb)) {
|
|
|
|
l2_mdl_error_ua(fi, event, arg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
FreeSkb(skb);
|
|
|
|
|
|
|
|
if (test_and_clear_bit(FLG_PEND_REL, &st->l2.flag))
|
|
|
|
l2_disconnect(fi, event, arg);
|
|
|
|
|
|
|
|
if (test_and_clear_bit(FLG_L3_INIT, &st->l2.flag)) {
|
|
|
|
pr = DL_ESTABLISH | CONFIRM;
|
|
|
|
} else if (st->l2.vs != st->l2.va) {
|
|
|
|
discard_queue(&st->l2.i_queue);
|
|
|
|
pr = DL_ESTABLISH | INDICATION;
|
|
|
|
}
|
|
|
|
|
|
|
|
stop_t200(st, 5);
|
|
|
|
|
|
|
|
st->l2.vr = 0;
|
|
|
|
st->l2.vs = 0;
|
|
|
|
st->l2.va = 0;
|
|
|
|
st->l2.sow = 0;
|
|
|
|
FsmChangeState(fi, ST_L2_7);
|
|
|
|
FsmAddTimer(&st->l2.t203, st->l2.T203, EV_L2_T203, NULL, 4);
|
|
|
|
|
|
|
|
if (pr != -1)
|
|
|
|
st->l2.l2l3(st, pr, NULL);
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
if (skb_queue_len(&st->l2.i_queue) && cansend(st))
|
|
|
|
st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
l2_released(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-02-09 00:29:11 +00:00
|
|
|
struct PStack *st = fi->userdata;
|
1997-04-06 22:59:59 +00:00
|
|
|
struct sk_buff *skb = arg;
|
1997-10-29 19:02:01 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
if (!get_PollFlag(st, skb)) {
|
|
|
|
l2_mdl_error_ua(fi, event, arg);
|
1997-06-26 11:07:29 +00:00
|
|
|
return;
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
1999-07-01 08:12:15 +00:00
|
|
|
FreeSkb(skb);
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
stop_t200(st, 6);
|
|
|
|
lapb_dl_release_l2l3(st, CONFIRM);
|
|
|
|
FsmChangeState(fi, ST_L2_4);
|
|
|
|
}
|
1997-06-26 11:07:29 +00:00
|
|
|
|
1996-12-08 19:51:51 +00:00
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
l2_reestablish(struct FsmInst *fi, int event, void *arg)
|
1996-12-08 19:51:51 +00:00
|
|
|
{
|
1997-02-09 00:29:11 +00:00
|
|
|
struct PStack *st = fi->userdata;
|
1997-04-06 22:59:59 +00:00
|
|
|
struct sk_buff *skb = arg;
|
1997-10-29 19:02:01 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
if (!get_PollFlagFree(st, skb)) {
|
|
|
|
establishlink(fi);
|
|
|
|
test_and_set_bit(FLG_L3_INIT, &st->l2.flag);
|
1997-06-26 11:07:29 +00:00
|
|
|
}
|
1999-07-01 08:12:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_st5_dm_release(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
struct sk_buff *skb = arg;
|
1996-12-08 19:51:51 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
if (get_PollFlagFree(st, skb)) {
|
|
|
|
stop_t200(st, 7);
|
|
|
|
if (!test_bit(FLG_L3_INIT, &st->l2.flag))
|
1998-05-25 12:58:26 +00:00
|
|
|
discard_queue(&st->l2.i_queue);
|
1998-06-18 23:17:20 +00:00
|
|
|
if (test_bit(FLG_LAPB, &st->l2.flag))
|
1998-05-25 14:10:20 +00:00
|
|
|
st->l2.l2l1(st, PH_DEACTIVATE | REQUEST, NULL);
|
1999-07-01 08:12:15 +00:00
|
|
|
st5_dl_release_l2l3(st);
|
1997-06-26 11:07:29 +00:00
|
|
|
FsmChangeState(fi, ST_L2_4);
|
|
|
|
}
|
1996-12-08 19:51:51 +00:00
|
|
|
}
|
|
|
|
|
1996-10-13 20:04:59 +00:00
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
l2_st6_dm_release(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-02-09 00:29:11 +00:00
|
|
|
struct PStack *st = fi->userdata;
|
1997-04-06 22:59:59 +00:00
|
|
|
struct sk_buff *skb = arg;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
if (get_PollFlagFree(st, skb)) {
|
|
|
|
stop_t200(st, 8);
|
|
|
|
lapb_dl_release_l2l3(st, CONFIRM);
|
|
|
|
FsmChangeState(fi, ST_L2_4);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-04-06 22:59:59 +00:00
|
|
|
inline void
|
1997-05-06 09:38:13 +00:00
|
|
|
enquiry_cr(struct PStack *st, u_char typ, u_char cr, u_char pf)
|
1996-12-08 19:51:51 +00:00
|
|
|
{
|
1997-04-06 22:59:59 +00:00
|
|
|
struct sk_buff *skb;
|
1997-02-09 00:29:11 +00:00
|
|
|
struct Layer2 *l2;
|
1997-04-06 22:59:59 +00:00
|
|
|
u_char tmp[MAX_HEADER_LEN];
|
|
|
|
int i;
|
1996-12-08 19:51:51 +00:00
|
|
|
|
|
|
|
l2 = &st->l2;
|
1997-04-06 22:59:59 +00:00
|
|
|
i = sethdraddr(l2, tmp, cr);
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_bit(FLG_MOD128, &l2->flag)) {
|
1997-04-06 22:59:59 +00:00
|
|
|
tmp[i++] = typ;
|
1997-05-06 09:38:13 +00:00
|
|
|
tmp[i++] = (l2->vr << 1) | (pf ? 1 : 0);
|
1997-04-06 22:59:59 +00:00
|
|
|
} else
|
1997-05-06 09:38:13 +00:00
|
|
|
tmp[i++] = (l2->vr << 5) | typ | (pf ? 0x10 : 0);
|
1997-04-06 22:59:59 +00:00
|
|
|
if (!(skb = alloc_skb(i, GFP_ATOMIC))) {
|
|
|
|
printk(KERN_WARNING "isdl2 can't alloc sbbuff for enquiry_cr\n");
|
|
|
|
return;
|
1996-12-08 19:51:51 +00:00
|
|
|
}
|
1999-07-01 08:12:15 +00:00
|
|
|
SET_SKB_FREE(skb);
|
1997-04-06 22:59:59 +00:00
|
|
|
memcpy(skb_put(skb, i), tmp, i);
|
|
|
|
enqueue_super(st, skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
1997-06-26 11:07:29 +00:00
|
|
|
enquiry_response(struct PStack *st)
|
1997-04-06 22:59:59 +00:00
|
|
|
{
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_bit(FLG_OWN_BUSY, &st->l2.flag))
|
1997-06-26 11:07:29 +00:00
|
|
|
enquiry_cr(st, RNR, RSP, 1);
|
|
|
|
else
|
|
|
|
enquiry_cr(st, RR, RSP, 1);
|
1997-10-29 19:02:01 +00:00
|
|
|
test_and_clear_bit(FLG_ACK_PEND, &st->l2.flag);
|
1997-04-06 22:59:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
1997-06-26 11:07:29 +00:00
|
|
|
transmit_enquiry(struct PStack *st)
|
1997-04-06 22:59:59 +00:00
|
|
|
{
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_bit(FLG_OWN_BUSY, &st->l2.flag))
|
1997-06-26 11:07:29 +00:00
|
|
|
enquiry_cr(st, RNR, CMD, 1);
|
|
|
|
else
|
|
|
|
enquiry_cr(st, RR, CMD, 1);
|
1997-10-29 19:02:01 +00:00
|
|
|
test_and_clear_bit(FLG_ACK_PEND, &st->l2.flag);
|
1999-07-01 08:12:15 +00:00
|
|
|
start_t200(st, 9);
|
1996-12-08 19:51:51 +00:00
|
|
|
}
|
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
|
1996-12-08 19:51:51 +00:00
|
|
|
static void
|
|
|
|
nrerrorrecovery(struct FsmInst *fi)
|
|
|
|
{
|
1997-06-26 11:07:29 +00:00
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
1998-05-25 12:58:26 +00:00
|
|
|
st->ma.layer(st, MDL_ERROR | INDICATION, (void *) 'J');
|
1997-02-09 00:29:11 +00:00
|
|
|
establishlink(fi);
|
1999-07-01 08:12:15 +00:00
|
|
|
test_and_clear_bit(FLG_L3_INIT, &st->l2.flag);
|
1996-12-08 19:51:51 +00:00
|
|
|
}
|
|
|
|
|
1996-10-13 20:04:59 +00:00
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
invoke_retransmission(struct PStack *st, unsigned int nr)
|
1997-06-26 11:07:29 +00:00
|
|
|
{
|
|
|
|
struct Layer2 *l2 = &st->l2;
|
1999-07-01 08:12:15 +00:00
|
|
|
unsigned int p1;
|
1997-06-26 11:07:29 +00:00
|
|
|
|
|
|
|
if (l2->vs != nr) {
|
|
|
|
while (l2->vs != nr) {
|
1999-07-01 08:12:15 +00:00
|
|
|
(l2->vs)--;
|
|
|
|
if(test_bit(FLG_MOD128, &l2->flag)) {
|
|
|
|
l2->vs %= 128;
|
|
|
|
p1 = (l2->vs - l2->va) % 128;
|
|
|
|
} else {
|
|
|
|
l2->vs %= 8;
|
|
|
|
p1 = (l2->vs - l2->va) % 8;
|
|
|
|
}
|
1997-06-26 11:07:29 +00:00
|
|
|
p1 = (p1 + l2->sow) % l2->window;
|
1998-06-19 15:19:18 +00:00
|
|
|
if (test_bit(FLG_LAPB, &l2->flag))
|
|
|
|
st->l1.bcs->tx_cnt += l2->windowar[p1]->len + l2headersize(l2, 0);
|
1997-06-26 11:07:29 +00:00
|
|
|
skb_queue_head(&l2->i_queue, l2->windowar[p1]);
|
|
|
|
l2->windowar[p1] = NULL;
|
|
|
|
}
|
1998-05-25 12:58:26 +00:00
|
|
|
st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
|
1997-06-26 11:07:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
l2_st7_got_super(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-02-09 00:29:11 +00:00
|
|
|
struct PStack *st = fi->userdata;
|
1997-04-06 22:59:59 +00:00
|
|
|
struct sk_buff *skb = arg;
|
1999-07-01 08:12:15 +00:00
|
|
|
int PollFlag, rsp, typ = RR;
|
|
|
|
unsigned int nr;
|
1997-06-26 11:07:29 +00:00
|
|
|
struct Layer2 *l2 = &st->l2;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
rsp = *skb->data & 0x2;
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_bit(FLG_ORIG, &l2->flag))
|
1997-04-06 22:59:59 +00:00
|
|
|
rsp = !rsp;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-04-06 22:59:59 +00:00
|
|
|
skb_pull(skb, l2addrsize(l2));
|
1999-07-01 08:12:15 +00:00
|
|
|
if (IsRNR(skb->data, st)) {
|
1999-07-21 14:46:28 +00:00
|
|
|
set_peer_busy(l2);
|
1997-06-26 11:07:29 +00:00
|
|
|
typ = RNR;
|
|
|
|
} else
|
1999-07-21 14:46:28 +00:00
|
|
|
clear_peer_busy(l2);
|
1999-07-01 08:12:15 +00:00
|
|
|
if (IsREJ(skb->data, st))
|
1997-06-26 11:07:29 +00:00
|
|
|
typ = REJ;
|
1999-07-01 08:12:15 +00:00
|
|
|
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_bit(FLG_MOD128, &l2->flag)) {
|
1999-07-01 08:12:15 +00:00
|
|
|
PollFlag = (skb->data[1] & 0x1) == 0x1;
|
|
|
|
nr = skb->data[1] >> 1;
|
1996-10-13 20:04:59 +00:00
|
|
|
} else {
|
1999-07-01 08:12:15 +00:00
|
|
|
PollFlag = (skb->data[0] & 0x10);
|
|
|
|
nr = (skb->data[0] >> 5) & 0x7;
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
1997-06-26 11:07:29 +00:00
|
|
|
FreeSkb(skb);
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
if (PollFlag) {
|
|
|
|
if (rsp)
|
|
|
|
st->ma.layer(st, MDL_ERROR | INDICATION, (void *) 'A');
|
|
|
|
else
|
|
|
|
enquiry_response(st);
|
|
|
|
}
|
1997-06-26 11:07:29 +00:00
|
|
|
if (legalnr(st, nr)) {
|
|
|
|
if (typ == REJ) {
|
|
|
|
setva(st, nr);
|
|
|
|
invoke_retransmission(st, nr);
|
1999-07-01 08:12:15 +00:00
|
|
|
stop_t200(st, 10);
|
1997-07-27 21:34:38 +00:00
|
|
|
if (FsmAddTimer(&st->l2.t203, st->l2.T203,
|
1997-06-26 11:07:29 +00:00
|
|
|
EV_L2_T203, NULL, 6))
|
|
|
|
l2m_debug(&st->l2.l2m, "Restart T203 ST7 REJ");
|
|
|
|
} else if ((nr == l2->vs) && (typ == RR)) {
|
|
|
|
setva(st, nr);
|
1999-07-01 08:12:15 +00:00
|
|
|
stop_t200(st, 11);
|
1997-07-27 21:34:38 +00:00
|
|
|
FsmRestartTimer(&st->l2.t203, st->l2.T203,
|
1997-06-26 11:07:29 +00:00
|
|
|
EV_L2_T203, NULL, 7);
|
|
|
|
} else if ((l2->va != nr) || (typ == RNR)) {
|
|
|
|
setva(st, nr);
|
1999-07-01 08:12:15 +00:00
|
|
|
if(typ != RR) FsmDelTimer(&st->l2.t203, 9);
|
|
|
|
restart_t200(st, 12);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
1997-06-26 11:07:29 +00:00
|
|
|
if (skb_queue_len(&st->l2.i_queue) && (typ == RR))
|
1998-05-25 12:58:26 +00:00
|
|
|
st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
|
1997-02-09 00:29:11 +00:00
|
|
|
} else
|
|
|
|
nrerrorrecovery(fi);
|
1999-07-01 08:12:15 +00:00
|
|
|
}
|
1996-12-08 19:51:51 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
static void
|
|
|
|
l2_feed_i_if_reest(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
struct sk_buff *skb = arg;
|
|
|
|
|
|
|
|
if (test_bit(FLG_LAPB, &st->l2.flag))
|
|
|
|
st->l1.bcs->tx_cnt += skb->len + l2headersize(&st->l2, 0);
|
|
|
|
if (!test_bit(FLG_L3_INIT, &st->l2.flag))
|
|
|
|
skb_queue_tail(&st->l2.i_queue, skb);
|
|
|
|
else
|
|
|
|
FreeSkb(skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_feed_i_pull(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
struct sk_buff *skb = arg;
|
|
|
|
|
|
|
|
if (test_bit(FLG_LAPB, &st->l2.flag))
|
|
|
|
st->l1.bcs->tx_cnt += skb->len + l2headersize(&st->l2, 0);
|
|
|
|
skb_queue_tail(&st->l2.i_queue, skb);
|
|
|
|
st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-04-06 22:59:59 +00:00
|
|
|
l2_feed_iqueue(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-02-09 00:29:11 +00:00
|
|
|
struct PStack *st = fi->userdata;
|
1997-04-06 22:59:59 +00:00
|
|
|
struct sk_buff *skb = arg;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_bit(FLG_LAPB, &st->l2.flag))
|
1997-07-27 21:34:38 +00:00
|
|
|
st->l1.bcs->tx_cnt += skb->len + l2headersize(&st->l2, 0);
|
1999-07-01 08:12:15 +00:00
|
|
|
skb_queue_tail(&st->l2.i_queue, skb);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
static void
|
|
|
|
l2_got_iframe(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-02-09 00:29:11 +00:00
|
|
|
struct PStack *st = fi->userdata;
|
1997-04-06 22:59:59 +00:00
|
|
|
struct sk_buff *skb = arg;
|
1997-02-09 00:29:11 +00:00
|
|
|
struct Layer2 *l2 = &(st->l2);
|
1999-07-01 08:12:15 +00:00
|
|
|
int PollFlag, ns, i;
|
|
|
|
unsigned int nr;
|
1997-10-29 19:02:01 +00:00
|
|
|
|
1997-04-06 22:59:59 +00:00
|
|
|
i = l2addrsize(l2);
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_bit(FLG_MOD128, &l2->flag)) {
|
|
|
|
PollFlag = ((skb->data[i + 1] & 0x1) == 0x1);
|
1997-06-26 11:07:29 +00:00
|
|
|
ns = skb->data[i] >> 1;
|
|
|
|
nr = (skb->data[i + 1] >> 1) & 0x7f;
|
1996-10-13 20:04:59 +00:00
|
|
|
} else {
|
1997-06-26 11:07:29 +00:00
|
|
|
PollFlag = (skb->data[i] & 0x10);
|
|
|
|
ns = (skb->data[i] >> 1) & 0x7;
|
|
|
|
nr = (skb->data[i] >> 5) & 0x7;
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_bit(FLG_OWN_BUSY, &l2->flag)) {
|
1997-06-26 11:07:29 +00:00
|
|
|
FreeSkb(skb);
|
1999-07-01 08:12:15 +00:00
|
|
|
if(PollFlag) enquiry_response(st);
|
1997-06-26 11:07:29 +00:00
|
|
|
} else if (l2->vr == ns) {
|
1999-07-01 08:12:15 +00:00
|
|
|
(l2->vr)++;
|
|
|
|
if(test_bit(FLG_MOD128, &l2->flag))
|
|
|
|
l2->vr %= 128;
|
|
|
|
else
|
|
|
|
l2->vr %= 8;
|
1997-10-29 19:02:01 +00:00
|
|
|
test_and_clear_bit(FLG_REJEXC, &l2->flag);
|
1999-07-01 08:12:15 +00:00
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
if (PollFlag)
|
|
|
|
enquiry_response(st);
|
|
|
|
else
|
1997-10-29 19:02:01 +00:00
|
|
|
test_and_set_bit(FLG_ACK_PEND, &l2->flag);
|
1997-04-06 22:59:59 +00:00
|
|
|
skb_pull(skb, l2headersize(l2, 0));
|
1998-05-25 12:58:26 +00:00
|
|
|
st->l2.l2l3(st, DL_DATA | INDICATION, skb);
|
1996-10-13 20:04:59 +00:00
|
|
|
} else {
|
1997-02-09 00:29:11 +00:00
|
|
|
/* n(s)!=v(r) */
|
1997-06-26 11:07:29 +00:00
|
|
|
FreeSkb(skb);
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_and_set_bit(FLG_REJEXC, &l2->flag)) {
|
1997-06-26 11:07:29 +00:00
|
|
|
if (PollFlag)
|
|
|
|
enquiry_response(st);
|
1997-10-29 19:02:01 +00:00
|
|
|
} else {
|
|
|
|
enquiry_cr(st, REJ, RSP, PollFlag);
|
|
|
|
test_and_clear_bit(FLG_ACK_PEND, &l2->flag);
|
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
1996-12-08 19:51:51 +00:00
|
|
|
|
|
|
|
if (legalnr(st, nr)) {
|
1997-10-29 19:02:01 +00:00
|
|
|
if (!test_bit(FLG_PEER_BUSY, &st->l2.flag) && (fi->state == ST_L2_7)) {
|
1997-06-26 11:07:29 +00:00
|
|
|
if (nr == st->l2.vs) {
|
1999-07-01 08:12:15 +00:00
|
|
|
stop_t200(st, 13);
|
1997-07-27 21:34:38 +00:00
|
|
|
FsmRestartTimer(&st->l2.t203, st->l2.T203,
|
1997-06-26 11:07:29 +00:00
|
|
|
EV_L2_T203, NULL, 7);
|
1999-07-01 08:12:15 +00:00
|
|
|
} else if (nr != st->l2.va)
|
|
|
|
restart_t200(st, 14);
|
1997-06-26 11:07:29 +00:00
|
|
|
}
|
1999-07-01 08:12:15 +00:00
|
|
|
setva(st, nr);
|
1997-06-26 11:07:29 +00:00
|
|
|
} else {
|
1997-02-09 00:29:11 +00:00
|
|
|
nrerrorrecovery(fi);
|
1997-06-26 11:07:29 +00:00
|
|
|
return;
|
|
|
|
}
|
1997-01-04 13:47:06 +00:00
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
if (skb_queue_len(&st->l2.i_queue) && (fi->state == ST_L2_7))
|
1998-05-25 12:58:26 +00:00
|
|
|
st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_and_clear_bit(FLG_ACK_PEND, &st->l2.flag))
|
1997-06-26 11:07:29 +00:00
|
|
|
enquiry_cr(st, RR, RSP, 0);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-06-26 11:07:29 +00:00
|
|
|
l2_got_tei(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-02-09 00:29:11 +00:00
|
|
|
struct PStack *st = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1998-03-07 22:57:08 +00:00
|
|
|
st->l2.tei = (long) arg;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
if (fi->state == ST_L2_3) {
|
|
|
|
establishlink(fi);
|
1997-10-29 19:02:01 +00:00
|
|
|
test_and_set_bit(FLG_L3_INIT, &st->l2.flag);
|
1997-06-26 11:07:29 +00:00
|
|
|
} else
|
|
|
|
FsmChangeState(fi, ST_L2_4);
|
|
|
|
if (skb_queue_len(&st->l2.ui_queue))
|
1999-07-01 08:12:15 +00:00
|
|
|
tx_ui(st);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-04-06 22:59:59 +00:00
|
|
|
l2_st5_tout_200(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-02-09 00:29:11 +00:00
|
|
|
struct PStack *st = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_bit(FLG_LAPD, &st->l2.flag) &&
|
|
|
|
test_bit(FLG_DCHAN_BUSY, &st->l2.flag)) {
|
|
|
|
FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 9);
|
|
|
|
} else if (st->l2.rc == st->l2.N200) {
|
1996-10-13 20:04:59 +00:00
|
|
|
FsmChangeState(fi, ST_L2_4);
|
1997-10-29 19:02:01 +00:00
|
|
|
test_and_clear_bit(FLG_T200_RUN, &st->l2.flag);
|
1998-05-25 12:58:26 +00:00
|
|
|
discard_queue(&st->l2.i_queue);
|
|
|
|
st->ma.layer(st, MDL_ERROR | INDICATION, (void *) 'G');
|
1998-06-18 23:17:20 +00:00
|
|
|
if (test_bit(FLG_LAPB, &st->l2.flag))
|
1998-05-25 14:10:20 +00:00
|
|
|
st->l2.l2l1(st, PH_DEACTIVATE | REQUEST, NULL);
|
1999-07-01 08:12:15 +00:00
|
|
|
st5_dl_release_l2l3(st);
|
1996-10-13 20:04:59 +00:00
|
|
|
} else {
|
|
|
|
st->l2.rc++;
|
1997-10-29 19:02:01 +00:00
|
|
|
FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 9);
|
|
|
|
send_uframe(st, (test_bit(FLG_MOD128, &st->l2.flag) ? SABME : SABM)
|
1997-06-26 11:07:29 +00:00
|
|
|
| 0x10, CMD);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-04-06 22:59:59 +00:00
|
|
|
l2_st6_tout_200(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-02-09 00:29:11 +00:00
|
|
|
struct PStack *st = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_bit(FLG_LAPD, &st->l2.flag) &&
|
|
|
|
test_bit(FLG_DCHAN_BUSY, &st->l2.flag)) {
|
|
|
|
FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 9);
|
|
|
|
} else if (st->l2.rc == st->l2.N200) {
|
1996-10-13 20:04:59 +00:00
|
|
|
FsmChangeState(fi, ST_L2_4);
|
1999-07-01 08:12:15 +00:00
|
|
|
test_and_clear_bit(FLG_T200_RUN, &st->l2.flag);
|
1998-05-25 12:58:26 +00:00
|
|
|
st->ma.layer(st, MDL_ERROR | INDICATION, (void *) 'H');
|
1999-07-01 08:12:15 +00:00
|
|
|
lapb_dl_release_l2l3(st, CONFIRM);
|
1996-10-13 20:04:59 +00:00
|
|
|
} else {
|
|
|
|
st->l2.rc++;
|
1997-07-27 21:34:38 +00:00
|
|
|
FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200,
|
1997-06-26 11:07:29 +00:00
|
|
|
NULL, 9);
|
|
|
|
send_uframe(st, DISC | 0x10, CMD);
|
|
|
|
}
|
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
l2_st7_tout_200(struct FsmInst *fi, int event, void *arg)
|
1997-06-26 11:07:29 +00:00
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_bit(FLG_LAPD, &st->l2.flag) &&
|
|
|
|
test_bit(FLG_DCHAN_BUSY, &st->l2.flag)) {
|
|
|
|
FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 9);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
test_and_clear_bit(FLG_T200_RUN, &st->l2.flag);
|
1999-07-01 08:12:15 +00:00
|
|
|
st->l2.rc = 0;
|
|
|
|
FsmChangeState(fi, ST_L2_8);
|
|
|
|
|
|
|
|
transmit_enquiry(st);
|
|
|
|
st->l2.rc++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_st8_tout_200(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
|
|
|
if (test_bit(FLG_LAPD, &st->l2.flag) &&
|
|
|
|
test_bit(FLG_DCHAN_BUSY, &st->l2.flag)) {
|
|
|
|
FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 9);
|
|
|
|
return;
|
1997-06-26 11:07:29 +00:00
|
|
|
}
|
1999-07-01 08:12:15 +00:00
|
|
|
test_and_clear_bit(FLG_T200_RUN, &st->l2.flag);
|
1997-07-27 21:34:38 +00:00
|
|
|
if (st->l2.rc == st->l2.N200) {
|
1999-07-01 08:12:15 +00:00
|
|
|
st->ma.layer(st, MDL_ERROR | INDICATION, (void *) 'I');
|
1997-06-26 11:07:29 +00:00
|
|
|
establishlink(fi);
|
1999-07-01 08:12:15 +00:00
|
|
|
test_and_clear_bit(FLG_L3_INIT, &st->l2.flag);
|
1997-06-26 11:07:29 +00:00
|
|
|
} else {
|
|
|
|
transmit_enquiry(st);
|
|
|
|
st->l2.rc++;
|
|
|
|
}
|
|
|
|
}
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
static void
|
|
|
|
l2_st7_tout_203(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_bit(FLG_LAPD, &st->l2.flag) &&
|
|
|
|
test_bit(FLG_DCHAN_BUSY, &st->l2.flag)) {
|
|
|
|
FsmAddTimer(&st->l2.t203, st->l2.T203, EV_L2_T203, NULL, 9);
|
|
|
|
return;
|
|
|
|
}
|
1997-06-26 11:07:29 +00:00
|
|
|
FsmChangeState(fi, ST_L2_8);
|
|
|
|
transmit_enquiry(st);
|
|
|
|
st->l2.rc = 0;
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-04-06 22:59:59 +00:00
|
|
|
l2_pull_iqueue(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-02-09 00:29:11 +00:00
|
|
|
struct PStack *st = fi->userdata;
|
1997-06-26 11:07:29 +00:00
|
|
|
struct sk_buff *skb, *oskb;
|
1997-02-09 00:29:11 +00:00
|
|
|
struct Layer2 *l2 = &st->l2;
|
1997-04-06 22:59:59 +00:00
|
|
|
u_char header[MAX_HEADER_LEN];
|
1999-07-01 08:12:15 +00:00
|
|
|
int i;
|
|
|
|
int unsigned p1;
|
|
|
|
long flags;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
|
|
|
if (!cansend(st))
|
|
|
|
return;
|
|
|
|
|
1997-04-06 22:59:59 +00:00
|
|
|
skb = skb_dequeue(&l2->i_queue);
|
|
|
|
if (!skb)
|
1996-10-13 20:04:59 +00:00
|
|
|
return;
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
save_flags(flags);
|
|
|
|
cli();
|
|
|
|
if(test_bit(FLG_MOD128, &l2->flag))
|
|
|
|
p1 = (l2->vs - l2->va) % 128;
|
|
|
|
else
|
|
|
|
p1 = (l2->vs - l2->va) % 8;
|
1996-10-13 20:04:59 +00:00
|
|
|
p1 = (p1 + l2->sow) % l2->window;
|
1997-04-06 22:59:59 +00:00
|
|
|
if (l2->windowar[p1]) {
|
|
|
|
printk(KERN_WARNING "isdnl2 try overwrite ack queue entry %d\n",
|
|
|
|
p1);
|
1999-07-01 08:12:15 +00:00
|
|
|
idev_kfree_skb(l2->windowar[p1], FREE_WRITE);
|
1997-04-06 22:59:59 +00:00
|
|
|
}
|
|
|
|
l2->windowar[p1] = skb_clone(skb, GFP_ATOMIC);
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-04-06 22:59:59 +00:00
|
|
|
i = sethdraddr(&st->l2, header, CMD);
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_bit(FLG_MOD128, &l2->flag)) {
|
1997-04-06 22:59:59 +00:00
|
|
|
header[i++] = l2->vs << 1;
|
|
|
|
header[i++] = l2->vr << 1;
|
1996-10-13 20:04:59 +00:00
|
|
|
l2->vs = (l2->vs + 1) % 128;
|
|
|
|
} else {
|
1997-04-06 22:59:59 +00:00
|
|
|
header[i++] = (l2->vr << 5) | (l2->vs << 1);
|
1996-10-13 20:04:59 +00:00
|
|
|
l2->vs = (l2->vs + 1) % 8;
|
|
|
|
}
|
1999-07-01 08:12:15 +00:00
|
|
|
restore_flags(flags);
|
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
p1 = skb->data - skb->head;
|
|
|
|
if (p1 >= i)
|
|
|
|
memcpy(skb_push(skb, i), header, i);
|
|
|
|
else {
|
|
|
|
printk(KERN_WARNING
|
|
|
|
"isdl2 pull_iqueue skb header(%d/%d) too short\n", i, p1);
|
|
|
|
oskb = skb;
|
|
|
|
skb = alloc_skb(oskb->len + i, GFP_ATOMIC);
|
1999-07-01 08:12:15 +00:00
|
|
|
SET_SKB_FREE(skb);
|
1997-06-26 11:07:29 +00:00
|
|
|
memcpy(skb_put(skb, i), header, i);
|
|
|
|
memcpy(skb_put(skb, oskb->len), oskb->data, oskb->len);
|
|
|
|
FreeSkb(oskb);
|
|
|
|
}
|
1998-05-25 12:58:26 +00:00
|
|
|
st->l2.l2l1(st, PH_PULL | INDICATION, skb);
|
1997-10-29 19:02:01 +00:00
|
|
|
test_and_clear_bit(FLG_ACK_PEND, &st->l2.flag);
|
|
|
|
if (!test_and_set_bit(FLG_T200_RUN, &st->l2.flag)) {
|
1997-07-27 21:34:38 +00:00
|
|
|
FsmDelTimer(&st->l2.t203, 13);
|
|
|
|
FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 11);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
1997-04-06 22:59:59 +00:00
|
|
|
if (skb_queue_len(&l2->i_queue) && cansend(st))
|
1998-05-25 12:58:26 +00:00
|
|
|
st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-01 08:12:15 +00:00
|
|
|
l2_st8_got_super(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-02-09 00:29:11 +00:00
|
|
|
struct PStack *st = fi->userdata;
|
1997-04-06 22:59:59 +00:00
|
|
|
struct sk_buff *skb = arg;
|
1999-07-01 08:12:15 +00:00
|
|
|
int PollFlag, rsp, rnr = 0;
|
|
|
|
unsigned int nr;
|
1997-06-26 11:07:29 +00:00
|
|
|
struct Layer2 *l2 = &st->l2;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
rsp = *skb->data & 0x2;
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_bit(FLG_ORIG, &l2->flag))
|
1997-04-06 22:59:59 +00:00
|
|
|
rsp = !rsp;
|
1999-07-01 08:12:15 +00:00
|
|
|
|
1997-04-06 22:59:59 +00:00
|
|
|
skb_pull(skb, l2addrsize(l2));
|
1997-06-26 11:07:29 +00:00
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
if (IsRNR(skb->data, st)) {
|
1999-07-21 14:46:28 +00:00
|
|
|
set_peer_busy(l2);
|
1997-06-26 11:07:29 +00:00
|
|
|
rnr = 1;
|
|
|
|
} else
|
1999-07-21 14:46:28 +00:00
|
|
|
clear_peer_busy(l2);
|
1999-07-01 08:12:15 +00:00
|
|
|
|
1997-10-29 19:02:01 +00:00
|
|
|
if (test_bit(FLG_MOD128, &l2->flag)) {
|
1999-07-01 08:12:15 +00:00
|
|
|
PollFlag = (skb->data[1] & 0x1) == 0x1;
|
|
|
|
nr = skb->data[1] >> 1;
|
1996-10-13 20:04:59 +00:00
|
|
|
} else {
|
1999-07-01 08:12:15 +00:00
|
|
|
PollFlag = (skb->data[0] & 0x10);
|
|
|
|
nr = (skb->data[0] >> 5) & 0x7;
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
1997-06-26 11:07:29 +00:00
|
|
|
FreeSkb(skb);
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-04-06 22:59:59 +00:00
|
|
|
if (rsp && PollFlag) {
|
1997-06-26 11:07:29 +00:00
|
|
|
if (legalnr(st, nr)) {
|
|
|
|
if (rnr) {
|
1999-07-01 08:12:15 +00:00
|
|
|
restart_t200(st, 15);
|
|
|
|
} else {
|
|
|
|
stop_t200(st, 16);
|
1997-07-27 21:34:38 +00:00
|
|
|
FsmAddTimer(&l2->t203, l2->T203,
|
1997-06-26 11:07:29 +00:00
|
|
|
EV_L2_T203, NULL, 5);
|
1999-07-01 08:12:15 +00:00
|
|
|
setva(st, nr);
|
|
|
|
}
|
1997-06-26 11:07:29 +00:00
|
|
|
invoke_retransmission(st, nr);
|
|
|
|
FsmChangeState(fi, ST_L2_7);
|
1997-04-06 22:59:59 +00:00
|
|
|
if (skb_queue_len(&l2->i_queue) && cansend(st))
|
1998-05-25 12:58:26 +00:00
|
|
|
st->l2.l2l1(st, PH_PULL | REQUEST, NULL);
|
1999-07-01 08:12:15 +00:00
|
|
|
} else
|
|
|
|
nrerrorrecovery(fi);
|
1996-10-13 20:04:59 +00:00
|
|
|
} else {
|
1997-04-06 22:59:59 +00:00
|
|
|
if (!rsp && PollFlag)
|
1997-06-26 11:07:29 +00:00
|
|
|
enquiry_response(st);
|
|
|
|
if (legalnr(st, nr)) {
|
|
|
|
setva(st, nr);
|
1999-07-01 08:12:15 +00:00
|
|
|
} else
|
|
|
|
nrerrorrecovery(fi);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-04-06 22:59:59 +00:00
|
|
|
l2_got_FRMR(struct FsmInst *fi, int event, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-02-09 00:29:11 +00:00
|
|
|
struct PStack *st = fi->userdata;
|
1997-04-06 22:59:59 +00:00
|
|
|
struct sk_buff *skb = arg;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
skb_pull(skb, l2addrsize(&st->l2) + 1);
|
1999-07-01 08:12:15 +00:00
|
|
|
|
1997-06-26 11:07:29 +00:00
|
|
|
if (!(skb->data[0] & 1) || ((skb->data[0] & 3) == 1) || /* I or S */
|
1999-07-01 08:12:15 +00:00
|
|
|
(IsUA(skb->data) && (fi->state == ST_L2_7))) {
|
1998-05-25 12:58:26 +00:00
|
|
|
st->ma.layer(st, MDL_ERROR | INDICATION, (void *) 'K');
|
1997-06-26 11:07:29 +00:00
|
|
|
establishlink(fi);
|
1997-10-29 19:02:01 +00:00
|
|
|
test_and_clear_bit(FLG_L3_INIT, &st->l2.flag);
|
1997-06-26 11:07:29 +00:00
|
|
|
}
|
|
|
|
FreeSkb(skb);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
static void
|
|
|
|
l2_st24_tei_remove(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
|
|
|
discard_queue(&st->l2.ui_queue);
|
|
|
|
st->l2.tei = -1;
|
|
|
|
FsmChangeState(fi, ST_L2_1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_st3_tei_remove(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
|
|
|
discard_queue(&st->l2.ui_queue);
|
|
|
|
st->l2.tei = -1;
|
|
|
|
st->l2.l2l3(st, DL_RELEASE | INDICATION, NULL);
|
|
|
|
FsmChangeState(fi, ST_L2_1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_st5_tei_remove(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
|
|
|
discard_queue(&st->l2.i_queue);
|
|
|
|
discard_queue(&st->l2.ui_queue);
|
|
|
|
freewin(st);
|
|
|
|
st->l2.tei = -1;
|
|
|
|
stop_t200(st, 17);
|
|
|
|
st5_dl_release_l2l3(st);
|
|
|
|
FsmChangeState(fi, ST_L2_1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_st6_tei_remove(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
|
|
|
discard_queue(&st->l2.ui_queue);
|
|
|
|
st->l2.tei = -1;
|
|
|
|
stop_t200(st, 18);
|
|
|
|
st->l2.l2l3(st, DL_RELEASE | CONFIRM, NULL);
|
|
|
|
FsmChangeState(fi, ST_L2_1);
|
|
|
|
}
|
|
|
|
|
1997-01-04 13:47:06 +00:00
|
|
|
static void
|
1997-04-06 22:59:59 +00:00
|
|
|
l2_tei_remove(struct FsmInst *fi, int event, void *arg)
|
1997-01-04 13:47:06 +00:00
|
|
|
{
|
1997-02-09 00:29:11 +00:00
|
|
|
struct PStack *st = fi->userdata;
|
1997-01-04 13:47:06 +00:00
|
|
|
|
1998-05-25 12:58:26 +00:00
|
|
|
discard_queue(&st->l2.i_queue);
|
|
|
|
discard_queue(&st->l2.ui_queue);
|
1999-07-01 08:12:15 +00:00
|
|
|
freewin(st);
|
1997-07-27 21:34:38 +00:00
|
|
|
st->l2.tei = -1;
|
1999-07-01 08:12:15 +00:00
|
|
|
stop_t200(st, 17);
|
1997-07-27 21:34:38 +00:00
|
|
|
FsmDelTimer(&st->l2.t203, 19);
|
1999-07-01 08:12:15 +00:00
|
|
|
st->l2.l2l3(st, DL_RELEASE | INDICATION, NULL);
|
1997-01-04 13:47:06 +00:00
|
|
|
FsmChangeState(fi, ST_L2_1);
|
|
|
|
}
|
|
|
|
|
1997-10-29 19:02:01 +00:00
|
|
|
static void
|
1999-08-05 20:40:26 +00:00
|
|
|
l2_st14_persistant_da(struct FsmInst *fi, int event, void *arg)
|
1997-10-29 19:02:01 +00:00
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
1999-07-01 08:12:15 +00:00
|
|
|
discard_queue(&st->l2.i_queue);
|
1999-08-05 20:40:26 +00:00
|
|
|
discard_queue(&st->l2.ui_queue);
|
|
|
|
if (test_and_clear_bit(FLG_ESTAB_PEND, &st->l2.flag))
|
|
|
|
st->l2.l2l3(st, DL_RELEASE | INDICATION, NULL);
|
1999-07-01 08:12:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_st5_persistant_da(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
|
|
|
discard_queue(&st->l2.i_queue);
|
|
|
|
discard_queue(&st->l2.ui_queue);
|
|
|
|
freewin(st);
|
|
|
|
stop_t200(st, 19);
|
|
|
|
st5_dl_release_l2l3(st);
|
|
|
|
FsmChangeState(fi, ST_L2_4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_st6_persistant_da(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
|
|
|
discard_queue(&st->l2.ui_queue);
|
|
|
|
stop_t200(st, 20);
|
|
|
|
st->l2.l2l3(st, DL_RELEASE | CONFIRM, NULL);
|
|
|
|
FsmChangeState(fi, ST_L2_4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_persistant_da(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
1998-05-25 12:58:26 +00:00
|
|
|
discard_queue(&st->l2.i_queue);
|
|
|
|
discard_queue(&st->l2.ui_queue);
|
1999-07-01 08:12:15 +00:00
|
|
|
freewin(st);
|
|
|
|
stop_t200(st, 19);
|
1997-10-29 19:02:01 +00:00
|
|
|
FsmDelTimer(&st->l2.t203, 19);
|
1999-07-01 08:12:15 +00:00
|
|
|
st->l2.l2l3(st, DL_RELEASE | INDICATION, NULL);
|
|
|
|
FsmChangeState(fi, ST_L2_4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_set_own_busy(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
|
|
|
if(!test_and_set_bit(FLG_OWN_BUSY, &st->l2.flag)) {
|
|
|
|
enquiry_cr(st, RNR, RSP, 0);
|
|
|
|
test_and_clear_bit(FLG_ACK_PEND, &st->l2.flag);
|
1997-10-29 19:02:01 +00:00
|
|
|
}
|
1999-07-01 08:12:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_clear_own_busy(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
|
|
|
if(!test_and_clear_bit(FLG_OWN_BUSY, &st->l2.flag)) {
|
|
|
|
enquiry_cr(st, RR, RSP, 0);
|
|
|
|
test_and_clear_bit(FLG_ACK_PEND, &st->l2.flag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_frame_error(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
|
|
|
st->ma.layer(st, MDL_ERROR | INDICATION, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
l2_frame_error_reest(struct FsmInst *fi, int event, void *arg)
|
|
|
|
{
|
|
|
|
struct PStack *st = fi->userdata;
|
|
|
|
|
|
|
|
st->ma.layer(st, MDL_ERROR | INDICATION, arg);
|
|
|
|
establishlink(fi);
|
|
|
|
test_and_clear_bit(FLG_L3_INIT, &st->l2.flag);
|
1997-10-29 19:02:01 +00:00
|
|
|
}
|
|
|
|
|
1997-11-06 17:13:35 +00:00
|
|
|
static struct FsmNode L2FnList[] HISAX_INITDATA =
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
{ST_L2_1, EV_L2_DL_ESTABLISH_REQ, l2_mdl_assign},
|
|
|
|
{ST_L2_2, EV_L2_DL_ESTABLISH_REQ, l2_go_st3},
|
|
|
|
{ST_L2_4, EV_L2_DL_ESTABLISH_REQ, l2_establish},
|
|
|
|
{ST_L2_5, EV_L2_DL_ESTABLISH_REQ, l2_discard_i_setl3},
|
|
|
|
{ST_L2_7, EV_L2_DL_ESTABLISH_REQ, l2_l3_reestablish},
|
|
|
|
{ST_L2_8, EV_L2_DL_ESTABLISH_REQ, l2_l3_reestablish},
|
|
|
|
{ST_L2_4, EV_L2_DL_RELEASE_REQ, l2_release},
|
|
|
|
{ST_L2_5, EV_L2_DL_RELEASE_REQ, l2_pend_rel},
|
|
|
|
{ST_L2_7, EV_L2_DL_RELEASE_REQ, l2_disconnect},
|
|
|
|
{ST_L2_8, EV_L2_DL_RELEASE_REQ, l2_disconnect},
|
|
|
|
{ST_L2_5, EV_L2_DL_DATA, l2_feed_i_if_reest},
|
|
|
|
{ST_L2_7, EV_L2_DL_DATA, l2_feed_i_pull},
|
1997-04-06 22:59:59 +00:00
|
|
|
{ST_L2_8, EV_L2_DL_DATA, l2_feed_iqueue},
|
1999-07-01 08:12:15 +00:00
|
|
|
{ST_L2_1, EV_L2_DL_UNIT_DATA, l2_queue_ui_assign},
|
|
|
|
{ST_L2_2, EV_L2_DL_UNIT_DATA, l2_queue_ui},
|
|
|
|
{ST_L2_3, EV_L2_DL_UNIT_DATA, l2_queue_ui},
|
|
|
|
{ST_L2_4, EV_L2_DL_UNIT_DATA, l2_send_ui},
|
|
|
|
{ST_L2_5, EV_L2_DL_UNIT_DATA, l2_send_ui},
|
|
|
|
{ST_L2_6, EV_L2_DL_UNIT_DATA, l2_send_ui},
|
|
|
|
{ST_L2_7, EV_L2_DL_UNIT_DATA, l2_send_ui},
|
|
|
|
{ST_L2_8, EV_L2_DL_UNIT_DATA, l2_send_ui},
|
1997-06-26 11:07:29 +00:00
|
|
|
{ST_L2_1, EV_L2_MDL_ASSIGN, l2_got_tei},
|
|
|
|
{ST_L2_2, EV_L2_MDL_ASSIGN, l2_got_tei},
|
|
|
|
{ST_L2_3, EV_L2_MDL_ASSIGN, l2_got_tei},
|
1999-07-01 08:12:15 +00:00
|
|
|
{ST_L2_2, EV_L2_MDL_ERROR, l2_st24_tei_remove},
|
|
|
|
{ST_L2_3, EV_L2_MDL_ERROR, l2_st3_tei_remove},
|
|
|
|
{ST_L2_4, EV_L2_MDL_REMOVE, l2_st24_tei_remove},
|
|
|
|
{ST_L2_5, EV_L2_MDL_REMOVE, l2_st5_tei_remove},
|
|
|
|
{ST_L2_6, EV_L2_MDL_REMOVE, l2_st6_tei_remove},
|
1997-06-26 11:07:29 +00:00
|
|
|
{ST_L2_7, EV_L2_MDL_REMOVE, l2_tei_remove},
|
|
|
|
{ST_L2_8, EV_L2_MDL_REMOVE, l2_tei_remove},
|
1999-07-01 08:12:15 +00:00
|
|
|
{ST_L2_4, EV_L2_SABME, l2_start_multi},
|
|
|
|
{ST_L2_5, EV_L2_SABME, l2_send_UA},
|
|
|
|
{ST_L2_6, EV_L2_SABME, l2_send_DM},
|
|
|
|
{ST_L2_7, EV_L2_SABME, l2_restart_multi},
|
|
|
|
{ST_L2_8, EV_L2_SABME, l2_restart_multi},
|
|
|
|
{ST_L2_4, EV_L2_DISC, l2_send_DM},
|
|
|
|
{ST_L2_5, EV_L2_DISC, l2_send_DM},
|
|
|
|
{ST_L2_6, EV_L2_DISC, l2_send_UA},
|
|
|
|
{ST_L2_7, EV_L2_DISC, l2_stop_multi},
|
|
|
|
{ST_L2_8, EV_L2_DISC, l2_stop_multi},
|
|
|
|
{ST_L2_4, EV_L2_UA, l2_mdl_error_ua},
|
|
|
|
{ST_L2_5, EV_L2_UA, l2_connected},
|
|
|
|
{ST_L2_6, EV_L2_UA, l2_released},
|
|
|
|
{ST_L2_7, EV_L2_UA, l2_mdl_error_ua},
|
|
|
|
{ST_L2_8, EV_L2_UA, l2_mdl_error_ua},
|
|
|
|
{ST_L2_4, EV_L2_DM, l2_reestablish},
|
|
|
|
{ST_L2_5, EV_L2_DM, l2_st5_dm_release},
|
|
|
|
{ST_L2_6, EV_L2_DM, l2_st6_dm_release},
|
|
|
|
{ST_L2_7, EV_L2_DM, l2_mdl_error_dm},
|
|
|
|
{ST_L2_8, EV_L2_DM, l2_st8_mdl_error_dm},
|
1997-06-26 11:07:29 +00:00
|
|
|
{ST_L2_1, EV_L2_UI, l2_got_ui},
|
|
|
|
{ST_L2_2, EV_L2_UI, l2_got_ui},
|
|
|
|
{ST_L2_3, EV_L2_UI, l2_got_ui},
|
|
|
|
{ST_L2_4, EV_L2_UI, l2_got_ui},
|
|
|
|
{ST_L2_5, EV_L2_UI, l2_got_ui},
|
|
|
|
{ST_L2_6, EV_L2_UI, l2_got_ui},
|
|
|
|
{ST_L2_7, EV_L2_UI, l2_got_ui},
|
|
|
|
{ST_L2_8, EV_L2_UI, l2_got_ui},
|
|
|
|
{ST_L2_7, EV_L2_FRMR, l2_got_FRMR},
|
1997-04-06 22:59:59 +00:00
|
|
|
{ST_L2_8, EV_L2_FRMR, l2_got_FRMR},
|
1999-07-01 08:12:15 +00:00
|
|
|
{ST_L2_7, EV_L2_SUPER, l2_st7_got_super},
|
|
|
|
{ST_L2_8, EV_L2_SUPER, l2_st8_got_super},
|
1997-06-26 11:07:29 +00:00
|
|
|
{ST_L2_7, EV_L2_I, l2_got_iframe},
|
|
|
|
{ST_L2_8, EV_L2_I, l2_got_iframe},
|
1997-04-06 22:59:59 +00:00
|
|
|
{ST_L2_5, EV_L2_T200, l2_st5_tout_200},
|
|
|
|
{ST_L2_6, EV_L2_T200, l2_st6_tout_200},
|
1999-07-01 08:12:15 +00:00
|
|
|
{ST_L2_7, EV_L2_T200, l2_st7_tout_200},
|
|
|
|
{ST_L2_8, EV_L2_T200, l2_st8_tout_200},
|
1997-04-06 22:59:59 +00:00
|
|
|
{ST_L2_7, EV_L2_T203, l2_st7_tout_203},
|
1997-06-26 11:07:29 +00:00
|
|
|
{ST_L2_7, EV_L2_ACK_PULL, l2_pull_iqueue},
|
1999-07-01 08:12:15 +00:00
|
|
|
{ST_L2_7, EV_L2_SET_OWN_BUSY, l2_set_own_busy},
|
|
|
|
{ST_L2_8, EV_L2_SET_OWN_BUSY, l2_set_own_busy},
|
|
|
|
{ST_L2_7, EV_L2_CLEAR_OWN_BUSY, l2_clear_own_busy},
|
|
|
|
{ST_L2_8, EV_L2_CLEAR_OWN_BUSY, l2_clear_own_busy},
|
|
|
|
{ST_L2_4, EV_L2_FRAME_ERROR, l2_frame_error},
|
|
|
|
{ST_L2_5, EV_L2_FRAME_ERROR, l2_frame_error},
|
|
|
|
{ST_L2_6, EV_L2_FRAME_ERROR, l2_frame_error},
|
|
|
|
{ST_L2_7, EV_L2_FRAME_ERROR, l2_frame_error_reest},
|
|
|
|
{ST_L2_8, EV_L2_FRAME_ERROR, l2_frame_error_reest},
|
1999-08-05 20:40:26 +00:00
|
|
|
{ST_L2_1, EV_L1_DEACTIVATE, l2_st14_persistant_da},
|
1999-07-01 08:12:15 +00:00
|
|
|
{ST_L2_2, EV_L1_DEACTIVATE, l2_st24_tei_remove},
|
|
|
|
{ST_L2_3, EV_L1_DEACTIVATE, l2_st3_tei_remove},
|
1999-08-05 20:40:26 +00:00
|
|
|
{ST_L2_4, EV_L1_DEACTIVATE, l2_st14_persistant_da},
|
1999-07-01 08:12:15 +00:00
|
|
|
{ST_L2_5, EV_L1_DEACTIVATE, l2_st5_persistant_da},
|
|
|
|
{ST_L2_6, EV_L1_DEACTIVATE, l2_st6_persistant_da},
|
1997-10-29 19:02:01 +00:00
|
|
|
{ST_L2_7, EV_L1_DEACTIVATE, l2_persistant_da},
|
|
|
|
{ST_L2_8, EV_L1_DEACTIVATE, l2_persistant_da},
|
1996-10-13 20:04:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define L2_FN_COUNT (sizeof(L2FnList)/sizeof(struct FsmNode))
|
|
|
|
|
|
|
|
static void
|
1997-04-06 22:59:59 +00:00
|
|
|
isdnl2_l1l2(struct PStack *st, int pr, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1997-04-06 22:59:59 +00:00
|
|
|
struct sk_buff *skb = arg;
|
|
|
|
u_char *datap;
|
1997-06-26 11:07:29 +00:00
|
|
|
int ret = 1, len;
|
1999-07-01 08:12:15 +00:00
|
|
|
int c = 0;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
|
|
|
switch (pr) {
|
1998-05-25 12:58:26 +00:00
|
|
|
case (PH_DATA | INDICATION):
|
1997-04-06 22:59:59 +00:00
|
|
|
datap = skb->data;
|
1997-06-26 11:07:29 +00:00
|
|
|
len = l2addrsize(&st->l2);
|
|
|
|
if (skb->len > len)
|
|
|
|
datap += len;
|
|
|
|
else {
|
1999-07-01 08:12:15 +00:00
|
|
|
FsmEvent(&st->l2.l2m, EV_L2_FRAME_ERROR, (void *) 'N');
|
1997-06-26 11:07:29 +00:00
|
|
|
FreeSkb(skb);
|
|
|
|
return;
|
|
|
|
}
|
1999-07-01 08:12:15 +00:00
|
|
|
if (!(*datap & 1)) { /* I-Frame */
|
|
|
|
if(!(c = iframe_error(st, skb)))
|
|
|
|
ret = FsmEvent(&st->l2.l2m, EV_L2_I, skb);
|
|
|
|
} else if (IsSFrame(datap, st)) { /* S-Frame */
|
|
|
|
if(!(c = super_error(st, skb)))
|
|
|
|
ret = FsmEvent(&st->l2.l2m, EV_L2_SUPER, skb);
|
|
|
|
} else if (IsUI(datap)) {
|
|
|
|
if(!(c = UI_error(st, skb)))
|
|
|
|
ret = FsmEvent(&st->l2.l2m, EV_L2_UI, skb);
|
|
|
|
} else if (IsSABME(datap, st)) {
|
|
|
|
if(!(c = unnum_error(st, skb, CMD)))
|
|
|
|
ret = FsmEvent(&st->l2.l2m, EV_L2_SABME, skb);
|
|
|
|
} else if (IsUA(datap)) {
|
|
|
|
if(!(c = unnum_error(st, skb, RSP)))
|
|
|
|
ret = FsmEvent(&st->l2.l2m, EV_L2_UA, skb);
|
|
|
|
} else if (IsDISC(datap)) {
|
|
|
|
if(!(c = unnum_error(st, skb, CMD)))
|
|
|
|
ret = FsmEvent(&st->l2.l2m, EV_L2_DISC, skb);
|
|
|
|
} else if (IsDM(datap)) {
|
|
|
|
if(!(c = unnum_error(st, skb, RSP)))
|
|
|
|
ret = FsmEvent(&st->l2.l2m, EV_L2_DM, skb);
|
|
|
|
} else if (IsFRMR(datap)) {
|
|
|
|
if(!(c = FRMR_error(st,skb)))
|
|
|
|
ret = FsmEvent(&st->l2.l2m, EV_L2_FRMR, skb);
|
|
|
|
} else {
|
|
|
|
FsmEvent(&st->l2.l2m, EV_L2_FRAME_ERROR, (void *) 'L');
|
|
|
|
FreeSkb(skb);
|
|
|
|
ret = 0;
|
1997-06-26 11:07:29 +00:00
|
|
|
}
|
1999-07-01 08:12:15 +00:00
|
|
|
if(c) {
|
1997-06-26 11:07:29 +00:00
|
|
|
FreeSkb(skb);
|
1999-08-25 16:52:04 +00:00
|
|
|
FsmEvent(&st->l2.l2m, EV_L2_FRAME_ERROR, (void *)(long)c);
|
1999-07-01 08:12:15 +00:00
|
|
|
ret = 0;
|
1997-04-07 23:02:11 +00:00
|
|
|
}
|
1999-07-01 08:12:15 +00:00
|
|
|
if (ret)
|
|
|
|
FreeSkb(skb);
|
1997-02-09 00:29:11 +00:00
|
|
|
break;
|
1998-05-25 12:58:26 +00:00
|
|
|
case (PH_PULL | CONFIRM):
|
1997-02-09 00:29:11 +00:00
|
|
|
FsmEvent(&st->l2.l2m, EV_L2_ACK_PULL, arg);
|
|
|
|
break;
|
1998-05-25 12:58:26 +00:00
|
|
|
case (PH_PAUSE | INDICATION):
|
1997-10-29 19:02:01 +00:00
|
|
|
test_and_set_bit(FLG_DCHAN_BUSY, &st->l2.flag);
|
|
|
|
break;
|
1998-05-25 12:58:26 +00:00
|
|
|
case (PH_PAUSE | CONFIRM):
|
1997-10-29 19:02:01 +00:00
|
|
|
test_and_clear_bit(FLG_DCHAN_BUSY, &st->l2.flag);
|
|
|
|
break;
|
1998-05-25 12:58:26 +00:00
|
|
|
case (PH_ACTIVATE | CONFIRM):
|
|
|
|
case (PH_ACTIVATE | INDICATION):
|
1998-05-25 14:10:20 +00:00
|
|
|
test_and_set_bit(FLG_L1_ACTIV, &st->l2.flag);
|
1998-05-25 12:58:26 +00:00
|
|
|
if (test_and_clear_bit(FLG_ESTAB_PEND, &st->l2.flag))
|
1999-07-01 08:12:15 +00:00
|
|
|
FsmEvent(&st->l2.l2m, EV_L2_DL_ESTABLISH_REQ, arg);
|
1998-05-25 12:58:26 +00:00
|
|
|
break;
|
|
|
|
case (PH_DEACTIVATE | INDICATION):
|
1998-05-25 14:10:20 +00:00
|
|
|
case (PH_DEACTIVATE | CONFIRM):
|
|
|
|
test_and_clear_bit(FLG_L1_ACTIV, &st->l2.flag);
|
1998-05-25 12:58:26 +00:00
|
|
|
FsmEvent(&st->l2.l2m, EV_L1_DEACTIVATE, arg);
|
|
|
|
break;
|
|
|
|
default:
|
1998-11-15 23:55:28 +00:00
|
|
|
l2m_debug(&st->l2.l2m, "l2 unknown pr %04x", pr);
|
1998-05-25 12:58:26 +00:00
|
|
|
break;
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-04-06 22:59:59 +00:00
|
|
|
isdnl2_l3l2(struct PStack *st, int pr, void *arg)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
|
|
|
switch (pr) {
|
1998-05-25 12:58:26 +00:00
|
|
|
case (DL_DATA | REQUEST):
|
1997-04-06 22:59:59 +00:00
|
|
|
if (FsmEvent(&st->l2.l2m, EV_L2_DL_DATA, arg)) {
|
1999-07-01 08:12:15 +00:00
|
|
|
idev_kfree_skb((struct sk_buff *) arg, FREE_READ);
|
1997-04-06 22:59:59 +00:00
|
|
|
}
|
1997-02-09 00:29:11 +00:00
|
|
|
break;
|
1998-05-25 12:58:26 +00:00
|
|
|
case (DL_UNIT_DATA | REQUEST):
|
1997-04-06 22:59:59 +00:00
|
|
|
if (FsmEvent(&st->l2.l2m, EV_L2_DL_UNIT_DATA, arg)) {
|
1999-07-01 08:12:15 +00:00
|
|
|
idev_kfree_skb((struct sk_buff *) arg, FREE_READ);
|
1997-04-06 22:59:59 +00:00
|
|
|
}
|
1997-02-09 00:29:11 +00:00
|
|
|
break;
|
1998-05-25 12:58:26 +00:00
|
|
|
case (DL_ESTABLISH | REQUEST):
|
1998-05-25 14:10:20 +00:00
|
|
|
if (test_bit(FLG_L1_ACTIV, &st->l2.flag)) {
|
|
|
|
if (test_bit(FLG_LAPD, &st->l2.flag) ||
|
|
|
|
test_bit(FLG_ORIG, &st->l2.flag)) {
|
1999-07-01 08:12:15 +00:00
|
|
|
FsmEvent(&st->l2.l2m, EV_L2_DL_ESTABLISH_REQ, arg);
|
1998-05-25 14:10:20 +00:00
|
|
|
}
|
1998-05-25 12:58:26 +00:00
|
|
|
} else {
|
1998-05-25 14:10:20 +00:00
|
|
|
if (test_bit(FLG_LAPD, &st->l2.flag) ||
|
|
|
|
test_bit(FLG_ORIG, &st->l2.flag)) {
|
1998-06-18 23:17:20 +00:00
|
|
|
test_and_set_bit(FLG_ESTAB_PEND, &st->l2.flag);
|
1998-05-25 14:10:20 +00:00
|
|
|
}
|
1998-05-25 12:58:26 +00:00
|
|
|
st->l2.l2l1(st, PH_ACTIVATE, NULL);
|
|
|
|
}
|
1997-02-09 00:29:11 +00:00
|
|
|
break;
|
1998-05-25 12:58:26 +00:00
|
|
|
case (DL_RELEASE | REQUEST):
|
1998-05-25 14:10:20 +00:00
|
|
|
if (test_bit(FLG_LAPB, &st->l2.flag)) {
|
|
|
|
st->l2.l2l1(st, PH_DEACTIVATE, NULL);
|
|
|
|
}
|
1999-07-01 08:12:15 +00:00
|
|
|
FsmEvent(&st->l2.l2m, EV_L2_DL_RELEASE_REQ, arg);
|
1997-02-09 00:29:11 +00:00
|
|
|
break;
|
1998-05-25 12:58:26 +00:00
|
|
|
case (MDL_ASSIGN | REQUEST):
|
1997-02-09 00:29:11 +00:00
|
|
|
FsmEvent(&st->l2.l2m, EV_L2_MDL_ASSIGN, arg);
|
|
|
|
break;
|
1998-05-25 12:58:26 +00:00
|
|
|
case (MDL_REMOVE | REQUEST):
|
1997-02-09 00:29:11 +00:00
|
|
|
FsmEvent(&st->l2.l2m, EV_L2_MDL_REMOVE, arg);
|
|
|
|
break;
|
1998-05-25 12:58:26 +00:00
|
|
|
case (MDL_ERROR | RESPONSE):
|
1997-07-31 11:49:05 +00:00
|
|
|
FsmEvent(&st->l2.l2m, EV_L2_MDL_ERROR, arg);
|
|
|
|
break;
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
releasestack_isdnl2(struct PStack *st)
|
|
|
|
{
|
1999-07-01 08:12:15 +00:00
|
|
|
FsmDelTimer(&st->l2.t200, 21);
|
1997-07-27 21:34:38 +00:00
|
|
|
FsmDelTimer(&st->l2.t203, 16);
|
1998-05-25 12:58:26 +00:00
|
|
|
discard_queue(&st->l2.i_queue);
|
|
|
|
discard_queue(&st->l2.ui_queue);
|
1997-04-06 22:59:59 +00:00
|
|
|
ReleaseWin(&st->l2);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-11-15 23:55:28 +00:00
|
|
|
l2m_debug(struct FsmInst *fi, char *fmt, ...)
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
1998-11-15 23:55:28 +00:00
|
|
|
va_list args;
|
1997-02-09 00:29:11 +00:00
|
|
|
struct PStack *st = fi->userdata;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
1998-11-15 23:55:28 +00:00
|
|
|
va_start(args, fmt);
|
|
|
|
VHiSax_putstatus(st->l1.hardware, st->l2.debug_id, fmt, args);
|
|
|
|
va_end(args);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
setstack_isdnl2(struct PStack *st, char *debug_id)
|
|
|
|
{
|
|
|
|
st->l1.l1l2 = isdnl2_l1l2;
|
|
|
|
st->l3.l3l2 = isdnl2_l3l2;
|
|
|
|
|
1997-04-06 22:59:59 +00:00
|
|
|
skb_queue_head_init(&st->l2.i_queue);
|
1997-06-26 11:07:29 +00:00
|
|
|
skb_queue_head_init(&st->l2.ui_queue);
|
1997-04-06 22:59:59 +00:00
|
|
|
InitWin(&st->l2);
|
1997-02-09 00:29:11 +00:00
|
|
|
st->l2.debug = 0;
|
1996-10-13 20:04:59 +00:00
|
|
|
|
|
|
|
st->l2.l2m.fsm = &l2fsm;
|
1998-06-18 23:17:20 +00:00
|
|
|
if (test_bit(FLG_LAPB, &st->l2.flag))
|
1998-05-25 14:10:20 +00:00
|
|
|
st->l2.l2m.state = ST_L2_4;
|
|
|
|
else
|
1996-10-13 20:04:59 +00:00
|
|
|
st->l2.l2m.state = ST_L2_1;
|
|
|
|
st->l2.l2m.debug = 0;
|
|
|
|
st->l2.l2m.userdata = st;
|
1996-12-08 19:51:51 +00:00
|
|
|
st->l2.l2m.userint = 0;
|
1996-10-13 20:04:59 +00:00
|
|
|
st->l2.l2m.printdebug = l2m_debug;
|
|
|
|
strcpy(st->l2.debug_id, debug_id);
|
|
|
|
|
1997-07-27 21:34:38 +00:00
|
|
|
FsmInitTimer(&st->l2.l2m, &st->l2.t200);
|
|
|
|
FsmInitTimer(&st->l2.l2m, &st->l2.t203);
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
1998-05-25 12:58:26 +00:00
|
|
|
static void
|
|
|
|
transl2_l3l2(struct PStack *st, int pr, void *arg)
|
|
|
|
{
|
|
|
|
switch (pr) {
|
|
|
|
case (DL_DATA | REQUEST):
|
|
|
|
case (DL_UNIT_DATA | REQUEST):
|
1998-08-13 23:36:54 +00:00
|
|
|
st->l2.l2l1(st, PH_DATA | REQUEST, arg);
|
1998-05-25 12:58:26 +00:00
|
|
|
break;
|
|
|
|
case (DL_ESTABLISH | REQUEST):
|
1998-08-13 23:36:54 +00:00
|
|
|
st->l2.l2l1(st, PH_ACTIVATE | REQUEST, NULL);
|
1998-05-25 12:58:26 +00:00
|
|
|
break;
|
|
|
|
case (DL_RELEASE | REQUEST):
|
1998-08-13 23:36:54 +00:00
|
|
|
st->l2.l2l1(st, PH_DEACTIVATE | REQUEST, NULL);
|
1998-05-25 12:58:26 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-10-13 20:04:59 +00:00
|
|
|
void
|
|
|
|
setstack_transl2(struct PStack *st)
|
|
|
|
{
|
1998-05-25 12:58:26 +00:00
|
|
|
st->l3.l3l2 = transl2_l3l2;
|
1996-10-13 20:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
releasestack_transl2(struct PStack *st)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1997-11-06 17:13:35 +00:00
|
|
|
HISAX_INITFUNC(void
|
|
|
|
Isdnl2New(void))
|
1996-10-13 20:04:59 +00:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|