From 98950f62e4ff76ec415522bf3ee221344b7e9a06 Mon Sep 17 00:00:00 2001
From: hoelscher <jens.hoelscher@fh-muenster.de>
Date: Fri, 30 Oct 2015 16:42:48 +0100
Subject: [PATCH] updates from review

---
 gtests/net/packetdrill/sctp_chunk_to_string.c |  2 +-
 gtests/net/packetdrill/sctp_packet.c          | 13 ++++++++-----
 gtests/net/packetdrill/sctp_packet.h          |  2 +-
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/gtests/net/packetdrill/sctp_chunk_to_string.c b/gtests/net/packetdrill/sctp_chunk_to_string.c
index 56cfbc5d..027873a9 100644
--- a/gtests/net/packetdrill/sctp_chunk_to_string.c
+++ b/gtests/net/packetdrill/sctp_chunk_to_string.c
@@ -346,7 +346,7 @@ static int sctp_adaptation_indication_parameter_to_string(
 	u16 length;
 
 	length = ntohs(parameter->length);
-	if (length < sizeof(struct sctp_parameter)) {
+	if (length < sizeof(struct sctp_adaptation_indication_parameter)) {
 		asprintf(error, "PARAMETER too short (type=0x%04x, length=%u)",
 			 ntohs(parameter->type), length);
 		return STATUS_ERR;
diff --git a/gtests/net/packetdrill/sctp_packet.c b/gtests/net/packetdrill/sctp_packet.c
index b3ce132f..5ddca4a7 100644
--- a/gtests/net/packetdrill/sctp_packet.c
+++ b/gtests/net/packetdrill/sctp_packet.c
@@ -1570,8 +1570,6 @@ sctp_supported_address_types_parameter_new(struct sctp_address_type_list *list)
 	                                    parameter_length, flags);
 }
 
-
-
 struct sctp_parameter_list_item *
 sctp_supported_extensions_parameter_new(struct sctp_byte_list *list)
 {
@@ -1614,7 +1612,7 @@ sctp_supported_extensions_parameter_new(struct sctp_byte_list *list)
 }
 
 struct sctp_parameter_list_item *
-sctp_adaptation_indication_parameter_new(u32 val)
+sctp_adaptation_indication_parameter_new(s64 val)
 {
 	u32 flags;
 	struct sctp_adaptation_indication_parameter *parameter;
@@ -1629,8 +1627,13 @@ sctp_adaptation_indication_parameter_new(u32 val)
 
 	parameter->type = htons(SCTP_ADAPTATION_INDICATION_PARAMETER_TYPE);
 	parameter->length = htons(parameter_length);
-	parameter->adaptation_code_point = htonl(val);
-	
+	if (val == -1) {
+		parameter->adaptation_code_point = htonl(0);
+		flags |= FLAG_PARAMETER_VALUE_NOCHECK;
+	} else {
+		assert(is_valid_u32(val));
+		parameter->adaptation_code_point = htonl((u32)val);
+	}
 	return sctp_parameter_list_item_new((struct sctp_parameter *)parameter,
 	                                    parameter_length, flags);
 }
diff --git a/gtests/net/packetdrill/sctp_packet.h b/gtests/net/packetdrill/sctp_packet.h
index e7c8c491..b492ebc7 100644
--- a/gtests/net/packetdrill/sctp_packet.h
+++ b/gtests/net/packetdrill/sctp_packet.h
@@ -341,7 +341,7 @@ struct sctp_parameter_list_item *
 sctp_pad_parameter_new(s64 len, u8 *padding);
 
 struct sctp_parameter_list_item *
-sctp_adaptation_indication_parameter_new(u32 val);
+sctp_adaptation_indication_parameter_new(s64 val);
 
 struct sctp_parameter_list_item *
 sctp_supported_extensions_parameter_new(struct sctp_byte_list *list);
-- 
GitLab