From 288c5bd11cdba3fe200a3401e3caaf8626e55237 Mon Sep 17 00:00:00 2001
From: Aomx <aomx@riseup.net>
Date: Mon, 11 Jul 2016 22:04:49 +0200
Subject: [PATCH] first commit regarding implementation of
 forward_tsn_supported parameter in packetdrill

---
 gtests/net/packetdrill/lexer.l       |  1 +
 gtests/net/packetdrill/parser.y      |  9 ++++++++-
 gtests/net/packetdrill/sctp.h        |  6 ++++++
 gtests/net/packetdrill/sctp_packet.c | 14 ++++++++++++++
 gtests/net/packetdrill/sctp_packet.h |  3 +++
 5 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/gtests/net/packetdrill/lexer.l b/gtests/net/packetdrill/lexer.l
index da93842b..1d7f3a81 100644
--- a/gtests/net/packetdrill/lexer.l
+++ b/gtests/net/packetdrill/lexer.l
@@ -598,6 +598,7 @@ HOSTNAME_ADDRESS		return HOSTNAME_ADDRESS;
 SUPPORTED_ADDRESS_TYPES		return SUPPORTED_ADDRESS_TYPES;
 ADAPTATION_INDICATION		return ADAPTATION_INDICATION;
 ECN_CAPABLE			return ECN_CAPABLE;
+FORWARD_TSN_SUPPORTED           return FORWARD_TSN_SUPPORTED;
 SUPPORTED_EXTENSIONS		return SUPPORTED_EXTENSIONS;
 addr				return ADDR;
 incr				return INCR;
