sm_statetable.c 32.5 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
/* SCTP kernel reference Implementation
 * (C) Copyright IBM Corp. 2001, 2004
 * Copyright (c) 1999-2000 Cisco, Inc.
 * Copyright (c) 1999-2001 Motorola, Inc.
 * Copyright (c) 2001 Intel Corp.
 * Copyright (c) 2001 Nokia, Inc.
 *
 * This file is part of the SCTP kernel reference Implementation
 *
 * These are the state tables for the SCTP state machine.
 *
 * The SCTP reference implementation is free software;
 * you can redistribute it and/or modify it under the terms of
 * the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * The SCTP reference implementation is distributed in the hope that it
 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
 *                 ************************
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GNU CC; see the file COPYING.  If not, write to
 * the Free Software Foundation, 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * Please send any bug reports or fixes you make to the
 * email address(es):
 *    lksctp developers <lksctp-developers@lists.sourceforge.net>
 *
 * Or submit a bug report through the following website:
 *    http://www.sf.net/projects/lksctp
 *
 * Written or modified by:
 *    La Monte H.P. Yarroll <piggy@acm.org>
 *    Karl Knutson          <karl@athena.chicago.il.us>
 *    Jon Grimm             <jgrimm@us.ibm.com>
 *    Hui Huang		    <hui.huang@nokia.com>
 *    Daisy Chang	    <daisyc@us.ibm.com>
 *    Ardelle Fan	    <ardelle.fan@intel.com>
 *    Sridhar Samudrala	    <sri@us.ibm.com>
 *
 * Any bugs reported given to us we will try to fix... any fixes shared will
 * be incorporated into the next SCTP release.
 */

#include <linux/skbuff.h>
#include <net/sctp/sctp.h>
#include <net/sctp/sm.h>

static const sctp_sm_table_entry_t
primitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES];
static const sctp_sm_table_entry_t
other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES];
static const sctp_sm_table_entry_t
timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES];

static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t cid,
							    sctp_state_t state);


static const sctp_sm_table_entry_t bug = {
	.fn = sctp_sf_bug,
	.name = "sctp_sf_bug"
};

#define DO_LOOKUP(_max, _type, _table) \
	if ((event_subtype._type > (_max))) { \
		printk(KERN_WARNING \
		       "sctp table %p possible attack:" \
		       " event %d exceeds max %d\n", \
		       _table, event_subtype._type, _max); \
		return &bug; \
	} \
	return &_table[event_subtype._type][(int)state];

const sctp_sm_table_entry_t *sctp_sm_lookup_event(sctp_event_t event_type,
						  sctp_state_t state,
						  sctp_subtype_t event_subtype)
{
	switch (event_type) {
	case SCTP_EVENT_T_CHUNK:
		return sctp_chunk_event_lookup(event_subtype.chunk, state);
		break;
	case SCTP_EVENT_T_TIMEOUT:
		DO_LOOKUP(SCTP_EVENT_TIMEOUT_MAX, timeout,
			  timeout_event_table);
		break;

	case SCTP_EVENT_T_OTHER:
		DO_LOOKUP(SCTP_EVENT_OTHER_MAX, other, other_event_table);
		break;

	case SCTP_EVENT_T_PRIMITIVE:
		DO_LOOKUP(SCTP_EVENT_PRIMITIVE_MAX, primitive,
			  primitive_event_table);
		break;

	default:
		/* Yikes!  We got an illegal event type.  */
		return &bug;
104
	}
L
Linus Torvalds 已提交
105 106
}

107 108
#define TYPE_SCTP_FUNC(func) {.fn = func, .name = #func}

L
Linus Torvalds 已提交
109 110
#define TYPE_SCTP_DATA { \
	/* SCTP_STATE_EMPTY */ \
111
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
112
	/* SCTP_STATE_CLOSED */ \
113
	TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
L
Linus Torvalds 已提交
114
	/* SCTP_STATE_COOKIE_WAIT */ \
115
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
116
	/* SCTP_STATE_COOKIE_ECHOED */ \
117
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
118
	/* SCTP_STATE_ESTABLISHED */ \
119
	TYPE_SCTP_FUNC(sctp_sf_eat_data_6_2), \
L
Linus Torvalds 已提交
120
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
121
	TYPE_SCTP_FUNC(sctp_sf_eat_data_6_2), \
L
Linus Torvalds 已提交
122
	/* SCTP_STATE_SHUTDOWN_SENT */ \
123
	TYPE_SCTP_FUNC(sctp_sf_eat_data_fast_4_4), \
L
Linus Torvalds 已提交
124
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
125
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
126
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
127
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
128 129 130 131
} /* TYPE_SCTP_DATA */

#define TYPE_SCTP_INIT { \
	/* SCTP_STATE_EMPTY */ \
132
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
133
	/* SCTP_STATE_CLOSED */ \
