llc_c_ev.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. #ifndef LLC_C_EV_H
  2. #define LLC_C_EV_H
  3. /*
  4. * Copyright (c) 1997 by Procom Technology,Inc.
  5. * 2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  6. *
  7. * This program can be redistributed or modified under the terms of the
  8. * GNU General Public License as published by the Free Software Foundation.
  9. * This program is distributed without any warranty or implied warranty
  10. * of merchantability or fitness for a particular purpose.
  11. *
  12. * See the GNU General Public License for more details.
  13. */
  14. #include <net/sock.h>
  15. /* Connection component state transition event qualifiers */
  16. /* Types of events (possible values in 'ev->type') */
  17. #define LLC_CONN_EV_TYPE_SIMPLE 1
  18. #define LLC_CONN_EV_TYPE_CONDITION 2
  19. #define LLC_CONN_EV_TYPE_PRIM 3
  20. #define LLC_CONN_EV_TYPE_PDU 4 /* command/response PDU */
  21. #define LLC_CONN_EV_TYPE_ACK_TMR 5
  22. #define LLC_CONN_EV_TYPE_P_TMR 6
  23. #define LLC_CONN_EV_TYPE_REJ_TMR 7
  24. #define LLC_CONN_EV_TYPE_BUSY_TMR 8
  25. #define LLC_CONN_EV_TYPE_RPT_STATUS 9
  26. #define LLC_CONN_EV_TYPE_SENDACK_TMR 10
  27. #define NBR_CONN_EV 5
  28. /* Connection events which cause state transitions when fully qualified */
  29. #define LLC_CONN_EV_CONN_REQ 1
  30. #define LLC_CONN_EV_CONN_RESP 2
  31. #define LLC_CONN_EV_DATA_REQ 3
  32. #define LLC_CONN_EV_DISC_REQ 4
  33. #define LLC_CONN_EV_RESET_REQ 5
  34. #define LLC_CONN_EV_RESET_RESP 6
  35. #define LLC_CONN_EV_LOCAL_BUSY_DETECTED 7
  36. #define LLC_CONN_EV_LOCAL_BUSY_CLEARED 8
  37. #define LLC_CONN_EV_RX_BAD_PDU 9
  38. #define LLC_CONN_EV_RX_DISC_CMD_Pbit_SET_X 10
  39. #define LLC_CONN_EV_RX_DM_RSP_Fbit_SET_X 11
  40. #define LLC_CONN_EV_RX_FRMR_RSP_Fbit_SET_X 12
  41. #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_X 13
  42. #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_X_UNEXPD_Ns 14
  43. #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_X_INVAL_Ns 15
  44. #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_X 16
  45. #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_X_UNEXPD_Ns 17
  46. #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_X_INVAL_Ns 18
  47. #define LLC_CONN_EV_RX_REJ_CMD_Pbit_SET_X 19
  48. #define LLC_CONN_EV_RX_REJ_RSP_Fbit_SET_X 20
  49. #define LLC_CONN_EV_RX_RNR_CMD_Pbit_SET_X 21
  50. #define LLC_CONN_EV_RX_RNR_RSP_Fbit_SET_X 22
  51. #define LLC_CONN_EV_RX_RR_CMD_Pbit_SET_X 23
  52. #define LLC_CONN_EV_RX_RR_RSP_Fbit_SET_X 24
  53. #define LLC_CONN_EV_RX_SABME_CMD_Pbit_SET_X 25
  54. #define LLC_CONN_EV_RX_UA_RSP_Fbit_SET_X 26
  55. #define LLC_CONN_EV_RX_XXX_CMD_Pbit_SET_X 27
  56. #define LLC_CONN_EV_RX_XXX_RSP_Fbit_SET_X 28
  57. #define LLC_CONN_EV_RX_XXX_YYY 29
  58. #define LLC_CONN_EV_RX_ZZZ_CMD_Pbit_SET_X_INVAL_Nr 30
  59. #define LLC_CONN_EV_RX_ZZZ_RSP_Fbit_SET_X_INVAL_Nr 31
  60. #define LLC_CONN_EV_P_TMR_EXP 32
  61. #define LLC_CONN_EV_ACK_TMR_EXP 33
  62. #define LLC_CONN_EV_REJ_TMR_EXP 34
  63. #define LLC_CONN_EV_BUSY_TMR_EXP 35
  64. #define LLC_CONN_EV_RX_XXX_CMD_Pbit_SET_1 36
  65. #define LLC_CONN_EV_RX_XXX_CMD_Pbit_SET_0 37
  66. #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_0_UNEXPD_Ns 38
  67. #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_0_UNEXPD_Ns 39
  68. #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_1_UNEXPD_Ns 40
  69. #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_1_UNEXPD_Ns 41
  70. #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_0 42
  71. #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_0 43
  72. #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_1 44
  73. #define LLC_CONN_EV_RX_RR_CMD_Pbit_SET_0 45
  74. #define LLC_CONN_EV_RX_RR_RSP_Fbit_SET_0 46
  75. #define LLC_CONN_EV_RX_RR_RSP_Fbit_SET_1 47
  76. #define LLC_CONN_EV_RX_RR_CMD_Pbit_SET_1 48
  77. #define LLC_CONN_EV_RX_RNR_CMD_Pbit_SET_0 49
  78. #define LLC_CONN_EV_RX_RNR_RSP_Fbit_SET_0 50
  79. #define LLC_CONN_EV_RX_RNR_RSP_Fbit_SET_1 51
  80. #define LLC_CONN_EV_RX_RNR_CMD_Pbit_SET_1 52
  81. #define LLC_CONN_EV_RX_REJ_CMD_Pbit_SET_0 53
  82. #define LLC_CONN_EV_RX_REJ_RSP_Fbit_SET_0 54
  83. #define LLC_CONN_EV_RX_REJ_CMD_Pbit_SET_1 55
  84. #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_1 56
  85. #define LLC_CONN_EV_RX_REJ_RSP_Fbit_SET_1 57
  86. #define LLC_CONN_EV_RX_XXX_RSP_Fbit_SET_1 58
  87. #define LLC_CONN_EV_TX_BUFF_FULL 59
  88. #define LLC_CONN_EV_INIT_P_F_CYCLE 100
  89. /*
  90. * Connection event qualifiers; for some events a certain combination of
  91. * these qualifiers must be TRUE before event recognized valid for state;
  92. * these constants act as indexes into the Event Qualifier function
  93. * table
  94. */
  95. #define LLC_CONN_EV_QFY_DATA_FLAG_EQ_1 1
  96. #define LLC_CONN_EV_QFY_DATA_FLAG_EQ_0 2
  97. #define LLC_CONN_EV_QFY_DATA_FLAG_EQ_2 3
  98. #define LLC_CONN_EV_QFY_P_FLAG_EQ_1 4
  99. #define LLC_CONN_EV_QFY_P_FLAG_EQ_0 5
  100. #define LLC_CONN_EV_QFY_P_FLAG_EQ_Fbit 6
  101. #define LLC_CONN_EV_QFY_REMOTE_BUSY_EQ_0 7
  102. #define LLC_CONN_EV_QFY_RETRY_CNT_LT_N2 8
  103. #define LLC_CONN_EV_QFY_RETRY_CNT_GTE_N2 9
  104. #define LLC_CONN_EV_QFY_S_FLAG_EQ_1 10
  105. #define LLC_CONN_EV_QFY_S_FLAG_EQ_0 11
  106. #define LLC_CONN_EV_QFY_INIT_P_F_CYCLE 12
  107. struct llc_conn_state_ev {
  108. u8 type;
  109. u8 prim;
  110. u8 prim_type;
  111. u8 reason;
  112. u8 status;
  113. u8 ind_prim;
  114. u8 cfm_prim;
  115. };
  116. static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
  117. {
  118. return (struct llc_conn_state_ev *)skb->cb;
  119. }
  120. typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
  121. typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
  122. extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
  123. extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
  124. extern int llc_conn_ev_disc_req(struct sock *sk, struct sk_buff *skb);
  125. extern int llc_conn_ev_rst_req(struct sock *sk, struct sk_buff *skb);
  126. extern int llc_conn_ev_local_busy_detected(struct sock *sk,
  127. struct sk_buff *skb);
  128. extern int llc_conn_ev_local_busy_cleared(struct sock *sk, struct sk_buff *skb);
  129. extern int llc_conn_ev_rx_bad_pdu(struct sock *sk, struct sk_buff *skb);
  130. extern int llc_conn_ev_rx_disc_cmd_pbit_set_x(struct sock *sk,
  131. struct sk_buff *skb);
  132. extern int llc_conn_ev_rx_dm_rsp_fbit_set_x(struct sock *sk,
  133. struct sk_buff *skb);
  134. extern int llc_conn_ev_rx_frmr_rsp_fbit_set_x(struct sock *sk,
  135. struct sk_buff *skb);
  136. extern int llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns(struct sock *sk,
  137. struct sk_buff *skb);
  138. extern int llc_conn_ev_rx_i_rsp_fbit_set_x(struct sock *sk,
  139. struct sk_buff *skb);
  140. extern int llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns(struct sock *sk,
  141. struct sk_buff *skb);
  142. extern int llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns(struct sock *sk,
  143. struct sk_buff *skb);
  144. extern int llc_conn_ev_rx_rej_rsp_fbit_set_x(struct sock *sk,
  145. struct sk_buff *skb);
  146. extern int llc_conn_ev_rx_sabme_cmd_pbit_set_x(struct sock *sk,
  147. struct sk_buff *skb);
  148. extern int llc_conn_ev_rx_ua_rsp_fbit_set_x(struct sock *sk,
  149. struct sk_buff *skb);
  150. extern int llc_conn_ev_rx_xxx_cmd_pbit_set_x(struct sock *sk,
  151. struct sk_buff *skb);
  152. extern int llc_conn_ev_rx_xxx_rsp_fbit_set_x(struct sock *sk,
  153. struct sk_buff *skb);
  154. extern int llc_conn_ev_rx_zzz_cmd_pbit_set_x_inval_nr(struct sock *sk,
  155. struct sk_buff *skb);
  156. extern int llc_conn_ev_rx_zzz_rsp_fbit_set_x_inval_nr(struct sock *sk,
  157. struct sk_buff *skb);
  158. extern int llc_conn_ev_p_tmr_exp(struct sock *sk, struct sk_buff *skb);
  159. extern int llc_conn_ev_ack_tmr_exp(struct sock *sk, struct sk_buff *skb);
  160. extern int llc_conn_ev_rej_tmr_exp(struct sock *sk, struct sk_buff *skb);
  161. extern int llc_conn_ev_busy_tmr_exp(struct sock *sk, struct sk_buff *skb);
  162. extern int llc_conn_ev_sendack_tmr_exp(struct sock *sk, struct sk_buff *skb);
  163. /* NOT_USED functions and their variations */
  164. extern int llc_conn_ev_rx_xxx_cmd_pbit_set_1(struct sock *sk,
  165. struct sk_buff *skb);
  166. extern int llc_conn_ev_rx_xxx_rsp_fbit_set_1(struct sock *sk,
  167. struct sk_buff *skb);
  168. extern int llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns(struct sock *sk,
  169. struct sk_buff *skb);
  170. extern int llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns(struct sock *sk,
  171. struct sk_buff *skb);
  172. extern int llc_conn_ev_rx_i_cmd_pbit_set_0(struct sock *sk,
  173. struct sk_buff *skb);
  174. extern int llc_conn_ev_rx_i_cmd_pbit_set_1(struct sock *sk,
  175. struct sk_buff *skb);
  176. extern int llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns(struct sock *sk,
  177. struct sk_buff *skb);
  178. extern int llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns(struct sock *sk,
  179. struct sk_buff *skb);
  180. extern int llc_conn_ev_rx_i_rsp_fbit_set_0(struct sock *sk,
  181. struct sk_buff *skb);
  182. extern int llc_conn_ev_rx_i_rsp_fbit_set_1(struct sock *sk,
  183. struct sk_buff *skb);
  184. extern int llc_conn_ev_rx_rr_cmd_pbit_set_0(struct sock *sk,
  185. struct sk_buff *skb);
  186. extern int llc_conn_ev_rx_rr_cmd_pbit_set_1(struct sock *sk,
  187. struct sk_buff *skb);
  188. extern int llc_conn_ev_rx_rr_rsp_fbit_set_0(struct sock *sk,
  189. struct sk_buff *skb);
  190. extern int llc_conn_ev_rx_rr_rsp_fbit_set_1(struct sock *sk,
  191. struct sk_buff *skb);
  192. extern int llc_conn_ev_rx_rnr_cmd_pbit_set_0(struct sock *sk,
  193. struct sk_buff *skb);
  194. extern int llc_conn_ev_rx_rnr_cmd_pbit_set_1(struct sock *sk,
  195. struct sk_buff *skb);
  196. extern int llc_conn_ev_rx_rnr_rsp_fbit_set_0(struct sock *sk,
  197. struct sk_buff *skb);
  198. extern int llc_conn_ev_rx_rnr_rsp_fbit_set_1(struct sock *sk,
  199. struct sk_buff *skb);
  200. extern int llc_conn_ev_rx_rej_cmd_pbit_set_0(struct sock *sk,
  201. struct sk_buff *skb);
  202. extern int llc_conn_ev_rx_rej_cmd_pbit_set_1(struct sock *sk,
  203. struct sk_buff *skb);
  204. extern int llc_conn_ev_rx_rej_rsp_fbit_set_0(struct sock *sk,
  205. struct sk_buff *skb);
  206. extern int llc_conn_ev_rx_rej_rsp_fbit_set_1(struct sock *sk,
  207. struct sk_buff *skb);
  208. extern int llc_conn_ev_rx_any_frame(struct sock *sk, struct sk_buff *skb);
  209. extern int llc_conn_ev_tx_buffer_full(struct sock *sk, struct sk_buff *skb);
  210. extern int llc_conn_ev_init_p_f_cycle(struct sock *sk, struct sk_buff *skb);
  211. /* Available connection action qualifiers */
  212. extern int llc_conn_ev_qlfy_data_flag_eq_1(struct sock *sk,
  213. struct sk_buff *skb);
  214. extern int llc_conn_ev_qlfy_data_flag_eq_0(struct sock *sk,
  215. struct sk_buff *skb);
  216. extern int llc_conn_ev_qlfy_data_flag_eq_2(struct sock *sk,
  217. struct sk_buff *skb);
  218. extern int llc_conn_ev_qlfy_p_flag_eq_1(struct sock *sk, struct sk_buff *skb);
  219. extern int llc_conn_ev_qlfy_last_frame_eq_1(struct sock *sk,
  220. struct sk_buff *skb);
  221. extern int llc_conn_ev_qlfy_last_frame_eq_0(struct sock *sk,
  222. struct sk_buff *skb);
  223. extern int llc_conn_ev_qlfy_p_flag_eq_0(struct sock *sk, struct sk_buff *skb);
  224. extern int llc_conn_ev_qlfy_p_flag_eq_f(struct sock *sk, struct sk_buff *skb);
  225. extern int llc_conn_ev_qlfy_remote_busy_eq_0(struct sock *sk,
  226. struct sk_buff *skb);
  227. extern int llc_conn_ev_qlfy_remote_busy_eq_1(struct sock *sk,
  228. struct sk_buff *skb);
  229. extern int llc_conn_ev_qlfy_retry_cnt_lt_n2(struct sock *sk,
  230. struct sk_buff *skb);
  231. extern int llc_conn_ev_qlfy_retry_cnt_gte_n2(struct sock *sk,
  232. struct sk_buff *skb);
  233. extern int llc_conn_ev_qlfy_s_flag_eq_1(struct sock *sk, struct sk_buff *skb);
  234. extern int llc_conn_ev_qlfy_s_flag_eq_0(struct sock *sk, struct sk_buff *skb);
  235. extern int llc_conn_ev_qlfy_cause_flag_eq_1(struct sock *sk,
  236. struct sk_buff *skb);
  237. extern int llc_conn_ev_qlfy_cause_flag_eq_0(struct sock *sk,
  238. struct sk_buff *skb);
  239. extern int llc_conn_ev_qlfy_set_status_conn(struct sock *sk,
  240. struct sk_buff *skb);
  241. extern int llc_conn_ev_qlfy_set_status_disc(struct sock *sk,
  242. struct sk_buff *skb);
  243. extern int llc_conn_ev_qlfy_set_status_failed(struct sock *sk,
  244. struct sk_buff *skb);
  245. extern int llc_conn_ev_qlfy_set_status_remote_busy(struct sock *sk,
  246. struct sk_buff *skb);
  247. extern int llc_conn_ev_qlfy_set_status_refuse(struct sock *sk,
  248. struct sk_buff *skb);
  249. extern int llc_conn_ev_qlfy_set_status_conflict(struct sock *sk,
  250. struct sk_buff *skb);
  251. extern int llc_conn_ev_qlfy_set_status_rst_done(struct sock *sk,
  252. struct sk_buff *skb);
  253. static __inline__ int llc_conn_space(struct sock *sk, struct sk_buff *skb)
  254. {
  255. return atomic_read(&sk->sk_rmem_alloc) + skb->truesize <
  256. (unsigned)sk->sk_rcvbuf;
  257. }
  258. #endif /* LLC_C_EV_H */