sm_statetable.c 33.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_ootb), \
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_ootb), \
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_ootb), \
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_ootb), \
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_ootb), \
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_ootb), \
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_do_asconf), \
L
Linus Torvalds 已提交
461
	/* SCTP_STATE_SHUTDOWN_SENT */ \
462
	TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
L
Linus Torvalds 已提交
463
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
464
	TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
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_do_asconf_ack), \
L
Linus Torvalds 已提交
482
	/* SCTP_STATE_SHUTDOWN_SENT */ \
483
	TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
L
Linus Torvalds 已提交
484
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
485
	TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
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_ootb), \
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
} /* 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[][] */

526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553
#define TYPE_SCTP_AUTH { \
	/* SCTP_STATE_EMPTY */ \
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
	/* SCTP_STATE_CLOSED */ \
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
	/* SCTP_STATE_COOKIE_WAIT */ \
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
	/* SCTP_STATE_COOKIE_ECHOED */ \
	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
	/* SCTP_STATE_ESTABLISHED */ \
	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
	/* SCTP_STATE_SHUTDOWN_SENT */ \
	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
} /* TYPE_SCTP_AUTH */

/* 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 auth_chunk_event_table[SCTP_NUM_AUTH_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
	TYPE_SCTP_AUTH,
}; /*state_fn_t auth_chunk_event_table[][] */

L
Linus Torvalds 已提交
554 555 556
static const sctp_sm_table_entry_t
chunk_event_table_unknown[SCTP_STATE_NUM_STATES] = {
	/* SCTP_STATE_EMPTY */
557
	TYPE_SCTP_FUNC(sctp_sf_ootb),
L
Linus Torvalds 已提交
558
	/* SCTP_STATE_CLOSED */
559
	TYPE_SCTP_FUNC(sctp_sf_ootb),
L
Linus Torvalds 已提交
560
	/* SCTP_STATE_COOKIE_WAIT */
561
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
562
	/* SCTP_STATE_COOKIE_ECHOED */
563
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
564
	/* SCTP_STATE_ESTABLISHED */
565
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
566
	/* SCTP_STATE_SHUTDOWN_PENDING */
567
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
568
	/* SCTP_STATE_SHUTDOWN_SENT */
569
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
570
	/* SCTP_STATE_SHUTDOWN_RECEIVED */
571
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
572
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */
573
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
574 575 576 577 578
};	/* chunk unknown */


#define TYPE_SCTP_PRIMITIVE_ASSOCIATE  { \
	/* SCTP_STATE_EMPTY */ \
579
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
580
	/* SCTP_STATE_CLOSED */ \
581
	TYPE_SCTP_FUNC(sctp_sf_do_prm_asoc), \
L
Linus Torvalds 已提交
582
	/* SCTP_STATE_COOKIE_WAIT */ \
583
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
584
	/* SCTP_STATE_COOKIE_ECHOED */ \
585
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
586
	/* SCTP_STATE_ESTABLISHED */ \
587
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
588
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
589
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
590
	/* SCTP_STATE_SHUTDOWN_SENT */ \
591
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
592
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
593
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
594
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
595
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
596 597 598 599
} /* TYPE_SCTP_PRIMITIVE_ASSOCIATE */

#define TYPE_SCTP_PRIMITIVE_SHUTDOWN  { \
	/* SCTP_STATE_EMPTY */ \
600
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
601
	/* SCTP_STATE_CLOSED */ \
602
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
603
	/* SCTP_STATE_COOKIE_WAIT */ \
604
	TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_shutdown), \
L
Linus Torvalds 已提交
605
	/* SCTP_STATE_COOKIE_ECHOED */ \
606
	TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_shutdown),\
L
Linus Torvalds 已提交
607
	/* SCTP_STATE_ESTABLISHED */ \
608
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_prm_shutdown), \
L
Linus Torvalds 已提交
609
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
610
	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
L
Linus Torvalds 已提交
611
	/* SCTP_STATE_SHUTDOWN_SENT */ \
612
	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
L
Linus Torvalds 已提交
613
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
614
	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
L
Linus Torvalds 已提交
615
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
616
	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
