xref: /openbmc/linux/net/sctp/sm_statetable.c (revision 4f6cce39)
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, see
26  * <http://www.gnu.org/licenses/>.
27  *
28  * Please send any bug reports or fixes you make to the
29  * email address(es):
30  *    lksctp developers <linux-sctp@vger.kernel.org>
31  *
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>
40  */
41 
42 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
43 
44 #include <linux/skbuff.h>
45 #include <net/sctp/sctp.h>
46 #include <net/sctp/sm.h>
47 
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];
54 
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);
58 
59 
60 static const sctp_sm_table_entry_t bug = {
61 	.fn = sctp_sf_bug,
62 	.name = "sctp_sf_bug"
63 };
64 
65 #define DO_LOOKUP(_max, _type, _table)					\
66 ({									\
67 	const sctp_sm_table_entry_t *rtn;				\
68 									\
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];		\
75 									\
76 	rtn;								\
77 })
78 
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)
83 {
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;
99 	}
100 }
101 
102 #define TYPE_SCTP_FUNC(func) {.fn = func, .name = #func}
103 
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 */
122 
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 */
141 
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 */
160 
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 */
179 
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 */
199 
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 */
218 
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 */
237 
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 */
256 
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 */
275 
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 */
294 
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 */
313 
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 */
332 
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 */
351 
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 */
370 
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 */
389 
390 /* The primary index for this table is the chunk type.
391  * The secondary index for this table is the state.
392  *
393  * For base protocol (RFC 2960).
394  */
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[][] */
412 
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 */
431 
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 */
450 
451 /* The primary index for this table is the chunk type.
452  * The secondary index for this table is the state.
453  */
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[][] */
458 
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 */
477 
478 /* The primary index for this table is the chunk type.
479  * The secondary index for this table is the state.
480  */
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[][] */
484 
485 #define TYPE_SCTP_RECONF { \
486 	/* SCTP_STATE_CLOSED */ \
487 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
488 	/* SCTP_STATE_COOKIE_WAIT */ \
489 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
490 	/* SCTP_STATE_COOKIE_ECHOED */ \
491 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
492 	/* SCTP_STATE_ESTABLISHED */ \
493 	TYPE_SCTP_FUNC(sctp_sf_do_reconf), \
494 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
495 	TYPE_SCTP_FUNC(sctp_sf_do_reconf), \
496 	/* SCTP_STATE_SHUTDOWN_SENT */ \
497 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
498 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
499 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
500 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
501 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
502 } /* TYPE_SCTP_RECONF */
503 
504 /* The primary index for this table is the chunk type.
505  * The secondary index for this table is the state.
506  */
507 static const sctp_sm_table_entry_t reconf_chunk_event_table[SCTP_NUM_RECONF_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
508 	TYPE_SCTP_RECONF,
509 }; /*state_fn_t reconf_chunk_event_table[][] */
510 
511 #define TYPE_SCTP_AUTH { \
512 	/* SCTP_STATE_CLOSED */ \
513 	TYPE_SCTP_FUNC(sctp_sf_ootb), \
514 	/* SCTP_STATE_COOKIE_WAIT */ \
515 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
516 	/* SCTP_STATE_COOKIE_ECHOED */ \
517 	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
518 	/* SCTP_STATE_ESTABLISHED */ \
519 	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
520 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
521 	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
522 	/* SCTP_STATE_SHUTDOWN_SENT */ \
523 	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
524 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
525 	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
526 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
527 	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
528 } /* TYPE_SCTP_AUTH */
529 
530 /* The primary index for this table is the chunk type.
531  * The secondary index for this table is the state.
532  */
533 static const sctp_sm_table_entry_t auth_chunk_event_table[SCTP_NUM_AUTH_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
534 	TYPE_SCTP_AUTH,
535 }; /*state_fn_t auth_chunk_event_table[][] */
536 
537 static const sctp_sm_table_entry_t
538 chunk_event_table_unknown[SCTP_STATE_NUM_STATES] = {
539 	/* SCTP_STATE_CLOSED */
540 	TYPE_SCTP_FUNC(sctp_sf_ootb),
541 	/* SCTP_STATE_COOKIE_WAIT */
542 	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
543 	/* SCTP_STATE_COOKIE_ECHOED */
544 	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
545 	/* SCTP_STATE_ESTABLISHED */
546 	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
547 	/* SCTP_STATE_SHUTDOWN_PENDING */
548 	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
549 	/* SCTP_STATE_SHUTDOWN_SENT */
550 	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
551 	/* SCTP_STATE_SHUTDOWN_RECEIVED */
552 	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
553 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */
554 	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
555 };	/* chunk unknown */
556 
557 
558 #define TYPE_SCTP_PRIMITIVE_ASSOCIATE  { \
559 	/* SCTP_STATE_CLOSED */ \
560 	TYPE_SCTP_FUNC(sctp_sf_do_prm_asoc), \
561 	/* SCTP_STATE_COOKIE_WAIT */ \
562 	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
563 	/* SCTP_STATE_COOKIE_ECHOED */ \
564 	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
565 	/* SCTP_STATE_ESTABLISHED */ \
566 	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
567 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
568 	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
569 	/* SCTP_STATE_SHUTDOWN_SENT */ \
570 	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
571 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
572 	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
573 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
574 	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
575 } /* TYPE_SCTP_PRIMITIVE_ASSOCIATE */
576 
577 #define TYPE_SCTP_PRIMITIVE_SHUTDOWN  { \
578 	/* SCTP_STATE_CLOSED */ \
579 	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
580 	/* SCTP_STATE_COOKIE_WAIT */ \
581 	TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_shutdown), \
582 	/* SCTP_STATE_COOKIE_ECHOED */ \
583 	TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_shutdown),\
584 	/* SCTP_STATE_ESTABLISHED */ \
585 	TYPE_SCTP_FUNC(sctp_sf_do_9_2_prm_shutdown), \
586 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
587 	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
588 	/* SCTP_STATE_SHUTDOWN_SENT */ \
589 	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
590 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
591 	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
592 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
593 	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
594 } /* TYPE_SCTP_PRIMITIVE_SHUTDOWN */
595 
596 #define TYPE_SCTP_PRIMITIVE_ABORT  { \
597 	/* SCTP_STATE_CLOSED */ \
598 	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
599 	/* SCTP_STATE_COOKIE_WAIT */ \
600 	TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_abort), \
601 	/* SCTP_STATE_COOKIE_ECHOED */ \
602 	TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_abort), \
603 	/* SCTP_STATE_ESTABLISHED */ \
604 	TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
605 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
606 	TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_prm_abort), \
607 	/* SCTP_STATE_SHUTDOWN_SENT */ \
608 	TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_prm_abort), \
609 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
610 	TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
611 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
612 	TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_prm_abort), \
613 } /* TYPE_SCTP_PRIMITIVE_ABORT */
614 
615 #define TYPE_SCTP_PRIMITIVE_SEND  { \
616 	/* SCTP_STATE_CLOSED */ \
617 	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
618 	/* SCTP_STATE_COOKIE_WAIT */ \
619 	TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
620 	/* SCTP_STATE_COOKIE_ECHOED */ \
621 	TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
622 	/* SCTP_STATE_ESTABLISHED */ \
623 	TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
624 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
625 	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
626 	/* SCTP_STATE_SHUTDOWN_SENT */ \
627 	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
628 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
629 	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
630 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
631 	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
632 } /* TYPE_SCTP_PRIMITIVE_SEND */
633 
634 #define TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT  { \
635 	/* SCTP_STATE_CLOSED */ \
636 	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
637 	/* SCTP_STATE_COOKIE_WAIT */ \
638 	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
639 	/* SCTP_STATE_COOKIE_ECHOED */ \
640 	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
641 	/* SCTP_STATE_ESTABLISHED */ \
642 	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
643 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
644 	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
645 	/* SCTP_STATE_SHUTDOWN_SENT */ \
646 	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
647 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
648 	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
649 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
650 	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
651 } /* TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT */
652 
653 #define TYPE_SCTP_PRIMITIVE_ASCONF { \
654 	/* SCTP_STATE_CLOSED */ \
655 	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
656 	/* SCTP_STATE_COOKIE_WAIT */ \
657 	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
658 	/* SCTP_STATE_COOKIE_ECHOED */ \
659 	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
660 	/* SCTP_STATE_ESTABLISHED */ \
661 	TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
662 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
663 	TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
664 	/* SCTP_STATE_SHUTDOWN_SENT */ \
665 	TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
666 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
667 	TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
668 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
669 	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
670 } /* TYPE_SCTP_PRIMITIVE_ASCONF */
671 
672 #define TYPE_SCTP_PRIMITIVE_RECONF { \
673 	/* SCTP_STATE_CLOSED */ \
674 	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
675 	/* SCTP_STATE_COOKIE_WAIT */ \
676 	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
677 	/* SCTP_STATE_COOKIE_ECHOED */ \
678 	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
679 	/* SCTP_STATE_ESTABLISHED */ \
680 	TYPE_SCTP_FUNC(sctp_sf_do_prm_reconf), \
681 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
682 	TYPE_SCTP_FUNC(sctp_sf_do_prm_reconf), \
683 	/* SCTP_STATE_SHUTDOWN_SENT */ \
684 	TYPE_SCTP_FUNC(sctp_sf_do_prm_reconf), \
685 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
686 	TYPE_SCTP_FUNC(sctp_sf_do_prm_reconf), \
687 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
688 	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
689 } /* TYPE_SCTP_PRIMITIVE_RECONF */
690 
691 /* The primary index for this table is the primitive type.
692  * The secondary index for this table is the state.
693  */
694 static const sctp_sm_table_entry_t primitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES] = {
695 	TYPE_SCTP_PRIMITIVE_ASSOCIATE,
696 	TYPE_SCTP_PRIMITIVE_SHUTDOWN,
697 	TYPE_SCTP_PRIMITIVE_ABORT,
698 	TYPE_SCTP_PRIMITIVE_SEND,
699 	TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT,
700 	TYPE_SCTP_PRIMITIVE_ASCONF,
701 	TYPE_SCTP_PRIMITIVE_RECONF,
702 };
703 
704 #define TYPE_SCTP_OTHER_NO_PENDING_TSN  { \
705 	/* SCTP_STATE_CLOSED */ \
706 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
707 	/* SCTP_STATE_COOKIE_WAIT */ \
708 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
709 	/* SCTP_STATE_COOKIE_ECHOED */ \
710 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
711 	/* SCTP_STATE_ESTABLISHED */ \
712 	TYPE_SCTP_FUNC(sctp_sf_do_no_pending_tsn), \
713 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
714 	TYPE_SCTP_FUNC(sctp_sf_do_9_2_start_shutdown), \
715 	/* SCTP_STATE_SHUTDOWN_SENT */ \
716 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
717 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
718 	TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
719 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
720 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
721 }
722 
723 #define TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH  { \
724 	/* SCTP_STATE_CLOSED */ \
725 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
726 	/* SCTP_STATE_COOKIE_WAIT */ \
727 	TYPE_SCTP_FUNC(sctp_sf_cookie_wait_icmp_abort), \
728 	/* SCTP_STATE_COOKIE_ECHOED */ \
729 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
730 	/* SCTP_STATE_ESTABLISHED */ \
731 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
732 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
733 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
734 	/* SCTP_STATE_SHUTDOWN_SENT */ \
735 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
736 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
737 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
738 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
739 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
740 }
741 
742 static const sctp_sm_table_entry_t other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES] = {
743 	TYPE_SCTP_OTHER_NO_PENDING_TSN,
744 	TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH,
745 };
746 
747 #define TYPE_SCTP_EVENT_TIMEOUT_NONE { \
748 	/* SCTP_STATE_CLOSED */ \
749 	TYPE_SCTP_FUNC(sctp_sf_bug), \
750 	/* SCTP_STATE_COOKIE_WAIT */ \
751 	TYPE_SCTP_FUNC(sctp_sf_bug), \
752 	/* SCTP_STATE_COOKIE_ECHOED */ \
753 	TYPE_SCTP_FUNC(sctp_sf_bug), \
754 	/* SCTP_STATE_ESTABLISHED */ \
755 	TYPE_SCTP_FUNC(sctp_sf_bug), \
756 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
757 	TYPE_SCTP_FUNC(sctp_sf_bug), \
758 	/* SCTP_STATE_SHUTDOWN_SENT */ \
759 	TYPE_SCTP_FUNC(sctp_sf_bug), \
760 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
761 	TYPE_SCTP_FUNC(sctp_sf_bug), \
762 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
763 	TYPE_SCTP_FUNC(sctp_sf_bug), \
764 }
765 
766 #define TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE { \
767 	/* SCTP_STATE_CLOSED */ \
768 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
769 	/* SCTP_STATE_COOKIE_WAIT */ \
770 	TYPE_SCTP_FUNC(sctp_sf_bug), \
771 	/* SCTP_STATE_COOKIE_ECHOED */ \
772 	TYPE_SCTP_FUNC(sctp_sf_t1_cookie_timer_expire), \
773 	/* SCTP_STATE_ESTABLISHED */ \
774 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
775 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
776 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
777 	/* SCTP_STATE_SHUTDOWN_SENT */ \
778 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
779 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
780 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
781 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
782 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
783 }
784 
785 #define TYPE_SCTP_EVENT_TIMEOUT_T1_INIT { \
786 	/* SCTP_STATE_CLOSED */ \
787 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
788 	/* SCTP_STATE_COOKIE_WAIT */ \
789 	TYPE_SCTP_FUNC(sctp_sf_t1_init_timer_expire), \
790 	/* SCTP_STATE_COOKIE_ECHOED */ \
791 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
792 	/* SCTP_STATE_ESTABLISHED */ \
793 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
794 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
795 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
796 	/* SCTP_STATE_SHUTDOWN_SENT */ \
797 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
798 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
799 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
800 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
801 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
802 }
803 
804 #define TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN { \
805 	/* SCTP_STATE_CLOSED */ \
806 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
807 	/* SCTP_STATE_COOKIE_WAIT */ \
808 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
809 	/* SCTP_STATE_COOKIE_ECHOED */ \
810 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
811 	/* SCTP_STATE_ESTABLISHED */ \
812 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
813 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
814 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
815 	/* SCTP_STATE_SHUTDOWN_SENT */ \
816 	TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
817 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
818 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
819 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
820 	TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
821 }
822 
823 #define TYPE_SCTP_EVENT_TIMEOUT_T3_RTX { \
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_do_6_3_3_rtx), \
830 	/* SCTP_STATE_ESTABLISHED */ \
831 	TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
832 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
833 	TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
834 	/* SCTP_STATE_SHUTDOWN_SENT */ \
835 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
836 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
837 	TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
838 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
839 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
840 }
841 
842 #define TYPE_SCTP_EVENT_TIMEOUT_T4_RTO { \
843 	/* SCTP_STATE_CLOSED */ \
844 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
845 	/* SCTP_STATE_COOKIE_WAIT */ \
846 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
847 	/* SCTP_STATE_COOKIE_ECHOED */ \
848 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
849 	/* SCTP_STATE_ESTABLISHED */ \
850 	TYPE_SCTP_FUNC(sctp_sf_t4_timer_expire), \
851 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
852 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
853 	/* SCTP_STATE_SHUTDOWN_SENT */ \
854 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
855 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
856 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
857 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
858 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
859 }
860 
861 #define TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD { \
862 	/* SCTP_STATE_CLOSED */ \
863 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
864 	/* SCTP_STATE_COOKIE_WAIT */ \
865 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
866 	/* SCTP_STATE_COOKIE_ECHOED */ \
867 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
868 	/* SCTP_STATE_ESTABLISHED */ \
869 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
870 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
871 	TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
872 	/* SCTP_STATE_SHUTDOWN_SENT */ \
873 	TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
874 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
875 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
876 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
877 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
878 }
879 
880 #define TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT { \
881 	/* SCTP_STATE_CLOSED */ \
882 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
883 	/* SCTP_STATE_COOKIE_WAIT */ \
884 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
885 	/* SCTP_STATE_COOKIE_ECHOED */ \
886 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
887 	/* SCTP_STATE_ESTABLISHED */ \
888 	TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
889 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
890 	TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
891 	/* SCTP_STATE_SHUTDOWN_SENT */ \
892 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
893 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
894 	TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
895 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
896 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
897 }
898 
899 #define TYPE_SCTP_EVENT_TIMEOUT_SACK { \
900 	/* SCTP_STATE_CLOSED */ \
901 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
902 	/* SCTP_STATE_COOKIE_WAIT */ \
903 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
904 	/* SCTP_STATE_COOKIE_ECHOED */ \
905 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
906 	/* SCTP_STATE_ESTABLISHED */ \
907 	TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
908 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
909 	TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
910 	/* SCTP_STATE_SHUTDOWN_SENT */ \
911 	TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
912 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
913 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
914 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
915 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
916 }
917 
918 #define TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE { \
919 	/* SCTP_STATE_CLOSED */ \
920 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
921 	/* SCTP_STATE_COOKIE_WAIT */ \
922 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
923 	/* SCTP_STATE_COOKIE_ECHOED */ \
924 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
925 	/* SCTP_STATE_ESTABLISHED */ \
926 	TYPE_SCTP_FUNC(sctp_sf_autoclose_timer_expire), \
927 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
928 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
929 	/* SCTP_STATE_SHUTDOWN_SENT */ \
930 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
931 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
932 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
933 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
934 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
935 }
936 
937 #define TYPE_SCTP_EVENT_TIMEOUT_RECONF { \
938 	/* SCTP_STATE_CLOSED */ \
939 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
940 	/* SCTP_STATE_COOKIE_WAIT */ \
941 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
942 	/* SCTP_STATE_COOKIE_ECHOED */ \
943 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
944 	/* SCTP_STATE_ESTABLISHED */ \
945 	TYPE_SCTP_FUNC(sctp_sf_send_reconf), \
946 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
947 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
948 	/* SCTP_STATE_SHUTDOWN_SENT */ \
949 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
950 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
951 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
952 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
953 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
954 }
955 
956 static const sctp_sm_table_entry_t timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES] = {
957 	TYPE_SCTP_EVENT_TIMEOUT_NONE,
958 	TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE,
959 	TYPE_SCTP_EVENT_TIMEOUT_T1_INIT,
960 	TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN,
961 	TYPE_SCTP_EVENT_TIMEOUT_T3_RTX,
962 	TYPE_SCTP_EVENT_TIMEOUT_T4_RTO,
963 	TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD,
964 	TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT,
965 	TYPE_SCTP_EVENT_TIMEOUT_RECONF,
966 	TYPE_SCTP_EVENT_TIMEOUT_SACK,
967 	TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE,
968 };
969 
970 static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(struct net *net,
971 							    sctp_cid_t cid,
972 							    sctp_state_t state)
973 {
974 	if (state > SCTP_STATE_MAX)
975 		return &bug;
976 
977 	if (cid <= SCTP_CID_BASE_MAX)
978 		return &chunk_event_table[cid][state];
979 
980 	if (net->sctp.prsctp_enable) {
981 		if (cid == SCTP_CID_FWD_TSN)
982 			return &prsctp_chunk_event_table[0][state];
983 	}
984 
985 	if (net->sctp.addip_enable) {
986 		if (cid == SCTP_CID_ASCONF)
987 			return &addip_chunk_event_table[0][state];
988 
989 		if (cid == SCTP_CID_ASCONF_ACK)
990 			return &addip_chunk_event_table[1][state];
991 	}
992 
993 	if (net->sctp.reconf_enable)
994 		if (cid == SCTP_CID_RECONF)
995 			return &reconf_chunk_event_table[0][state];
996 
997 	if (net->sctp.auth_enable) {
998 		if (cid == SCTP_CID_AUTH)
999 			return &auth_chunk_event_table[0][state];
1000 	}
1001 
1002 	return &chunk_event_table_unknown[state];
1003 }
1004