From 15c648648c4db57dc74cc66e333f2b69afe078c3 Mon Sep 17 00:00:00 2001
From: Aomx <julian.cordes@gmail.com>
Date: Tue, 10 Nov 2015 17:29:23 +0100
Subject: [PATCH] injecting custom hb-information with heartbeat-ack-chunk now
 possible

---
 gtests/net/packetdrill/run_packet.c  | 8 ++++++++
 gtests/net/packetdrill/sctp_packet.c | 3 +++
 gtests/net/packetdrill/sctp_packet.h | 1 +
 3 files changed, 12 insertions(+)

diff --git a/gtests/net/packetdrill/run_packet.c b/gtests/net/packetdrill/run_packet.c
index aa9ef94c..6f83911b 100644
--- a/gtests/net/packetdrill/run_packet.c
+++ b/gtests/net/packetdrill/run_packet.c
@@ -2479,6 +2479,10 @@ static int send_live_ip_packet(struct netdev *netdev,
 	return netdev_send(netdev, packet);
 }
 
+static inline bool is_generic_chunk(struct sctp_chunk_list_item *item) {
+	return item->flags & FLAG_CHUNK_IS_GENERIC_CHUNK;
+}
+
 /* Perform the action implied by an inbound packet in a script */
 static int do_inbound_script_packet(
 	struct state *state, struct packet *packet,
@@ -2559,6 +2563,10 @@ static int do_inbound_script_packet(
 				}
 				break;
 			case SCTP_HEARTBEAT_ACK_CHUNK_TYPE:
+				if (is_generic_chunk(item)) {
+					break;
+				}
+
 				temp_offset = socket->prepared_heartbeat_ack_length - item->length;
 				assert(packet->ip_bytes + temp_offset <= packet->buffer_bytes);
 				memmove((u8 *)item->chunk + item->length + temp_offset,
diff --git a/gtests/net/packetdrill/sctp_packet.c b/gtests/net/packetdrill/sctp_packet.c
index 5ddca4a7..00589f6b 100644
--- a/gtests/net/packetdrill/sctp_packet.c
+++ b/gtests/net/packetdrill/sctp_packet.c
@@ -325,6 +325,9 @@ sctp_generic_chunk_new(s64 type, s64 flgs, s64 len,
 	u16 length, padding_length, i;
 
 	flags = 0;
+
+	flags |= FLAG_CHUNK_IS_GENERIC_CHUNK;
+
 	if (bytes == NULL) {
 		flags |= FLAG_CHUNK_VALUE_NOCHECK;
 	}
diff --git a/gtests/net/packetdrill/sctp_packet.h b/gtests/net/packetdrill/sctp_packet.h
index b492ebc7..a8d0b434 100644
--- a/gtests/net/packetdrill/sctp_packet.h
+++ b/gtests/net/packetdrill/sctp_packet.h
@@ -187,6 +187,7 @@ sctp_chunk_list_item_new(struct sctp_chunk *chunk, u32 length, u32 flags,
 #define FLAG_CHUNK_FLAGS_NOCHECK                0x00000002
 #define FLAG_CHUNK_LENGTH_NOCHECK               0x00000004
 #define FLAG_CHUNK_VALUE_NOCHECK                0x00000008
+#define FLAG_CHUNK_IS_GENERIC_CHUNK		0x00000010
 
 struct sctp_chunk_list_item *
 sctp_generic_chunk_new(s64 type, s64 flgs, s64 len,
-- 
GitLab