L
Linus Torvalds 已提交
617 618 619 620
} /* TYPE_SCTP_PRIMITIVE_SHUTDOWN */

#define TYPE_SCTP_PRIMITIVE_ABORT  { \
	/* SCTP_STATE_EMPTY */ \
621
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
622
	/* SCTP_STATE_CLOSED */ \
623
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
624
	/* SCTP_STATE_COOKIE_WAIT */ \
625
	TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_abort), \
L
Linus Torvalds 已提交
626
	/* SCTP_STATE_COOKIE_ECHOED */ \
627
	TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_abort), \
L
Linus Torvalds 已提交
628
	/* SCTP_STATE_ESTABLISHED */ \
629
	TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
L
Linus Torvalds 已提交
630
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
631
	TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_prm_abort), \
L
Linus Torvalds 已提交
632
	/* SCTP_STATE_SHUTDOWN_SENT */ \
633
	TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_prm_abort), \
L
Linus Torvalds 已提交
634
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
635
	TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
L
Linus Torvalds 已提交
636
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
637
	TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_prm_abort), \
L
Linus Torvalds 已提交
638 639 640 641
} /* TYPE_SCTP_PRIMITIVE_ABORT */

#define TYPE_SCTP_PRIMITIVE_SEND  { \
	/* SCTP_STATE_EMPTY */ \
642
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
643
	/* SCTP_STATE_CLOSED */ \
644
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
645
	/* SCTP_STATE_COOKIE_WAIT */ \
646
	TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
L
Linus Torvalds 已提交
647
	/* SCTP_STATE_COOKIE_ECHOED */ \
648
	TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
L
Linus Torvalds 已提交
649
	/* SCTP_STATE_ESTABLISHED */ \
650
	TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
L
Linus Torvalds 已提交
651
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
652
	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
L
Linus Torvalds 已提交
653
	/* SCTP_STATE_SHUTDOWN_SENT */ \
654
	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
L
Linus Torvalds 已提交
655
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
656
	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
L
Linus Torvalds 已提交
657
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
658
	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
L
Linus Torvalds 已提交
659 660 661 662
} /* TYPE_SCTP_PRIMITIVE_SEND */

#define TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT  { \
	/* SCTP_STATE_EMPTY */ \
663
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
664
	/* SCTP_STATE_CLOSED */ \
665
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
666
	/* SCTP_STATE_COOKIE_WAIT */ \
667
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
668
	/* SCTP_STATE_COOKIE_ECHOED */ \
669
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
670
	/* SCTP_STATE_ESTABLISHED */ \
671
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
672
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
673
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
674
	/* SCTP_STATE_SHUTDOWN_SENT */ \
675
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
676
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
677
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
678
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
679
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
680 681 682 683
} /* TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT */

#define TYPE_SCTP_PRIMITIVE_ASCONF { \
	/* SCTP_STATE_EMPTY */ \
684
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
685
	/* SCTP_STATE_CLOSED */ \
686
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
687
	/* SCTP_STATE_COOKIE_WAIT */ \
688
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
689
	/* SCTP_STATE_COOKIE_ECHOED */ \
690
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
691
	/* SCTP_STATE_ESTABLISHED */ \
692
	TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
L
Linus Torvalds 已提交
693
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
694
	TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
L
Linus Torvalds 已提交
695
	/* SCTP_STATE_SHUTDOWN_SENT */ \
696
	TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
L
Linus Torvalds 已提交
697
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
698
	TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
L
Linus Torvalds 已提交
699
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
700
	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
L
Linus Torvalds 已提交
701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716
} /* 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 */ \
717
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
718
	/* SCTP_STATE_CLOSED */ \
719
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
720
	/* SCTP_STATE_COOKIE_WAIT */ \
721
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
722
	/* SCTP_STATE_COOKIE_ECHOED */ \
723
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
724
	/* SCTP_STATE_ESTABLISHED */ \
725
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
726
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
727
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_start_shutdown), \
L
Linus Torvalds 已提交
728
	/* SCTP_STATE_SHUTDOWN_SENT */ \
729
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
730
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
731
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
L
Linus Torvalds 已提交
732
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
733
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
734 735 736 737
}