134
	TYPE_SCTP_FUNC(sctp_sf_do_5_1B_init), \
L
Linus Torvalds 已提交
135
	/* SCTP_STATE_COOKIE_WAIT */ \
136
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_1_siminit), \
L
Linus Torvalds 已提交
137
	/* SCTP_STATE_COOKIE_ECHOED */ \
138
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_1_siminit), \
L
Linus Torvalds 已提交
139
	/* SCTP_STATE_ESTABLISHED */ \
140
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
L
Linus Torvalds 已提交
141
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
142
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
L
Linus Torvalds 已提交
143
	/* SCTP_STATE_SHUTDOWN_SENT */ \
144
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
L
Linus Torvalds 已提交
145
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
146
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
L
Linus Torvalds 已提交
147
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
148
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_reshutack), \
L
Linus Torvalds 已提交
149 150 151 152
} /* TYPE_SCTP_INIT */

#define TYPE_SCTP_INIT_ACK { \
	/* SCTP_STATE_EMPTY */ \
153
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
154
	/* SCTP_STATE_CLOSED */ \
155
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_3_initack), \
L
Linus Torvalds 已提交
156
	/* SCTP_STATE_COOKIE_WAIT */ \
157
	TYPE_SCTP_FUNC(sctp_sf_do_5_1C_ack), \
L
Linus Torvalds 已提交
158
	/* SCTP_STATE_COOKIE_ECHOED */ \
159
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
160
	/* SCTP_STATE_ESTABLISHED */ \
161
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
162
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
163
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
164
	/* SCTP_STATE_SHUTDOWN_SENT */ \
165
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
166
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
167
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
168
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
169
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
170 171 172 173
} /* TYPE_SCTP_INIT_ACK */

#define TYPE_SCTP_SACK { \
	/*  SCTP_STATE_EMPTY */ \
174
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
175
	/* SCTP_STATE_CLOSED */ \
176
	TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
L
Linus Torvalds 已提交
177
	/* SCTP_STATE_COOKIE_WAIT */ \
178
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
179
	/* SCTP_STATE_COOKIE_ECHOED */ \
180
	TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
L
Linus Torvalds 已提交
181
	/* SCTP_STATE_ESTABLISHED */ \
182
	TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
L
Linus Torvalds 已提交
183
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
184
	TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
L
Linus Torvalds 已提交
185
	/* SCTP_STATE_SHUTDOWN_SENT */ \
186
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
187
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
188
	TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
L
Linus Torvalds 已提交
189
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
190
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
191 192 193 194
} /* TYPE_SCTP_SACK */

#define TYPE_SCTP_HEARTBEAT { \
	/*  SCTP_STATE_EMPTY */ \
195
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
196
	/* SCTP_STATE_CLOSED */ \
197
	TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
L
Linus Torvalds 已提交
198
	/* SCTP_STATE_COOKIE_WAIT */ \
199
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
200
	/* SCTP_STATE_COOKIE_ECHOED */ \
201
	TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
L
Linus Torvalds 已提交
202
	/* SCTP_STATE_ESTABLISHED */ \
203
	TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
L
Linus Torvalds 已提交
204
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
205
	TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
L
Linus Torvalds 已提交
206
	/* SCTP_STATE_SHUTDOWN_SENT */ \
207
	TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
L
Linus Torvalds 已提交
208
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
209
	TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
L
Linus Torvalds 已提交
210 211
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
	/* This should not happen, but we are nice.  */ \
212
	TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
L
Linus Torvalds 已提交
213 214 215 216
} /* TYPE_SCTP_HEARTBEAT */

#define TYPE_SCTP_HEARTBEAT_ACK { \
	/*  SCTP_STATE_EMPTY */ \
217
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
218
	/* SCTP_STATE_CLOSED */ \
219
	TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
L
Linus Torvalds 已提交
220
	/* SCTP_STATE_COOKIE_WAIT */ \
221
	TYPE_SCTP_FUNC(sctp_sf_violation), \
L
Linus Torvalds 已提交
222
	/* SCTP_STATE_COOKIE_ECHOED */ \
223
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
224
	/* SCTP_STATE_ESTABLISHED */ \
225
	TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
L
Linus Torvalds 已提交
226
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
227
	TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
L
Linus Torvalds 已提交
228
	/* SCTP_STATE_SHUTDOWN_SENT */ \
229
	TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
L
Linus Torvalds 已提交
230
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
231
	TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
L
Linus Torvalds 已提交
232
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
233
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
234 235 236 237
} /* TYPE_SCTP_HEARTBEAT_ACK */

#define TYPE_SCTP_ABORT { \
	/* SCTP_STATE_EMPTY */ \
238
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
239
	/* SCTP_STATE_CLOSED */ \
240
	TYPE_SCTP_FUNC(sctp_sf_pdiscard), \
L
Linus Torvalds 已提交
241
	/* SCTP_STATE_COOKIE_WAIT */ \
242
	TYPE_SCTP_FUNC(sctp_sf_cookie_wait_abort), \
L
Linus Torvalds 已提交
243
	/* SCTP_STATE_COOKIE_ECHOED */ \
244
	TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_abort), \
L
Linus Torvalds 已提交
245
	/* SCTP_STATE_ESTABLISHED */ \
246
	TYPE_SCTP_FUNC(sctp_sf_do_9_1_abort), \
L
Linus Torvalds 已提交
247
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
248
	TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_abort), \
L
Linus Torvalds 已提交
249
	/* SCTP_STATE_SHUTDOWN_SENT */ \
250
	TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_abort), \
L
Linus Torvalds 已提交
251
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
252
	TYPE_SCTP_FUNC(sctp_sf_do_9_1_abort), \
L
Linus Torvalds 已提交
253
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
254
	TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_abort), \
L
Linus Torvalds 已提交
255 256 257 258
} /* TYPE_SCTP_ABORT */

#define TYPE_SCTP_SHUTDOWN { \
	/* SCTP_STATE_EMPTY */ \
259
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
260
	/* SCTP_STATE_CLOSED */ \
261
	TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
L
Linus Torvalds 已提交
262
	/* SCTP_STATE_COOKIE_WAIT */ \
263
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
264
	/* SCTP_STATE_COOKIE_ECHOED */ \
265
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
266
	/* SCTP_STATE_ESTABLISHED */ \
267
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown), \
L
Linus Torvalds 已提交
268
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
269
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
270
	/* SCTP_STATE_SHUTDOWN_SENT */ \
271
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
L
Linus Torvalds 已提交
272
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
273
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
274
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
275
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
276 277 278 279
} /* TYPE_SCTP_SHUTDOWN */

#define TYPE_SCTP_SHUTDOWN_ACK { \
	/* SCTP_STATE_EMPTY */ \
280
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
281
	/* SCTP_STATE_CLOSED */ \
282
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
283
	/* SCTP_STATE_COOKIE_WAIT */ \
284
	TYPE_SCTP_FUNC(sctp_sf_do_8_5_1_E_sa), \
L
Linus Torvalds 已提交
285
	/* SCTP_STATE_COOKIE_ECHOED */ \
286
	TYPE_SCTP_FUNC(sctp_sf_do_8_5_1_E_sa), \
L
Linus Torvalds 已提交
287
	/* SCTP_STATE_ESTABLISHED */ \
288
	TYPE_SCTP_FUNC(sctp_sf_violation), \
L
Linus Torvalds 已提交
289
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
290
	TYPE_SCTP_FUNC(sctp_sf_violation), \
L
Linus Torvalds 已提交
291
	/* SCTP_STATE_SHUTDOWN_SENT */ \
292
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_final), \
L
Linus Torvalds 已提交
293
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
294
	TYPE_SCTP_FUNC(sctp_sf_violation), \
L
Linus Torvalds 已提交
295
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
296
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_final), \
L
Linus Torvalds 已提交
297 298 299 300
} /* TYPE_SCTP_SHUTDOWN_ACK */

#define TYPE_SCTP_ERROR { \
	/* SCTP_STATE_EMPTY */ \
301
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
302
	/* SCTP_STATE_CLOSED */ \
303
	TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
L
Linus Torvalds 已提交
304
	/* SCTP_STATE_COOKIE_WAIT */ \
305
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
306
	/* SCTP_STATE_COOKIE_ECHOED */ \
307
	TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_err), \
L
Linus Torvalds 已提交
308
	/* SCTP_STATE_ESTABLISHED */ \
309
	TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
L
Linus Torvalds 已提交
310
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
311
	TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
L
Linus Torvalds 已提交
312
	/* SCTP_STATE_SHUTDOWN_SENT */ \
313
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
314
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
315
	TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
L
Linus Torvalds 已提交
316
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
317
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
318 319 320 321
} /* TYPE_SCTP_ERROR */

#define TYPE_SCTP_COOKIE_ECHO { \
	/* SCTP_STATE_EMPTY */ \
322
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
323
	/* SCTP_STATE_CLOSED */ \
324
	TYPE_SCTP_FUNC(sctp_sf_do_5_1D_ce), \
L
Linus Torvalds 已提交
325
	/* SCTP_STATE_COOKIE_WAIT */ \
326
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
L
Linus Torvalds 已提交
327
	/* SCTP_STATE_COOKIE_ECHOED */ \
328
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
L
Linus Torvalds 已提交
329
	/* SCTP_STATE_ESTABLISHED */ \
330
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
L
Linus Torvalds 已提交
331
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
332
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
L
Linus Torvalds 已提交
333
	/* SCTP_STATE_SHUTDOWN_SENT */ \
