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