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