From 6d9d97edd221aef573ceae67b74e2125e1a6d51f Mon Sep 17 00:00:00 2001
From: Neal Cardwell <ncardwell@google.com>
Date: Fri, 3 Jan 2014 14:32:14 -0500
Subject: [PATCH] net-test: packetdrill: add packet_inner_header() helper

Add a little helper for accessing the inner-most header of a
packet. In preparation for a patch to support parsing ICMP packets on
the wire.
---
 gtests/net/packetdrill/packet.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gtests/net/packetdrill/packet.h b/gtests/net/packetdrill/packet.h
index 3ecb94f4..4ca1059a 100644
--- a/gtests/net/packetdrill/packet.h
+++ b/gtests/net/packetdrill/packet.h
@@ -119,6 +119,15 @@ extern struct packet *packet_copy(struct packet *old_packet);
 /* Return the number of headers in the given packet. */
 extern int packet_header_count(const struct packet *packet);
 
+/* Return the inner-most header in the given packet. */
+static inline struct header *packet_inner_header(struct packet *packet)
+{
+	int num_headers = packet_header_count(packet);
+
+	assert(num_headers > 0);
+	return &packet->headers[num_headers - 1];
+}
+
 /* Attempt to append a new header to the given packet. Return a
  * pointer to the new header metadata, or NULL if we can't add the
  * header.
-- 
GitLab