Back to home page

OSCL-LXR

 
 

    


0001 #ifndef LLC_C_EV_H
0002 #define LLC_C_EV_H
0003 /*
0004  * Copyright (c) 1997 by Procom Technology,Inc.
0005  *       2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
0006  *
0007  * This program can be redistributed or modified under the terms of the
0008  * GNU General Public License as published by the Free Software Foundation.
0009  * This program is distributed without any warranty or implied warranty
0010  * of merchantability or fitness for a particular purpose.
0011  *
0012  * See the GNU General Public License for more details.
0013  */
0014 
0015 #include <net/sock.h>
0016 
0017 /* Connection component state transition event qualifiers */
0018 /* Types of events (possible values in 'ev->type') */
0019 #define LLC_CONN_EV_TYPE_SIMPLE      1
0020 #define LLC_CONN_EV_TYPE_CONDITION   2
0021 #define LLC_CONN_EV_TYPE_PRIM        3
0022 #define LLC_CONN_EV_TYPE_PDU         4  /* command/response PDU */
0023 #define LLC_CONN_EV_TYPE_ACK_TMR     5
0024 #define LLC_CONN_EV_TYPE_P_TMR       6
0025 #define LLC_CONN_EV_TYPE_REJ_TMR     7
0026 #define LLC_CONN_EV_TYPE_BUSY_TMR    8
0027 #define LLC_CONN_EV_TYPE_RPT_STATUS  9
0028 #define LLC_CONN_EV_TYPE_SENDACK_TMR    10
0029 
0030 #define NBR_CONN_EV        5
0031 /* Connection events which cause state transitions when fully qualified */
0032 
0033 #define LLC_CONN_EV_CONN_REQ                 1
0034 #define LLC_CONN_EV_CONN_RESP                2
0035 #define LLC_CONN_EV_DATA_REQ                 3
0036 #define LLC_CONN_EV_DISC_REQ                 4
0037 #define LLC_CONN_EV_RESET_REQ                5
0038 #define LLC_CONN_EV_RESET_RESP               6
0039 #define LLC_CONN_EV_LOCAL_BUSY_DETECTED          7
0040 #define LLC_CONN_EV_LOCAL_BUSY_CLEARED           8
0041 #define LLC_CONN_EV_RX_BAD_PDU               9
0042 #define LLC_CONN_EV_RX_DISC_CMD_Pbit_SET_X      10
0043 #define LLC_CONN_EV_RX_DM_RSP_Fbit_SET_X        11
0044 #define LLC_CONN_EV_RX_FRMR_RSP_Fbit_SET_X      12
0045 #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_X         13
0046 #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_X_UNEXPD_Ns   14
0047 #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_X_INVAL_Ns    15
0048 #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_X         16
0049 #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_X_UNEXPD_Ns   17
0050 #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_X_INVAL_Ns    18
0051 #define LLC_CONN_EV_RX_REJ_CMD_Pbit_SET_X       19
0052 #define LLC_CONN_EV_RX_REJ_RSP_Fbit_SET_X       20
0053 #define LLC_CONN_EV_RX_RNR_CMD_Pbit_SET_X       21
0054 #define LLC_CONN_EV_RX_RNR_RSP_Fbit_SET_X       22
0055 #define LLC_CONN_EV_RX_RR_CMD_Pbit_SET_X        23
0056 #define LLC_CONN_EV_RX_RR_RSP_Fbit_SET_X        24
0057 #define LLC_CONN_EV_RX_SABME_CMD_Pbit_SET_X     25
0058 #define LLC_CONN_EV_RX_UA_RSP_Fbit_SET_X        26
0059 #define LLC_CONN_EV_RX_XXX_CMD_Pbit_SET_X       27
0060 #define LLC_CONN_EV_RX_XXX_RSP_Fbit_SET_X       28
0061 #define LLC_CONN_EV_RX_XXX_YYY              29
0062 #define LLC_CONN_EV_RX_ZZZ_CMD_Pbit_SET_X_INVAL_Nr  30
0063 #define LLC_CONN_EV_RX_ZZZ_RSP_Fbit_SET_X_INVAL_Nr  31
0064 #define LLC_CONN_EV_P_TMR_EXP               32
0065 #define LLC_CONN_EV_ACK_TMR_EXP             33
0066 #define LLC_CONN_EV_REJ_TMR_EXP             34
0067 #define LLC_CONN_EV_BUSY_TMR_EXP            35
0068 #define LLC_CONN_EV_RX_XXX_CMD_Pbit_SET_1       36
0069 #define LLC_CONN_EV_RX_XXX_CMD_Pbit_SET_0       37
0070 #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_0_UNEXPD_Ns   38
0071 #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_0_UNEXPD_Ns   39
0072 #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_1_UNEXPD_Ns   40
0073 #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_1_UNEXPD_Ns   41
0074 #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_0         42
0075 #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_0         43
0076 #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_1         44
0077 #define LLC_CONN_EV_RX_RR_CMD_Pbit_SET_0        45
0078 #define LLC_CONN_EV_RX_RR_RSP_Fbit_SET_0        46
0079 #define LLC_CONN_EV_RX_RR_RSP_Fbit_SET_1        47
0080 #define LLC_CONN_EV_RX_RR_CMD_Pbit_SET_1        48
0081 #define LLC_CONN_EV_RX_RNR_CMD_Pbit_SET_0       49
0082 #define LLC_CONN_EV_RX_RNR_RSP_Fbit_SET_0       50
0083 #define LLC_CONN_EV_RX_RNR_RSP_Fbit_SET_1       51
0084 #define LLC_CONN_EV_RX_RNR_CMD_Pbit_SET_1       52
0085 #define LLC_CONN_EV_RX_REJ_CMD_Pbit_SET_0       53
0086 #define LLC_CONN_EV_RX_REJ_RSP_Fbit_SET_0       54
0087 #define LLC_CONN_EV_RX_REJ_CMD_Pbit_SET_1       55
0088 #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_1         56
0089 #define LLC_CONN_EV_RX_REJ_RSP_Fbit_SET_1       57
0090 #define LLC_CONN_EV_RX_XXX_RSP_Fbit_SET_1       58
0091 #define LLC_CONN_EV_TX_BUFF_FULL            59
0092 
0093 #define LLC_CONN_EV_INIT_P_F_CYCLE          100
0094 /*
0095  * Connection event qualifiers; for some events a certain combination of
0096  * these qualifiers must be TRUE before event recognized valid for state;
0097  * these constants act as indexes into the Event Qualifier function
0098  * table
0099  */
0100 #define LLC_CONN_EV_QFY_DATA_FLAG_EQ_1       1
0101 #define LLC_CONN_EV_QFY_DATA_FLAG_EQ_0       2
0102 #define LLC_CONN_EV_QFY_DATA_FLAG_EQ_2       3
0103 #define LLC_CONN_EV_QFY_P_FLAG_EQ_1      4
0104 #define LLC_CONN_EV_QFY_P_FLAG_EQ_0      5
0105 #define LLC_CONN_EV_QFY_P_FLAG_EQ_Fbit       6
0106 #define LLC_CONN_EV_QFY_REMOTE_BUSY_EQ_0     7
0107 #define LLC_CONN_EV_QFY_RETRY_CNT_LT_N2      8
0108 #define LLC_CONN_EV_QFY_RETRY_CNT_GTE_N2     9
0109 #define LLC_CONN_EV_QFY_S_FLAG_EQ_1     10
0110 #define LLC_CONN_EV_QFY_S_FLAG_EQ_0     11
0111 #define LLC_CONN_EV_QFY_INIT_P_F_CYCLE      12
0112 
0113 struct llc_conn_state_ev {
0114     u8 type;
0115     u8 prim;
0116     u8 prim_type;
0117     u8 reason;
0118     u8 status;
0119     u8 ind_prim;
0120     u8 cfm_prim;
0121 };
0122 
0123 static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
0124 {
0125     return (struct llc_conn_state_ev *)skb->cb;
0126 }
0127 
0128 typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
0129 typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
0130 
0131 int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
0132 int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
0133 int llc_conn_ev_disc_req(struct sock *sk, struct sk_buff *skb);
0134 int llc_conn_ev_rst_req(struct sock *sk, struct sk_buff *skb);
0135 int llc_conn_ev_local_busy_detected(struct sock *sk, struct sk_buff *skb);
0136 int llc_conn_ev_local_busy_cleared(struct sock *sk, struct sk_buff *skb);
0137 int llc_conn_ev_rx_bad_pdu(struct sock *sk, struct sk_buff *skb);
0138 int llc_conn_ev_rx_disc_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb);
0139 int llc_conn_ev_rx_dm_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb);
0140 int llc_conn_ev_rx_frmr_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb);
0141 int llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns(struct sock *sk,
0142                          struct sk_buff *skb);
0143 int llc_conn_ev_rx_i_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb);
0144 int llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns(struct sock *sk,
0145                           struct sk_buff *skb);
0146 int llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns(struct sock *sk,
0147                          struct sk_buff *skb);
0148 int llc_conn_ev_rx_rej_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb);
0149 int llc_conn_ev_rx_sabme_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb);
0150 int llc_conn_ev_rx_ua_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb);
0151 int llc_conn_ev_rx_xxx_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb);
0152 int llc_conn_ev_rx_xxx_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb);
0153 int llc_conn_ev_rx_zzz_cmd_pbit_set_x_inval_nr(struct sock *sk,
0154                            struct sk_buff *skb);
0155 int llc_conn_ev_rx_zzz_rsp_fbit_set_x_inval_nr(struct sock *sk,
0156                            struct sk_buff *skb);
0157 int llc_conn_ev_p_tmr_exp(struct sock *sk, struct sk_buff *skb);
0158 int llc_conn_ev_ack_tmr_exp(struct sock *sk, struct sk_buff *skb);
0159 int llc_conn_ev_rej_tmr_exp(struct sock *sk, struct sk_buff *skb);
0160 int llc_conn_ev_busy_tmr_exp(struct sock *sk, struct sk_buff *skb);
0161 int llc_conn_ev_sendack_tmr_exp(struct sock *sk, struct sk_buff *skb);
0162 /* NOT_USED functions and their variations */
0163 int llc_conn_ev_rx_xxx_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb);
0164 int llc_conn_ev_rx_xxx_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb);
0165 int llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns(struct sock *sk,
0166                           struct sk_buff *skb);
0167 int llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns(struct sock *sk,
0168                           struct sk_buff *skb);
0169 int llc_conn_ev_rx_i_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb);
0170 int llc_conn_ev_rx_i_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb);
0171 int llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns(struct sock *sk,
0172                           struct sk_buff *skb);
0173 int llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns(struct sock *sk,
0174                           struct sk_buff *skb);
0175 int llc_conn_ev_rx_i_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb);
0176 int llc_conn_ev_rx_i_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb);
0177 int llc_conn_ev_rx_rr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb);
0178 int llc_conn_ev_rx_rr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb);
0179 int llc_conn_ev_rx_rr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb);
0180 int llc_conn_ev_rx_rr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb);
0181 int llc_conn_ev_rx_rnr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb);
0182 int llc_conn_ev_rx_rnr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb);
0183 int llc_conn_ev_rx_rnr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb);
0184 int llc_conn_ev_rx_rnr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb);
0185 int llc_conn_ev_rx_rej_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb);
0186 int llc_conn_ev_rx_rej_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb);
0187 int llc_conn_ev_rx_rej_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb);
0188 int llc_conn_ev_rx_rej_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb);
0189 int llc_conn_ev_rx_any_frame(struct sock *sk, struct sk_buff *skb);
0190 int llc_conn_ev_tx_buffer_full(struct sock *sk, struct sk_buff *skb);
0191 int llc_conn_ev_init_p_f_cycle(struct sock *sk, struct sk_buff *skb);
0192 
0193 /* Available connection action qualifiers */
0194 int llc_conn_ev_qlfy_data_flag_eq_1(struct sock *sk, struct sk_buff *skb);
0195 int llc_conn_ev_qlfy_data_flag_eq_0(struct sock *sk, struct sk_buff *skb);
0196 int llc_conn_ev_qlfy_data_flag_eq_2(struct sock *sk, struct sk_buff *skb);
0197 int llc_conn_ev_qlfy_p_flag_eq_1(struct sock *sk, struct sk_buff *skb);
0198 int llc_conn_ev_qlfy_last_frame_eq_1(struct sock *sk, struct sk_buff *skb);
0199 int llc_conn_ev_qlfy_last_frame_eq_0(struct sock *sk, struct sk_buff *skb);
0200 int llc_conn_ev_qlfy_p_flag_eq_0(struct sock *sk, struct sk_buff *skb);
0201 int llc_conn_ev_qlfy_p_flag_eq_f(struct sock *sk, struct sk_buff *skb);
0202 int llc_conn_ev_qlfy_remote_busy_eq_0(struct sock *sk, struct sk_buff *skb);
0203 int llc_conn_ev_qlfy_remote_busy_eq_1(struct sock *sk, struct sk_buff *skb);
0204 int llc_conn_ev_qlfy_retry_cnt_lt_n2(struct sock *sk, struct sk_buff *skb);
0205 int llc_conn_ev_qlfy_retry_cnt_gte_n2(struct sock *sk, struct sk_buff *skb);
0206 int llc_conn_ev_qlfy_s_flag_eq_1(struct sock *sk, struct sk_buff *skb);
0207 int llc_conn_ev_qlfy_s_flag_eq_0(struct sock *sk, struct sk_buff *skb);
0208 int llc_conn_ev_qlfy_cause_flag_eq_1(struct sock *sk, struct sk_buff *skb);
0209 int llc_conn_ev_qlfy_cause_flag_eq_0(struct sock *sk, struct sk_buff *skb);
0210 int llc_conn_ev_qlfy_set_status_conn(struct sock *sk, struct sk_buff *skb);
0211 int llc_conn_ev_qlfy_set_status_disc(struct sock *sk, struct sk_buff *skb);
0212 int llc_conn_ev_qlfy_set_status_failed(struct sock *sk, struct sk_buff *skb);
0213 int llc_conn_ev_qlfy_set_status_remote_busy(struct sock *sk,
0214                         struct sk_buff *skb);
0215 int llc_conn_ev_qlfy_set_status_refuse(struct sock *sk, struct sk_buff *skb);
0216 int llc_conn_ev_qlfy_set_status_conflict(struct sock *sk, struct sk_buff *skb);
0217 int llc_conn_ev_qlfy_set_status_rst_done(struct sock *sk, struct sk_buff *skb);
0218 
0219 static __inline__ int llc_conn_space(struct sock *sk, struct sk_buff *skb)
0220 {
0221     return atomic_read(&sk->sk_rmem_alloc) + skb->truesize <
0222            (unsigned int)sk->sk_rcvbuf;
0223 }
0224 #endif /* LLC_C_EV_H */