1#include <linux/skbuff.h>
2
3#define LLC_MODULE
4
5typedef struct llc_struct llc;
6typedef struct llc_struct *llcptr;
7
8/*
9 *	LLC private data area structure.
10 */
11
12struct llc_struct
13{
14	char eye[4];			/* To recognize llc area in dump */
15	int retry_count;		/* LLC link state variables */
16	unsigned char name[9];		/* name of this llc instance */
17	unsigned char s_flag;
18	unsigned char p_flag;
19	unsigned char f_flag;
20	unsigned char data_flag;
21	unsigned char cause_flag;
22	unsigned char vs;		/* Send state variable */
23	unsigned char vr;		/* Receive state variable */
24	unsigned char remote_busy;
25	unsigned char state;		/* Current state of type2 llc procedure */
26	int n1;				/* Maximum number of bytes in I pdu 7.8.2 */
27	int n2;				/* Naximum number of retransmissions 7.8.2 */
28	unsigned char k;		/* Transmit window size 7.8.4, tw in IBM doc*/
29	unsigned char rw;		/* Receive window size */
30	struct
31	{
32		/*
33		 *	FRMR_RSP info field structure: 5.4.2.3.5 p55
34		 */
35
36		unsigned char cntl1;
37		unsigned char cntl2;
38		unsigned char vs;
39		unsigned char vr_cr;
40		unsigned char xxyz;
41	} frmr_info_fld;
42
43	/*
44	 *	Timers in 7.8.1 page 78
45	 */
46
47#define P_TIMER         0
48#define REJ_TIMER       1
49#define ACK_TIMER       2
50#define BUSY_TIMER      3
51	unsigned long timer_expire_time[4];
52	unsigned char timer_state[4];	/* The state of each timer */
53#define TIMER_IDLE      0
54#define TIMER_RUNNING   1
55#define TIMER_EXPIRED   2
56	unsigned long timer_interval[4];
57	struct timer_list tl[4];
58
59	/*
60	 *	Client entry point, called by the LLC.
61	 */
62
63	void	(*llc_event)(struct llc_struct *);
64
65	/*
66	 *	Mux and Demux variables
67	 */
68
69	char * client_data;		/* Pointer to clients context */
70	unsigned char local_sap;
71	unsigned char remote_sap ;
72	char remote_mac[MAX_ADDR_LEN];  /* MAC address of remote session partner */
73	struct net_device *dev;		/* Device we are attached to */
74
75	unsigned char llc_mode;		/* See doc 7.1 on p70 */
76#define MODE_ADM 1
77#define MODE_ABM 2
78
79	int llc_callbacks;		/* Pending callbacks */
80#define LLC_CONN_INDICATION	1	/* We have to ensure the names don't */
81#define LLC_CONN_CONFIRM	2	/* mix up with the 802 state table */
82#define LLC_DATA_INDIC		4
83#define LLC_DISC_INDICATION	8
84#define LLC_RESET_INDIC_LOC	16
85#define LLC_RESET_INDIC_REM	32
86#define LLC_RST_CONFIRM		64
87#define LLC_FRMR_RECV		128
88#define LLC_FRMR_SENT		256
89#define LLC_REMOTE_BUSY		512
90#define LLC_REMOTE_NOTBUSY	1024
91#define LLC_TEST_INDICATION	2048
92#define LLC_XID_INDICATION	4096
93#define LLC_UI_DATA		8192
94
95	struct sk_buff *inc_skb;	/* Saved data buffer for indications */
96
97	struct sk_buff_head rtq;	/* Retransmit queue */
98	struct sk_buff_head atq;	/* Await transit queue */
99
100	unsigned char xid_count;
101
102	struct llc_struct *nextllc;	/* ptr to next llc struct in proto chain */
103};
104
105#define ADD_TO_RTQ(skb) skb_queue_tail(&lp->rtq,skb)
106#define ADD_TO_ATQ(skb) skb_queue_tail(&lp->atq,skb)
107
108void 		llc_cancel_timers(llcptr lp);
109int		llc_decode_frametype(frameptr fr);
110llcptr 		llc_find(void);
111int		llc_free_acknowledged_skbs(llcptr lp, unsigned char ack);
112void		llc_handle_xid_indication( char *chsp, short int ll, char *xid_data);
113void		llc_interpret_pseudo_code(llcptr lp, int pc_label, struct sk_buff *skb, char type);
114void		llc_add_to_queue(struct sk_buff *skb, struct sk_buff **f, struct sk_buff **b);
115void		llc_process_otype2_frame(llcptr lp, struct sk_buff *skb, char type);
116struct sk_buff *llc_pull_from_atq(llcptr lp);
117int 		llc_resend_ipdu(llcptr lp, unsigned char ack_nr, unsigned char type, char p);
118void 		llc_sendpdu(llcptr lp, char type, char pf, int data_len, char *pdu_data);
119void 		llc_sendipdu(llcptr lp, char type, char pf, struct sk_buff *skb);
120void		llc_start_timer(llcptr lp, int t);
121void		llc_stop_timer(llcptr lp, int t);
122void		llc_timer_expired(llcptr lp, int t);
123int		llc_validate_seq_nos(llcptr lp, frameptr fr);
124
125int		llc_data_request(llcptr lp, struct sk_buff *skb);
126void		llc_unit_data_request(llcptr lp, int ll, char * data);
127void		llc_disconnect_request(llcptr lp);
128void		llc_connect_request(llcptr lp);
129void		llc_xid_request(llcptr lp, char opt, int data_len, char *pdu_data);
130void		llc_test_request(llcptr lp, int data_len, char *pdu_data);
131
132int		register_cl2llc_client(llcptr llc, const char *device, void (*ops)(llcptr), u8 *rmac, u8 ssap, u8 dsap);
133void		unregister_cl2llc_client(llcptr lp);
134int 		llc_mac_data_indicate(llcptr lp, struct sk_buff *skb );
135
136