xref: /linux/drivers/isdn/mISDN/layer2.h (revision a4eb44a6435d6d8f9e642407a4a06f65eb90ca04)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Layer 2 defines
4  *
5  * Copyright 2008  by Karsten Keil <kkeil@novell.com>
6  */
7 
8 #include <linux/mISDNif.h>
9 #include <linux/skbuff.h>
10 #include "fsm.h"
11 
12 #define MAX_WINDOW	8
13 
14 struct manager {
15 	struct mISDNchannel	ch;
16 	struct mISDNchannel	bcast;
17 	u_long			options;
18 	struct list_head	layer2;
19 	rwlock_t		lock;
20 	struct FsmInst		deact;
21 	struct FsmTimer		datimer;
22 	struct sk_buff_head	sendq;
23 	struct mISDNchannel	*up;
24 	u_int			nextid;
25 	u_int			lastid;
26 };
27 
28 struct teimgr {
29 	int			ri;
30 	int			rcnt;
31 	struct FsmInst		tei_m;
32 	struct FsmTimer		timer;
33 	int			tval, nval;
34 	struct layer2		*l2;
35 	struct manager		*mgr;
36 };
37 
38 struct laddr {
39 	u_char	A;
40 	u_char	B;
41 };
42 
43 struct layer2 {
44 	struct list_head	list;
45 	struct mISDNchannel	ch;
46 	u_long			flag;
47 	int			id;
48 	struct mISDNchannel	*up;
49 	signed char		sapi;
50 	signed char		tei;
51 	struct laddr		addr;
52 	u_int			maxlen;
53 	struct teimgr		*tm;
54 	u_int			vs, va, vr;
55 	int			rc;
56 	u_int			window;
57 	u_int			sow;
58 	struct FsmInst		l2m;
59 	struct FsmTimer		t200, t203;
60 	int			T200, N200, T203;
61 	u_int			next_id;
62 	u_int			down_id;
63 	struct sk_buff		*windowar[MAX_WINDOW];
64 	struct sk_buff_head	i_queue;
65 	struct sk_buff_head	ui_queue;
66 	struct sk_buff_head	down_queue;
67 	struct sk_buff_head	tmp_queue;
68 };
69 
70 enum {
71 	ST_L2_1,
72 	ST_L2_2,
73 	ST_L2_3,
74 	ST_L2_4,
75 	ST_L2_5,
76 	ST_L2_6,
77 	ST_L2_7,
78 	ST_L2_8,
79 };
80 
81 #define L2_STATE_COUNT (ST_L2_8 + 1)
82 
83 extern struct layer2	*create_l2(struct mISDNchannel *, u_int,
84 				   u_long, int, int);
85 extern int		tei_l2(struct layer2 *, u_int, u_long arg);
86 
87 
88 /* from tei.c */
89 extern int		l2_tei(struct layer2 *, u_int, u_long arg);
90 extern void		TEIrelease(struct layer2 *);
91 extern int		TEIInit(u_int *);
92 extern void		TEIFree(void);
93 
94 #define MAX_L2HEADER_LEN 4
95 
96 #define RR	0x01
97 #define RNR	0x05
98 #define REJ	0x09
99 #define SABME	0x6f
100 #define SABM	0x2f
101 #define DM	0x0f
102 #define UI	0x03
103 #define DISC	0x43
104 #define UA	0x63
105 #define FRMR	0x87
106 #define XID	0xaf
107 
108 #define CMD	0
109 #define RSP	1
110 
111 #define LC_FLUSH_WAIT 1
112 
113 #define FLG_LAPB	0
114 #define FLG_LAPD	1
115 #define FLG_ORIG	2
116 #define FLG_MOD128	3
117 #define FLG_PEND_REL	4
118 #define FLG_L3_INIT	5
119 #define FLG_T200_RUN	6
120 #define FLG_ACK_PEND	7
121 #define FLG_REJEXC	8
122 #define FLG_OWN_BUSY	9
123 #define FLG_PEER_BUSY	10
124 #define FLG_DCHAN_BUSY	11
125 #define FLG_L1_ACTIV	12
126 #define FLG_ESTAB_PEND	13
127 #define FLG_PTP		14
128 #define FLG_FIXED_TEI	15
129 #define FLG_L2BLOCK	16
130 #define FLG_L1_NOTREADY	17
131 #define FLG_LAPD_NET	18
132