Merge ../linux-2.6-watchdog-mm
[linux-2.6] / net / sctp / sm_statetable.c
1 /* SCTP kernel reference 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 reference Implementation
9  *
10  * These are the state tables for the SCTP state machine.
11  *
12  * The SCTP reference 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  * The SCTP reference 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
49 #include <linux/skbuff.h>
50 #include <net/sctp/sctp.h>
51 #include <net/sctp/sm.h>
52
53 static const sctp_sm_table_entry_t
54 primitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES];
55 static const sctp_sm_table_entry_t
56 other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES];
57 static const sctp_sm_table_entry_t
58 timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES];
59
60 static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t cid,
61                                                             sctp_state_t state);
62
63
64 static const sctp_sm_table_entry_t bug = {
65         .fn = sctp_sf_bug,
66         .name = "sctp_sf_bug"
67 };
68
69 #define DO_LOOKUP(_max, _type, _table) \
70         if ((event_subtype._type > (_max))) { \
71                 printk(KERN_WARNING \
72                        "sctp table %p possible attack:" \
73                        " event %d exceeds max %d\n", \
74                        _table, event_subtype._type, _max); \
75                 return &bug; \
76         } \
77         return &_table[event_subtype._type][(int)state];
78
79 const sctp_sm_table_entry_t *sctp_sm_lookup_event(sctp_event_t event_type,
80                                                   sctp_state_t state,
81                                                   sctp_subtype_t event_subtype)
82 {
83         switch (event_type) {
84         case SCTP_EVENT_T_CHUNK:
85                 return sctp_chunk_event_lookup(event_subtype.chunk, state);
86                 break;
87         case SCTP_EVENT_T_TIMEOUT:
88                 DO_LOOKUP(SCTP_EVENT_TIMEOUT_MAX, timeout,
89                           timeout_event_table);
90                 break;
91
92         case SCTP_EVENT_T_OTHER:
93                 DO_LOOKUP(SCTP_EVENT_OTHER_MAX, other, other_event_table);
94                 break;
95
96         case SCTP_EVENT_T_PRIMITIVE:
97                 DO_LOOKUP(SCTP_EVENT_PRIMITIVE_MAX, primitive,
98                           primitive_event_table);
99                 break;
100
101         default:
102                 /* Yikes!  We got an illegal event type.  */
103                 return &bug;
104         };
105 }
106
107 #define TYPE_SCTP_FUNC(func) {.fn = func, .name = #func}
108
109 #define TYPE_SCTP_DATA { \
110         /* SCTP_STATE_EMPTY */ \
111         TYPE_SCTP_FUNC(sctp_sf_ootb), \
112         /* SCTP_STATE_CLOSED */ \
113         TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
114         /* SCTP_STATE_COOKIE_WAIT */ \
115         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
116         /* SCTP_STATE_COOKIE_ECHOED */ \
117         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
118         /* SCTP_STATE_ESTABLISHED */ \
119         TYPE_SCTP_FUNC(sctp_sf_eat_data_6_2), \
120         /* SCTP_STATE_SHUTDOWN_PENDING */ \
121         TYPE_SCTP_FUNC(sctp_sf_eat_data_6_2), \
122         /* SCTP_STATE_SHUTDOWN_SENT */ \
123         TYPE_SCTP_FUNC(sctp_sf_eat_data_fast_4_4), \
124         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
125         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
126         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
127         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
128 } /* TYPE_SCTP_DATA */
129
130 #define TYPE_SCTP_INIT { \
131         /* SCTP_STATE_EMPTY */ \
132         TYPE_SCTP_FUNC(sctp_sf_bug), \
133         /* SCTP_STATE_CLOSED */ \
134         TYPE_SCTP_FUNC(sctp_sf_do_5_1B_init), \
135         /* SCTP_STATE_COOKIE_WAIT */ \
136         TYPE_SCTP_FUNC(sctp_sf_do_5_2_1_siminit), \
137         /* SCTP_STATE_COOKIE_ECHOED */ \
138         TYPE_SCTP_FUNC(sctp_sf_do_5_2_1_siminit), \
139         /* SCTP_STATE_ESTABLISHED */ \
140         TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
141         /* SCTP_STATE_SHUTDOWN_PENDING */ \
142         TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
143         /* SCTP_STATE_SHUTDOWN_SENT */ \
144         TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
145         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
146         TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
147         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
148         TYPE_SCTP_FUNC(sctp_sf_do_9_2_reshutack), \
149 } /* TYPE_SCTP_INIT */
150
151 #define TYPE_SCTP_INIT_ACK { \
152         /* SCTP_STATE_EMPTY */ \
153         TYPE_SCTP_FUNC(sctp_sf_ootb), \
154         /* SCTP_STATE_CLOSED */ \
155         TYPE_SCTP_FUNC(sctp_sf_do_5_2_3_initack), \
156         /* SCTP_STATE_COOKIE_WAIT */ \
157         TYPE_SCTP_FUNC(sctp_sf_do_5_1C_ack), \
158         /* SCTP_STATE_COOKIE_ECHOED */ \
159         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
160         /* SCTP_STATE_ESTABLISHED */ \
161         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
162         /* SCTP_STATE_SHUTDOWN_PENDING */ \
163         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
164         /* SCTP_STATE_SHUTDOWN_SENT */ \
165         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
166         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
167         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
168         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
169         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
170 } /* TYPE_SCTP_INIT_ACK */
171
172 #define TYPE_SCTP_SACK { \
173         /*  SCTP_STATE_EMPTY */ \
174         TYPE_SCTP_FUNC(sctp_sf_ootb), \
175         /* SCTP_STATE_CLOSED */ \
176         TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
177         /* SCTP_STATE_COOKIE_WAIT */ \
178         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
179         /* SCTP_STATE_COOKIE_ECHOED */ \
180         TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
181         /* SCTP_STATE_ESTABLISHED */ \
182         TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
183         /* SCTP_STATE_SHUTDOWN_PENDING */ \
184         TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
185         /* SCTP_STATE_SHUTDOWN_SENT */ \
186         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
187         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
188         TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
189         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
190         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
191 } /* TYPE_SCTP_SACK */
192
193 #define TYPE_SCTP_HEARTBEAT { \
194         /*  SCTP_STATE_EMPTY */ \
195         TYPE_SCTP_FUNC(sctp_sf_ootb), \
196         /* SCTP_STATE_CLOSED */ \
197         TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
198         /* SCTP_STATE_COOKIE_WAIT */ \
199         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
200         /* SCTP_STATE_COOKIE_ECHOED */ \
201         TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
202         /* SCTP_STATE_ESTABLISHED */ \
203         TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
204         /* SCTP_STATE_SHUTDOWN_PENDING */ \
205         TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
206         /* SCTP_STATE_SHUTDOWN_SENT */ \
207         TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
208         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
209         TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
210         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
211         /* This should not happen, but we are nice.  */ \
212         TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
213 } /* TYPE_SCTP_HEARTBEAT */
214
215 #define TYPE_SCTP_HEARTBEAT_ACK { \
216         /*  SCTP_STATE_EMPTY */ \
217         TYPE_SCTP_FUNC(sctp_sf_ootb), \
218         /* SCTP_STATE_CLOSED */ \
219         TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
220         /* SCTP_STATE_COOKIE_WAIT */ \
221         TYPE_SCTP_FUNC(sctp_sf_violation), \
222         /* SCTP_STATE_COOKIE_ECHOED */ \
223         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
224         /* SCTP_STATE_ESTABLISHED */ \
225         TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
226         /* SCTP_STATE_SHUTDOWN_PENDING */ \
227         TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
228         /* SCTP_STATE_SHUTDOWN_SENT */ \
229         TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
230         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
231         TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
232         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
233         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
234 } /* TYPE_SCTP_HEARTBEAT_ACK */
235
236 #define TYPE_SCTP_ABORT { \
237         /* SCTP_STATE_EMPTY */ \
238         TYPE_SCTP_FUNC(sctp_sf_ootb), \
239         /* SCTP_STATE_CLOSED */ \
240         TYPE_SCTP_FUNC(sctp_sf_pdiscard), \
241         /* SCTP_STATE_COOKIE_WAIT */ \
242         TYPE_SCTP_FUNC(sctp_sf_cookie_wait_abort), \
243         /* SCTP_STATE_COOKIE_ECHOED */ \
244         TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_abort), \
245         /* SCTP_STATE_ESTABLISHED */ \
246         TYPE_SCTP_FUNC(sctp_sf_do_9_1_abort), \
247         /* SCTP_STATE_SHUTDOWN_PENDING */ \
248         TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_abort), \
249         /* SCTP_STATE_SHUTDOWN_SENT */ \
250         TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_abort), \
251         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
252         TYPE_SCTP_FUNC(sctp_sf_do_9_1_abort), \
253         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
254         TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_abort), \
255 } /* TYPE_SCTP_ABORT */
256
257 #define TYPE_SCTP_SHUTDOWN { \
258         /* SCTP_STATE_EMPTY */ \
259         TYPE_SCTP_FUNC(sctp_sf_ootb), \
260         /* SCTP_STATE_CLOSED */ \
261         TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
262         /* SCTP_STATE_COOKIE_WAIT */ \
263         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
264         /* SCTP_STATE_COOKIE_ECHOED */ \
265         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
266         /* SCTP_STATE_ESTABLISHED */ \
267         TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown), \
268         /* SCTP_STATE_SHUTDOWN_PENDING */ \
269         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
270         /* SCTP_STATE_SHUTDOWN_SENT */ \
271         TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
272         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
273         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
274         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
275         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
276 } /* TYPE_SCTP_SHUTDOWN */
277
278 #define TYPE_SCTP_SHUTDOWN_ACK { \
279         /* SCTP_STATE_EMPTY */ \
280         TYPE_SCTP_FUNC(sctp_sf_ootb), \
281         /* SCTP_STATE_CLOSED */ \
282         TYPE_SCTP_FUNC(sctp_sf_ootb), \
283         /* SCTP_STATE_COOKIE_WAIT */ \
284         TYPE_SCTP_FUNC(sctp_sf_do_8_5_1_E_sa), \
285         /* SCTP_STATE_COOKIE_ECHOED */ \
286         TYPE_SCTP_FUNC(sctp_sf_do_8_5_1_E_sa), \
287         /* SCTP_STATE_ESTABLISHED */ \
288         TYPE_SCTP_FUNC(sctp_sf_violation), \
289         /* SCTP_STATE_SHUTDOWN_PENDING */ \
290         TYPE_SCTP_FUNC(sctp_sf_violation), \
291         /* SCTP_STATE_SHUTDOWN_SENT */ \
292         TYPE_SCTP_FUNC(sctp_sf_do_9_2_final), \
293         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
294         TYPE_SCTP_FUNC(sctp_sf_violation), \
295         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
296         TYPE_SCTP_FUNC(sctp_sf_do_9_2_final), \
297 } /* TYPE_SCTP_SHUTDOWN_ACK */
298
299 #define TYPE_SCTP_ERROR { \
300         /* SCTP_STATE_EMPTY */ \
301         TYPE_SCTP_FUNC(sctp_sf_ootb), \
302         /* SCTP_STATE_CLOSED */ \
303         TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
304         /* SCTP_STATE_COOKIE_WAIT */ \
305         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
306         /* SCTP_STATE_COOKIE_ECHOED */ \
307         TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_err), \
308         /* SCTP_STATE_ESTABLISHED */ \
309         TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
310         /* SCTP_STATE_SHUTDOWN_PENDING */ \
311         TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
312         /* SCTP_STATE_SHUTDOWN_SENT */ \
313         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
314         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
315         TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
316         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
317         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
318 } /* TYPE_SCTP_ERROR */
319
320 #define TYPE_SCTP_COOKIE_ECHO { \
321         /* SCTP_STATE_EMPTY */ \
322         TYPE_SCTP_FUNC(sctp_sf_bug), \
323         /* SCTP_STATE_CLOSED */ \
324         TYPE_SCTP_FUNC(sctp_sf_do_5_1D_ce), \
325         /* SCTP_STATE_COOKIE_WAIT */ \
326         TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
327         /* SCTP_STATE_COOKIE_ECHOED */ \
328         TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
329         /* SCTP_STATE_ESTABLISHED */ \
330         TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
331         /* SCTP_STATE_SHUTDOWN_PENDING */ \
332         TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
333         /* SCTP_STATE_SHUTDOWN_SENT */ \
334         TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
335         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
336         TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
337         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
338         TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
339 } /* TYPE_SCTP_COOKIE_ECHO */
340
341 #define TYPE_SCTP_COOKIE_ACK { \
342         /* SCTP_STATE_EMPTY */ \
343         TYPE_SCTP_FUNC(sctp_sf_ootb), \
344         /* SCTP_STATE_CLOSED */ \
345         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
346         /* SCTP_STATE_COOKIE_WAIT */ \
347         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
348         /* SCTP_STATE_COOKIE_ECHOED */ \
349         TYPE_SCTP_FUNC(sctp_sf_do_5_1E_ca), \
350         /* SCTP_STATE_ESTABLISHED */ \
351         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
352         /* SCTP_STATE_SHUTDOWN_PENDING */ \
353         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
354         /* SCTP_STATE_SHUTDOWN_SENT */ \
355         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
356         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
357         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
358         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
359         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
360 } /* TYPE_SCTP_COOKIE_ACK */
361
362 #define TYPE_SCTP_ECN_ECNE { \
363         /* SCTP_STATE_EMPTY */ \
364         TYPE_SCTP_FUNC(sctp_sf_ootb), \
365         /* SCTP_STATE_CLOSED */ \
366         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
367         /* SCTP_STATE_COOKIE_WAIT */ \
368         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
369         /* SCTP_STATE_COOKIE_ECHOED */ \
370         TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
371         /* SCTP_STATE_ESTABLISHED */ \
372         TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
373         /* SCTP_STATE_SHUTDOWN_PENDING */ \
374         TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
375         /* SCTP_STATE_SHUTDOWN_SENT */ \
376         TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
377         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
378         TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
379         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
380         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
381 } /* TYPE_SCTP_ECN_ECNE */
382
383 #define TYPE_SCTP_ECN_CWR { \
384         /* SCTP_STATE_EMPTY */ \
385         TYPE_SCTP_FUNC(sctp_sf_ootb), \
386         /* SCTP_STATE_CLOSED */ \
387         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
388         /* SCTP_STATE_COOKIE_WAIT */ \
389         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
390         /* SCTP_STATE_COOKIE_ECHOED */ \
391         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
392         /* SCTP_STATE_ESTABLISHED */ \
393         TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
394         /* SCTP_STATE_SHUTDOWN_PENDING */ \
395         TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
396         /* SCTP_STATE_SHUTDOWN_SENT */ \
397         TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
398         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
399         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
400         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
401         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
402 } /* TYPE_SCTP_ECN_CWR */
403
404 #define TYPE_SCTP_SHUTDOWN_COMPLETE { \
405         /* SCTP_STATE_EMPTY */ \
406         TYPE_SCTP_FUNC(sctp_sf_ootb), \
407         /* SCTP_STATE_CLOSED */ \
408         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
409         /* SCTP_STATE_COOKIE_WAIT */ \
410         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
411         /* SCTP_STATE_COOKIE_ECHOED */ \
412         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
413         /* SCTP_STATE_ESTABLISHED */ \
414         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
415         /* SCTP_STATE_SHUTDOWN_PENDING */ \
416         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
417         /* SCTP_STATE_SHUTDOWN_SENT */ \
418         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
419         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
420         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
421         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
422         TYPE_SCTP_FUNC(sctp_sf_do_4_C), \
423 } /* TYPE_SCTP_SHUTDOWN_COMPLETE */
424
425 /* The primary index for this table is the chunk type.
426  * The secondary index for this table is the state.
427  *
428  * For base protocol (RFC 2960).
429  */
430 static const sctp_sm_table_entry_t chunk_event_table[SCTP_NUM_BASE_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
431         TYPE_SCTP_DATA,
432         TYPE_SCTP_INIT,
433         TYPE_SCTP_INIT_ACK,
434         TYPE_SCTP_SACK,
435         TYPE_SCTP_HEARTBEAT,
436         TYPE_SCTP_HEARTBEAT_ACK,
437         TYPE_SCTP_ABORT,
438         TYPE_SCTP_SHUTDOWN,
439         TYPE_SCTP_SHUTDOWN_ACK,
440         TYPE_SCTP_ERROR,
441         TYPE_SCTP_COOKIE_ECHO,
442         TYPE_SCTP_COOKIE_ACK,
443         TYPE_SCTP_ECN_ECNE,
444         TYPE_SCTP_ECN_CWR,
445         TYPE_SCTP_SHUTDOWN_COMPLETE,
446 }; /* state_fn_t chunk_event_table[][] */
447
448 #define TYPE_SCTP_ASCONF { \
449         /* SCTP_STATE_EMPTY */ \
450         TYPE_SCTP_FUNC(sctp_sf_ootb), \
451         /* SCTP_STATE_CLOSED */ \
452         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
453         /* SCTP_STATE_COOKIE_WAIT */ \
454         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
455         /* SCTP_STATE_COOKIE_ECHOED */ \
456         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
457         /* SCTP_STATE_ESTABLISHED */ \
458         TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
459         /* SCTP_STATE_SHUTDOWN_PENDING */ \
460         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
461         /* SCTP_STATE_SHUTDOWN_SENT */ \
462         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
463         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
464         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
465         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
466         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
467 } /* TYPE_SCTP_ASCONF */
468
469 #define TYPE_SCTP_ASCONF_ACK { \
470         /* SCTP_STATE_EMPTY */ \
471         TYPE_SCTP_FUNC(sctp_sf_ootb), \
472         /* SCTP_STATE_CLOSED */ \
473         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
474         /* SCTP_STATE_COOKIE_WAIT */ \
475         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
476         /* SCTP_STATE_COOKIE_ECHOED */ \
477         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
478         /* SCTP_STATE_ESTABLISHED */ \
479         TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
480         /* SCTP_STATE_SHUTDOWN_PENDING */ \
481         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
482         /* SCTP_STATE_SHUTDOWN_SENT */ \
483         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
484         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
485         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
486         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
487         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
488 } /* TYPE_SCTP_ASCONF_ACK */
489
490 /* The primary index for this table is the chunk type.
491  * The secondary index for this table is the state.
492  */
493 static const sctp_sm_table_entry_t addip_chunk_event_table[SCTP_NUM_ADDIP_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
494         TYPE_SCTP_ASCONF,
495         TYPE_SCTP_ASCONF_ACK,
496 }; /*state_fn_t addip_chunk_event_table[][] */
497
498 #define TYPE_SCTP_FWD_TSN { \
499         /* SCTP_STATE_EMPTY */ \
500         TYPE_SCTP_FUNC(sctp_sf_ootb), \
501         /* SCTP_STATE_CLOSED */ \
502         TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
503         /* SCTP_STATE_COOKIE_WAIT */ \
504         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
505         /* SCTP_STATE_COOKIE_ECHOED */ \
506         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
507         /* SCTP_STATE_ESTABLISHED */ \
508         TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn), \
509         /* SCTP_STATE_SHUTDOWN_PENDING */ \
510         TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn), \
511         /* SCTP_STATE_SHUTDOWN_SENT */ \
512         TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn_fast), \
513         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
514         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
515         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
516         TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
517 } /* TYPE_SCTP_FWD_TSN */
518
519 /* The primary index for this table is the chunk type.
520  * The secondary index for this table is the state.
521  */
522 static const sctp_sm_table_entry_t prsctp_chunk_event_table[SCTP_NUM_PRSCTP_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
523         TYPE_SCTP_FWD_TSN,
524 }; /*state_fn_t prsctp_chunk_event_table[][] */
525
526 static const sctp_sm_table_entry_t
527 chunk_event_table_unknown[SCTP_STATE_NUM_STATES] = {
528         /* SCTP_STATE_EMPTY */
529         TYPE_SCTP_FUNC(sctp_sf_ootb),
530         /* SCTP_STATE_CLOSED */
531         TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8),
532         /* SCTP_STATE_COOKIE_WAIT */
533         TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
534         /* SCTP_STATE_COOKIE_ECHOED */
535         TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
536         /* SCTP_STATE_ESTABLISHED */
537         TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
538         /* SCTP_STATE_SHUTDOWN_PENDING */
539         TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
540         /* SCTP_STATE_SHUTDOWN_SENT */
541         TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
542         /* SCTP_STATE_SHUTDOWN_RECEIVED */
543         TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
544         /* SCTP_STATE_SHUTDOWN_ACK_SENT */
545         TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
546 };      /* chunk unknown */
547
548
549 #define TYPE_SCTP_PRIMITIVE_ASSOCIATE  { \
550         /* SCTP_STATE_EMPTY */ \
551         TYPE_SCTP_FUNC(sctp_sf_bug), \
552         /* SCTP_STATE_CLOSED */ \
553         TYPE_SCTP_FUNC(sctp_sf_do_prm_asoc), \
554         /* SCTP_STATE_COOKIE_WAIT */ \
555         TYPE_SCTP_FUNC(sctp_sf_not_impl), \
556         /* SCTP_STATE_COOKIE_ECHOED */ \
557         TYPE_SCTP_FUNC(sctp_sf_not_impl), \
558         /* SCTP_STATE_ESTABLISHED */ \
559         TYPE_SCTP_FUNC(sctp_sf_not_impl), \
560         /* SCTP_STATE_SHUTDOWN_PENDING */ \
561         TYPE_SCTP_FUNC(sctp_sf_not_impl), \
562         /* SCTP_STATE_SHUTDOWN_SENT */ \
563         TYPE_SCTP_FUNC(sctp_sf_not_impl), \
564         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
565         TYPE_SCTP_FUNC(sctp_sf_not_impl), \
566         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
567         TYPE_SCTP_FUNC(sctp_sf_not_impl), \
568 } /* TYPE_SCTP_PRIMITIVE_ASSOCIATE */
569
570 #define TYPE_SCTP_PRIMITIVE_SHUTDOWN  { \
571         /* SCTP_STATE_EMPTY */ \
572         TYPE_SCTP_FUNC(sctp_sf_bug), \
573         /* SCTP_STATE_CLOSED */ \
574         TYPE_SCTP_FUNC(sctp_sf_error_closed), \
575         /* SCTP_STATE_COOKIE_WAIT */ \
576         TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_shutdown), \
577         /* SCTP_STATE_COOKIE_ECHOED */ \
578         TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_shutdown),\
579         /* SCTP_STATE_ESTABLISHED */ \
580         TYPE_SCTP_FUNC(sctp_sf_do_9_2_prm_shutdown), \
581         /* SCTP_STATE_SHUTDOWN_PENDING */ \
582         TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
583         /* SCTP_STATE_SHUTDOWN_SENT */ \
584         TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
585         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
586         TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
587         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
588         TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
589 } /* TYPE_SCTP_PRIMITIVE_SHUTDOWN */
590
591 #define TYPE_SCTP_PRIMITIVE_ABORT  { \
592         /* SCTP_STATE_EMPTY */ \
593         TYPE_SCTP_FUNC(sctp_sf_bug), \
594         /* SCTP_STATE_CLOSED */ \
595         TYPE_SCTP_FUNC(sctp_sf_error_closed), \
596         /* SCTP_STATE_COOKIE_WAIT */ \
597         TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_abort), \
598         /* SCTP_STATE_COOKIE_ECHOED */ \
599         TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_abort), \
600         /* SCTP_STATE_ESTABLISHED */ \
601         TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
602         /* SCTP_STATE_SHUTDOWN_PENDING */ \
603         TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_prm_abort), \
604         /* SCTP_STATE_SHUTDOWN_SENT */ \
605         TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_prm_abort), \
606         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
607         TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
608         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
609         TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_prm_abort), \
610 } /* TYPE_SCTP_PRIMITIVE_ABORT */
611
612 #define TYPE_SCTP_PRIMITIVE_SEND  { \
613         /* SCTP_STATE_EMPTY */ \
614         TYPE_SCTP_FUNC(sctp_sf_bug), \
615         /* SCTP_STATE_CLOSED */ \
616         TYPE_SCTP_FUNC(sctp_sf_error_closed), \
617         /* SCTP_STATE_COOKIE_WAIT */ \
618         TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
619         /* SCTP_STATE_COOKIE_ECHOED */ \
620         TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
621         /* SCTP_STATE_ESTABLISHED */ \
622         TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
623         /* SCTP_STATE_SHUTDOWN_PENDING */ \
624         TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
625         /* SCTP_STATE_SHUTDOWN_SENT */ \
626         TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
627         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
628         TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
629         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
630         TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
631 } /* TYPE_SCTP_PRIMITIVE_SEND */
632
633 #define TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT  { \
634         /* SCTP_STATE_EMPTY */ \
635         TYPE_SCTP_FUNC(sctp_sf_bug), \
636         /* SCTP_STATE_CLOSED */ \
637         TYPE_SCTP_FUNC(sctp_sf_error_closed), \
638         /* SCTP_STATE_COOKIE_WAIT */ \
639         TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
640         /* SCTP_STATE_COOKIE_ECHOED */ \
641         TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
642         /* SCTP_STATE_ESTABLISHED */ \
643         TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
644         /* SCTP_STATE_SHUTDOWN_PENDING */ \
645         TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
646         /* SCTP_STATE_SHUTDOWN_SENT */ \
647         TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
648         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
649         TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
650         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
651         TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
652 } /* TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT */
653
654 #define TYPE_SCTP_PRIMITIVE_ASCONF { \
655         /* SCTP_STATE_EMPTY */ \
656         TYPE_SCTP_FUNC(sctp_sf_bug), \
657         /* SCTP_STATE_CLOSED */ \
658         TYPE_SCTP_FUNC(sctp_sf_error_closed), \
659         /* SCTP_STATE_COOKIE_WAIT */ \
660         TYPE_SCTP_FUNC(sctp_sf_error_closed), \
661         /* SCTP_STATE_COOKIE_ECHOED */ \
662         TYPE_SCTP_FUNC(sctp_sf_error_closed), \
663         /* SCTP_STATE_ESTABLISHED */ \
664         TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
665         /* SCTP_STATE_SHUTDOWN_PENDING */ \
666         TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
667         /* SCTP_STATE_SHUTDOWN_SENT */ \
668         TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
669         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
670         TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
671         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
672         TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
673 } /* TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT */
674
675 /* The primary index for this table is the primitive type.
676  * The secondary index for this table is the state.
677  */
678 static const sctp_sm_table_entry_t primitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES] = {
679         TYPE_SCTP_PRIMITIVE_ASSOCIATE,
680         TYPE_SCTP_PRIMITIVE_SHUTDOWN,
681         TYPE_SCTP_PRIMITIVE_ABORT,
682         TYPE_SCTP_PRIMITIVE_SEND,
683         TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT,
684         TYPE_SCTP_PRIMITIVE_ASCONF,
685 };
686
687 #define TYPE_SCTP_OTHER_NO_PENDING_TSN  { \
688         /* SCTP_STATE_EMPTY */ \
689         TYPE_SCTP_FUNC(sctp_sf_bug), \
690         /* SCTP_STATE_CLOSED */ \
691         TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
692         /* SCTP_STATE_COOKIE_WAIT */ \
693         TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
694         /* SCTP_STATE_COOKIE_ECHOED */ \
695         TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
696         /* SCTP_STATE_ESTABLISHED */ \
697         TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
698         /* SCTP_STATE_SHUTDOWN_PENDING */ \
699         TYPE_SCTP_FUNC(sctp_sf_do_9_2_start_shutdown), \
700         /* SCTP_STATE_SHUTDOWN_SENT */ \
701         TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
702         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
703         TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
704         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
705         TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
706 }
707
708 #define TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH  { \
709         /* SCTP_STATE_EMPTY */ \
710         TYPE_SCTP_FUNC(sctp_sf_bug), \
711         /* SCTP_STATE_CLOSED */ \
712         TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
713         /* SCTP_STATE_COOKIE_WAIT */ \
714         TYPE_SCTP_FUNC(sctp_sf_cookie_wait_icmp_abort), \
715         /* SCTP_STATE_COOKIE_ECHOED */ \
716         TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
717         /* SCTP_STATE_ESTABLISHED */ \
718         TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
719         /* SCTP_STATE_SHUTDOWN_PENDING */ \
720         TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
721         /* SCTP_STATE_SHUTDOWN_SENT */ \
722         TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
723         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
724         TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
725         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
726         TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
727 }
728
729 static const sctp_sm_table_entry_t other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES] = {
730         TYPE_SCTP_OTHER_NO_PENDING_TSN,
731         TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH,
732 };
733
734 #define TYPE_SCTP_EVENT_TIMEOUT_NONE { \
735         /* SCTP_STATE_EMPTY */ \
736         TYPE_SCTP_FUNC(sctp_sf_bug), \
737         /* SCTP_STATE_CLOSED */ \
738         TYPE_SCTP_FUNC(sctp_sf_bug), \
739         /* SCTP_STATE_COOKIE_WAIT */ \
740         TYPE_SCTP_FUNC(sctp_sf_bug), \
741         /* SCTP_STATE_COOKIE_ECHOED */ \
742         TYPE_SCTP_FUNC(sctp_sf_bug), \
743         /* SCTP_STATE_ESTABLISHED */ \
744         TYPE_SCTP_FUNC(sctp_sf_bug), \
745         /* SCTP_STATE_SHUTDOWN_PENDING */ \
746         TYPE_SCTP_FUNC(sctp_sf_bug), \
747         /* SCTP_STATE_SHUTDOWN_SENT */ \
748         TYPE_SCTP_FUNC(sctp_sf_bug), \
749         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
750         TYPE_SCTP_FUNC(sctp_sf_bug), \
751         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
752         TYPE_SCTP_FUNC(sctp_sf_bug), \
753 }
754
755 #define TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE { \
756         /* SCTP_STATE_EMPTY */ \
757         TYPE_SCTP_FUNC(sctp_sf_bug), \
758         /* SCTP_STATE_CLOSED */ \
759         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
760         /* SCTP_STATE_COOKIE_WAIT */ \
761         TYPE_SCTP_FUNC(sctp_sf_bug), \
762         /* SCTP_STATE_COOKIE_ECHOED */ \
763         TYPE_SCTP_FUNC(sctp_sf_t1_cookie_timer_expire), \
764         /* SCTP_STATE_ESTABLISHED */ \
765         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
766         /* SCTP_STATE_SHUTDOWN_PENDING */ \
767         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
768         /* SCTP_STATE_SHUTDOWN_SENT */ \
769         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
770         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
771         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
772         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
773         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
774 }
775
776 #define TYPE_SCTP_EVENT_TIMEOUT_T1_INIT { \
777         /* SCTP_STATE_EMPTY */ \
778         TYPE_SCTP_FUNC(sctp_sf_bug), \
779         /* SCTP_STATE_CLOSED */ \
780         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
781         /* SCTP_STATE_COOKIE_WAIT */ \
782         TYPE_SCTP_FUNC(sctp_sf_t1_init_timer_expire), \
783         /* SCTP_STATE_COOKIE_ECHOED */ \
784         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
785         /* SCTP_STATE_ESTABLISHED */ \
786         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
787         /* SCTP_STATE_SHUTDOWN_PENDING */ \
788         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
789         /* SCTP_STATE_SHUTDOWN_SENT */ \
790         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
791         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
792         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
793         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
794         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
795 }
796
797 #define TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN { \
798         /* SCTP_STATE_EMPTY */ \
799         TYPE_SCTP_FUNC(sctp_sf_bug), \
800         /* SCTP_STATE_CLOSED */ \
801         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
802         /* SCTP_STATE_COOKIE_WAIT */ \
803         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
804         /* SCTP_STATE_COOKIE_ECHOED */ \
805         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
806         /* SCTP_STATE_ESTABLISHED */ \
807         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
808         /* SCTP_STATE_SHUTDOWN_PENDING */ \
809         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
810         /* SCTP_STATE_SHUTDOWN_SENT */ \
811         TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
812         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
813         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
814         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
815         TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
816 }
817
818 #define TYPE_SCTP_EVENT_TIMEOUT_T3_RTX { \
819         /* SCTP_STATE_EMPTY */ \
820         TYPE_SCTP_FUNC(sctp_sf_bug), \
821         /* SCTP_STATE_CLOSED */ \
822         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
823         /* SCTP_STATE_COOKIE_WAIT */ \
824         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
825         /* SCTP_STATE_COOKIE_ECHOED */ \
826         TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
827         /* SCTP_STATE_ESTABLISHED */ \
828         TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
829         /* SCTP_STATE_SHUTDOWN_PENDING */ \
830         TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
831         /* SCTP_STATE_SHUTDOWN_SENT */ \
832         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
833         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
834         TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
835         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
836         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
837 }
838
839 #define TYPE_SCTP_EVENT_TIMEOUT_T4_RTO { \
840         /* SCTP_STATE_EMPTY */ \
841         TYPE_SCTP_FUNC(sctp_sf_bug), \
842         /* SCTP_STATE_CLOSED */ \
843         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
844         /* SCTP_STATE_COOKIE_WAIT */ \
845         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
846         /* SCTP_STATE_COOKIE_ECHOED */ \
847         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
848         /* SCTP_STATE_ESTABLISHED */ \
849         TYPE_SCTP_FUNC(sctp_sf_t4_timer_expire), \
850         /* SCTP_STATE_SHUTDOWN_PENDING */ \
851         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
852         /* SCTP_STATE_SHUTDOWN_SENT */ \
853         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
854         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
855         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
856         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
857         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
858 }
859
860 #define TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD { \
861         /* SCTP_STATE_EMPTY */ \
862         TYPE_SCTP_FUNC(sctp_sf_bug), \
863         /* SCTP_STATE_CLOSED */ \
864         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
865         /* SCTP_STATE_COOKIE_WAIT */ \
866         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
867         /* SCTP_STATE_COOKIE_ECHOED */ \
868         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
869         /* SCTP_STATE_ESTABLISHED */ \
870         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
871         /* SCTP_STATE_SHUTDOWN_PENDING */ \
872         TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
873         /* SCTP_STATE_SHUTDOWN_SENT */ \
874         TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
875         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
876         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
877         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
878         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
879 }
880
881 #define TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT { \
882         /* SCTP_STATE_EMPTY */ \
883         TYPE_SCTP_FUNC(sctp_sf_bug), \
884         /* SCTP_STATE_CLOSED */ \
885         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
886         /* SCTP_STATE_COOKIE_WAIT */ \
887         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
888         /* SCTP_STATE_COOKIE_ECHOED */ \
889         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
890         /* SCTP_STATE_ESTABLISHED */ \
891         TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
892         /* SCTP_STATE_SHUTDOWN_PENDING */ \
893         TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
894         /* SCTP_STATE_SHUTDOWN_SENT */ \
895         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
896         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
897         TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
898         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
899         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
900 }
901
902 #define TYPE_SCTP_EVENT_TIMEOUT_SACK { \
903         /* SCTP_STATE_EMPTY */ \
904         TYPE_SCTP_FUNC(sctp_sf_bug), \
905         /* SCTP_STATE_CLOSED */ \
906         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
907         /* SCTP_STATE_COOKIE_WAIT */ \
908         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
909         /* SCTP_STATE_COOKIE_ECHOED */ \
910         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
911         /* SCTP_STATE_ESTABLISHED */ \
912         TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
913         /* SCTP_STATE_SHUTDOWN_PENDING */ \
914         TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
915         /* SCTP_STATE_SHUTDOWN_SENT */ \
916         TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
917         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
918         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
919         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
920         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
921 }
922
923 #define TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE { \
924         /* SCTP_STATE_EMPTY */ \
925         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
926         /* SCTP_STATE_CLOSED */ \
927         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
928         /* SCTP_STATE_COOKIE_WAIT */ \
929         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
930         /* SCTP_STATE_COOKIE_ECHOED */ \
931         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
932         /* SCTP_STATE_ESTABLISHED */ \
933         TYPE_SCTP_FUNC(sctp_sf_autoclose_timer_expire), \
934         /* SCTP_STATE_SHUTDOWN_PENDING */ \
935         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
936         /* SCTP_STATE_SHUTDOWN_SENT */ \
937         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
938         /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
939         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
940         /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
941         TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
942 }
943
944 static const sctp_sm_table_entry_t timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES] = {
945         TYPE_SCTP_EVENT_TIMEOUT_NONE,
946         TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE,
947         TYPE_SCTP_EVENT_TIMEOUT_T1_INIT,
948         TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN,
949         TYPE_SCTP_EVENT_TIMEOUT_T3_RTX,
950         TYPE_SCTP_EVENT_TIMEOUT_T4_RTO,
951         TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD,
952         TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT,
953         TYPE_SCTP_EVENT_TIMEOUT_SACK,
954         TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE,
955 };
956
957 static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t cid, 
958                                                             sctp_state_t state)
959 {
960         if (state > SCTP_STATE_MAX)
961                 return &bug;
962
963         if (cid >= 0 && cid <= SCTP_CID_BASE_MAX)
964                 return &chunk_event_table[cid][state];
965
966         if (sctp_prsctp_enable) {
967                 if (cid == SCTP_CID_FWD_TSN)
968                         return &prsctp_chunk_event_table[0][state];
969         }
970
971         if (sctp_addip_enable) {
972                 if (cid == SCTP_CID_ASCONF)
973                         return &addip_chunk_event_table[0][state];
974
975                 if (cid == SCTP_CID_ASCONF_ACK)
976                         return &addip_chunk_event_table[1][state];
977         }
978
979         return &chunk_event_table_unknown[state];
980 }