Skip to content
Snippets Groups Projects
Commit 6d9d97ed authored by Neal Cardwell's avatar Neal Cardwell
Browse files

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.
parent d3a9bb9f
No related branches found
No related tags found
No related merge requests found
...@@ -119,6 +119,15 @@ extern struct packet *packet_copy(struct packet *old_packet); ...@@ -119,6 +119,15 @@ extern struct packet *packet_copy(struct packet *old_packet);
/* Return the number of headers in the given packet. */ /* Return the number of headers in the given packet. */
extern int packet_header_count(const struct packet *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 /* 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 * pointer to the new header metadata, or NULL if we can't add the
* header. * header.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment