11da177e4SLinus Torvalds #ifndef LLC_C_EV_H
21da177e4SLinus Torvalds #define LLC_C_EV_H
31da177e4SLinus Torvalds /*
41da177e4SLinus Torvalds * Copyright (c) 1997 by Procom Technology,Inc.
51da177e4SLinus Torvalds * 2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
61da177e4SLinus Torvalds *
71da177e4SLinus Torvalds * This program can be redistributed or modified under the terms of the
81da177e4SLinus Torvalds * GNU General Public License as published by the Free Software Foundation.
91da177e4SLinus Torvalds * This program is distributed without any warranty or implied warranty
101da177e4SLinus Torvalds * of merchantability or fitness for a particular purpose.
111da177e4SLinus Torvalds *
121da177e4SLinus Torvalds * See the GNU General Public License for more details.
131da177e4SLinus Torvalds */
141da177e4SLinus Torvalds
151da177e4SLinus Torvalds #include <net/sock.h>
161da177e4SLinus Torvalds
171da177e4SLinus Torvalds /* Connection component state transition event qualifiers */
181da177e4SLinus Torvalds /* Types of events (possible values in 'ev->type') */
191da177e4SLinus Torvalds #define LLC_CONN_EV_TYPE_SIMPLE 1
201da177e4SLinus Torvalds #define LLC_CONN_EV_TYPE_CONDITION 2
211da177e4SLinus Torvalds #define LLC_CONN_EV_TYPE_PRIM 3
221da177e4SLinus Torvalds #define LLC_CONN_EV_TYPE_PDU 4 /* command/response PDU */
231da177e4SLinus Torvalds #define LLC_CONN_EV_TYPE_ACK_TMR 5
241da177e4SLinus Torvalds #define LLC_CONN_EV_TYPE_P_TMR 6
251da177e4SLinus Torvalds #define LLC_CONN_EV_TYPE_REJ_TMR 7
261da177e4SLinus Torvalds #define LLC_CONN_EV_TYPE_BUSY_TMR 8
271da177e4SLinus Torvalds #define LLC_CONN_EV_TYPE_RPT_STATUS 9
281da177e4SLinus Torvalds #define LLC_CONN_EV_TYPE_SENDACK_TMR 10
291da177e4SLinus Torvalds
301da177e4SLinus Torvalds #define NBR_CONN_EV 5
311da177e4SLinus Torvalds /* Connection events which cause state transitions when fully qualified */
321da177e4SLinus Torvalds
331da177e4SLinus Torvalds #define LLC_CONN_EV_CONN_REQ 1
341da177e4SLinus Torvalds #define LLC_CONN_EV_CONN_RESP 2
351da177e4SLinus Torvalds #define LLC_CONN_EV_DATA_REQ 3
361da177e4SLinus Torvalds #define LLC_CONN_EV_DISC_REQ 4
371da177e4SLinus Torvalds #define LLC_CONN_EV_RESET_REQ 5
381da177e4SLinus Torvalds #define LLC_CONN_EV_RESET_RESP 6
391da177e4SLinus Torvalds #define LLC_CONN_EV_LOCAL_BUSY_DETECTED 7
401da177e4SLinus Torvalds #define LLC_CONN_EV_LOCAL_BUSY_CLEARED 8
411da177e4SLinus Torvalds #define LLC_CONN_EV_RX_BAD_PDU 9
421da177e4SLinus Torvalds #define LLC_CONN_EV_RX_DISC_CMD_Pbit_SET_X 10
431da177e4SLinus Torvalds #define LLC_CONN_EV_RX_DM_RSP_Fbit_SET_X 11
441da177e4SLinus Torvalds #define LLC_CONN_EV_RX_FRMR_RSP_Fbit_SET_X 12
451da177e4SLinus Torvalds #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_X 13
461da177e4SLinus Torvalds #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_X_UNEXPD_Ns 14
471da177e4SLinus Torvalds #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_X_INVAL_Ns 15
481da177e4SLinus Torvalds #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_X 16
491da177e4SLinus Torvalds #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_X_UNEXPD_Ns 17
501da177e4SLinus Torvalds #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_X_INVAL_Ns 18
511da177e4SLinus Torvalds #define LLC_CONN_EV_RX_REJ_CMD_Pbit_SET_X 19
521da177e4SLinus Torvalds #define LLC_CONN_EV_RX_REJ_RSP_Fbit_SET_X 20
531da177e4SLinus Torvalds #define LLC_CONN_EV_RX_RNR_CMD_Pbit_SET_X 21
541da177e4SLinus Torvalds #define LLC_CONN_EV_RX_RNR_RSP_Fbit_SET_X 22
551da177e4SLinus Torvalds #define LLC_CONN_EV_RX_RR_CMD_Pbit_SET_X 23
561da177e4SLinus Torvalds #define LLC_CONN_EV_RX_RR_RSP_Fbit_SET_X 24
571da177e4SLinus Torvalds #define LLC_CONN_EV_RX_SABME_CMD_Pbit_SET_X 25
581da177e4SLinus Torvalds #define LLC_CONN_EV_RX_UA_RSP_Fbit_SET_X 26
591da177e4SLinus Torvalds #define LLC_CONN_EV_RX_XXX_CMD_Pbit_SET_X 27
601da177e4SLinus Torvalds #define LLC_CONN_EV_RX_XXX_RSP_Fbit_SET_X 28
611da177e4SLinus Torvalds #define LLC_CONN_EV_RX_XXX_YYY 29
621da177e4SLinus Torvalds #define LLC_CONN_EV_RX_ZZZ_CMD_Pbit_SET_X_INVAL_Nr 30
631da177e4SLinus Torvalds #define LLC_CONN_EV_RX_ZZZ_RSP_Fbit_SET_X_INVAL_Nr 31
641da177e4SLinus Torvalds #define LLC_CONN_EV_P_TMR_EXP 32
651da177e4SLinus Torvalds #define LLC_CONN_EV_ACK_TMR_EXP 33
661da177e4SLinus Torvalds #define LLC_CONN_EV_REJ_TMR_EXP 34
671da177e4SLinus Torvalds #define LLC_CONN_EV_BUSY_TMR_EXP 35
681da177e4SLinus Torvalds #define LLC_CONN_EV_RX_XXX_CMD_Pbit_SET_1 36
691da177e4SLinus Torvalds #define LLC_CONN_EV_RX_XXX_CMD_Pbit_SET_0 37
701da177e4SLinus Torvalds #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_0_UNEXPD_Ns 38
711da177e4SLinus Torvalds #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_0_UNEXPD_Ns 39
721da177e4SLinus Torvalds #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_1_UNEXPD_Ns 40
731da177e4SLinus Torvalds #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_1_UNEXPD_Ns 41
741da177e4SLinus Torvalds #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_0 42
751da177e4SLinus Torvalds #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_0 43
761da177e4SLinus Torvalds #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_1 44
771da177e4SLinus Torvalds #define LLC_CONN_EV_RX_RR_CMD_Pbit_SET_0 45
781da177e4SLinus Torvalds #define LLC_CONN_EV_RX_RR_RSP_Fbit_SET_0 46
791da177e4SLinus Torvalds #define LLC_CONN_EV_RX_RR_RSP_Fbit_SET_1 47
801da177e4SLinus Torvalds #define LLC_CONN_EV_RX_RR_CMD_Pbit_SET_1 48
811da177e4SLinus Torvalds #define LLC_CONN_EV_RX_RNR_CMD_Pbit_SET_0 49
821da177e4SLinus Torvalds #define LLC_CONN_EV_RX_RNR_RSP_Fbit_SET_0 50
831da177e4SLinus Torvalds #define LLC_CONN_EV_RX_RNR_RSP_Fbit_SET_1 51
841da177e4SLinus Torvalds #define LLC_CONN_EV_RX_RNR_CMD_Pbit_SET_1 52
851da177e4SLinus Torvalds #define LLC_CONN_EV_RX_REJ_CMD_Pbit_SET_0 53
861da177e4SLinus Torvalds #define LLC_CONN_EV_RX_REJ_RSP_Fbit_SET_0 54
871da177e4SLinus Torvalds #define LLC_CONN_EV_RX_REJ_CMD_Pbit_SET_1 55
881da177e4SLinus Torvalds #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_1 56
891da177e4SLinus Torvalds #define LLC_CONN_EV_RX_REJ_RSP_Fbit_SET_1 57
901da177e4SLinus Torvalds #define LLC_CONN_EV_RX_XXX_RSP_Fbit_SET_1 58
911da177e4SLinus Torvalds #define LLC_CONN_EV_TX_BUFF_FULL 59
921da177e4SLinus Torvalds
931da177e4SLinus Torvalds #define LLC_CONN_EV_INIT_P_F_CYCLE 100
941da177e4SLinus Torvalds /*
951da177e4SLinus Torvalds * Connection event qualifiers; for some events a certain combination of
961da177e4SLinus Torvalds * these qualifiers must be TRUE before event recognized valid for state;
971da177e4SLinus Torvalds * these constants act as indexes into the Event Qualifier function
981da177e4SLinus Torvalds * table
991da177e4SLinus Torvalds */
1001da177e4SLinus Torvalds #define LLC_CONN_EV_QFY_DATA_FLAG_EQ_1 1
1011da177e4SLinus Torvalds #define LLC_CONN_EV_QFY_DATA_FLAG_EQ_0 2
1021da177e4SLinus Torvalds #define LLC_CONN_EV_QFY_DATA_FLAG_EQ_2 3
1031da177e4SLinus Torvalds #define LLC_CONN_EV_QFY_P_FLAG_EQ_1 4
1041da177e4SLinus Torvalds #define LLC_CONN_EV_QFY_P_FLAG_EQ_0 5
1051da177e4SLinus Torvalds #define LLC_CONN_EV_QFY_P_FLAG_EQ_Fbit 6
1061da177e4SLinus Torvalds #define LLC_CONN_EV_QFY_REMOTE_BUSY_EQ_0 7
1071da177e4SLinus Torvalds #define LLC_CONN_EV_QFY_RETRY_CNT_LT_N2 8
1081da177e4SLinus Torvalds #define LLC_CONN_EV_QFY_RETRY_CNT_GTE_N2 9
1091da177e4SLinus Torvalds #define LLC_CONN_EV_QFY_S_FLAG_EQ_1 10
1101da177e4SLinus Torvalds #define LLC_CONN_EV_QFY_S_FLAG_EQ_0 11
1111da177e4SLinus Torvalds #define LLC_CONN_EV_QFY_INIT_P_F_CYCLE 12
1121da177e4SLinus Torvalds
1131da177e4SLinus Torvalds struct llc_conn_state_ev {
1141da177e4SLinus Torvalds u8 type;
1151da177e4SLinus Torvalds u8 prim;
1161da177e4SLinus Torvalds u8 prim_type;
1171da177e4SLinus Torvalds u8 reason;
1181da177e4SLinus Torvalds u8 status;
1191da177e4SLinus Torvalds u8 ind_prim;
1201da177e4SLinus Torvalds u8 cfm_prim;
1211da177e4SLinus Torvalds };
1221da177e4SLinus Torvalds
llc_conn_ev(struct sk_buff * skb)1231da177e4SLinus Torvalds static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
1241da177e4SLinus Torvalds {
1251da177e4SLinus Torvalds return (struct llc_conn_state_ev *)skb->cb;
1261da177e4SLinus Torvalds }
1271da177e4SLinus Torvalds
1281da177e4SLinus Torvalds typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
1291da177e4SLinus Torvalds typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
1301da177e4SLinus Torvalds
131*bf3c710fSJoe Perches int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
132*bf3c710fSJoe Perches int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
133*bf3c710fSJoe Perches int llc_conn_ev_disc_req(struct sock *sk, struct sk_buff *skb);
134*bf3c710fSJoe Perches int llc_conn_ev_rst_req(struct sock *sk, struct sk_buff *skb);
135*bf3c710fSJoe Perches int llc_conn_ev_local_busy_detected(struct sock *sk, struct sk_buff *skb);
136*bf3c710fSJoe Perches int llc_conn_ev_local_busy_cleared(struct sock *sk, struct sk_buff *skb);
137*bf3c710fSJoe Perches int llc_conn_ev_rx_bad_pdu(struct sock *sk, struct sk_buff *skb);
138*bf3c710fSJoe Perches int llc_conn_ev_rx_disc_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb);
139*bf3c710fSJoe Perches int llc_conn_ev_rx_dm_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb);
140*bf3c710fSJoe Perches int llc_conn_ev_rx_frmr_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb);
141*bf3c710fSJoe Perches int llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns(struct sock *sk,
1421da177e4SLinus Torvalds struct sk_buff *skb);
143*bf3c710fSJoe Perches int llc_conn_ev_rx_i_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb);
144*bf3c710fSJoe Perches int llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns(struct sock *sk,
1451da177e4SLinus Torvalds struct sk_buff *skb);
146*bf3c710fSJoe Perches int llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns(struct sock *sk,
1471da177e4SLinus Torvalds struct sk_buff *skb);
148*bf3c710fSJoe Perches int llc_conn_ev_rx_rej_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb);
149*bf3c710fSJoe Perches int llc_conn_ev_rx_sabme_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb);
150*bf3c710fSJoe Perches int llc_conn_ev_rx_ua_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb);
151*bf3c710fSJoe Perches int llc_conn_ev_rx_xxx_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb);
152*bf3c710fSJoe Perches int llc_conn_ev_rx_xxx_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb);
153*bf3c710fSJoe Perches int llc_conn_ev_rx_zzz_cmd_pbit_set_x_inval_nr(struct sock *sk,
1541da177e4SLinus Torvalds struct sk_buff *skb);
155*bf3c710fSJoe Perches int llc_conn_ev_rx_zzz_rsp_fbit_set_x_inval_nr(struct sock *sk,
1561da177e4SLinus Torvalds struct sk_buff *skb);
157*bf3c710fSJoe Perches int llc_conn_ev_p_tmr_exp(struct sock *sk, struct sk_buff *skb);
158*bf3c710fSJoe Perches int llc_conn_ev_ack_tmr_exp(struct sock *sk, struct sk_buff *skb);
159*bf3c710fSJoe Perches int llc_conn_ev_rej_tmr_exp(struct sock *sk, struct sk_buff *skb);
160*bf3c710fSJoe Perches int llc_conn_ev_busy_tmr_exp(struct sock *sk, struct sk_buff *skb);
1611da177e4SLinus Torvalds /* NOT_USED functions and their variations */
162*bf3c710fSJoe Perches int llc_conn_ev_rx_xxx_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb);
163*bf3c710fSJoe Perches int llc_conn_ev_rx_xxx_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb);
164*bf3c710fSJoe Perches int llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns(struct sock *sk,
1651da177e4SLinus Torvalds struct sk_buff *skb);
166*bf3c710fSJoe Perches int llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns(struct sock *sk,
1671da177e4SLinus Torvalds struct sk_buff *skb);
168*bf3c710fSJoe Perches int llc_conn_ev_rx_i_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb);
169*bf3c710fSJoe Perches int llc_conn_ev_rx_i_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb);
170*bf3c710fSJoe Perches int llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns(struct sock *sk,
1711da177e4SLinus Torvalds struct sk_buff *skb);
172*bf3c710fSJoe Perches int llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns(struct sock *sk,
1731da177e4SLinus Torvalds struct sk_buff *skb);
174*bf3c710fSJoe Perches int llc_conn_ev_rx_i_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb);
175*bf3c710fSJoe Perches int llc_conn_ev_rx_i_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb);
176*bf3c710fSJoe Perches int llc_conn_ev_rx_rr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb);
177*bf3c710fSJoe Perches int llc_conn_ev_rx_rr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb);
178*bf3c710fSJoe Perches int llc_conn_ev_rx_rr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb);
179*bf3c710fSJoe Perches int llc_conn_ev_rx_rr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb);
180*bf3c710fSJoe Perches int llc_conn_ev_rx_rnr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb);
181*bf3c710fSJoe Perches int llc_conn_ev_rx_rnr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb);
182*bf3c710fSJoe Perches int llc_conn_ev_rx_rnr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb);
183*bf3c710fSJoe Perches int llc_conn_ev_rx_rnr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb);
184*bf3c710fSJoe Perches int llc_conn_ev_rx_rej_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb);
185*bf3c710fSJoe Perches int llc_conn_ev_rx_rej_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb);
186*bf3c710fSJoe Perches int llc_conn_ev_rx_rej_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb);
187*bf3c710fSJoe Perches int llc_conn_ev_rx_rej_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb);
188*bf3c710fSJoe Perches int llc_conn_ev_rx_any_frame(struct sock *sk, struct sk_buff *skb);
189*bf3c710fSJoe Perches int llc_conn_ev_tx_buffer_full(struct sock *sk, struct sk_buff *skb);
190*bf3c710fSJoe Perches int llc_conn_ev_init_p_f_cycle(struct sock *sk, struct sk_buff *skb);
1911da177e4SLinus Torvalds
1921da177e4SLinus Torvalds /* Available connection action qualifiers */
193*bf3c710fSJoe Perches int llc_conn_ev_qlfy_data_flag_eq_1(struct sock *sk, struct sk_buff *skb);
194*bf3c710fSJoe Perches int llc_conn_ev_qlfy_data_flag_eq_0(struct sock *sk, struct sk_buff *skb);
195*bf3c710fSJoe Perches int llc_conn_ev_qlfy_data_flag_eq_2(struct sock *sk, struct sk_buff *skb);
196*bf3c710fSJoe Perches int llc_conn_ev_qlfy_p_flag_eq_1(struct sock *sk, struct sk_buff *skb);
197*bf3c710fSJoe Perches int llc_conn_ev_qlfy_last_frame_eq_1(struct sock *sk, struct sk_buff *skb);
198*bf3c710fSJoe Perches int llc_conn_ev_qlfy_last_frame_eq_0(struct sock *sk, struct sk_buff *skb);
199*bf3c710fSJoe Perches int llc_conn_ev_qlfy_p_flag_eq_0(struct sock *sk, struct sk_buff *skb);
200*bf3c710fSJoe Perches int llc_conn_ev_qlfy_p_flag_eq_f(struct sock *sk, struct sk_buff *skb);
201*bf3c710fSJoe Perches int llc_conn_ev_qlfy_remote_busy_eq_0(struct sock *sk, struct sk_buff *skb);
202*bf3c710fSJoe Perches int llc_conn_ev_qlfy_remote_busy_eq_1(struct sock *sk, struct sk_buff *skb);
203*bf3c710fSJoe Perches int llc_conn_ev_qlfy_retry_cnt_lt_n2(struct sock *sk, struct sk_buff *skb);
204*bf3c710fSJoe Perches int llc_conn_ev_qlfy_retry_cnt_gte_n2(struct sock *sk, struct sk_buff *skb);
205*bf3c710fSJoe Perches int llc_conn_ev_qlfy_s_flag_eq_1(struct sock *sk, struct sk_buff *skb);
206*bf3c710fSJoe Perches int llc_conn_ev_qlfy_s_flag_eq_0(struct sock *sk, struct sk_buff *skb);
207*bf3c710fSJoe Perches int llc_conn_ev_qlfy_cause_flag_eq_1(struct sock *sk, struct sk_buff *skb);
208*bf3c710fSJoe Perches int llc_conn_ev_qlfy_cause_flag_eq_0(struct sock *sk, struct sk_buff *skb);
209*bf3c710fSJoe Perches int llc_conn_ev_qlfy_set_status_conn(struct sock *sk, struct sk_buff *skb);
210*bf3c710fSJoe Perches int llc_conn_ev_qlfy_set_status_disc(struct sock *sk, struct sk_buff *skb);
211*bf3c710fSJoe Perches int llc_conn_ev_qlfy_set_status_failed(struct sock *sk, struct sk_buff *skb);
212*bf3c710fSJoe Perches int llc_conn_ev_qlfy_set_status_remote_busy(struct sock *sk,
2131da177e4SLinus Torvalds struct sk_buff *skb);
214*bf3c710fSJoe Perches int llc_conn_ev_qlfy_set_status_refuse(struct sock *sk, struct sk_buff *skb);
215*bf3c710fSJoe Perches int llc_conn_ev_qlfy_set_status_conflict(struct sock *sk, struct sk_buff *skb);
216*bf3c710fSJoe Perches int llc_conn_ev_qlfy_set_status_rst_done(struct sock *sk, struct sk_buff *skb);
2171da177e4SLinus Torvalds
llc_conn_space(struct sock * sk,struct sk_buff * skb)2181da177e4SLinus Torvalds static __inline__ int llc_conn_space(struct sock *sk, struct sk_buff *skb)
2191da177e4SLinus Torvalds {
2201da177e4SLinus Torvalds return atomic_read(&sk->sk_rmem_alloc) + skb->truesize <
22195c96174SEric Dumazet (unsigned int)sk->sk_rcvbuf;
2221da177e4SLinus Torvalds }
2231da177e4SLinus Torvalds #endif /* LLC_C_EV_H */
224