#define TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH  { \
	/* SCTP_STATE_EMPTY */ \
738
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
739
	/* SCTP_STATE_CLOSED */ \
740
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
741
	/* SCTP_STATE_COOKIE_WAIT */ \
742
	TYPE_SCTP_FUNC(sctp_sf_cookie_wait_icmp_abort), \
L
Linus Torvalds 已提交
743
	/* SCTP_STATE_COOKIE_ECHOED */ \
744
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
745
	/* SCTP_STATE_ESTABLISHED */ \
746
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
747
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
748
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
749
	/* SCTP_STATE_SHUTDOWN_SENT */ \
750
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
751
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
752
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
753
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
754
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
755 756 757 758 759 760 761 762 763
}

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 */ \
764
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
765
	/* SCTP_STATE_CLOSED */ \
766
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
767
	/* SCTP_STATE_COOKIE_WAIT */ \
768
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
769
	/* SCTP_STATE_COOKIE_ECHOED */ \
770
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
771
	/* SCTP_STATE_ESTABLISHED */ \
772
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
773
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
774
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
775
	/* SCTP_STATE_SHUTDOWN_SENT */ \
776
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
777
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
778
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
779
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
780
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
781 782 783 784
}

#define TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE { \
	/* SCTP_STATE_EMPTY */ \
785
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
786
	/* SCTP_STATE_CLOSED */ \
787
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
788
	/* SCTP_STATE_COOKIE_WAIT */ \
789
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
790
	/* SCTP_STATE_COOKIE_ECHOED */ \
791
	TYPE_SCTP_FUNC(sctp_sf_t1_cookie_timer_expire), \
L
Linus Torvalds 已提交
792
	/* SCTP_STATE_ESTABLISHED */ \
793
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
794
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
795
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
796
	/* SCTP_STATE_SHUTDOWN_SENT */ \
797
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
798
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
799
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
800
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
801
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
802 803 804 805
}

#define TYPE_SCTP_EVENT_TIMEOUT_T1_INIT { \
	/* SCTP_STATE_EMPTY */ \
806
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
807
	/* SCTP_STATE_CLOSED */ \
808
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
809
	/* SCTP_STATE_COOKIE_WAIT */ \
810
	TYPE_SCTP_FUNC(sctp_sf_t1_init_timer_expire), \
L
Linus Torvalds 已提交
811
	/* SCTP_STATE_COOKIE_ECHOED */ \
812
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
813
	/* SCTP_STATE_ESTABLISHED */ \
814
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
815
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
816
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
817
	/* SCTP_STATE_SHUTDOWN_SENT */ \
818
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
819
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
820
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
821
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
822
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
823 824 825 826
}

#define TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN { \
	/* SCTP_STATE_EMPTY */ \
827
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
828
	/* SCTP_STATE_CLOSED */ \
829
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
830
	/* SCTP_STATE_COOKIE_WAIT */ \
831
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
832
	/* SCTP_STATE_COOKIE_ECHOED */ \
833
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
834
	/* SCTP_STATE_ESTABLISHED */ \
835
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
836
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
837
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
838
	/* SCTP_STATE_SHUTDOWN_SENT */ \
839
	TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
L
Linus Torvalds 已提交
840
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
841
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
842
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
843
	TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
L
Linus Torvalds 已提交
844 845 846 847
}

#define TYPE_SCTP_EVENT_TIMEOUT_T3_RTX { \
	/* SCTP_STATE_EMPTY */ \
848
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
849
	/* SCTP_STATE_CLOSED */ \
850
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
851
	/* SCTP_STATE_COOKIE_WAIT */ \
852
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
853
	/* SCTP_STATE_COOKIE_ECHOED */ \
854
	TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
L
Linus Torvalds 已提交
855
	/* SCTP_STATE_ESTABLISHED */ \
856
	TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
L
Linus Torvalds 已提交
857
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
858
	TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
L
Linus Torvalds 已提交
859
	/* SCTP_STATE_SHUTDOWN_SENT */ \
860
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
861
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
862
	TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
L
Linus Torvalds 已提交
863
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
864
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
865 866 867 868
}

#define TYPE_SCTP_EVENT_TIMEOUT_T4_RTO { \
	/* SCTP_STATE_EMPTY */ \
869
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
870
	/* SCTP_STATE_CLOSED */ \
871
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
872
	/* SCTP_STATE_COOKIE_WAIT */ \
873
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
874
	/* SCTP_STATE_COOKIE_ECHOED */ \
875
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
876
	/* SCTP_STATE_ESTABLISHED */ \
877
	TYPE_SCTP_FUNC(sctp_sf_t4_timer_expire), \
L
Linus Torvalds 已提交
878
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
879
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
880
	/* SCTP_STATE_SHUTDOWN_SENT */ \
881
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
882
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
883
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
884
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
885
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
886 887 888 889
}

#define TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD { \
	/* SCTP_STATE_EMPTY */ \
890
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
891
	/* SCTP_STATE_CLOSED */ \
892
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
893
	/* SCTP_STATE_COOKIE_WAIT */ \
894
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
895
	/* SCTP_STATE_COOKIE_ECHOED */ \
896
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
897
	/* SCTP_STATE_ESTABLISHED */ \
898
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
899
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
900
	TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
L
Linus Torvalds 已提交
901
	/* SCTP_STATE_SHUTDOWN_SENT */ \
902
	TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
L
Linus Torvalds 已提交
903
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
904
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
905
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
906
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
907 908 909 910
}

#define TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT { \
	/* SCTP_STATE_EMPTY */ \
911
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
912
	/* SCTP_STATE_CLOSED */ \
913
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
914
	/* SCTP_STATE_COOKIE_WAIT */ \
915
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
916
	/* SCTP_STATE_COOKIE_ECHOED */ \
917
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
918
	/* SCTP_STATE_ESTABLISHED */ \
919
	TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
L
Linus Torvalds 已提交
920
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
921
	TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
L
Linus Torvalds 已提交
922
	/* SCTP_STATE_SHUTDOWN_SENT */ \
923
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
924
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
925
	TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
L
Linus Torvalds 已提交
926
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
927
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
928 929 930 931
}

#define TYPE_SCTP_EVENT_TIMEOUT_SACK { \
	/* SCTP_STATE_EMPTY */ \
932
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
933
	/* SCTP_STATE_CLOSED */ \
934
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
935
	/* SCTP_STATE_COOKIE_WAIT */ \
936
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
937
	/* SCTP_STATE_COOKIE_ECHOED */ \
938
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
939
	/* SCTP_STATE_ESTABLISHED */ \
940
	TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
L
Linus Torvalds 已提交
941
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
942
	TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
L
Linus Torvalds 已提交
943
	/* SCTP_STATE_SHUTDOWN_SENT */ \
944
	TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
L
Linus Torvalds 已提交
945
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
946
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
947
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
948
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
949 950 951 952
}

#define TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE { \
	/* SCTP_STATE_EMPTY */ \
953
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
954
	/* SCTP_STATE_CLOSED */ \
955
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
956
	/* SCTP_STATE_COOKIE_WAIT */ \
957
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
958
	/* SCTP_STATE_COOKIE_ECHOED */ \
959
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
960
	/* SCTP_STATE_ESTABLISHED */ \
961
	TYPE_SCTP_FUNC(sctp_sf_autoclose_timer_expire), \
L
Linus Torvalds 已提交
962
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
963
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
964
	/* SCTP_STATE_SHUTDOWN_SENT */ \
965
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
966
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
967
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
968
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
969
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
970 971 972 973 974 975 976 977 978 979 980 981 982 983 984
}

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,
};

985
static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t cid,
L
Linus Torvalds 已提交
986 987 988 989 990
							    sctp_state_t state)
{
	if (state > SCTP_STATE_MAX)
		return &bug;

991
	if (cid <= SCTP_CID_BASE_MAX)
L
Linus Torvalds 已提交
992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006
		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];
	}

1007 1008 1009 1010 1011
	if (sctp_auth_enable) {
		if (cid == SCTP_CID_AUTH)
			return &auth_chunk_event_table[0][state];
	}

L
Linus Torvalds 已提交
1012 1013
	return &chunk_event_table_unknown[state];
}