sm_statetable.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938
  1. /* SCTP kernel implementation
  2. * (C) Copyright IBM Corp. 2001, 2004
  3. * Copyright (c) 1999-2000 Cisco, Inc.
  4. * Copyright (c) 1999-2001 Motorola, Inc.
  5. * Copyright (c) 2001 Intel Corp.
  6. * Copyright (c) 2001 Nokia, Inc.
  7. *
  8. * This file is part of the SCTP kernel implementation
  9. *
  10. * These are the state tables for the SCTP state machine.
  11. *
  12. * This SCTP implementation is free software;
  13. * you can redistribute it and/or modify it under the terms of
  14. * the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2, or (at your option)
  16. * any later version.
  17. *
  18. * This SCTP implementation is distributed in the hope that it
  19. * will be useful, but WITHOUT ANY WARRANTY; without even the implied
  20. * ************************
  21. * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  22. * See the GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with GNU CC; see the file COPYING. If not, write to
  26. * the Free Software Foundation, 59 Temple Place - Suite 330,
  27. * Boston, MA 02111-1307, USA.
  28. *
  29. * Please send any bug reports or fixes you make to the
  30. * email address(es):
  31. * lksctp developers <lksctp-developers@lists.sourceforge.net>
  32. *
  33. * Or submit a bug report through the following website:
  34. * http://www.sf.net/projects/lksctp
  35. *
  36. * Written or modified by:
  37. * La Monte H.P. Yarroll <piggy@acm.org>
  38. * Karl Knutson <karl@athena.chicago.il.us>
  39. * Jon Grimm <jgrimm@us.ibm.com>
  40. * Hui Huang <hui.huang@nokia.com>
  41. * Daisy Chang <daisyc@us.ibm.com>
  42. * Ardelle Fan <ardelle.fan@intel.com>
  43. * Sridhar Samudrala <sri@us.ibm.com>
  44. *
  45. * Any bugs reported given to us we will try to fix... any fixes shared will
  46. * be incorporated into the next SCTP release.
  47. */
  48. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  49. #include <linux/skbuff.h>
  50. #include <net/sctp/sctp.h>
  51. #include <net/sctp/sm.h>
  52. static const sctp_sm_table_entry_t
  53. primitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES];
  54. static const sctp_sm_table_entry_t
  55. other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES];
  56. static const sctp_sm_table_entry_t
  57. timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES];
  58. static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t cid,
  59. sctp_state_t state);
  60. static const sctp_sm_table_entry_t bug = {
  61. .fn = sctp_sf_bug,
  62. .name = "sctp_sf_bug"
  63. };
  64. #define DO_LOOKUP(_max, _type, _table) \
  65. ({ \
  66. const sctp_sm_table_entry_t *rtn; \
  67. \
  68. if ((event_subtype._type > (_max))) { \
  69. pr_warn("table %p possible attack: event %d exceeds max %d\n", \
  70. _table, event_subtype._type, _max); \
  71. rtn = &bug; \
  72. } else \
  73. rtn = &_table[event_subtype._type][(int)state]; \
  74. \
  75. rtn; \
  76. })
  77. const sctp_sm_table_entry_t *sctp_sm_lookup_event(sctp_event_t event_type,
  78. sctp_state_t state,
  79. sctp_subtype_t event_subtype)
  80. {
  81. switch (event_type) {
  82. case SCTP_EVENT_T_CHUNK:
  83. return sctp_chunk_event_lookup(event_subtype.chunk, state);
  84. case SCTP_EVENT_T_TIMEOUT:
  85. return DO_LOOKUP(SCTP_EVENT_TIMEOUT_MAX, timeout,
  86. timeout_event_table);
  87. case SCTP_EVENT_T_OTHER:
  88. return DO_LOOKUP(SCTP_EVENT_OTHER_MAX, other,
  89. other_event_table);
  90. case SCTP_EVENT_T_PRIMITIVE:
  91. return DO_LOOKUP(SCTP_EVENT_PRIMITIVE_MAX, primitive,
  92. primitive_event_table);
  93. default:
  94. /* Yikes! We got an illegal event type. */
  95. return &bug;
  96. }
  97. }
  98. #define TYPE_SCTP_FUNC(func) {.fn = func, .name = #func}
  99. #define TYPE_SCTP_DATA { \
  100. /* SCTP_STATE_CLOSED */ \
  101. TYPE_SCTP_FUNC(sctp_sf_ootb), \
  102. /* SCTP_STATE_COOKIE_WAIT */ \
  103. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  104. /* SCTP_STATE_COOKIE_ECHOED */ \
  105. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  106. /* SCTP_STATE_ESTABLISHED */ \
  107. TYPE_SCTP_FUNC(sctp_sf_eat_data_6_2), \
  108. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  109. TYPE_SCTP_FUNC(sctp_sf_eat_data_6_2), \
  110. /* SCTP_STATE_SHUTDOWN_SENT */ \
  111. TYPE_SCTP_FUNC(sctp_sf_eat_data_fast_4_4), \
  112. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  113. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  114. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  115. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  116. } /* TYPE_SCTP_DATA */
  117. #define TYPE_SCTP_INIT { \
  118. /* SCTP_STATE_CLOSED */ \
  119. TYPE_SCTP_FUNC(sctp_sf_do_5_1B_init), \
  120. /* SCTP_STATE_COOKIE_WAIT */ \
  121. TYPE_SCTP_FUNC(sctp_sf_do_5_2_1_siminit), \
  122. /* SCTP_STATE_COOKIE_ECHOED */ \
  123. TYPE_SCTP_FUNC(sctp_sf_do_5_2_1_siminit), \
  124. /* SCTP_STATE_ESTABLISHED */ \
  125. TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
  126. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  127. TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
  128. /* SCTP_STATE_SHUTDOWN_SENT */ \
  129. TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
  130. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  131. TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
  132. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  133. TYPE_SCTP_FUNC(sctp_sf_do_9_2_reshutack), \
  134. } /* TYPE_SCTP_INIT */
  135. #define TYPE_SCTP_INIT_ACK { \
  136. /* SCTP_STATE_CLOSED */ \
  137. TYPE_SCTP_FUNC(sctp_sf_do_5_2_3_initack), \
  138. /* SCTP_STATE_COOKIE_WAIT */ \
  139. TYPE_SCTP_FUNC(sctp_sf_do_5_1C_ack), \
  140. /* SCTP_STATE_COOKIE_ECHOED */ \
  141. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  142. /* SCTP_STATE_ESTABLISHED */ \
  143. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  144. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  145. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  146. /* SCTP_STATE_SHUTDOWN_SENT */ \
  147. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  148. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  149. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  150. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  151. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  152. } /* TYPE_SCTP_INIT_ACK */
  153. #define TYPE_SCTP_SACK { \
  154. /* SCTP_STATE_CLOSED */ \
  155. TYPE_SCTP_FUNC(sctp_sf_ootb), \
  156. /* SCTP_STATE_COOKIE_WAIT */ \
  157. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  158. /* SCTP_STATE_COOKIE_ECHOED */ \
  159. TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
  160. /* SCTP_STATE_ESTABLISHED */ \
  161. TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
  162. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  163. TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
  164. /* SCTP_STATE_SHUTDOWN_SENT */ \
  165. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  166. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  167. TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
  168. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  169. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  170. } /* TYPE_SCTP_SACK */
  171. #define TYPE_SCTP_HEARTBEAT { \
  172. /* SCTP_STATE_CLOSED */ \
  173. TYPE_SCTP_FUNC(sctp_sf_ootb), \
  174. /* SCTP_STATE_COOKIE_WAIT */ \
  175. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  176. /* SCTP_STATE_COOKIE_ECHOED */ \
  177. TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
  178. /* SCTP_STATE_ESTABLISHED */ \
  179. TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
  180. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  181. TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
  182. /* SCTP_STATE_SHUTDOWN_SENT */ \
  183. TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
  184. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  185. TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
  186. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  187. /* This should not happen, but we are nice. */ \
  188. TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
  189. } /* TYPE_SCTP_HEARTBEAT */
  190. #define TYPE_SCTP_HEARTBEAT_ACK { \
  191. /* SCTP_STATE_CLOSED */ \
  192. TYPE_SCTP_FUNC(sctp_sf_ootb), \
  193. /* SCTP_STATE_COOKIE_WAIT */ \
  194. TYPE_SCTP_FUNC(sctp_sf_violation), \
  195. /* SCTP_STATE_COOKIE_ECHOED */ \
  196. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  197. /* SCTP_STATE_ESTABLISHED */ \
  198. TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
  199. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  200. TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
  201. /* SCTP_STATE_SHUTDOWN_SENT */ \
  202. TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
  203. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  204. TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
  205. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  206. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  207. } /* TYPE_SCTP_HEARTBEAT_ACK */
  208. #define TYPE_SCTP_ABORT { \
  209. /* SCTP_STATE_CLOSED */ \
  210. TYPE_SCTP_FUNC(sctp_sf_pdiscard), \
  211. /* SCTP_STATE_COOKIE_WAIT */ \
  212. TYPE_SCTP_FUNC(sctp_sf_cookie_wait_abort), \
  213. /* SCTP_STATE_COOKIE_ECHOED */ \
  214. TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_abort), \
  215. /* SCTP_STATE_ESTABLISHED */ \
  216. TYPE_SCTP_FUNC(sctp_sf_do_9_1_abort), \
  217. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  218. TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_abort), \
  219. /* SCTP_STATE_SHUTDOWN_SENT */ \
  220. TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_abort), \
  221. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  222. TYPE_SCTP_FUNC(sctp_sf_do_9_1_abort), \
  223. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  224. TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_abort), \
  225. } /* TYPE_SCTP_ABORT */
  226. #define TYPE_SCTP_SHUTDOWN { \
  227. /* SCTP_STATE_CLOSED */ \
  228. TYPE_SCTP_FUNC(sctp_sf_ootb), \
  229. /* SCTP_STATE_COOKIE_WAIT */ \
  230. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  231. /* SCTP_STATE_COOKIE_ECHOED */ \
  232. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  233. /* SCTP_STATE_ESTABLISHED */ \
  234. TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown), \
  235. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  236. TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown), \
  237. /* SCTP_STATE_SHUTDOWN_SENT */ \
  238. TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
  239. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  240. TYPE_SCTP_FUNC(sctp_sf_do_9_2_shut_ctsn), \
  241. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  242. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  243. } /* TYPE_SCTP_SHUTDOWN */
  244. #define TYPE_SCTP_SHUTDOWN_ACK { \
  245. /* SCTP_STATE_CLOSED */ \
  246. TYPE_SCTP_FUNC(sctp_sf_ootb), \
  247. /* SCTP_STATE_COOKIE_WAIT */ \
  248. TYPE_SCTP_FUNC(sctp_sf_do_8_5_1_E_sa), \
  249. /* SCTP_STATE_COOKIE_ECHOED */ \
  250. TYPE_SCTP_FUNC(sctp_sf_do_8_5_1_E_sa), \
  251. /* SCTP_STATE_ESTABLISHED */ \
  252. TYPE_SCTP_FUNC(sctp_sf_violation), \
  253. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  254. TYPE_SCTP_FUNC(sctp_sf_violation), \
  255. /* SCTP_STATE_SHUTDOWN_SENT */ \
  256. TYPE_SCTP_FUNC(sctp_sf_do_9_2_final), \
  257. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  258. TYPE_SCTP_FUNC(sctp_sf_violation), \
  259. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  260. TYPE_SCTP_FUNC(sctp_sf_do_9_2_final), \
  261. } /* TYPE_SCTP_SHUTDOWN_ACK */
  262. #define TYPE_SCTP_ERROR { \
  263. /* SCTP_STATE_CLOSED */ \
  264. TYPE_SCTP_FUNC(sctp_sf_ootb), \
  265. /* SCTP_STATE_COOKIE_WAIT */ \
  266. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  267. /* SCTP_STATE_COOKIE_ECHOED */ \
  268. TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_err), \
  269. /* SCTP_STATE_ESTABLISHED */ \
  270. TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
  271. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  272. TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
  273. /* SCTP_STATE_SHUTDOWN_SENT */ \
  274. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  275. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  276. TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
  277. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  278. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  279. } /* TYPE_SCTP_ERROR */
  280. #define TYPE_SCTP_COOKIE_ECHO { \
  281. /* SCTP_STATE_CLOSED */ \
  282. TYPE_SCTP_FUNC(sctp_sf_do_5_1D_ce), \
  283. /* SCTP_STATE_COOKIE_WAIT */ \
  284. TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
  285. /* SCTP_STATE_COOKIE_ECHOED */ \
  286. TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
  287. /* SCTP_STATE_ESTABLISHED */ \
  288. TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
  289. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  290. TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
  291. /* SCTP_STATE_SHUTDOWN_SENT */ \
  292. TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
  293. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  294. TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
  295. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  296. TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
  297. } /* TYPE_SCTP_COOKIE_ECHO */
  298. #define TYPE_SCTP_COOKIE_ACK { \
  299. /* SCTP_STATE_CLOSED */ \
  300. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  301. /* SCTP_STATE_COOKIE_WAIT */ \
  302. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  303. /* SCTP_STATE_COOKIE_ECHOED */ \
  304. TYPE_SCTP_FUNC(sctp_sf_do_5_1E_ca), \
  305. /* SCTP_STATE_ESTABLISHED */ \
  306. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  307. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  308. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  309. /* SCTP_STATE_SHUTDOWN_SENT */ \
  310. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  311. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  312. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  313. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  314. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  315. } /* TYPE_SCTP_COOKIE_ACK */
  316. #define TYPE_SCTP_ECN_ECNE { \
  317. /* SCTP_STATE_CLOSED */ \
  318. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  319. /* SCTP_STATE_COOKIE_WAIT */ \
  320. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  321. /* SCTP_STATE_COOKIE_ECHOED */ \
  322. TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
  323. /* SCTP_STATE_ESTABLISHED */ \
  324. TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
  325. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  326. TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
  327. /* SCTP_STATE_SHUTDOWN_SENT */ \
  328. TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
  329. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  330. TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
  331. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  332. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  333. } /* TYPE_SCTP_ECN_ECNE */
  334. #define TYPE_SCTP_ECN_CWR { \
  335. /* SCTP_STATE_CLOSED */ \
  336. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  337. /* SCTP_STATE_COOKIE_WAIT */ \
  338. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  339. /* SCTP_STATE_COOKIE_ECHOED */ \
  340. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  341. /* SCTP_STATE_ESTABLISHED */ \
  342. TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
  343. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  344. TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
  345. /* SCTP_STATE_SHUTDOWN_SENT */ \
  346. TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
  347. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  348. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  349. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  350. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  351. } /* TYPE_SCTP_ECN_CWR */
  352. #define TYPE_SCTP_SHUTDOWN_COMPLETE { \
  353. /* SCTP_STATE_CLOSED */ \
  354. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  355. /* SCTP_STATE_COOKIE_WAIT */ \
  356. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  357. /* SCTP_STATE_COOKIE_ECHOED */ \
  358. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  359. /* SCTP_STATE_ESTABLISHED */ \
  360. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  361. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  362. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  363. /* SCTP_STATE_SHUTDOWN_SENT */ \
  364. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  365. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  366. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  367. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  368. TYPE_SCTP_FUNC(sctp_sf_do_4_C), \
  369. } /* TYPE_SCTP_SHUTDOWN_COMPLETE */
  370. /* The primary index for this table is the chunk type.
  371. * The secondary index for this table is the state.
  372. *
  373. * For base protocol (RFC 2960).
  374. */
  375. static const sctp_sm_table_entry_t chunk_event_table[SCTP_NUM_BASE_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
  376. TYPE_SCTP_DATA,
  377. TYPE_SCTP_INIT,
  378. TYPE_SCTP_INIT_ACK,
  379. TYPE_SCTP_SACK,
  380. TYPE_SCTP_HEARTBEAT,
  381. TYPE_SCTP_HEARTBEAT_ACK,
  382. TYPE_SCTP_ABORT,
  383. TYPE_SCTP_SHUTDOWN,
  384. TYPE_SCTP_SHUTDOWN_ACK,
  385. TYPE_SCTP_ERROR,
  386. TYPE_SCTP_COOKIE_ECHO,
  387. TYPE_SCTP_COOKIE_ACK,
  388. TYPE_SCTP_ECN_ECNE,
  389. TYPE_SCTP_ECN_CWR,
  390. TYPE_SCTP_SHUTDOWN_COMPLETE,
  391. }; /* state_fn_t chunk_event_table[][] */
  392. #define TYPE_SCTP_ASCONF { \
  393. /* SCTP_STATE_CLOSED */ \
  394. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  395. /* SCTP_STATE_COOKIE_WAIT */ \
  396. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  397. /* SCTP_STATE_COOKIE_ECHOED */ \
  398. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  399. /* SCTP_STATE_ESTABLISHED */ \
  400. TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
  401. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  402. TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
  403. /* SCTP_STATE_SHUTDOWN_SENT */ \
  404. TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
  405. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  406. TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
  407. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  408. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  409. } /* TYPE_SCTP_ASCONF */
  410. #define TYPE_SCTP_ASCONF_ACK { \
  411. /* SCTP_STATE_CLOSED */ \
  412. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  413. /* SCTP_STATE_COOKIE_WAIT */ \
  414. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  415. /* SCTP_STATE_COOKIE_ECHOED */ \
  416. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  417. /* SCTP_STATE_ESTABLISHED */ \
  418. TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
  419. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  420. TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
  421. /* SCTP_STATE_SHUTDOWN_SENT */ \
  422. TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
  423. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  424. TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
  425. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  426. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  427. } /* TYPE_SCTP_ASCONF_ACK */
  428. /* The primary index for this table is the chunk type.
  429. * The secondary index for this table is the state.
  430. */
  431. static const sctp_sm_table_entry_t addip_chunk_event_table[SCTP_NUM_ADDIP_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
  432. TYPE_SCTP_ASCONF,
  433. TYPE_SCTP_ASCONF_ACK,
  434. }; /*state_fn_t addip_chunk_event_table[][] */
  435. #define TYPE_SCTP_FWD_TSN { \
  436. /* SCTP_STATE_CLOSED */ \
  437. TYPE_SCTP_FUNC(sctp_sf_ootb), \
  438. /* SCTP_STATE_COOKIE_WAIT */ \
  439. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  440. /* SCTP_STATE_COOKIE_ECHOED */ \
  441. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  442. /* SCTP_STATE_ESTABLISHED */ \
  443. TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn), \
  444. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  445. TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn), \
  446. /* SCTP_STATE_SHUTDOWN_SENT */ \
  447. TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn_fast), \
  448. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  449. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  450. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  451. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  452. } /* TYPE_SCTP_FWD_TSN */
  453. /* The primary index for this table is the chunk type.
  454. * The secondary index for this table is the state.
  455. */
  456. static const sctp_sm_table_entry_t prsctp_chunk_event_table[SCTP_NUM_PRSCTP_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
  457. TYPE_SCTP_FWD_TSN,
  458. }; /*state_fn_t prsctp_chunk_event_table[][] */
  459. #define TYPE_SCTP_AUTH { \
  460. /* SCTP_STATE_CLOSED */ \
  461. TYPE_SCTP_FUNC(sctp_sf_ootb), \
  462. /* SCTP_STATE_COOKIE_WAIT */ \
  463. TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
  464. /* SCTP_STATE_COOKIE_ECHOED */ \
  465. TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
  466. /* SCTP_STATE_ESTABLISHED */ \
  467. TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
  468. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  469. TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
  470. /* SCTP_STATE_SHUTDOWN_SENT */ \
  471. TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
  472. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  473. TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
  474. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  475. TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
  476. } /* TYPE_SCTP_AUTH */
  477. /* The primary index for this table is the chunk type.
  478. * The secondary index for this table is the state.
  479. */
  480. static const sctp_sm_table_entry_t auth_chunk_event_table[SCTP_NUM_AUTH_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
  481. TYPE_SCTP_AUTH,
  482. }; /*state_fn_t auth_chunk_event_table[][] */
  483. static const sctp_sm_table_entry_t
  484. chunk_event_table_unknown[SCTP_STATE_NUM_STATES] = {
  485. /* SCTP_STATE_CLOSED */
  486. TYPE_SCTP_FUNC(sctp_sf_ootb),
  487. /* SCTP_STATE_COOKIE_WAIT */
  488. TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
  489. /* SCTP_STATE_COOKIE_ECHOED */
  490. TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
  491. /* SCTP_STATE_ESTABLISHED */
  492. TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
  493. /* SCTP_STATE_SHUTDOWN_PENDING */
  494. TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
  495. /* SCTP_STATE_SHUTDOWN_SENT */
  496. TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
  497. /* SCTP_STATE_SHUTDOWN_RECEIVED */
  498. TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
  499. /* SCTP_STATE_SHUTDOWN_ACK_SENT */
  500. TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
  501. }; /* chunk unknown */
  502. #define TYPE_SCTP_PRIMITIVE_ASSOCIATE { \
  503. /* SCTP_STATE_CLOSED */ \
  504. TYPE_SCTP_FUNC(sctp_sf_do_prm_asoc), \
  505. /* SCTP_STATE_COOKIE_WAIT */ \
  506. TYPE_SCTP_FUNC(sctp_sf_not_impl), \
  507. /* SCTP_STATE_COOKIE_ECHOED */ \
  508. TYPE_SCTP_FUNC(sctp_sf_not_impl), \
  509. /* SCTP_STATE_ESTABLISHED */ \
  510. TYPE_SCTP_FUNC(sctp_sf_not_impl), \
  511. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  512. TYPE_SCTP_FUNC(sctp_sf_not_impl), \
  513. /* SCTP_STATE_SHUTDOWN_SENT */ \
  514. TYPE_SCTP_FUNC(sctp_sf_not_impl), \
  515. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  516. TYPE_SCTP_FUNC(sctp_sf_not_impl), \
  517. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  518. TYPE_SCTP_FUNC(sctp_sf_not_impl), \
  519. } /* TYPE_SCTP_PRIMITIVE_ASSOCIATE */
  520. #define TYPE_SCTP_PRIMITIVE_SHUTDOWN { \
  521. /* SCTP_STATE_CLOSED */ \
  522. TYPE_SCTP_FUNC(sctp_sf_error_closed), \
  523. /* SCTP_STATE_COOKIE_WAIT */ \
  524. TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_shutdown), \
  525. /* SCTP_STATE_COOKIE_ECHOED */ \
  526. TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_shutdown),\
  527. /* SCTP_STATE_ESTABLISHED */ \
  528. TYPE_SCTP_FUNC(sctp_sf_do_9_2_prm_shutdown), \
  529. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  530. TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
  531. /* SCTP_STATE_SHUTDOWN_SENT */ \
  532. TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
  533. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  534. TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
  535. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  536. TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
  537. } /* TYPE_SCTP_PRIMITIVE_SHUTDOWN */
  538. #define TYPE_SCTP_PRIMITIVE_ABORT { \
  539. /* SCTP_STATE_CLOSED */ \
  540. TYPE_SCTP_FUNC(sctp_sf_error_closed), \
  541. /* SCTP_STATE_COOKIE_WAIT */ \
  542. TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_abort), \
  543. /* SCTP_STATE_COOKIE_ECHOED */ \
  544. TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_abort), \
  545. /* SCTP_STATE_ESTABLISHED */ \
  546. TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
  547. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  548. TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_prm_abort), \
  549. /* SCTP_STATE_SHUTDOWN_SENT */ \
  550. TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_prm_abort), \
  551. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  552. TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
  553. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  554. TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_prm_abort), \
  555. } /* TYPE_SCTP_PRIMITIVE_ABORT */
  556. #define TYPE_SCTP_PRIMITIVE_SEND { \
  557. /* SCTP_STATE_CLOSED */ \
  558. TYPE_SCTP_FUNC(sctp_sf_error_closed), \
  559. /* SCTP_STATE_COOKIE_WAIT */ \
  560. TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
  561. /* SCTP_STATE_COOKIE_ECHOED */ \
  562. TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
  563. /* SCTP_STATE_ESTABLISHED */ \
  564. TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
  565. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  566. TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
  567. /* SCTP_STATE_SHUTDOWN_SENT */ \
  568. TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
  569. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  570. TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
  571. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  572. TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
  573. } /* TYPE_SCTP_PRIMITIVE_SEND */
  574. #define TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT { \
  575. /* SCTP_STATE_CLOSED */ \
  576. TYPE_SCTP_FUNC(sctp_sf_error_closed), \
  577. /* SCTP_STATE_COOKIE_WAIT */ \
  578. TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
  579. /* SCTP_STATE_COOKIE_ECHOED */ \
  580. TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
  581. /* SCTP_STATE_ESTABLISHED */ \
  582. TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
  583. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  584. TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
  585. /* SCTP_STATE_SHUTDOWN_SENT */ \
  586. TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
  587. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  588. TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
  589. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  590. TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
  591. } /* TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT */
  592. #define TYPE_SCTP_PRIMITIVE_ASCONF { \
  593. /* SCTP_STATE_CLOSED */ \
  594. TYPE_SCTP_FUNC(sctp_sf_error_closed), \
  595. /* SCTP_STATE_COOKIE_WAIT */ \
  596. TYPE_SCTP_FUNC(sctp_sf_error_closed), \
  597. /* SCTP_STATE_COOKIE_ECHOED */ \
  598. TYPE_SCTP_FUNC(sctp_sf_error_closed), \
  599. /* SCTP_STATE_ESTABLISHED */ \
  600. TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
  601. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  602. TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
  603. /* SCTP_STATE_SHUTDOWN_SENT */ \
  604. TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
  605. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  606. TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
  607. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  608. TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
  609. } /* TYPE_SCTP_PRIMITIVE_ASCONF */
  610. /* The primary index for this table is the primitive type.
  611. * The secondary index for this table is the state.
  612. */
  613. static const sctp_sm_table_entry_t primitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES] = {
  614. TYPE_SCTP_PRIMITIVE_ASSOCIATE,
  615. TYPE_SCTP_PRIMITIVE_SHUTDOWN,
  616. TYPE_SCTP_PRIMITIVE_ABORT,
  617. TYPE_SCTP_PRIMITIVE_SEND,
  618. TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT,
  619. TYPE_SCTP_PRIMITIVE_ASCONF,
  620. };
  621. #define TYPE_SCTP_OTHER_NO_PENDING_TSN { \
  622. /* SCTP_STATE_CLOSED */ \
  623. TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
  624. /* SCTP_STATE_COOKIE_WAIT */ \
  625. TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
  626. /* SCTP_STATE_COOKIE_ECHOED */ \
  627. TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
  628. /* SCTP_STATE_ESTABLISHED */ \
  629. TYPE_SCTP_FUNC(sctp_sf_do_no_pending_tsn), \
  630. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  631. TYPE_SCTP_FUNC(sctp_sf_do_9_2_start_shutdown), \
  632. /* SCTP_STATE_SHUTDOWN_SENT */ \
  633. TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
  634. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  635. TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
  636. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  637. TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
  638. }
  639. #define TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH { \
  640. /* SCTP_STATE_CLOSED */ \
  641. TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
  642. /* SCTP_STATE_COOKIE_WAIT */ \
  643. TYPE_SCTP_FUNC(sctp_sf_cookie_wait_icmp_abort), \
  644. /* SCTP_STATE_COOKIE_ECHOED */ \
  645. TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
  646. /* SCTP_STATE_ESTABLISHED */ \
  647. TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
  648. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  649. TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
  650. /* SCTP_STATE_SHUTDOWN_SENT */ \
  651. TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
  652. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  653. TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
  654. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  655. TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
  656. }
  657. static const sctp_sm_table_entry_t other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES] = {
  658. TYPE_SCTP_OTHER_NO_PENDING_TSN,
  659. TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH,
  660. };
  661. #define TYPE_SCTP_EVENT_TIMEOUT_NONE { \
  662. /* SCTP_STATE_CLOSED */ \
  663. TYPE_SCTP_FUNC(sctp_sf_bug), \
  664. /* SCTP_STATE_COOKIE_WAIT */ \
  665. TYPE_SCTP_FUNC(sctp_sf_bug), \
  666. /* SCTP_STATE_COOKIE_ECHOED */ \
  667. TYPE_SCTP_FUNC(sctp_sf_bug), \
  668. /* SCTP_STATE_ESTABLISHED */ \
  669. TYPE_SCTP_FUNC(sctp_sf_bug), \
  670. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  671. TYPE_SCTP_FUNC(sctp_sf_bug), \
  672. /* SCTP_STATE_SHUTDOWN_SENT */ \
  673. TYPE_SCTP_FUNC(sctp_sf_bug), \
  674. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  675. TYPE_SCTP_FUNC(sctp_sf_bug), \
  676. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  677. TYPE_SCTP_FUNC(sctp_sf_bug), \
  678. }
  679. #define TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE { \
  680. /* SCTP_STATE_CLOSED */ \
  681. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  682. /* SCTP_STATE_COOKIE_WAIT */ \
  683. TYPE_SCTP_FUNC(sctp_sf_bug), \
  684. /* SCTP_STATE_COOKIE_ECHOED */ \
  685. TYPE_SCTP_FUNC(sctp_sf_t1_cookie_timer_expire), \
  686. /* SCTP_STATE_ESTABLISHED */ \
  687. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  688. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  689. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  690. /* SCTP_STATE_SHUTDOWN_SENT */ \
  691. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  692. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  693. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  694. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  695. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  696. }
  697. #define TYPE_SCTP_EVENT_TIMEOUT_T1_INIT { \
  698. /* SCTP_STATE_CLOSED */ \
  699. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  700. /* SCTP_STATE_COOKIE_WAIT */ \
  701. TYPE_SCTP_FUNC(sctp_sf_t1_init_timer_expire), \
  702. /* SCTP_STATE_COOKIE_ECHOED */ \
  703. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  704. /* SCTP_STATE_ESTABLISHED */ \
  705. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  706. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  707. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  708. /* SCTP_STATE_SHUTDOWN_SENT */ \
  709. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  710. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  711. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  712. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  713. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  714. }
  715. #define TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN { \
  716. /* SCTP_STATE_CLOSED */ \
  717. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  718. /* SCTP_STATE_COOKIE_WAIT */ \
  719. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  720. /* SCTP_STATE_COOKIE_ECHOED */ \
  721. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  722. /* SCTP_STATE_ESTABLISHED */ \
  723. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  724. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  725. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  726. /* SCTP_STATE_SHUTDOWN_SENT */ \
  727. TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
  728. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  729. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  730. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  731. TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
  732. }
  733. #define TYPE_SCTP_EVENT_TIMEOUT_T3_RTX { \
  734. /* SCTP_STATE_CLOSED */ \
  735. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  736. /* SCTP_STATE_COOKIE_WAIT */ \
  737. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  738. /* SCTP_STATE_COOKIE_ECHOED */ \
  739. TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
  740. /* SCTP_STATE_ESTABLISHED */ \
  741. TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
  742. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  743. TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
  744. /* SCTP_STATE_SHUTDOWN_SENT */ \
  745. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  746. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  747. TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
  748. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  749. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  750. }
  751. #define TYPE_SCTP_EVENT_TIMEOUT_T4_RTO { \
  752. /* SCTP_STATE_CLOSED */ \
  753. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  754. /* SCTP_STATE_COOKIE_WAIT */ \
  755. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  756. /* SCTP_STATE_COOKIE_ECHOED */ \
  757. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  758. /* SCTP_STATE_ESTABLISHED */ \
  759. TYPE_SCTP_FUNC(sctp_sf_t4_timer_expire), \
  760. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  761. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  762. /* SCTP_STATE_SHUTDOWN_SENT */ \
  763. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  764. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  765. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  766. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  767. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  768. }
  769. #define TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD { \
  770. /* SCTP_STATE_CLOSED */ \
  771. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  772. /* SCTP_STATE_COOKIE_WAIT */ \
  773. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  774. /* SCTP_STATE_COOKIE_ECHOED */ \
  775. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  776. /* SCTP_STATE_ESTABLISHED */ \
  777. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  778. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  779. TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
  780. /* SCTP_STATE_SHUTDOWN_SENT */ \
  781. TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
  782. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  783. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  784. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  785. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  786. }
  787. #define TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT { \
  788. /* SCTP_STATE_CLOSED */ \
  789. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  790. /* SCTP_STATE_COOKIE_WAIT */ \
  791. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  792. /* SCTP_STATE_COOKIE_ECHOED */ \
  793. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  794. /* SCTP_STATE_ESTABLISHED */ \
  795. TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
  796. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  797. TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
  798. /* SCTP_STATE_SHUTDOWN_SENT */ \
  799. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  800. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  801. TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
  802. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  803. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  804. }
  805. #define TYPE_SCTP_EVENT_TIMEOUT_SACK { \
  806. /* SCTP_STATE_CLOSED */ \
  807. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  808. /* SCTP_STATE_COOKIE_WAIT */ \
  809. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  810. /* SCTP_STATE_COOKIE_ECHOED */ \
  811. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  812. /* SCTP_STATE_ESTABLISHED */ \
  813. TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
  814. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  815. TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
  816. /* SCTP_STATE_SHUTDOWN_SENT */ \
  817. TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
  818. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  819. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  820. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  821. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  822. }
  823. #define TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE { \
  824. /* SCTP_STATE_CLOSED */ \
  825. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  826. /* SCTP_STATE_COOKIE_WAIT */ \
  827. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  828. /* SCTP_STATE_COOKIE_ECHOED */ \
  829. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  830. /* SCTP_STATE_ESTABLISHED */ \
  831. TYPE_SCTP_FUNC(sctp_sf_autoclose_timer_expire), \
  832. /* SCTP_STATE_SHUTDOWN_PENDING */ \
  833. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  834. /* SCTP_STATE_SHUTDOWN_SENT */ \
  835. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  836. /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
  837. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  838. /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
  839. TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
  840. }
  841. static const sctp_sm_table_entry_t timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES] = {
  842. TYPE_SCTP_EVENT_TIMEOUT_NONE,
  843. TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE,
  844. TYPE_SCTP_EVENT_TIMEOUT_T1_INIT,
  845. TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN,
  846. TYPE_SCTP_EVENT_TIMEOUT_T3_RTX,
  847. TYPE_SCTP_EVENT_TIMEOUT_T4_RTO,
  848. TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD,
  849. TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT,
  850. TYPE_SCTP_EVENT_TIMEOUT_SACK,
  851. TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE,
  852. };
  853. static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t cid,
  854. sctp_state_t state)
  855. {
  856. if (state > SCTP_STATE_MAX)
  857. return &bug;
  858. if (cid <= SCTP_CID_BASE_MAX)
  859. return &chunk_event_table[cid][state];
  860. if (sctp_prsctp_enable) {
  861. if (cid == SCTP_CID_FWD_TSN)
  862. return &prsctp_chunk_event_table[0][state];
  863. }
  864. if (sctp_addip_enable) {
  865. if (cid == SCTP_CID_ASCONF)
  866. return &addip_chunk_event_table[0][state];
  867. if (cid == SCTP_CID_ASCONF_ACK)
  868. return &addip_chunk_event_table[1][state];
  869. }
  870. if (sctp_auth_enable) {
  871. if (cid == SCTP_CID_AUTH)
  872. return &auth_chunk_event_table[0][state];
  873. }
  874. return &chunk_event_table_unknown[state];
  875. }