Skip to content

Commit

Permalink
SCTP: Support PAD chunk
Browse files Browse the repository at this point in the history
Add support for printing PAD chunk based on RFC4820 section3.

Example:
[PAD]

Signed-off-by: Yuxuan Luo <yuxuan.luo@canonical.com>
  • Loading branch information
Yuxuan Luo authored and CacheUseOnly committed Mar 23, 2024
1 parent fe1cb32 commit be5667b
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 0 deletions.
2 changes: 2 additions & 0 deletions print-sctp.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
#define SCTP_I_DATA 0x40
#define SCTP_ASCONF_ACK 0x80
#define SCTP_RE_CONFIG 0x82
#define SCTP_PAD_CHUNK 0x84
#define SCTP_FORWARD_CUM_TSN 0xc0
#define SCTP_ASCONF 0xc1
#define SCTP_I_FORWARD_TSN 0xc2
Expand All @@ -136,6 +137,7 @@ static const struct tok sctp_chunkid_str[] = {
{ SCTP_SHUTDOWN_COMPLETE, "SHUTDOWN COMPLETE" },
{ SCTP_I_DATA, "I-DATA" },
{ SCTP_RE_CONFIG, "RE-CONFIG" },
{ SCTP_PAD_CHUNK, "PAD" },
{ SCTP_FORWARD_CUM_TSN, "FOR CUM TSN" },
{ SCTP_ASCONF, "ASCONF" },
{ SCTP_ASCONF_ACK, "ASCONF-ACK" },
Expand Down
5 changes: 5 additions & 0 deletions tests/TESTLIST
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ sctp-asconf-6 sctp-asconf-6.pcap sctp-asconf-6.out
sctp-asconf-6-v sctp-asconf-6.pcap sctp-asconf-6-v.out -v
sctp-asconf-6-vv sctp-asconf-6.pcap sctp-asconf-6-vv.out -vv

# PAD tests
sctp-pad sctp-pad.pcap sctp-pad.out
sctp-pad-v sctp-pad.pcap sctp-pad-v.out -v
sctp-pad-vv sctp-pad.pcap sctp-pad-vv.out -vv

# BGP tests
bgp_vpn_attrset bgp_vpn_attrset.pcap bgp_vpn_attrset.out -v
mpbgp-linklocal-nexthop mpbgp-linklocal-nexthop.pcap mpbgp-linklocal-nexthop.out -v
Expand Down
60 changes: 60 additions & 0 deletions tests/sctp-pad-v.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
1 2023-05-21 15:21:08.215897 IP (tos 0x2,ECT(0), ttl 64, id 0, offset 0, flags [DF], proto SCTP (132), length 100)
127.0.0.1.57694 > 127.0.0.1.31337: sctp (1) [INIT] [init tag: 413521971] [rwnd: 106496] [OS: 10] [MIS: 65535] [init TSN: 2253051237]
2 2023-05-21 15:21:08.215923 IP (tos 0x2,ECT(0), ttl 64, id 0, offset 0, flags [DF], proto SCTP (132), length 388)
127.0.0.1.31337 > 127.0.0.1.57694: sctp (1) [INIT ACK] [init tag: 145384071] [rwnd: 106496] [OS: 10] [MIS: 10] [init TSN: 4266748061]
3 2023-05-21 15:21:08.215940 IP (tos 0x2,ECT(0), ttl 64, id 0, offset 0, flags [DF], proto SCTP (132), length 328)
127.0.0.1.57694 > 127.0.0.1.31337: sctp (1) [COOKIE ECHO]
4 2023-05-21 15:21:08.215959 IP (tos 0x2,ECT(0), ttl 64, id 0, offset 0, flags [DF], proto SCTP (132), length 36)
127.0.0.1.31337 > 127.0.0.1.57694: sctp (1) [COOKIE ACK]
5 2023-05-21 15:21:09.986643 IP (tos 0x2,ECT(0), ttl 64, id 1, offset 0, flags [DF], proto SCTP (132), length 92)
10.0.0.169.57694 > 10.0.0.169.31337: sctp (1) [HB REQ]
6 2023-05-21 15:21:09.986673 IP (tos 0x2,ECT(0), ttl 64, id 31167, offset 0, flags [DF], proto SCTP (132), length 92)
10.0.0.169.31337 > 10.0.0.169.57694: sctp (1) [HB ACK]
7 2023-05-21 15:21:10.338722 IP (tos 0x2,ECT(0), ttl 64, id 31168, offset 0, flags [DF], proto SCTP (132), length 92)
10.0.0.169.31337 > 10.0.0.169.57694: sctp (1) [HB REQ]
8 2023-05-21 15:21:10.338734 IP (tos 0x2,ECT(0), ttl 64, id 2, offset 0, flags [DF], proto SCTP (132), length 92)
10.0.0.169.57694 > 10.0.0.169.31337: sctp (1) [HB ACK]
9 2023-05-21 15:21:11.106508 IP (tos 0x2,ECT(0), ttl 64, id 3, offset 0, flags [DF], proto SCTP (132), length 92)
192.168.122.1.57694 > 192.168.122.1.31337: sctp (1) [HB REQ]
10 2023-05-21 15:21:11.106570 IP (tos 0x2,ECT(0), ttl 64, id 31169, offset 0, flags [DF], proto SCTP (132), length 92)
192.168.122.1.31337 > 192.168.122.1.57694: sctp (1) [HB ACK]
11 2023-05-21 15:21:11.618660 IP (tos 0x2,ECT(0), ttl 64, id 4, offset 0, flags [DF], proto SCTP (132), length 92)
10.0.0.192.57694 > 10.0.0.192.31337: sctp (1) [HB REQ]
12 2023-05-21 15:21:11.618665 IP (tos 0x2,ECT(0), ttl 64, id 31170, offset 0, flags [DF], proto SCTP (132), length 92)
192.168.122.1.31337 > 192.168.122.1.57694: sctp (1) [HB REQ]
13 2023-05-21 15:21:11.618678 IP (tos 0x2,ECT(0), ttl 64, id 31171, offset 0, flags [DF], proto SCTP (132), length 92)
10.0.0.192.31337 > 10.0.0.192.57694: sctp (1) [HB ACK]
14 2023-05-21 15:21:11.618695 IP (tos 0x2,ECT(0), ttl 64, id 5, offset 0, flags [DF], proto SCTP (132), length 92)
192.168.122.1.57694 > 192.168.122.1.31337: sctp (1) [HB ACK]
15 2023-05-21 15:21:12.642329 IP (tos 0x2,ECT(0), ttl 64, id 31172, offset 0, flags [DF], proto SCTP (132), length 92)
10.0.0.192.31337 > 10.0.0.192.57694: sctp (1) [HB REQ]
16 2023-05-21 15:21:12.642340 IP (tos 0x2,ECT(0), ttl 64, id 6, offset 0, flags [DF], proto SCTP (132), length 92)
10.0.0.192.57694 > 10.0.0.192.31337: sctp (1) [HB ACK]
17 2023-05-21 15:21:13.410696 IP (tos 0x2,ECT(0), ttl 64, id 31173, offset 0, flags [DF], proto SCTP (132), length 1220)
127.0.0.1.31337 > 127.0.0.1.57694: sctp (1) [HB REQ] , (2) [PAD]
18 2023-05-21 15:21:13.410716 IP (tos 0x2,ECT(0), ttl 64, id 7, offset 0, flags [DF], proto SCTP (132), length 1220)
127.0.0.1.57694 > 127.0.0.1.31337: sctp (1) [HB REQ] , (2) [PAD]
19 2023-05-21 15:21:13.410727 IP (tos 0x2,ECT(0), ttl 64, id 8, offset 0, flags [DF], proto SCTP (132), length 92)
127.0.0.1.57694 > 127.0.0.1.31337: sctp (1) [HB ACK]
20 2023-05-21 15:21:13.410732 IP (tos 0x2,ECT(0), ttl 64, id 31174, offset 0, flags [DF], proto SCTP (132), length 92)
127.0.0.1.31337 > 127.0.0.1.57694: sctp (1) [HB ACK]
21 2023-05-21 15:21:13.410736 IP (tos 0x2,ECT(0), ttl 64, id 31175, offset 0, flags [DF], proto SCTP (132), length 1252)
127.0.0.1.31337 > 127.0.0.1.57694: sctp (1) [HB REQ] , (2) [PAD]
22 2023-05-21 15:21:13.410739 IP (tos 0x2,ECT(0), ttl 64, id 9, offset 0, flags [DF], proto SCTP (132), length 1252)
127.0.0.1.57694 > 127.0.0.1.31337: sctp (1) [HB REQ] , (2) [PAD]
23 2023-05-21 15:21:13.410743 IP (tos 0x2,ECT(0), ttl 64, id 10, offset 0, flags [DF], proto SCTP (132), length 92)
127.0.0.1.57694 > 127.0.0.1.31337: sctp (1) [HB ACK]
24 2023-05-21 15:21:13.410746 IP (tos 0x2,ECT(0), ttl 64, id 31176, offset 0, flags [DF], proto SCTP (132), length 92)
127.0.0.1.31337 > 127.0.0.1.57694: sctp (1) [HB ACK]
25 2023-05-21 15:21:13.410750 IP (tos 0x2,ECT(0), ttl 64, id 31177, offset 0, flags [DF], proto SCTP (132), length 1284)
127.0.0.1.31337 > 127.0.0.1.57694: sctp (1) [HB REQ] , (2) [PAD]
26 2023-05-21 15:21:13.410754 IP (tos 0x2,ECT(0), ttl 64, id 11, offset 0, flags [DF], proto SCTP (132), length 1284)
127.0.0.1.57694 > 127.0.0.1.31337: sctp (1) [HB REQ] , (2) [PAD]
27 2023-05-21 15:21:13.410757 IP (tos 0x2,ECT(0), ttl 64, id 12, offset 0, flags [DF], proto SCTP (132), length 92)
127.0.0.1.57694 > 127.0.0.1.31337: sctp (1) [HB ACK]
28 2023-05-21 15:21:13.410760 IP (tos 0x2,ECT(0), ttl 64, id 31178, offset 0, flags [DF], proto SCTP (132), length 92)
127.0.0.1.31337 > 127.0.0.1.57694: sctp (1) [HB ACK]
29 2023-05-21 15:21:13.410763 IP (tos 0x2,ECT(0), ttl 64, id 31179, offset 0, flags [DF], proto SCTP (132), length 1316)
127.0.0.1.31337 > 127.0.0.1.57694: sctp (1) [HB REQ] , (2) [PAD]
30 2023-05-21 15:21:13.410767 IP (tos 0x2,ECT(0), ttl 64, id 13, offset 0, flags [DF], proto SCTP (132), length 1316)
127.0.0.1.57694 > 127.0.0.1.31337: sctp (1) [HB REQ] , (2) [PAD]
98 changes: 98 additions & 0 deletions tests/sctp-pad-vv.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
1 2023-05-21 15:21:08.215897 IP (tos 0x2,ECT(0), ttl 64, id 0, offset 0, flags [DF], proto SCTP (132), length 100)
127.0.0.1.57694 > 127.0.0.1.31337: sctp
1) [INIT] [init tag: 413521971] [rwnd: 106496] [OS: 10] [MIS: 65535] [init TSN: 2253051237]
2 2023-05-21 15:21:08.215923 IP (tos 0x2,ECT(0), ttl 64, id 0, offset 0, flags [DF], proto SCTP (132), length 388)
127.0.0.1.31337 > 127.0.0.1.57694: sctp
1) [INIT ACK] [init tag: 145384071] [rwnd: 106496] [OS: 10] [MIS: 10] [init TSN: 4266748061]
3 2023-05-21 15:21:08.215940 IP (tos 0x2,ECT(0), ttl 64, id 0, offset 0, flags [DF], proto SCTP (132), length 328)
127.0.0.1.57694 > 127.0.0.1.31337: sctp
1) [COOKIE ECHO]
4 2023-05-21 15:21:08.215959 IP (tos 0x2,ECT(0), ttl 64, id 0, offset 0, flags [DF], proto SCTP (132), length 36)
127.0.0.1.31337 > 127.0.0.1.57694: sctp
1) [COOKIE ACK]
5 2023-05-21 15:21:09.986643 IP (tos 0x2,ECT(0), ttl 64, id 1, offset 0, flags [DF], proto SCTP (132), length 92)
10.0.0.169.57694 > 10.0.0.169.31337: sctp
1) [HB REQ]
6 2023-05-21 15:21:09.986673 IP (tos 0x2,ECT(0), ttl 64, id 31167, offset 0, flags [DF], proto SCTP (132), length 92)
10.0.0.169.31337 > 10.0.0.169.57694: sctp
1) [HB ACK]
7 2023-05-21 15:21:10.338722 IP (tos 0x2,ECT(0), ttl 64, id 31168, offset 0, flags [DF], proto SCTP (132), length 92)
10.0.0.169.31337 > 10.0.0.169.57694: sctp
1) [HB REQ]
8 2023-05-21 15:21:10.338734 IP (tos 0x2,ECT(0), ttl 64, id 2, offset 0, flags [DF], proto SCTP (132), length 92)
10.0.0.169.57694 > 10.0.0.169.31337: sctp
1) [HB ACK]
9 2023-05-21 15:21:11.106508 IP (tos 0x2,ECT(0), ttl 64, id 3, offset 0, flags [DF], proto SCTP (132), length 92)
192.168.122.1.57694 > 192.168.122.1.31337: sctp
1) [HB REQ]
10 2023-05-21 15:21:11.106570 IP (tos 0x2,ECT(0), ttl 64, id 31169, offset 0, flags [DF], proto SCTP (132), length 92)
192.168.122.1.31337 > 192.168.122.1.57694: sctp
1) [HB ACK]
11 2023-05-21 15:21:11.618660 IP (tos 0x2,ECT(0), ttl 64, id 4, offset 0, flags [DF], proto SCTP (132), length 92)
10.0.0.192.57694 > 10.0.0.192.31337: sctp
1) [HB REQ]
12 2023-05-21 15:21:11.618665 IP (tos 0x2,ECT(0), ttl 64, id 31170, offset 0, flags [DF], proto SCTP (132), length 92)
192.168.122.1.31337 > 192.168.122.1.57694: sctp
1) [HB REQ]
13 2023-05-21 15:21:11.618678 IP (tos 0x2,ECT(0), ttl 64, id 31171, offset 0, flags [DF], proto SCTP (132), length 92)
10.0.0.192.31337 > 10.0.0.192.57694: sctp
1) [HB ACK]
14 2023-05-21 15:21:11.618695 IP (tos 0x2,ECT(0), ttl 64, id 5, offset 0, flags [DF], proto SCTP (132), length 92)
192.168.122.1.57694 > 192.168.122.1.31337: sctp
1) [HB ACK]
15 2023-05-21 15:21:12.642329 IP (tos 0x2,ECT(0), ttl 64, id 31172, offset 0, flags [DF], proto SCTP (132), length 92)
10.0.0.192.31337 > 10.0.0.192.57694: sctp
1) [HB REQ]
16 2023-05-21 15:21:12.642340 IP (tos 0x2,ECT(0), ttl 64, id 6, offset 0, flags [DF], proto SCTP (132), length 92)
10.0.0.192.57694 > 10.0.0.192.31337: sctp
1) [HB ACK]
17 2023-05-21 15:21:13.410696 IP (tos 0x2,ECT(0), ttl 64, id 31173, offset 0, flags [DF], proto SCTP (132), length 1220)
127.0.0.1.31337 > 127.0.0.1.57694: sctp
1) [HB REQ]
2) [PAD]
18 2023-05-21 15:21:13.410716 IP (tos 0x2,ECT(0), ttl 64, id 7, offset 0, flags [DF], proto SCTP (132), length 1220)
127.0.0.1.57694 > 127.0.0.1.31337: sctp
1) [HB REQ]
2) [PAD]
19 2023-05-21 15:21:13.410727 IP (tos 0x2,ECT(0), ttl 64, id 8, offset 0, flags [DF], proto SCTP (132), length 92)
127.0.0.1.57694 > 127.0.0.1.31337: sctp
1) [HB ACK]
20 2023-05-21 15:21:13.410732 IP (tos 0x2,ECT(0), ttl 64, id 31174, offset 0, flags [DF], proto SCTP (132), length 92)
127.0.0.1.31337 > 127.0.0.1.57694: sctp
1) [HB ACK]
21 2023-05-21 15:21:13.410736 IP (tos 0x2,ECT(0), ttl 64, id 31175, offset 0, flags [DF], proto SCTP (132), length 1252)
127.0.0.1.31337 > 127.0.0.1.57694: sctp
1) [HB REQ]
2) [PAD]
22 2023-05-21 15:21:13.410739 IP (tos 0x2,ECT(0), ttl 64, id 9, offset 0, flags [DF], proto SCTP (132), length 1252)
127.0.0.1.57694 > 127.0.0.1.31337: sctp
1) [HB REQ]
2) [PAD]
23 2023-05-21 15:21:13.410743 IP (tos 0x2,ECT(0), ttl 64, id 10, offset 0, flags [DF], proto SCTP (132), length 92)
127.0.0.1.57694 > 127.0.0.1.31337: sctp
1) [HB ACK]
24 2023-05-21 15:21:13.410746 IP (tos 0x2,ECT(0), ttl 64, id 31176, offset 0, flags [DF], proto SCTP (132), length 92)
127.0.0.1.31337 > 127.0.0.1.57694: sctp
1) [HB ACK]
25 2023-05-21 15:21:13.410750 IP (tos 0x2,ECT(0), ttl 64, id 31177, offset 0, flags [DF], proto SCTP (132), length 1284)
127.0.0.1.31337 > 127.0.0.1.57694: sctp
1) [HB REQ]
2) [PAD]
26 2023-05-21 15:21:13.410754 IP (tos 0x2,ECT(0), ttl 64, id 11, offset 0, flags [DF], proto SCTP (132), length 1284)
127.0.0.1.57694 > 127.0.0.1.31337: sctp
1) [HB REQ]
2) [PAD]
27 2023-05-21 15:21:13.410757 IP (tos 0x2,ECT(0), ttl 64, id 12, offset 0, flags [DF], proto SCTP (132), length 92)
127.0.0.1.57694 > 127.0.0.1.31337: sctp
1) [HB ACK]
28 2023-05-21 15:21:13.410760 IP (tos 0x2,ECT(0), ttl 64, id 31178, offset 0, flags [DF], proto SCTP (132), length 92)
127.0.0.1.31337 > 127.0.0.1.57694: sctp
1) [HB ACK]
29 2023-05-21 15:21:13.410763 IP (tos 0x2,ECT(0), ttl 64, id 31179, offset 0, flags [DF], proto SCTP (132), length 1316)
127.0.0.1.31337 > 127.0.0.1.57694: sctp
1) [HB REQ]
2) [PAD]
30 2023-05-21 15:21:13.410767 IP (tos 0x2,ECT(0), ttl 64, id 13, offset 0, flags [DF], proto SCTP (132), length 1316)
127.0.0.1.57694 > 127.0.0.1.31337: sctp
1) [HB REQ]
2) [PAD]
30 changes: 30 additions & 0 deletions tests/sctp-pad.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
1 2023-05-21 15:21:08.215897 IP 127.0.0.1.57694 > 127.0.0.1.31337: sctp (1) [INIT] [init tag: 413521971] [rwnd: 106496] [OS: 10] [MIS: 65535] [init TSN: 2253051237]
2 2023-05-21 15:21:08.215923 IP 127.0.0.1.31337 > 127.0.0.1.57694: sctp (1) [INIT ACK] [init tag: 145384071] [rwnd: 106496] [OS: 10] [MIS: 10] [init TSN: 4266748061]
3 2023-05-21 15:21:08.215940 IP 127.0.0.1.57694 > 127.0.0.1.31337: sctp (1) [COOKIE ECHO]
4 2023-05-21 15:21:08.215959 IP 127.0.0.1.31337 > 127.0.0.1.57694: sctp (1) [COOKIE ACK]
5 2023-05-21 15:21:09.986643 IP 10.0.0.169.57694 > 10.0.0.169.31337: sctp (1) [HB REQ]
6 2023-05-21 15:21:09.986673 IP 10.0.0.169.31337 > 10.0.0.169.57694: sctp (1) [HB ACK]
7 2023-05-21 15:21:10.338722 IP 10.0.0.169.31337 > 10.0.0.169.57694: sctp (1) [HB REQ]
8 2023-05-21 15:21:10.338734 IP 10.0.0.169.57694 > 10.0.0.169.31337: sctp (1) [HB ACK]
9 2023-05-21 15:21:11.106508 IP 192.168.122.1.57694 > 192.168.122.1.31337: sctp (1) [HB REQ]
10 2023-05-21 15:21:11.106570 IP 192.168.122.1.31337 > 192.168.122.1.57694: sctp (1) [HB ACK]
11 2023-05-21 15:21:11.618660 IP 10.0.0.192.57694 > 10.0.0.192.31337: sctp (1) [HB REQ]
12 2023-05-21 15:21:11.618665 IP 192.168.122.1.31337 > 192.168.122.1.57694: sctp (1) [HB REQ]
13 2023-05-21 15:21:11.618678 IP 10.0.0.192.31337 > 10.0.0.192.57694: sctp (1) [HB ACK]
14 2023-05-21 15:21:11.618695 IP 192.168.122.1.57694 > 192.168.122.1.31337: sctp (1) [HB ACK]
15 2023-05-21 15:21:12.642329 IP 10.0.0.192.31337 > 10.0.0.192.57694: sctp (1) [HB REQ]
16 2023-05-21 15:21:12.642340 IP 10.0.0.192.57694 > 10.0.0.192.31337: sctp (1) [HB ACK]
17 2023-05-21 15:21:13.410696 IP 127.0.0.1.31337 > 127.0.0.1.57694: sctp (1) [HB REQ] , (2) [PAD]
18 2023-05-21 15:21:13.410716 IP 127.0.0.1.57694 > 127.0.0.1.31337: sctp (1) [HB REQ] , (2) [PAD]
19 2023-05-21 15:21:13.410727 IP 127.0.0.1.57694 > 127.0.0.1.31337: sctp (1) [HB ACK]
20 2023-05-21 15:21:13.410732 IP 127.0.0.1.31337 > 127.0.0.1.57694: sctp (1) [HB ACK]
21 2023-05-21 15:21:13.410736 IP 127.0.0.1.31337 > 127.0.0.1.57694: sctp (1) [HB REQ] , (2) [PAD]
22 2023-05-21 15:21:13.410739 IP 127.0.0.1.57694 > 127.0.0.1.31337: sctp (1) [HB REQ] , (2) [PAD]
23 2023-05-21 15:21:13.410743 IP 127.0.0.1.57694 > 127.0.0.1.31337: sctp (1) [HB ACK]
24 2023-05-21 15:21:13.410746 IP 127.0.0.1.31337 > 127.0.0.1.57694: sctp (1) [HB ACK]
25 2023-05-21 15:21:13.410750 IP 127.0.0.1.31337 > 127.0.0.1.57694: sctp (1) [HB REQ] , (2) [PAD]
26 2023-05-21 15:21:13.410754 IP 127.0.0.1.57694 > 127.0.0.1.31337: sctp (1) [HB REQ] , (2) [PAD]
27 2023-05-21 15:21:13.410757 IP 127.0.0.1.57694 > 127.0.0.1.31337: sctp (1) [HB ACK]
28 2023-05-21 15:21:13.410760 IP 127.0.0.1.31337 > 127.0.0.1.57694: sctp (1) [HB ACK]
29 2023-05-21 15:21:13.410763 IP 127.0.0.1.31337 > 127.0.0.1.57694: sctp (1) [HB REQ] , (2) [PAD]
30 2023-05-21 15:21:13.410767 IP 127.0.0.1.57694 > 127.0.0.1.31337: sctp (1) [HB REQ] , (2) [PAD]
Binary file added tests/sctp-pad.pcap
Binary file not shown.

0 comments on commit be5667b

Please sign in to comment.