Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
[linux/fpc-iii.git] / net / sctp / sm_statetable.c
bloba987d54b379c5c57513ef2f0fac046c8cae2bf75
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.
8 * This file is part of the SCTP kernel implementation
10 * These are the state tables for the SCTP state machine.
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.
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.
24 * You should have received a copy of the GNU General Public License
25 * along with GNU CC; see the file COPYING. If not, see
26 * <http://www.gnu.org/licenses/>.
28 * Please send any bug reports or fixes you make to the
29 * email address(es):
30 * lksctp developers <linux-sctp@vger.kernel.org>
32 * Written or modified by:
33 * La Monte H.P. Yarroll <piggy@acm.org>
34 * Karl Knutson <karl@athena.chicago.il.us>
35 * Jon Grimm <jgrimm@us.ibm.com>
36 * Hui Huang <hui.huang@nokia.com>
37 * Daisy Chang <daisyc@us.ibm.com>
38 * Ardelle Fan <ardelle.fan@intel.com>
39 * Sridhar Samudrala <sri@us.ibm.com>
42 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
44 #include <linux/skbuff.h>
45 #include <net/sctp/sctp.h>
46 #include <net/sctp/sm.h>
48 static const sctp_sm_table_entry_t
49 primitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES];
50 static const sctp_sm_table_entry_t
51 other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES];
52 static const sctp_sm_table_entry_t
53 timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES];
55 static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(struct net *net,
56 sctp_cid_t cid,
57 sctp_state_t state);
60 static const sctp_sm_table_entry_t bug = {
61 .fn = sctp_sf_bug,
62 .name = "sctp_sf_bug"
65 #define DO_LOOKUP(_max, _type, _table) \
66 ({ \
67 const sctp_sm_table_entry_t *rtn; \
69 if ((event_subtype._type > (_max))) { \
70 pr_warn("table %p possible attack: event %d exceeds max %d\n", \
71 _table, event_subtype._type, _max); \
72 rtn = &bug; \
73 } else \
74 rtn = &_table[event_subtype._type][(int)state]; \
76 rtn; \
79 const sctp_sm_table_entry_t *sctp_sm_lookup_event(struct net *net,
80 sctp_event_t event_type,
81 sctp_state_t state,
82 sctp_subtype_t event_subtype)
84 switch (event_type) {
85 case SCTP_EVENT_T_CHUNK:
86 return sctp_chunk_event_lookup(net, event_subtype.chunk, state);
87 case SCTP_EVENT_T_TIMEOUT:
88 return DO_LOOKUP(SCTP_EVENT_TIMEOUT_MAX, timeout,
89 timeout_event_table);
90 case SCTP_EVENT_T_OTHER:
91 return DO_LOOKUP(SCTP_EVENT_OTHER_MAX, other,
92 other_event_table);
93 case SCTP_EVENT_T_PRIMITIVE:
94 return DO_LOOKUP(SCTP_EVENT_PRIMITIVE_MAX, primitive,
95 primitive_event_table);
96 default:
97 /* Yikes! We got an illegal event type. */
98 return &bug;
102 #define TYPE_SCTP_FUNC(func) {.fn = func, .name = #func}
104 #define TYPE_SCTP_DATA { \
105 /* SCTP_STATE_CLOSED */ \
106 TYPE_SCTP_FUNC(sctp_sf_ootb), \
107 /* SCTP_STATE_COOKIE_WAIT */ \
108 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
109 /* SCTP_STATE_COOKIE_ECHOED */ \
110 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
111 /* SCTP_STATE_ESTABLISHED */ \
112 TYPE_SCTP_FUNC(sctp_sf_eat_data_6_2), \
113 /* SCTP_STATE_SHUTDOWN_PENDING */ \
114 TYPE_SCTP_FUNC(sctp_sf_eat_data_6_2), \
115 /* SCTP_STATE_SHUTDOWN_SENT */ \
116 TYPE_SCTP_FUNC(sctp_sf_eat_data_fast_4_4), \
117 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
118 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
119 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
120 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
121 } /* TYPE_SCTP_DATA */
123 #define TYPE_SCTP_INIT { \
124 /* SCTP_STATE_CLOSED */ \
125 TYPE_SCTP_FUNC(sctp_sf_do_5_1B_init), \
126 /* SCTP_STATE_COOKIE_WAIT */ \
127 TYPE_SCTP_FUNC(sctp_sf_do_5_2_1_siminit), \
128 /* SCTP_STATE_COOKIE_ECHOED */ \
129 TYPE_SCTP_FUNC(sctp_sf_do_5_2_1_siminit), \
130 /* SCTP_STATE_ESTABLISHED */ \
131 TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
132 /* SCTP_STATE_SHUTDOWN_PENDING */ \
133 TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
134 /* SCTP_STATE_SHUTDOWN_SENT */ \
135 TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
136 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
137 TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
138 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
139 TYPE_SCTP_FUNC(sctp_sf_do_9_2_reshutack), \
140 } /* TYPE_SCTP_INIT */
142 #define TYPE_SCTP_INIT_ACK { \
143 /* SCTP_STATE_CLOSED */ \
144 TYPE_SCTP_FUNC(sctp_sf_do_5_2_3_initack), \
145 /* SCTP_STATE_COOKIE_WAIT */ \
146 TYPE_SCTP_FUNC(sctp_sf_do_5_1C_ack), \
147 /* SCTP_STATE_COOKIE_ECHOED */ \
148 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
149 /* SCTP_STATE_ESTABLISHED */ \
150 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
151 /* SCTP_STATE_SHUTDOWN_PENDING */ \
152 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
153 /* SCTP_STATE_SHUTDOWN_SENT */ \
154 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
155 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
156 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
157 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
158 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
159 } /* TYPE_SCTP_INIT_ACK */
161 #define TYPE_SCTP_SACK { \
162 /* SCTP_STATE_CLOSED */ \
163 TYPE_SCTP_FUNC(sctp_sf_ootb), \
164 /* SCTP_STATE_COOKIE_WAIT */ \
165 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
166 /* SCTP_STATE_COOKIE_ECHOED */ \
167 TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
168 /* SCTP_STATE_ESTABLISHED */ \
169 TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
170 /* SCTP_STATE_SHUTDOWN_PENDING */ \
171 TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
172 /* SCTP_STATE_SHUTDOWN_SENT */ \
173 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
174 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
175 TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
176 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
177 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
178 } /* TYPE_SCTP_SACK */
180 #define TYPE_SCTP_HEARTBEAT { \
181 /* SCTP_STATE_CLOSED */ \
182 TYPE_SCTP_FUNC(sctp_sf_ootb), \
183 /* SCTP_STATE_COOKIE_WAIT */ \
184 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
185 /* SCTP_STATE_COOKIE_ECHOED */ \
186 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
187 /* SCTP_STATE_ESTABLISHED */ \
188 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
189 /* SCTP_STATE_SHUTDOWN_PENDING */ \
190 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
191 /* SCTP_STATE_SHUTDOWN_SENT */ \
192 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
193 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
194 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
195 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
196 /* This should not happen, but we are nice. */ \
197 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
198 } /* TYPE_SCTP_HEARTBEAT */
200 #define TYPE_SCTP_HEARTBEAT_ACK { \
201 /* SCTP_STATE_CLOSED */ \
202 TYPE_SCTP_FUNC(sctp_sf_ootb), \
203 /* SCTP_STATE_COOKIE_WAIT */ \
204 TYPE_SCTP_FUNC(sctp_sf_violation), \
205 /* SCTP_STATE_COOKIE_ECHOED */ \
206 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
207 /* SCTP_STATE_ESTABLISHED */ \
208 TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
209 /* SCTP_STATE_SHUTDOWN_PENDING */ \
210 TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
211 /* SCTP_STATE_SHUTDOWN_SENT */ \
212 TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
213 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
214 TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
215 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
216 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
217 } /* TYPE_SCTP_HEARTBEAT_ACK */
219 #define TYPE_SCTP_ABORT { \
220 /* SCTP_STATE_CLOSED */ \
221 TYPE_SCTP_FUNC(sctp_sf_pdiscard), \
222 /* SCTP_STATE_COOKIE_WAIT */ \
223 TYPE_SCTP_FUNC(sctp_sf_cookie_wait_abort), \
224 /* SCTP_STATE_COOKIE_ECHOED */ \
225 TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_abort), \
226 /* SCTP_STATE_ESTABLISHED */ \
227 TYPE_SCTP_FUNC(sctp_sf_do_9_1_abort), \
228 /* SCTP_STATE_SHUTDOWN_PENDING */ \
229 TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_abort), \
230 /* SCTP_STATE_SHUTDOWN_SENT */ \
231 TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_abort), \
232 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
233 TYPE_SCTP_FUNC(sctp_sf_do_9_1_abort), \
234 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
235 TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_abort), \
236 } /* TYPE_SCTP_ABORT */
238 #define TYPE_SCTP_SHUTDOWN { \
239 /* SCTP_STATE_CLOSED */ \
240 TYPE_SCTP_FUNC(sctp_sf_ootb), \
241 /* SCTP_STATE_COOKIE_WAIT */ \
242 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
243 /* SCTP_STATE_COOKIE_ECHOED */ \
244 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
245 /* SCTP_STATE_ESTABLISHED */ \
246 TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown), \
247 /* SCTP_STATE_SHUTDOWN_PENDING */ \
248 TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown), \
249 /* SCTP_STATE_SHUTDOWN_SENT */ \
250 TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
251 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
252 TYPE_SCTP_FUNC(sctp_sf_do_9_2_shut_ctsn), \
253 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
254 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
255 } /* TYPE_SCTP_SHUTDOWN */
257 #define TYPE_SCTP_SHUTDOWN_ACK { \
258 /* SCTP_STATE_CLOSED */ \
259 TYPE_SCTP_FUNC(sctp_sf_ootb), \
260 /* SCTP_STATE_COOKIE_WAIT */ \
261 TYPE_SCTP_FUNC(sctp_sf_do_8_5_1_E_sa), \
262 /* SCTP_STATE_COOKIE_ECHOED */ \
263 TYPE_SCTP_FUNC(sctp_sf_do_8_5_1_E_sa), \
264 /* SCTP_STATE_ESTABLISHED */ \
265 TYPE_SCTP_FUNC(sctp_sf_violation), \
266 /* SCTP_STATE_SHUTDOWN_PENDING */ \
267 TYPE_SCTP_FUNC(sctp_sf_violation), \
268 /* SCTP_STATE_SHUTDOWN_SENT */ \
269 TYPE_SCTP_FUNC(sctp_sf_do_9_2_final), \
270 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
271 TYPE_SCTP_FUNC(sctp_sf_violation), \
272 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
273 TYPE_SCTP_FUNC(sctp_sf_do_9_2_final), \
274 } /* TYPE_SCTP_SHUTDOWN_ACK */
276 #define TYPE_SCTP_ERROR { \
277 /* SCTP_STATE_CLOSED */ \
278 TYPE_SCTP_FUNC(sctp_sf_ootb), \
279 /* SCTP_STATE_COOKIE_WAIT */ \
280 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
281 /* SCTP_STATE_COOKIE_ECHOED */ \
282 TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_err), \
283 /* SCTP_STATE_ESTABLISHED */ \
284 TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
285 /* SCTP_STATE_SHUTDOWN_PENDING */ \
286 TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
287 /* SCTP_STATE_SHUTDOWN_SENT */ \
288 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
289 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
290 TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
291 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
292 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
293 } /* TYPE_SCTP_ERROR */
295 #define TYPE_SCTP_COOKIE_ECHO { \
296 /* SCTP_STATE_CLOSED */ \
297 TYPE_SCTP_FUNC(sctp_sf_do_5_1D_ce), \
298 /* SCTP_STATE_COOKIE_WAIT */ \
299 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
300 /* SCTP_STATE_COOKIE_ECHOED */ \
301 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
302 /* SCTP_STATE_ESTABLISHED */ \
303 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
304 /* SCTP_STATE_SHUTDOWN_PENDING */ \
305 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
306 /* SCTP_STATE_SHUTDOWN_SENT */ \
307 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
308 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
309 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
310 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
311 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
312 } /* TYPE_SCTP_COOKIE_ECHO */
314 #define TYPE_SCTP_COOKIE_ACK { \
315 /* SCTP_STATE_CLOSED */ \
316 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
317 /* SCTP_STATE_COOKIE_WAIT */ \
318 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
319 /* SCTP_STATE_COOKIE_ECHOED */ \
320 TYPE_SCTP_FUNC(sctp_sf_do_5_1E_ca), \
321 /* SCTP_STATE_ESTABLISHED */ \
322 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
323 /* SCTP_STATE_SHUTDOWN_PENDING */ \
324 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
325 /* SCTP_STATE_SHUTDOWN_SENT */ \
326 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
327 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
328 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
329 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
330 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
331 } /* TYPE_SCTP_COOKIE_ACK */
333 #define TYPE_SCTP_ECN_ECNE { \
334 /* SCTP_STATE_CLOSED */ \
335 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
336 /* SCTP_STATE_COOKIE_WAIT */ \
337 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
338 /* SCTP_STATE_COOKIE_ECHOED */ \
339 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
340 /* SCTP_STATE_ESTABLISHED */ \
341 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
342 /* SCTP_STATE_SHUTDOWN_PENDING */ \
343 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
344 /* SCTP_STATE_SHUTDOWN_SENT */ \
345 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
346 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
347 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
348 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
349 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
350 } /* TYPE_SCTP_ECN_ECNE */
352 #define TYPE_SCTP_ECN_CWR { \
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_do_ecn_cwr), \
361 /* SCTP_STATE_SHUTDOWN_PENDING */ \
362 TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
363 /* SCTP_STATE_SHUTDOWN_SENT */ \
364 TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
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_discard_chunk), \
369 } /* TYPE_SCTP_ECN_CWR */
371 #define TYPE_SCTP_SHUTDOWN_COMPLETE { \
372 /* SCTP_STATE_CLOSED */ \
373 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
374 /* SCTP_STATE_COOKIE_WAIT */ \
375 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
376 /* SCTP_STATE_COOKIE_ECHOED */ \
377 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
378 /* SCTP_STATE_ESTABLISHED */ \
379 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
380 /* SCTP_STATE_SHUTDOWN_PENDING */ \
381 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
382 /* SCTP_STATE_SHUTDOWN_SENT */ \
383 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
384 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
385 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
386 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
387 TYPE_SCTP_FUNC(sctp_sf_do_4_C), \
388 } /* TYPE_SCTP_SHUTDOWN_COMPLETE */
390 /* The primary index for this table is the chunk type.
391 * The secondary index for this table is the state.
393 * For base protocol (RFC 2960).
395 static const sctp_sm_table_entry_t chunk_event_table[SCTP_NUM_BASE_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
396 TYPE_SCTP_DATA,
397 TYPE_SCTP_INIT,
398 TYPE_SCTP_INIT_ACK,
399 TYPE_SCTP_SACK,
400 TYPE_SCTP_HEARTBEAT,
401 TYPE_SCTP_HEARTBEAT_ACK,
402 TYPE_SCTP_ABORT,
403 TYPE_SCTP_SHUTDOWN,
404 TYPE_SCTP_SHUTDOWN_ACK,
405 TYPE_SCTP_ERROR,
406 TYPE_SCTP_COOKIE_ECHO,
407 TYPE_SCTP_COOKIE_ACK,
408 TYPE_SCTP_ECN_ECNE,
409 TYPE_SCTP_ECN_CWR,
410 TYPE_SCTP_SHUTDOWN_COMPLETE,
411 }; /* state_fn_t chunk_event_table[][] */
413 #define TYPE_SCTP_ASCONF { \
414 /* SCTP_STATE_CLOSED */ \
415 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
416 /* SCTP_STATE_COOKIE_WAIT */ \
417 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
418 /* SCTP_STATE_COOKIE_ECHOED */ \
419 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
420 /* SCTP_STATE_ESTABLISHED */ \
421 TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
422 /* SCTP_STATE_SHUTDOWN_PENDING */ \
423 TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
424 /* SCTP_STATE_SHUTDOWN_SENT */ \
425 TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
426 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
427 TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
428 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
429 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
430 } /* TYPE_SCTP_ASCONF */
432 #define TYPE_SCTP_ASCONF_ACK { \
433 /* SCTP_STATE_CLOSED */ \
434 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
435 /* SCTP_STATE_COOKIE_WAIT */ \
436 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
437 /* SCTP_STATE_COOKIE_ECHOED */ \
438 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
439 /* SCTP_STATE_ESTABLISHED */ \
440 TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
441 /* SCTP_STATE_SHUTDOWN_PENDING */ \
442 TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
443 /* SCTP_STATE_SHUTDOWN_SENT */ \
444 TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
445 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
446 TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
447 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
448 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
449 } /* TYPE_SCTP_ASCONF_ACK */
451 /* The primary index for this table is the chunk type.
452 * The secondary index for this table is the state.
454 static const sctp_sm_table_entry_t addip_chunk_event_table[SCTP_NUM_ADDIP_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
455 TYPE_SCTP_ASCONF,
456 TYPE_SCTP_ASCONF_ACK,
457 }; /*state_fn_t addip_chunk_event_table[][] */
459 #define TYPE_SCTP_FWD_TSN { \
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_discard_chunk), \
466 /* SCTP_STATE_ESTABLISHED */ \
467 TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn), \
468 /* SCTP_STATE_SHUTDOWN_PENDING */ \
469 TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn), \
470 /* SCTP_STATE_SHUTDOWN_SENT */ \
471 TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn_fast), \
472 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
473 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
474 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
475 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
476 } /* TYPE_SCTP_FWD_TSN */
478 /* The primary index for this table is the chunk type.
479 * The secondary index for this table is the state.
481 static const sctp_sm_table_entry_t prsctp_chunk_event_table[SCTP_NUM_PRSCTP_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
482 TYPE_SCTP_FWD_TSN,
483 }; /*state_fn_t prsctp_chunk_event_table[][] */
485 #define TYPE_SCTP_AUTH { \
486 /* SCTP_STATE_CLOSED */ \
487 TYPE_SCTP_FUNC(sctp_sf_ootb), \
488 /* SCTP_STATE_COOKIE_WAIT */ \
489 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
490 /* SCTP_STATE_COOKIE_ECHOED */ \
491 TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
492 /* SCTP_STATE_ESTABLISHED */ \
493 TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
494 /* SCTP_STATE_SHUTDOWN_PENDING */ \
495 TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
496 /* SCTP_STATE_SHUTDOWN_SENT */ \
497 TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
498 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
499 TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
500 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
501 TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
502 } /* TYPE_SCTP_AUTH */
504 /* The primary index for this table is the chunk type.
505 * The secondary index for this table is the state.
507 static const sctp_sm_table_entry_t auth_chunk_event_table[SCTP_NUM_AUTH_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
508 TYPE_SCTP_AUTH,
509 }; /*state_fn_t auth_chunk_event_table[][] */
511 static const sctp_sm_table_entry_t
512 chunk_event_table_unknown[SCTP_STATE_NUM_STATES] = {
513 /* SCTP_STATE_CLOSED */
514 TYPE_SCTP_FUNC(sctp_sf_ootb),
515 /* SCTP_STATE_COOKIE_WAIT */
516 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
517 /* SCTP_STATE_COOKIE_ECHOED */
518 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
519 /* SCTP_STATE_ESTABLISHED */
520 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
521 /* SCTP_STATE_SHUTDOWN_PENDING */
522 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
523 /* SCTP_STATE_SHUTDOWN_SENT */
524 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
525 /* SCTP_STATE_SHUTDOWN_RECEIVED */
526 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
527 /* SCTP_STATE_SHUTDOWN_ACK_SENT */
528 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
529 }; /* chunk unknown */
532 #define TYPE_SCTP_PRIMITIVE_ASSOCIATE { \
533 /* SCTP_STATE_CLOSED */ \
534 TYPE_SCTP_FUNC(sctp_sf_do_prm_asoc), \
535 /* SCTP_STATE_COOKIE_WAIT */ \
536 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
537 /* SCTP_STATE_COOKIE_ECHOED */ \
538 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
539 /* SCTP_STATE_ESTABLISHED */ \
540 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
541 /* SCTP_STATE_SHUTDOWN_PENDING */ \
542 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
543 /* SCTP_STATE_SHUTDOWN_SENT */ \
544 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
545 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
546 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
547 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
548 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
549 } /* TYPE_SCTP_PRIMITIVE_ASSOCIATE */
551 #define TYPE_SCTP_PRIMITIVE_SHUTDOWN { \
552 /* SCTP_STATE_CLOSED */ \
553 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
554 /* SCTP_STATE_COOKIE_WAIT */ \
555 TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_shutdown), \
556 /* SCTP_STATE_COOKIE_ECHOED */ \
557 TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_shutdown),\
558 /* SCTP_STATE_ESTABLISHED */ \
559 TYPE_SCTP_FUNC(sctp_sf_do_9_2_prm_shutdown), \
560 /* SCTP_STATE_SHUTDOWN_PENDING */ \
561 TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
562 /* SCTP_STATE_SHUTDOWN_SENT */ \
563 TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
564 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
565 TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
566 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
567 TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
568 } /* TYPE_SCTP_PRIMITIVE_SHUTDOWN */
570 #define TYPE_SCTP_PRIMITIVE_ABORT { \
571 /* SCTP_STATE_CLOSED */ \
572 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
573 /* SCTP_STATE_COOKIE_WAIT */ \
574 TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_abort), \
575 /* SCTP_STATE_COOKIE_ECHOED */ \
576 TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_abort), \
577 /* SCTP_STATE_ESTABLISHED */ \
578 TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
579 /* SCTP_STATE_SHUTDOWN_PENDING */ \
580 TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_prm_abort), \
581 /* SCTP_STATE_SHUTDOWN_SENT */ \
582 TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_prm_abort), \
583 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
584 TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
585 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
586 TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_prm_abort), \
587 } /* TYPE_SCTP_PRIMITIVE_ABORT */
589 #define TYPE_SCTP_PRIMITIVE_SEND { \
590 /* SCTP_STATE_CLOSED */ \
591 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
592 /* SCTP_STATE_COOKIE_WAIT */ \
593 TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
594 /* SCTP_STATE_COOKIE_ECHOED */ \
595 TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
596 /* SCTP_STATE_ESTABLISHED */ \
597 TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
598 /* SCTP_STATE_SHUTDOWN_PENDING */ \
599 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
600 /* SCTP_STATE_SHUTDOWN_SENT */ \
601 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
602 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
603 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
604 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
605 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
606 } /* TYPE_SCTP_PRIMITIVE_SEND */
608 #define TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT { \
609 /* SCTP_STATE_CLOSED */ \
610 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
611 /* SCTP_STATE_COOKIE_WAIT */ \
612 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
613 /* SCTP_STATE_COOKIE_ECHOED */ \
614 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
615 /* SCTP_STATE_ESTABLISHED */ \
616 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
617 /* SCTP_STATE_SHUTDOWN_PENDING */ \
618 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
619 /* SCTP_STATE_SHUTDOWN_SENT */ \
620 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
621 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
622 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
623 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
624 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
625 } /* TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT */
627 #define TYPE_SCTP_PRIMITIVE_ASCONF { \
628 /* SCTP_STATE_CLOSED */ \
629 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
630 /* SCTP_STATE_COOKIE_WAIT */ \
631 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
632 /* SCTP_STATE_COOKIE_ECHOED */ \
633 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
634 /* SCTP_STATE_ESTABLISHED */ \
635 TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
636 /* SCTP_STATE_SHUTDOWN_PENDING */ \
637 TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
638 /* SCTP_STATE_SHUTDOWN_SENT */ \
639 TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
640 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
641 TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
642 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
643 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
644 } /* TYPE_SCTP_PRIMITIVE_ASCONF */
646 /* The primary index for this table is the primitive type.
647 * The secondary index for this table is the state.
649 static const sctp_sm_table_entry_t primitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES] = {
650 TYPE_SCTP_PRIMITIVE_ASSOCIATE,
651 TYPE_SCTP_PRIMITIVE_SHUTDOWN,
652 TYPE_SCTP_PRIMITIVE_ABORT,
653 TYPE_SCTP_PRIMITIVE_SEND,
654 TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT,
655 TYPE_SCTP_PRIMITIVE_ASCONF,
658 #define TYPE_SCTP_OTHER_NO_PENDING_TSN { \
659 /* SCTP_STATE_CLOSED */ \
660 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
661 /* SCTP_STATE_COOKIE_WAIT */ \
662 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
663 /* SCTP_STATE_COOKIE_ECHOED */ \
664 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
665 /* SCTP_STATE_ESTABLISHED */ \
666 TYPE_SCTP_FUNC(sctp_sf_do_no_pending_tsn), \
667 /* SCTP_STATE_SHUTDOWN_PENDING */ \
668 TYPE_SCTP_FUNC(sctp_sf_do_9_2_start_shutdown), \
669 /* SCTP_STATE_SHUTDOWN_SENT */ \
670 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
671 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
672 TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
673 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
674 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
677 #define TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH { \
678 /* SCTP_STATE_CLOSED */ \
679 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
680 /* SCTP_STATE_COOKIE_WAIT */ \
681 TYPE_SCTP_FUNC(sctp_sf_cookie_wait_icmp_abort), \
682 /* SCTP_STATE_COOKIE_ECHOED */ \
683 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
684 /* SCTP_STATE_ESTABLISHED */ \
685 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
686 /* SCTP_STATE_SHUTDOWN_PENDING */ \
687 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
688 /* SCTP_STATE_SHUTDOWN_SENT */ \
689 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
690 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
691 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
692 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
693 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
696 static const sctp_sm_table_entry_t other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES] = {
697 TYPE_SCTP_OTHER_NO_PENDING_TSN,
698 TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH,
701 #define TYPE_SCTP_EVENT_TIMEOUT_NONE { \
702 /* SCTP_STATE_CLOSED */ \
703 TYPE_SCTP_FUNC(sctp_sf_bug), \
704 /* SCTP_STATE_COOKIE_WAIT */ \
705 TYPE_SCTP_FUNC(sctp_sf_bug), \
706 /* SCTP_STATE_COOKIE_ECHOED */ \
707 TYPE_SCTP_FUNC(sctp_sf_bug), \
708 /* SCTP_STATE_ESTABLISHED */ \
709 TYPE_SCTP_FUNC(sctp_sf_bug), \
710 /* SCTP_STATE_SHUTDOWN_PENDING */ \
711 TYPE_SCTP_FUNC(sctp_sf_bug), \
712 /* SCTP_STATE_SHUTDOWN_SENT */ \
713 TYPE_SCTP_FUNC(sctp_sf_bug), \
714 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
715 TYPE_SCTP_FUNC(sctp_sf_bug), \
716 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
717 TYPE_SCTP_FUNC(sctp_sf_bug), \
720 #define TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE { \
721 /* SCTP_STATE_CLOSED */ \
722 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
723 /* SCTP_STATE_COOKIE_WAIT */ \
724 TYPE_SCTP_FUNC(sctp_sf_bug), \
725 /* SCTP_STATE_COOKIE_ECHOED */ \
726 TYPE_SCTP_FUNC(sctp_sf_t1_cookie_timer_expire), \
727 /* SCTP_STATE_ESTABLISHED */ \
728 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
729 /* SCTP_STATE_SHUTDOWN_PENDING */ \
730 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
731 /* SCTP_STATE_SHUTDOWN_SENT */ \
732 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
733 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
734 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
735 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
736 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
739 #define TYPE_SCTP_EVENT_TIMEOUT_T1_INIT { \
740 /* SCTP_STATE_CLOSED */ \
741 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
742 /* SCTP_STATE_COOKIE_WAIT */ \
743 TYPE_SCTP_FUNC(sctp_sf_t1_init_timer_expire), \
744 /* SCTP_STATE_COOKIE_ECHOED */ \
745 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
746 /* SCTP_STATE_ESTABLISHED */ \
747 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
748 /* SCTP_STATE_SHUTDOWN_PENDING */ \
749 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
750 /* SCTP_STATE_SHUTDOWN_SENT */ \
751 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
752 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
753 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
754 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
755 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
758 #define TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN { \
759 /* SCTP_STATE_CLOSED */ \
760 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
761 /* SCTP_STATE_COOKIE_WAIT */ \
762 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
763 /* SCTP_STATE_COOKIE_ECHOED */ \
764 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
765 /* SCTP_STATE_ESTABLISHED */ \
766 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
767 /* SCTP_STATE_SHUTDOWN_PENDING */ \
768 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
769 /* SCTP_STATE_SHUTDOWN_SENT */ \
770 TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
771 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
772 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
773 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
774 TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
777 #define TYPE_SCTP_EVENT_TIMEOUT_T3_RTX { \
778 /* SCTP_STATE_CLOSED */ \
779 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
780 /* SCTP_STATE_COOKIE_WAIT */ \
781 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
782 /* SCTP_STATE_COOKIE_ECHOED */ \
783 TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
784 /* SCTP_STATE_ESTABLISHED */ \
785 TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
786 /* SCTP_STATE_SHUTDOWN_PENDING */ \
787 TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
788 /* SCTP_STATE_SHUTDOWN_SENT */ \
789 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
790 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
791 TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
792 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
793 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
796 #define TYPE_SCTP_EVENT_TIMEOUT_T4_RTO { \
797 /* SCTP_STATE_CLOSED */ \
798 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
799 /* SCTP_STATE_COOKIE_WAIT */ \
800 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
801 /* SCTP_STATE_COOKIE_ECHOED */ \
802 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
803 /* SCTP_STATE_ESTABLISHED */ \
804 TYPE_SCTP_FUNC(sctp_sf_t4_timer_expire), \
805 /* SCTP_STATE_SHUTDOWN_PENDING */ \
806 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
807 /* SCTP_STATE_SHUTDOWN_SENT */ \
808 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
809 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
810 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
811 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
812 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
815 #define TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD { \
816 /* SCTP_STATE_CLOSED */ \
817 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
818 /* SCTP_STATE_COOKIE_WAIT */ \
819 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
820 /* SCTP_STATE_COOKIE_ECHOED */ \
821 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
822 /* SCTP_STATE_ESTABLISHED */ \
823 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
824 /* SCTP_STATE_SHUTDOWN_PENDING */ \
825 TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
826 /* SCTP_STATE_SHUTDOWN_SENT */ \
827 TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
828 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
829 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
830 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
831 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
834 #define TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT { \
835 /* SCTP_STATE_CLOSED */ \
836 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
837 /* SCTP_STATE_COOKIE_WAIT */ \
838 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
839 /* SCTP_STATE_COOKIE_ECHOED */ \
840 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
841 /* SCTP_STATE_ESTABLISHED */ \
842 TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
843 /* SCTP_STATE_SHUTDOWN_PENDING */ \
844 TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
845 /* SCTP_STATE_SHUTDOWN_SENT */ \
846 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
847 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
848 TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
849 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
850 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
853 #define TYPE_SCTP_EVENT_TIMEOUT_SACK { \
854 /* SCTP_STATE_CLOSED */ \
855 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
856 /* SCTP_STATE_COOKIE_WAIT */ \
857 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
858 /* SCTP_STATE_COOKIE_ECHOED */ \
859 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
860 /* SCTP_STATE_ESTABLISHED */ \
861 TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
862 /* SCTP_STATE_SHUTDOWN_PENDING */ \
863 TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
864 /* SCTP_STATE_SHUTDOWN_SENT */ \
865 TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
866 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
867 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
868 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
869 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
872 #define TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE { \
873 /* SCTP_STATE_CLOSED */ \
874 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
875 /* SCTP_STATE_COOKIE_WAIT */ \
876 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
877 /* SCTP_STATE_COOKIE_ECHOED */ \
878 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
879 /* SCTP_STATE_ESTABLISHED */ \
880 TYPE_SCTP_FUNC(sctp_sf_autoclose_timer_expire), \
881 /* SCTP_STATE_SHUTDOWN_PENDING */ \
882 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
883 /* SCTP_STATE_SHUTDOWN_SENT */ \
884 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
885 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
886 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
887 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
888 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
891 static const sctp_sm_table_entry_t timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES] = {
892 TYPE_SCTP_EVENT_TIMEOUT_NONE,
893 TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE,
894 TYPE_SCTP_EVENT_TIMEOUT_T1_INIT,
895 TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN,
896 TYPE_SCTP_EVENT_TIMEOUT_T3_RTX,
897 TYPE_SCTP_EVENT_TIMEOUT_T4_RTO,
898 TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD,
899 TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT,
900 TYPE_SCTP_EVENT_TIMEOUT_SACK,
901 TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE,
904 static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(struct net *net,
905 sctp_cid_t cid,
906 sctp_state_t state)
908 if (state > SCTP_STATE_MAX)
909 return &bug;
911 if (cid <= SCTP_CID_BASE_MAX)
912 return &chunk_event_table[cid][state];
914 if (net->sctp.prsctp_enable) {
915 if (cid == SCTP_CID_FWD_TSN)
916 return &prsctp_chunk_event_table[0][state];
919 if (net->sctp.addip_enable) {
920 if (cid == SCTP_CID_ASCONF)
921 return &addip_chunk_event_table[0][state];
923 if (cid == SCTP_CID_ASCONF_ACK)
924 return &addip_chunk_event_table[1][state];
927 if (net->sctp.auth_enable) {
928 if (cid == SCTP_CID_AUTH)
929 return &auth_chunk_event_table[0][state];
932 return &chunk_event_table_unknown[state];