llc_s_st.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * llc_s_st.c - Defines SAP component state machine transitions.
  3. *
  4. * The followed transitions are SAP component state machine transitions
  5. * which are described in 802.2 LLC protocol standard document.
  6. *
  7. * Copyright (c) 1997 by Procom Technology, Inc.
  8. * 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  9. *
  10. * This program can be redistributed or modified under the terms of the
  11. * GNU General Public License as published by the Free Software Foundation.
  12. * This program is distributed without any warranty or implied warranty
  13. * of merchantability or fitness for a particular purpose.
  14. *
  15. * See the GNU General Public License for more details.
  16. */
  17. #include <linux/types.h>
  18. #include <net/llc_if.h>
  19. #include <net/llc_s_ev.h>
  20. #include <net/llc_s_ac.h>
  21. #include <net/llc_s_st.h>
  22. /* dummy last-transition indicator; common to all state transition groups
  23. * last entry for this state
  24. * all members are zeros, .bss zeroes it
  25. */
  26. static struct llc_sap_state_trans llc_sap_state_trans_end;
  27. /* state LLC_SAP_STATE_INACTIVE transition for
  28. * LLC_SAP_EV_ACTIVATION_REQ event
  29. */
  30. static const llc_sap_action_t llc_sap_inactive_state_actions_1[] = {
  31. [0] = llc_sap_action_report_status,
  32. [1] = NULL,
  33. };
  34. static struct llc_sap_state_trans llc_sap_inactive_state_trans_1 = {
  35. .ev = llc_sap_ev_activation_req,
  36. .next_state = LLC_SAP_STATE_ACTIVE,
  37. .ev_actions = llc_sap_inactive_state_actions_1,
  38. };
  39. /* array of pointers; one to each transition */
  40. static struct llc_sap_state_trans *llc_sap_inactive_state_transitions[] = {
  41. [0] = &llc_sap_inactive_state_trans_1,
  42. [1] = &llc_sap_state_trans_end,
  43. };
  44. /* state LLC_SAP_STATE_ACTIVE transition for LLC_SAP_EV_RX_UI event */
  45. static const llc_sap_action_t llc_sap_active_state_actions_1[] = {
  46. [0] = llc_sap_action_unitdata_ind,
  47. [1] = NULL,
  48. };
  49. static struct llc_sap_state_trans llc_sap_active_state_trans_1 = {
  50. .ev = llc_sap_ev_rx_ui,
  51. .next_state = LLC_SAP_STATE_ACTIVE,
  52. .ev_actions = llc_sap_active_state_actions_1,
  53. };
  54. /* state LLC_SAP_STATE_ACTIVE transition for LLC_SAP_EV_UNITDATA_REQ event */
  55. static const llc_sap_action_t llc_sap_active_state_actions_2[] = {
  56. [0] = llc_sap_action_send_ui,
  57. [1] = NULL,
  58. };
  59. static struct llc_sap_state_trans llc_sap_active_state_trans_2 = {
  60. .ev = llc_sap_ev_unitdata_req,
  61. .next_state = LLC_SAP_STATE_ACTIVE,
  62. .ev_actions = llc_sap_active_state_actions_2,
  63. };
  64. /* state LLC_SAP_STATE_ACTIVE transition for LLC_SAP_EV_XID_REQ event */
  65. static const llc_sap_action_t llc_sap_active_state_actions_3[] = {
  66. [0] = llc_sap_action_send_xid_c,
  67. [1] = NULL,
  68. };
  69. static struct llc_sap_state_trans llc_sap_active_state_trans_3 = {
  70. .ev = llc_sap_ev_xid_req,
  71. .next_state = LLC_SAP_STATE_ACTIVE,
  72. .ev_actions = llc_sap_active_state_actions_3,
  73. };
  74. /* state LLC_SAP_STATE_ACTIVE transition for LLC_SAP_EV_RX_XID_C event */
  75. static const llc_sap_action_t llc_sap_active_state_actions_4[] = {
  76. [0] = llc_sap_action_send_xid_r,
  77. [1] = NULL,
  78. };
  79. static struct llc_sap_state_trans llc_sap_active_state_trans_4 = {
  80. .ev = llc_sap_ev_rx_xid_c,
  81. .next_state = LLC_SAP_STATE_ACTIVE,
  82. .ev_actions = llc_sap_active_state_actions_4,
  83. };
  84. /* state LLC_SAP_STATE_ACTIVE transition for LLC_SAP_EV_RX_XID_R event */
  85. static const llc_sap_action_t llc_sap_active_state_actions_5[] = {
  86. [0] = llc_sap_action_xid_ind,
  87. [1] = NULL,
  88. };
  89. static struct llc_sap_state_trans llc_sap_active_state_trans_5 = {
  90. .ev = llc_sap_ev_rx_xid_r,
  91. .next_state = LLC_SAP_STATE_ACTIVE,
  92. .ev_actions = llc_sap_active_state_actions_5,
  93. };
  94. /* state LLC_SAP_STATE_ACTIVE transition for LLC_SAP_EV_TEST_REQ event */
  95. static const llc_sap_action_t llc_sap_active_state_actions_6[] = {
  96. [0] = llc_sap_action_send_test_c,
  97. [1] = NULL,
  98. };
  99. static struct llc_sap_state_trans llc_sap_active_state_trans_6 = {
  100. .ev = llc_sap_ev_test_req,
  101. .next_state = LLC_SAP_STATE_ACTIVE,
  102. .ev_actions = llc_sap_active_state_actions_6,
  103. };
  104. /* state LLC_SAP_STATE_ACTIVE transition for LLC_SAP_EV_RX_TEST_C event */
  105. static const llc_sap_action_t llc_sap_active_state_actions_7[] = {
  106. [0] = llc_sap_action_send_test_r,
  107. [1] = NULL,
  108. };
  109. static struct llc_sap_state_trans llc_sap_active_state_trans_7 = {
  110. .ev = llc_sap_ev_rx_test_c,
  111. .next_state = LLC_SAP_STATE_ACTIVE,
  112. .ev_actions = llc_sap_active_state_actions_7
  113. };
  114. /* state LLC_SAP_STATE_ACTIVE transition for LLC_SAP_EV_RX_TEST_R event */
  115. static const llc_sap_action_t llc_sap_active_state_actions_8[] = {
  116. [0] = llc_sap_action_test_ind,
  117. [1] = NULL,
  118. };
  119. static struct llc_sap_state_trans llc_sap_active_state_trans_8 = {
  120. .ev = llc_sap_ev_rx_test_r,
  121. .next_state = LLC_SAP_STATE_ACTIVE,
  122. .ev_actions = llc_sap_active_state_actions_8,
  123. };
  124. /* state LLC_SAP_STATE_ACTIVE transition for
  125. * LLC_SAP_EV_DEACTIVATION_REQ event
  126. */
  127. static const llc_sap_action_t llc_sap_active_state_actions_9[] = {
  128. [0] = llc_sap_action_report_status,
  129. [1] = NULL,
  130. };
  131. static struct llc_sap_state_trans llc_sap_active_state_trans_9 = {
  132. .ev = llc_sap_ev_deactivation_req,
  133. .next_state = LLC_SAP_STATE_INACTIVE,
  134. .ev_actions = llc_sap_active_state_actions_9
  135. };
  136. /* array of pointers; one to each transition */
  137. static struct llc_sap_state_trans *llc_sap_active_state_transitions[] = {
  138. [0] = &llc_sap_active_state_trans_2,
  139. [1] = &llc_sap_active_state_trans_1,
  140. [2] = &llc_sap_active_state_trans_3,
  141. [3] = &llc_sap_active_state_trans_4,
  142. [4] = &llc_sap_active_state_trans_5,
  143. [5] = &llc_sap_active_state_trans_6,
  144. [6] = &llc_sap_active_state_trans_7,
  145. [7] = &llc_sap_active_state_trans_8,
  146. [8] = &llc_sap_active_state_trans_9,
  147. [9] = &llc_sap_state_trans_end,
  148. };
  149. /* SAP state transition table */
  150. struct llc_sap_state llc_sap_state_table[LLC_NR_SAP_STATES] = {
  151. [LLC_SAP_STATE_INACTIVE - 1] = {
  152. .curr_state = LLC_SAP_STATE_INACTIVE,
  153. .transitions = llc_sap_inactive_state_transitions,
  154. },
  155. [LLC_SAP_STATE_ACTIVE - 1] = {
  156. .curr_state = LLC_SAP_STATE_ACTIVE,
  157. .transitions = llc_sap_active_state_transitions,
  158. },
  159. };