334
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
L
Linus Torvalds 已提交
335
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
336
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
L
Linus Torvalds 已提交
337
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
338
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
L
Linus Torvalds 已提交
339 340 341 342
} /* TYPE_SCTP_COOKIE_ECHO */

#define TYPE_SCTP_COOKIE_ACK { \
	/* SCTP_STATE_EMPTY */ \
343
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
344
	/* SCTP_STATE_CLOSED */ \
345
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
346
	/* SCTP_STATE_COOKIE_WAIT */ \
347
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
348
	/* SCTP_STATE_COOKIE_ECHOED */ \
349
	TYPE_SCTP_FUNC(sctp_sf_do_5_1E_ca), \
L
Linus Torvalds 已提交
350
	/* SCTP_STATE_ESTABLISHED */ \
351
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
352
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
353
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
354
	/* SCTP_STATE_SHUTDOWN_SENT */ \
355
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
356
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
357
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
358
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
359
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
360 361 362 363
} /* TYPE_SCTP_COOKIE_ACK */

#define TYPE_SCTP_ECN_ECNE { \
	/* SCTP_STATE_EMPTY */ \
364
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
365
	/* SCTP_STATE_CLOSED */ \
366
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
367
	/* SCTP_STATE_COOKIE_WAIT */ \
368
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
369
	/* SCTP_STATE_COOKIE_ECHOED */ \
370
	TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
L
Linus Torvalds 已提交
371
	/* SCTP_STATE_ESTABLISHED */ \
372
	TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
L
Linus Torvalds 已提交
373
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
374
	TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
L
Linus Torvalds 已提交
375
	/* SCTP_STATE_SHUTDOWN_SENT */ \
376
	TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
L
Linus Torvalds 已提交
377
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
378
	TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
L
Linus Torvalds 已提交
379
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
380
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
381 382 383 384
} /* TYPE_SCTP_ECN_ECNE */

#define TYPE_SCTP_ECN_CWR { \
	/* SCTP_STATE_EMPTY */ \
385
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
386
	/* SCTP_STATE_CLOSED */ \
387
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
388
	/* SCTP_STATE_COOKIE_WAIT */ \
389
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
390
	/* SCTP_STATE_COOKIE_ECHOED */ \
391
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
392
	/* SCTP_STATE_ESTABLISHED */ \
393
	TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
L
Linus Torvalds 已提交
394
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
395
	TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
L
Linus Torvalds 已提交
396
	/* SCTP_STATE_SHUTDOWN_SENT */ \
397
	TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
L
Linus Torvalds 已提交
398
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
399
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
400
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
401
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
402 403 404 405
} /* TYPE_SCTP_ECN_CWR */

#define TYPE_SCTP_SHUTDOWN_COMPLETE { \
	/* SCTP_STATE_EMPTY */ \
406
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
407
	/* SCTP_STATE_CLOSED */ \
408
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
409
	/* SCTP_STATE_COOKIE_WAIT */ \
410
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
411
	/* SCTP_STATE_COOKIE_ECHOED */ \
412
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
413
	/* SCTP_STATE_ESTABLISHED */ \
414
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
415
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
416
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
417
	/* SCTP_STATE_SHUTDOWN_SENT */ \
418
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
419
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
420
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
421
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
422
	TYPE_SCTP_FUNC(sctp_sf_do_4_C), \
L
Linus Torvalds 已提交
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
} /* TYPE_SCTP_SHUTDOWN_COMPLETE */

/* The primary index for this table is the chunk type.
 * The secondary index for this table is the state.
 *
 * For base protocol (RFC 2960).
 */
static const sctp_sm_table_entry_t chunk_event_table[SCTP_NUM_BASE_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
	TYPE_SCTP_DATA,
	TYPE_SCTP_INIT,
	TYPE_SCTP_INIT_ACK,
	TYPE_SCTP_SACK,
	TYPE_SCTP_HEARTBEAT,
	TYPE_SCTP_HEARTBEAT_ACK,
	TYPE_SCTP_ABORT,
	TYPE_SCTP_SHUTDOWN,
	TYPE_SCTP_SHUTDOWN_ACK,
	TYPE_SCTP_ERROR,
	TYPE_SCTP_COOKIE_ECHO,
	TYPE_SCTP_COOKIE_ACK,
	TYPE_SCTP_ECN_ECNE,
	TYPE_SCTP_ECN_CWR,
	TYPE_SCTP_SHUTDOWN_COMPLETE,
}; /* state_fn_t chunk_event_table[][] */

#define TYPE_SCTP_ASCONF { \
	/* SCTP_STATE_EMPTY */ \
450
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
451
	/* SCTP_STATE_CLOSED */ \
452
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
453
	/* SCTP_STATE_COOKIE_WAIT */ \
454
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
455
	/* SCTP_STATE_COOKIE_ECHOED */ \
456
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
457
	/* SCTP_STATE_ESTABLISHED */ \
458
	TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
L
Linus Torvalds 已提交
459
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
460
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
461
	/* SCTP_STATE_SHUTDOWN_SENT */ \
462
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
463
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
464
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
465
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
466
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
467 468 469 470
} /* TYPE_SCTP_ASCONF */

#define TYPE_SCTP_ASCONF_ACK { \
	/* SCTP_STATE_EMPTY */ \
471
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
472
	/* SCTP_STATE_CLOSED */ \
473
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
474
	/* SCTP_STATE_COOKIE_WAIT */ \
475
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
476
	/* SCTP_STATE_COOKIE_ECHOED */ \
477
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
478
	/* SCTP_STATE_ESTABLISHED */ \
479
	TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
L
Linus Torvalds 已提交
480
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
481
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
482
	/* SCTP_STATE_SHUTDOWN_SENT */ \
483
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
484
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
485
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
486
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
487
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
488 489 490 491 492 493 494 495 496 497 498 499
} /* TYPE_SCTP_ASCONF_ACK */

/* The primary index for this table is the chunk type.
 * The secondary index for this table is the state.
 */
static const sctp_sm_table_entry_t addip_chunk_event_table[SCTP_NUM_ADDIP_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
	TYPE_SCTP_ASCONF,
	TYPE_SCTP_ASCONF_ACK,
}; /*state_fn_t addip_chunk_event_table[][] */

#define TYPE_SCTP_FWD_TSN { \
	/* SCTP_STATE_EMPTY */ \
500
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
501
	/* SCTP_STATE_CLOSED */ \
502
	TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
L
Linus Torvalds 已提交
503
	/* SCTP_STATE_COOKIE_WAIT */ \
504
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
505
	/* SCTP_STATE_COOKIE_ECHOED */ \
506
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
507
	/* SCTP_STATE_ESTABLISHED */ \
508
	TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn), \
L
Linus Torvalds 已提交
509
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
510
	TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn), \
L
Linus Torvalds 已提交
511
	/* SCTP_STATE_SHUTDOWN_SENT */ \
512
	TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn_fast), \
L
Linus Torvalds 已提交
513
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
514
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
515
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
516
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
517 518 519 520 521 522 523 524 525 526 527 528
} /* TYPE_SCTP_FWD_TSN */

/* The primary index for this table is the chunk type.
 * The secondary index for this table is the state.
 */
static const sctp_sm_table_entry_t prsctp_chunk_event_table[SCTP_NUM_PRSCTP_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
	TYPE_SCTP_FWD_TSN,
}; /*state_fn_t prsctp_chunk_event_table[][] */

static const sctp_sm_table_entry_t
chunk_event_table_unknown[SCTP_STATE_NUM_STATES] = {
	/* SCTP_STATE_EMPTY */
529
	TYPE_SCTP_FUNC(sctp_sf_ootb),
L
Linus Torvalds 已提交
530
	/* SCTP_STATE_CLOSED */
531
	TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8),
L
Linus Torvalds 已提交
532
	/* SCTP_STATE_COOKIE_WAIT */
533
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
534
	/* SCTP_STATE_COOKIE_ECHOED */
535
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
536
	/* SCTP_STATE_ESTABLISHED */
537
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
538
	/* SCTP_STATE_SHUTDOWN_PENDING */
539
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
540
	/* SCTP_STATE_SHUTDOWN_SENT */
541
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
542
	/* SCTP_STATE_SHUTDOWN_RECEIVED */
543
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
544
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */
545
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
546 547 548 549 550
};	/* chunk unknown */


#define TYPE_SCTP_PRIMITIVE_ASSOCIATE  { \
	/* SCTP_STATE_EMPTY */ \
551
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
552
	/* SCTP_STATE_CLOSED */ \
553
	TYPE_SCTP_FUNC(sctp_sf_do_prm_asoc), \
L
Linus Torvalds 已提交
554
	/* SCTP_STATE_COOKIE_WAIT */ \
555
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
556
	/* SCTP_STATE_COOKIE_ECHOED */ \
557
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
558
	/* SCTP_STATE_ESTABLISHED */ \
559
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
560
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
561
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
562
	/* SCTP_STATE_SHUTDOWN_SENT */ \
563
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
564
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
565
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
566
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
567
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
568 569 570 571
} /* TYPE_SCTP_PRIMITIVE_ASSOCIATE */

#define TYPE_SCTP_PRIMITIVE_SHUTDOWN  { \
	/* SCTP_STATE_EMPTY */ \
572
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
573
	/* SCTP_STATE_CLOSED */ \
574
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
575
	/* SCTP_STATE_COOKIE_WAIT */ \
576
	TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_shutdown), \
L
Linus Torvalds 已提交
577
	/* SCTP_STATE_COOKIE_ECHOED */ \
578
	TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_shutdown),\
