layer2.h revision 475be4d85a274d0961593db41cf85689db1d583c
11b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil/* 21b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil * Layer 2 defines 31b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil * 41b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil * Copyright 2008 by Karsten Keil <kkeil@novell.com> 51b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil * 61b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil * This program is free software; you can redistribute it and/or modify 71b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil * it under the terms of the GNU General Public License version 2 as 81b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil * published by the Free Software Foundation. 91b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil * 101b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil * This program is distributed in the hope that it will be useful, 111b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil * but WITHOUT ANY WARRANTY; without even the implied warranty of 121b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 131b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil * GNU General Public License for more details. 141b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil * 151b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil */ 161b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil 171b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#include <linux/mISDNif.h> 181b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#include <linux/skbuff.h> 191b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#include "fsm.h" 201b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil 211b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define MAX_WINDOW 8 221b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil 231b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keilstruct manager { 241b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct mISDNchannel ch; 251b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct mISDNchannel bcast; 261b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil u_long options; 271b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct list_head layer2; 281b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil rwlock_t lock; 291b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct FsmInst deact; 301b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct FsmTimer datimer; 311b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct sk_buff_head sendq; 321b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct mISDNchannel *up; 331b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil u_int nextid; 341b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil u_int lastid; 351b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil}; 361b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil 371b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keilstruct teimgr { 381b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil int ri; 391b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil int rcnt; 401b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct FsmInst tei_m; 411b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct FsmTimer timer; 421b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil int tval, nval; 431b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct layer2 *l2; 441b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct manager *mgr; 451b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil}; 461b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil 471b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keilstruct laddr { 481b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil u_char A; 491b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil u_char B; 501b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil}; 511b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil 521b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keilstruct layer2 { 531b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct list_head list; 541b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct mISDNchannel ch; 551b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil u_long flag; 561b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil int id; 571b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct mISDNchannel *up; 581b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil signed char sapi; 591b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil signed char tei; 601b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct laddr addr; 611b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil u_int maxlen; 621b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct teimgr *tm; 631b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil u_int vs, va, vr; 641b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil int rc; 651b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil u_int window; 661b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil u_int sow; 671b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct FsmInst l2m; 681b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct FsmTimer t200, t203; 691b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil int T200, N200, T203; 701b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil u_int next_id; 711b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil u_int down_id; 721b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct sk_buff *windowar[MAX_WINDOW]; 731b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct sk_buff_head i_queue; 741b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct sk_buff_head ui_queue; 751b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct sk_buff_head down_queue; 761b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil struct sk_buff_head tmp_queue; 771b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil}; 781b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil 791b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keilenum { 801b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil ST_L2_1, 811b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil ST_L2_2, 821b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil ST_L2_3, 831b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil ST_L2_4, 841b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil ST_L2_5, 851b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil ST_L2_6, 861b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil ST_L2_7, 871b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil ST_L2_8, 881b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil}; 891b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil 90475be4d85a274d0961593db41cf85689db1d583cJoe Perches#define L2_STATE_COUNT (ST_L2_8 + 1) 911b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil 921b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keilextern struct layer2 *create_l2(struct mISDNchannel *, u_int, 93475be4d85a274d0961593db41cf85689db1d583cJoe Perches u_long, int, int); 941b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keilextern int tei_l2(struct layer2 *, u_int, u_long arg); 951b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil 961b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil 971b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil/* from tei.c */ 98475be4d85a274d0961593db41cf85689db1d583cJoe Perchesextern int l2_tei(struct layer2 *, u_int, u_long arg); 99475be4d85a274d0961593db41cf85689db1d583cJoe Perchesextern void TEIrelease(struct layer2 *); 100475be4d85a274d0961593db41cf85689db1d583cJoe Perchesextern int TEIInit(u_int *); 101475be4d85a274d0961593db41cf85689db1d583cJoe Perchesextern void TEIFree(void); 1021b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil 1031b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define MAX_L2HEADER_LEN 4 1041b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil 1051b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define RR 0x01 1061b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define RNR 0x05 1071b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define REJ 0x09 1081b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define SABME 0x6f 1091b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define SABM 0x2f 1101b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define DM 0x0f 1111b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define UI 0x03 1121b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define DISC 0x43 1131b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define UA 0x63 1141b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FRMR 0x87 1151b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define XID 0xaf 1161b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil 1171b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define CMD 0 1181b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define RSP 1 1191b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil 1201b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define LC_FLUSH_WAIT 1 1211b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil 1221b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FLG_LAPB 0 1231b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FLG_LAPD 1 1241b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FLG_ORIG 2 1251b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FLG_MOD128 3 1261b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FLG_PEND_REL 4 1271b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FLG_L3_INIT 5 1281b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FLG_T200_RUN 6 1291b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FLG_ACK_PEND 7 1301b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FLG_REJEXC 8 1311b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FLG_OWN_BUSY 9 1321b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FLG_PEER_BUSY 10 1331b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FLG_DCHAN_BUSY 11 1341b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FLG_L1_ACTIV 12 1351b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FLG_ESTAB_PEND 13 1361b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FLG_PTP 14 1371b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FLG_FIXED_TEI 15 1381b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FLG_L2BLOCK 16 1391b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FLG_L1_NOTREADY 17 1401b2b03f8e514e4f68e293846ba511a948b80243cKarsten Keil#define FLG_LAPD_NET 18 141