Linux Audio

Check our new training course

Embedded Linux training

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