L
Linus Torvalds 已提交
579
	/* SCTP_STATE_ESTABLISHED */ \
580
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_prm_shutdown), \
L
Linus Torvalds 已提交
581
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
582
	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
L
Linus Torvalds 已提交
583
	/* SCTP_STATE_SHUTDOWN_SENT */ \
584
	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
L
Linus Torvalds 已提交
585
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
586
	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
L
Linus Torvalds 已提交
587
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
588
	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
L
Linus Torvalds 已提交
589 590 591 592
} /* TYPE_SCTP_PRIMITIVE_SHUTDOWN */

#define TYPE_SCTP_PRIMITIVE_ABORT  { \
	/* SCTP_STATE_EMPTY */ \
593
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
594
	/* SCTP_STATE_CLOSED */ \
595
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
596
	/* SCTP_STATE_COOKIE_WAIT */ \
597
	TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_abort), \
L
Linus Torvalds 已提交
598
	/* SCTP_STATE_COOKIE_ECHOED */ \
599
	TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_abort), \
L
Linus Torvalds 已提交
600
	/* SCTP_STATE_ESTABLISHED */ \
601
	TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
L
Linus Torvalds 已提交
602
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
603
	TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_prm_abort), \
L
Linus Torvalds 已提交
604
	/* SCTP_STATE_SHUTDOWN_SENT */ \
605
	TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_prm_abort), \
L
Linus Torvalds 已提交
606
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
607
	TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
L
Linus Torvalds 已提交
608
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
609
	TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_prm_abort), \
L
Linus Torvalds 已提交
610 611 612 613
} /* TYPE_SCTP_PRIMITIVE_ABORT */

#define TYPE_SCTP_PRIMITIVE_SEND  { \
	/* SCTP_STATE_EMPTY */ \
614
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
615
	/* SCTP_STATE_CLOSED */ \
616
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
617
	/* SCTP_STATE_COOKIE_WAIT */ \
618
	TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
L
Linus Torvalds 已提交
619
	/* SCTP_STATE_COOKIE_ECHOED */ \
620
	TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
L
Linus Torvalds 已提交
621
	/* SCTP_STATE_ESTABLISHED */ \
622
	TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
L
Linus Torvalds 已提交
623
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
624
	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
L
Linus Torvalds 已提交
625
	/* SCTP_STATE_SHUTDOWN_SENT */ \
626
	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
L
Linus Torvalds 已提交
627
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
628
	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
L
Linus Torvalds 已提交
629
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
630
	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
L
Linus Torvalds 已提交
631 632 633 634
} /* TYPE_SCTP_PRIMITIVE_SEND */

#define TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT  { \
	/* SCTP_STATE_EMPTY */ \
635
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
636
	/* SCTP_STATE_CLOSED */ \
637
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
638
	/* SCTP_STATE_COOKIE_WAIT */ \
639
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
640
	/* SCTP_STATE_COOKIE_ECHOED */ \
641
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
642
	/* SCTP_STATE_ESTABLISHED */ \
643
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
644
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
645
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
646
	/* SCTP_STATE_SHUTDOWN_SENT */ \
647
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
648
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
649
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
650
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
651
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
652 653 654 655
} /* TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT */

#define TYPE_SCTP_PRIMITIVE_ASCONF { \
	/* SCTP_STATE_EMPTY */ \
656
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
657
	/* SCTP_STATE_CLOSED */ \
658
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
659
	/* SCTP_STATE_COOKIE_WAIT */ \
660
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
661
	/* SCTP_STATE_COOKIE_ECHOED */ \
662
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
663
	/* SCTP_STATE_ESTABLISHED */ \
664
	TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
L
Linus Torvalds 已提交
665
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
666
	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
L
Linus Torvalds 已提交
667
	/* SCTP_STATE_SHUTDOWN_SENT */ \
668
	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
L
Linus Torvalds 已提交
669
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
670
	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
L
Linus Torvalds 已提交
671
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
672
	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
L
Linus Torvalds 已提交
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688
} /* TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT */

/* The primary index for this table is the primitive type.
 * The secondary index for this table is the state.
 */
static const sctp_sm_table_entry_t primitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES] = {
	TYPE_SCTP_PRIMITIVE_ASSOCIATE,
	TYPE_SCTP_PRIMITIVE_SHUTDOWN,
	TYPE_SCTP_PRIMITIVE_ABORT,
	TYPE_SCTP_PRIMITIVE_SEND,
	TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT,
	TYPE_SCTP_PRIMITIVE_ASCONF,
};

#define TYPE_SCTP_OTHER_NO_PENDING_TSN  { \
	/* SCTP_STATE_EMPTY */ \
689
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
690
	/* SCTP_STATE_CLOSED */ \
691
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
692
	/* SCTP_STATE_COOKIE_WAIT */ \
