From 884af2d2090ca28c23a6a90a1d5b5e51d7ae0348 Mon Sep 17 00:00:00 2001
From: Hoelscher <jens.hoelscher@fh-muenster.de>
Date: Wed, 11 May 2016 13:35:31 +0200
Subject: [PATCH] allow all sctp_parameter in reconfig_chunk

---
 gtests/net/packetdrill/parser.y          | 34 +++++++-----------------
 gtests/net/packetdrill/run_system_call.c | 17 ++++++++++++
 2 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/gtests/net/packetdrill/parser.y b/gtests/net/packetdrill/parser.y
index ecb74c63..8e09bcc1 100644
--- a/gtests/net/packetdrill/parser.y
+++ b/gtests/net/packetdrill/parser.y
@@ -674,7 +674,7 @@ static struct tcp_option *new_tcp_fast_open_option(const char *cookie_string,
 %type <chunk_list_item> sctp_shutdown_complete_chunk_spec
 %type <chunk_list_item> sctp_i_data_chunk_spec
 %type <chunk_list_item> sctp_pad_chunk_spec sctp_reconfig_chunk_spec
-%type <parameter_list> opt_parameter_list_spec sctp_parameter_list_spec sctp_reconfig_parameter_list_spec
+%type <parameter_list> opt_parameter_list_spec sctp_parameter_list_spec
 %type <parameter_list_item> sctp_parameter_spec
 %type <parameter_list_item> sctp_generic_parameter_spec
 %type <parameter_list_item> sctp_heartbeat_information_parameter_spec
@@ -688,7 +688,7 @@ static struct tcp_option *new_tcp_fast_open_option(const char *cookie_string,
 %type <parameter_list_item> sctp_ecn_capable_parameter_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 sctp_reconfig_parameter_spec
+%type <parameter_list_item> sctp_pad_parameter_spec
 %type <parameter_list_item> outgoing_ssn_reset_request incoming_ssn_reset_request
 %type <parameter_list_item> reconfig_response ssn_tsn_reset_request generic_reconfig_request
 %type <parameter_list_item> add_outgoing_streams_request add_incoming_streams_request
@@ -1734,27 +1734,6 @@ opt_result
 | RESULT '=' ELLIPSIS { $$ = -1; }
 ;
 
-sctp_reconfig_parameter_list_spec
-: sctp_reconfig_parameter_spec   {
-	$$ = sctp_parameter_list_new();
-	sctp_parameter_list_append($$, $1);
-}
-| sctp_reconfig_parameter_list_spec ',' sctp_reconfig_parameter_spec {
-	$$ = $1;
-	sctp_parameter_list_append($1, $3);
-}
-;
-
-sctp_reconfig_parameter_spec
-: outgoing_ssn_reset_request	{ $$ = $1; }
-| incoming_ssn_reset_request	{ $$ = $1; }
-| ssn_tsn_reset_request		{ $$ = $1; }
-| reconfig_response		{ $$ = $1; }
-| add_outgoing_streams_request  { $$ = $1; }
-| add_incoming_streams_request  { $$ = $1; }
-| generic_reconfig_request	{ $$ = $1; }
-;
-
 opt_sender_next_tsn
 : SENDER_NEXT_TSN '=' INTEGER {
 	if (!is_valid_u32($3)) {
@@ -1849,7 +1828,7 @@ generic_reconfig_request
 ;
 
 sctp_reconfig_chunk_spec
-: RECONFIG '[' opt_flags ',' sctp_reconfig_parameter_list_spec ']' {
+: RECONFIG '[' opt_flags ',' sctp_parameter_list_spec ']' {
 	$$ = sctp_reconfig_chunk_new($3, $5);
 }
 | RECONFIG '[' opt_flags ']' {
@@ -1884,6 +1863,13 @@ sctp_parameter_spec
 | sctp_supported_extensions_parameter_spec    { $$ = $1; }
 | sctp_adaptation_indication_parameter_spec   { $$ = $1; }
 | sctp_pad_parameter_spec                     { $$ = $1; }
+| outgoing_ssn_reset_request                  { $$ = $1; }
+| incoming_ssn_reset_request                  { $$ = $1; }
+| ssn_tsn_reset_request                       { $$ = $1; }
+| reconfig_response                           { $$ = $1; }
+| add_outgoing_streams_request                { $$ = $1; }
+| add_incoming_streams_request                { $$ = $1; }
+| generic_reconfig_request                    { $$ = $1; }
 ;
 
 opt_parameter_type
diff --git a/gtests/net/packetdrill/run_system_call.c b/gtests/net/packetdrill/run_system_call.c
index 4c55dbc8..c51ebf91 100644
--- a/gtests/net/packetdrill/run_system_call.c
+++ b/gtests/net/packetdrill/run_system_call.c
@@ -3319,6 +3319,18 @@ static int syscall_getsockopt(struct state *state, struct syscall_spec *syscall,
 			return STATUS_ERR;
 		}
 		break;
+#endif
+#ifdef SCTP_ADD_STREAMS
+	case EXPR_SCTP_ADD_STREAMS:
+		live_optval = malloc(sizeof(struct sctp_add_streams));
+		live_optlen = (socklen_t)sizeof(struct sctp_add_streams);
+		if (get_sctp_assoc_t(val_expression->value.sctp_add_streams->sas_assoc_id,
+				     &((struct sctp_add_streams *)live_optval)->sas_assoc_id,
+				     error)) {
+			free(live_optval);
+			return STATUS_ERR;
+		}
+		break;
 #endif
 	case EXPR_LIST:
 		s32_bracketed_arg(args, 3, &script_optval, error);
@@ -3455,6 +3467,11 @@ static int syscall_getsockopt(struct state *state, struct syscall_spec *syscall,
 	case EXPR_SCTP_RESET_STREAMS:
 		// SCTP_RESET_STREAMS should not be a successfull option
 		break;
+#endif
+#ifdef SCTP_ADD_STREAMS
+	case EXPR_SCTP_ADD_STREAMS:
+		// SCTP_ADD_STREAMS should not be a successfull option
+		break;
 #endif
 	case EXPR_LIST:
 		if (*(int*)live_optval != script_optval) {
-- 
GitLab