diff --git a/gtests/net/packetdrill/parser.y b/gtests/net/packetdrill/parser.y
index dc41710d..d716028a 100644
--- a/gtests/net/packetdrill/parser.y
+++ b/gtests/net/packetdrill/parser.y
@@ -524,7 +524,7 @@ static struct tcp_option *new_tcp_fast_open_option(const char *cookie_string,
 %token <reserved> TAG A_RWND OS IS TSN SID SSN MID PPID FSN CUM_TSN GAPS DUPS
 %token <reserved> PARAMETER HEARTBEAT_INFORMATION IPV4_ADDRESS IPV6_ADDRESS
 %token <reserved> STATE_COOKIE UNRECOGNIZED_PARAMETER COOKIE_PRESERVATIVE
-%token <reserved> HOSTNAME_ADDRESS SUPPORTED_ADDRESS_TYPES ECN_CAPABLE
+%token <reserved> HOSTNAME_ADDRESS SUPPORTED_ADDRESS_TYPES ECN_CAPABLE FORWARD_TSN_SUPPORTED
 %token <reserved> SUPPORTED_EXTENSIONS ADAPTATION_CODE_POINT ADAPTATION_INDICATION
 %token <reserved> OUTGOING_SSN_RESET REQ_SN RESP_SN LAST_TSN SIDS INCOMING_SSN_RESET
 %token <reserved> RECONFIG_RESPONSE RESULT SENDER_NEXT_TSN RECEIVER_NEXT_TSN
@@ -687,6 +687,7 @@ static struct tcp_option *new_tcp_fast_open_option(const char *cookie_string,
 %type <parameter_list_item> sctp_hostname_address_parameter_spec
 %type <parameter_list_item> sctp_supported_address_types_parameter_spec
 %type <parameter_list_item> sctp_ecn_capable_parameter_spec
+%type <parameter_list_item> sctp_fornward_tsn_supported_spec
 %type <parameter_list_item> sctp_supported_extensions_parameter_spec
 %type <parameter_list_item> sctp_adaptation_indication_parameter_spec
 %type <parameter_list_item> sctp_pad_parameter_spec
@@ -1858,6 +1859,7 @@ sctp_parameter_spec
 | sctp_hostname_address_parameter_spec        { $$ = $1; }
 | sctp_supported_address_types_parameter_spec { $$ = $1; }
 | sctp_ecn_capable_parameter_spec             { $$ = $1; }
+| sctp_fornward_tsn_supported_spec            { $$ = $1; }
 | sctp_supported_extensions_parameter_spec    { $$ = $1; }
 | sctp_adaptation_indication_parameter_spec   { $$ = $1; }
 | sctp_pad_parameter_spec                     { $$ = $1; }
@@ -2021,6 +2023,11 @@ sctp_ecn_capable_parameter_spec
 	$$ = sctp_ecn_capable_parameter_new();
 }
 
+sctp_fornward_tsn_supported_spec
+: FORWARD_TSN_SUPPORTED '[' ']' {
+	$$ = sctp_forward_tsn_supported_parameter_new();
+}
+
 chunk_types_list
 : {
 	$$ = sctp_byte_list_new();
diff --git a/gtests/net/packetdrill/sctp.h b/gtests/net/packetdrill/sctp.h
index 0b95445b..96c0d705 100644
--- a/gtests/net/packetdrill/sctp.h
+++ b/gtests/net/packetdrill/sctp.h
@@ -260,6 +260,7 @@ struct sctp_reconfig_chunk {
 #define SCTP_PAD_PARAMETER_TYPE				0x8005
 #define SCTP_Set_Primary_Address			0xc004
 #define SCTP_ADAPTATION_INDICATION_PARAMETER_TYPE	0xc006
+#define SCTP_FORWARD_TSN_SUPPORTED_PARAMETER_TYPE       0xc000
 
 #define MAX_SCTP_PARAMETER_BYTES			0xffff
 
@@ -394,6 +395,11 @@ struct sctp_reconfig_generic_request_parameter {
 	__u8 value[];
 } __packed;
 
+struct sctp_forward_tsn_supported_parameter {
+	__be16 type;
+	__be16 length;
+} __packed;
+
 #define SCTP_INVALID_STREAM_IDENTIFIER_CAUSE_CODE	0x0001
 #define SCTP_MISSING_MANDATORY_PARAMETER_CAUSE_CODE	0x0002
 #define SCTP_STALE_COOKIE_ERROR_CAUSE_CODE		0x0003
diff --git a/gtests/net/packetdrill/sctp_packet.c b/gtests/net/packetdrill/sctp_packet.c
index 725d59ba..eff5ac4d 100644
--- a/gtests/net/packetdrill/sctp_packet.c
+++ b/gtests/net/packetdrill/sctp_packet.c
@@ -2078,6 +2078,20 @@ sctp_ecn_capable_parameter_new(void)
 	                                    0);
 }
 
+struct sctp_parameter_list_item *
+sctp_forward_tsn_supported_parameter_new()
+{
+	struct sctp_forward_tsn_supported_parameter *parameter;
+
+	parameter = malloc(sizeof(struct sctp_forward_tsn_supported_parameter));
+	assert(parameter != NULL);
+	parameter->type = htons(SCTP_FORWARD_TSN_SUPPORTED_PARAMETER_TYPE);
+	parameter->length = htons(sizeof(struct sctp_forward_tsn_supported_parameter));
+	return sctp_parameter_list_item_new((struct sctp_parameter *)parameter,
+	                                    sizeof(struct sctp_forward_tsn_supported_parameter),
+	                                    0);
+}
+
 struct sctp_parameter_list *
 sctp_parameter_list_new(void)
 {
diff --git a/gtests/net/packetdrill/sctp_packet.h b/gtests/net/packetdrill/sctp_packet.h
index 01922281..d76f8171 100644
--- a/gtests/net/packetdrill/sctp_packet.h
+++ b/gtests/net/packetdrill/sctp_packet.h
@@ -364,6 +364,9 @@ sctp_supported_address_types_parameter_new(struct sctp_address_type_list *list);
 struct sctp_parameter_list_item *
 sctp_ecn_capable_parameter_new(void);
 
+struct sctp_parameter_list_item *
+sctp_forward_tsn_supported_parameter_new();
+
 struct sctp_parameter_list_item *
 sctp_pad_parameter_new(s64 len, u8 *padding);
 
-- 
GitLab