693
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
694
	/* SCTP_STATE_COOKIE_ECHOED */ \
695
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
696
	/* SCTP_STATE_ESTABLISHED */ \
697
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
698
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
699
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_start_shutdown), \
L
Linus Torvalds 已提交
700
	/* SCTP_STATE_SHUTDOWN_SENT */ \
701
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
702
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
703
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
L
Linus Torvalds 已提交
704
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
705
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
706 707 708 709
}

#define TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH  { \
	/* SCTP_STATE_EMPTY */ \
710
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
711
	/* SCTP_STATE_CLOSED */ \
712
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
713
	/* SCTP_STATE_COOKIE_WAIT */ \
714
	TYPE_SCTP_FUNC(sctp_sf_cookie_wait_icmp_abort), \
L
Linus Torvalds 已提交
715
	/* SCTP_STATE_COOKIE_ECHOED */ \
716
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
717
	/* SCTP_STATE_ESTABLISHED */ \
718
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
719
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
720
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
721
	/* SCTP_STATE_SHUTDOWN_SENT */ \
722
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
723
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
724
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
725
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
726
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
727 728 729 730 731 732 733 734 735
}

static const sctp_sm_table_entry_t other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES] = {
	TYPE_SCTP_OTHER_NO_PENDING_TSN,
	TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH,
};

#define TYPE_SCTP_EVENT_TIMEOUT_NONE { \
	/* SCTP_STATE_EMPTY */ \
736
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
737
	/* SCTP_STATE_CLOSED */ \
738
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
739
	/* SCTP_STATE_COOKIE_WAIT */ \
740
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
741
	/* SCTP_STATE_COOKIE_ECHOED */ \
742
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
743
	/* SCTP_STATE_ESTABLISHED */ \
744
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
745
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
746
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
747
	/* SCTP_STATE_SHUTDOWN_SENT */ \
748
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
749
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
750
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
751
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
752
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
753 754 755 756
}

#define TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE { \
	/* SCTP_STATE_EMPTY */ \
757
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
758
	/* SCTP_STATE_CLOSED */ \
759
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
760
	/* SCTP_STATE_COOKIE_WAIT */ \
761
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
762
	/* SCTP_STATE_COOKIE_ECHOED */ \
763
	TYPE_SCTP_FUNC(sctp_sf_t1_cookie_timer_expire), \
L
Linus Torvalds 已提交
764
	/* SCTP_STATE_ESTABLISHED */ \
765
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
766
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
767
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
768
	/* SCTP_STATE_SHUTDOWN_SENT */ \
769
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
770
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
771
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
772
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
773
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
774 775 776 777
}

#define TYPE_SCTP_EVENT_TIMEOUT_T1_INIT { \
	/* SCTP_STATE_EMPTY */ \
778
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
779
	/* SCTP_STATE_CLOSED */ \
780
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
781
	/* SCTP_STATE_COOKIE_WAIT */ \
782
	TYPE_SCTP_FUNC(sctp_sf_t1_init_timer_expire), \
L
Linus Torvalds 已提交
783
	/* SCTP_STATE_COOKIE_ECHOED */ \
784
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
785
	/* SCTP_STATE_ESTABLISHED */ \
786
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
787
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
788
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
789
	/* SCTP_STATE_SHUTDOWN_SENT */ \
790
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
791
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
792
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
793
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
794
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
795 796 797 798
}

#define TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN { \
	/* SCTP_STATE_EMPTY */ \
799
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
800
	/* SCTP_STATE_CLOSED */ \
801
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
802
	/* SCTP_STATE_COOKIE_WAIT */ \
803
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
804
	/* SCTP_STATE_COOKIE_ECHOED */ \
805
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
806
	/* SCTP_STATE_ESTABLISHED */ \
807
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
808
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
809
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
810
	/* SCTP_STATE_SHUTDOWN_SENT */ \
811
	TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
L
Linus Torvalds 已提交
812
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
813
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
814
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
815
	TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
L
Linus Torvalds 已提交
816 817 818 819
}

#define TYPE_SCTP_EVENT_TIMEOUT_T3_RTX { \
	/* SCTP_STATE_EMPTY */ \
820
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
821
	/* SCTP_STATE_CLOSED */ \
822
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
823
	/* SCTP_STATE_COOKIE_WAIT */ \
824
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
825
	/* SCTP_STATE_COOKIE_ECHOED */ \
826
	TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
L
Linus Torvalds 已提交
827
	/* SCTP_STATE_ESTABLISHED */ \
828
	TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
L
Linus Torvalds 已提交
829
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
830
	TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
L
Linus Torvalds 已提交
831
	/* SCTP_STATE_SHUTDOWN_SENT */ \
832
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
833
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
834
	TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
L
Linus Torvalds 已提交
835
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
836
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
837 838 839 840
}

