From 551a843f38f04c030e5dc4e18388d6c5533ad81f Mon Sep 17 00:00:00 2001
From: Hoelscher <jens.hoelscher@fh-muenster.de>
Date: Mon, 14 Mar 2016 15:37:57 +0100
Subject: [PATCH] add testcases for incoming_ssn_reset_request

---
 .../sctp/sctp_reconfig/reset_incoming_ssn.pkt | 38 ++++++++++++++++++
 .../reset_incoming_ssn_passiv.pkt             | 39 +++++++++++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 gtests/net/packetdrill/tests/bsd/sctp/sctp_reconfig/reset_incoming_ssn.pkt
 create mode 100644 gtests/net/packetdrill/tests/bsd/sctp/sctp_reconfig/reset_incoming_ssn_passiv.pkt

diff --git a/gtests/net/packetdrill/tests/bsd/sctp/sctp_reconfig/reset_incoming_ssn.pkt b/gtests/net/packetdrill/tests/bsd/sctp/sctp_reconfig/reset_incoming_ssn.pkt
new file mode 100644
index 00000000..1f6ef829
--- /dev/null
+++ b/gtests/net/packetdrill/tests/bsd/sctp/sctp_reconfig/reset_incoming_ssn.pkt
@@ -0,0 +1,38 @@
+--tolerance_usecs=100000
+
+// Create a non-blocking 1-to-1 style socket
+ 0.0 socket(..., SOCK_STREAM, IPPROTO_SCTP) = 3
++0.0 fcntl(3, F_GETFL) = 0x02 (flags O_RDWR)
++0.0 fcntl(3, F_SETFL, O_RDWR | O_NONBLOCK) = 0
+
++0.0 setsockopt(3, IPPROTO_SCTP, SCTP_ENABLE_STREAM_RESET, {assoc_id=3, assoc_value=SCTP_ENABLE_RESET_STREAM_REQ}, 8) = 0
++0.0 getsockopt(3, IPPROTO_SCTP, SCTP_ENABLE_STREAM_RESET, {assoc_id=3, assoc_value=SCTP_ENABLE_RESET_STREAM_REQ}, [8]) = 0
+
+// Trigger the active associtation setup
++0.1 connect(3, ..., ...) = -1 EINPROGRESS (Operation now in progress)
++0.0 > sctp: INIT[flgs=0, tag=1, a_rwnd=..., os=..., is=..., tsn=1, ...]
++0.0 < sctp: INIT_ACK[flgs=0, tag=2, a_rwnd=1500, os=1, is=1, tsn=1, STATE_COOKIE[len=4, val=...], SUPPORTED_EXTENSIONS[types=[0x82]]]
++0.0 > sctp: COOKIE_ECHO[flgs=0, len=4, val=...]
++0.0 < sctp: COOKIE_ACK[flgs=0]
+
+// Check if the setup was sucessful
++0.0 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
+// Generate some traffic so the tsn and ssn increase
++0.0 write(3, ..., 1000) = 1000
++0.0 > sctp: DATA[flgs=BE, len=1016, tsn=1, sid=0, ssn=0, ppid=0]
++0.0 < sctp: SACK[flgs=0, cum_tsn=1, a_rwnd=1500, gaps=[], dups=[]]
+
++0.0 write(3, ..., 1000) = 1000
++0.0 > sctp: DATA[flgs=BE, len=1016, tsn=2, sid=0, ssn=1, ppid=0]
++0.0 < sctp: SACK[flgs=0, cum_tsn=2, a_rwnd=1500, gaps=[], dups=[]]
+
+// Reset Stream 0
++0.0 setsockopt(3, IPPROTO_SCTP, SCTP_RESET_STREAMS, {srs_assoc_id=3,
+						      srs_flags=SCTP_STREAM_RESET_INCOMING,
+                                                      srs_number_streams=0,
+						      srs_stream_list=[]}, 8) = 0
++0.0 > sctp: RECONFIG[flgs=0, INCOMING_SSN_RESET[req_sn=1]]
++0.0 < sctp: RECONFIG[flgs=0, OUTGOING_SSN_RESET[req_sn=1, resp_sn=1, last_tsn=0, sids=[]]]
++0.0 > sctp: RECONFIG[flgs=0, RECONFIG_RESPONSE[resp_sn=1, result=1]]
+
++1.0 close(3) = 0
diff --git a/gtests/net/packetdrill/tests/bsd/sctp/sctp_reconfig/reset_incoming_ssn_passiv.pkt b/gtests/net/packetdrill/tests/bsd/sctp/sctp_reconfig/reset_incoming_ssn_passiv.pkt
new file mode 100644
index 00000000..45c7958b
--- /dev/null
+++ b/gtests/net/packetdrill/tests/bsd/sctp/sctp_reconfig/reset_incoming_ssn_passiv.pkt
@@ -0,0 +1,39 @@
+	--tolerance_usecs=100000
++0.0 socket(..., SOCK_STREAM, IPPROTO_SCTP) = 3
+// Check the handshake with en empty(!) cookie
+
++0.0 setsockopt(3, IPPROTO_SCTP, SCTP_ENABLE_STREAM_RESET, {assoc_id=0, assoc_value=SCTP_ENABLE_RESET_STREAM_REQ}, 8) = 0
+
++0.0 bind(3, ..., ...) = 0
++0.0 listen(3, 1) = 0
++0.0 < sctp: INIT[flgs=0, tag=1, a_rwnd=1500, os=1, is=1, tsn=1,
+                  ECN_CAPABLE[],
+		  SUPPORTED_EXTENSIONS[types=[RECONFIG]],
+                  COOKIE_PRESERVATIVE[incr=12345],
+                  SUPPORTED_ADDRESS_TYPES[types=[IPv4]]]
++0.0 > sctp: INIT_ACK[flgs=0, tag=2, a_rwnd=..., os=..., is=..., tsn=10, ...]
++0.1 < sctp: COOKIE_ECHO[flgs=0, len=..., val=...]
++0.0 > sctp: COOKIE_ACK[flgs=0]
+
++0.0 accept(3, ..., ...) = 4
+
++1.0 write(4, ..., 1000) = 1000
+*    > sctp: DATA[flgs=BE, len=1016, tsn=10, sid=0, ssn=0, ppid=0]
++0.1 < sctp: SACK[flgs=0, cum_tsn=10, a_rwnd=1500, gaps=[], dups=[]]
+
+// Send some data.
++1.0 write(4, ..., 1000) = 1000
+*    > sctp: DATA[flgs=BE, len=1016, tsn=11, sid=0, ssn=1, ppid=0]
++0.0 < sctp: SACK[flgs=0, cum_tsn=11, a_rwnd=1500, gaps=[], dups=[]]
+
++0.1 < sctp: DATA[flgs=BE, len=1016, tsn=1, sid=0, ssn=0, ppid=0]
+*    > sctp: SACK[flgs=0, cum_tsn=1, a_rwnd=..., gaps=[], dups=[]]
++0.0 read(4, ..., 1000) = 1000
+
++0.1 < sctp: DATA[flgs=BE, len=1016, tsn=2, sid=0, ssn=1, ppid=0]
+*    > sctp: SACK[flgs=0, cum_tsn=2, a_rwnd=..., gaps=[], dups=[]]
++0.0 read(4, ..., 1000) = 1000
+
++0.0 < sctp: RECONFIG[flgs=0, INCOMING_SSN_RESET[req_sn=0, sids=[0]]]
++0.0 > sctp: RECONFIG[flgs=0, OUTGOING_SSN_RESET[req_sn=0, resp_sn=0, last_tsn=2, sids=[0]]]
++0.0 < sctp: RECONFIG[flgs=0, RECONFIG_RESPONSE[resp_sn=0, result=1]]
-- 
GitLab