#define TYPE_SCTP_EVENT_TIMEOUT_T4_RTO { \
	/* SCTP_STATE_EMPTY */ \
841
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
842
	/* SCTP_STATE_CLOSED */ \
843
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
844
	/* SCTP_STATE_COOKIE_WAIT */ \
845
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
846
	/* SCTP_STATE_COOKIE_ECHOED */ \
847
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
848
	/* SCTP_STATE_ESTABLISHED */ \
849
	TYPE_SCTP_FUNC(sctp_sf_t4_timer_expire), \
L
Linus Torvalds 已提交
850
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
851
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
852
	/* SCTP_STATE_SHUTDOWN_SENT */ \
853
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
854
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
855
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
856
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
857
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
858 859 860 861
}

#define TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD { \
	/* SCTP_STATE_EMPTY */ \
862
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
863
	/* SCTP_STATE_CLOSED */ \
864
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
865
	/* SCTP_STATE_COOKIE_WAIT */ \
866
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
867
	/* SCTP_STATE_COOKIE_ECHOED */ \
868
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
869
	/* SCTP_STATE_ESTABLISHED */ \
870
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
871
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
872
	TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
L
Linus Torvalds 已提交
873
	/* SCTP_STATE_SHUTDOWN_SENT */ \
874
	TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
L
Linus Torvalds 已提交
875
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
876
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
877
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
878
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
879 880 881 882
}

#define TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT { \
	/* SCTP_STATE_EMPTY */ \
883
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
884
	/* SCTP_STATE_CLOSED */ \
885
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
886
	/* SCTP_STATE_COOKIE_WAIT */ \
887
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
888
	/* SCTP_STATE_COOKIE_ECHOED */ \
889
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
890
	/* SCTP_STATE_ESTABLISHED */ \
891
	TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
L
Linus Torvalds 已提交
892
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
893
	TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
L
Linus Torvalds 已提交
894
	/* SCTP_STATE_SHUTDOWN_SENT */ \
895
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
896
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
897
	TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
L
Linus Torvalds 已提交
898
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
899
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
900 901 902 903
}

#define TYPE_SCTP_EVENT_TIMEOUT_SACK { \
	/* SCTP_STATE_EMPTY */ \
904
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
905
	/* SCTP_STATE_CLOSED */ \
906
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
907
	/* SCTP_STATE_COOKIE_WAIT */ \
908
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
909
	/* SCTP_STATE_COOKIE_ECHOED */ \
910
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
911
	/* SCTP_STATE_ESTABLISHED */ \
912
	TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
L
Linus Torvalds 已提交
913
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
914
	TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
L
Linus Torvalds 已提交
915
	/* SCTP_STATE_SHUTDOWN_SENT */ \
916
	TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
L
Linus Torvalds 已提交
917
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
918
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
919
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
920
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
921 922 923 924
}

#define TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE { \
	/* SCTP_STATE_EMPTY */ \
925
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
926
	/* SCTP_STATE_CLOSED */ \
927
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
928
	/* SCTP_STATE_COOKIE_WAIT */ \
929
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
930
	/* SCTP_STATE_COOKIE_ECHOED */ \
931
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
932
	/* SCTP_STATE_ESTABLISHED */ \
933
	TYPE_SCTP_FUNC(sctp_sf_autoclose_timer_expire), \
L
Linus Torvalds 已提交
934
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
935
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
936
	/* SCTP_STATE_SHUTDOWN_SENT */ \
937
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
938
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
939
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
940
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
941
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
942 943 944 945 946 947 948 949 950 951 952 953 954 955 956
}

static const sctp_sm_table_entry_t timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES] = {
	TYPE_SCTP_EVENT_TIMEOUT_NONE,
	TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE,
	TYPE_SCTP_EVENT_TIMEOUT_T1_INIT,
	TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN,
	TYPE_SCTP_EVENT_TIMEOUT_T3_RTX,
	TYPE_SCTP_EVENT_TIMEOUT_T4_RTO,
	TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD,
	TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT,
	TYPE_SCTP_EVENT_TIMEOUT_SACK,
	TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE,
};

957
static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t cid,
L
Linus Torvalds 已提交
958 959 960 961 962
							    sctp_state_t state)
{
	if (state > SCTP_STATE_MAX)
		return &bug;

963
	if (cid <= SCTP_CID_BASE_MAX)
L
Linus Torvalds 已提交
964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980
		return &chunk_event_table[cid][state];

	if (sctp_prsctp_enable) {
		if (cid == SCTP_CID_FWD_TSN)
			return &prsctp_chunk_event_table[0][state];
	}

	if (sctp_addip_enable) {
		if (cid == SCTP_CID_ASCONF)
			return &addip_chunk_event_table[0][state];

		if (cid == SCTP_CID_ASCONF_ACK)
			return &addip_chunk_event_table[1][state];
	}

	return &chunk_event_table_unknown[state];
}