From 456a47ffcfb256beaae0b04d9021035c0e154ace Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Thu, 25 Aug 2022 15:19:33 +0000 Subject: feat: resize hicn_buffer_t to 24 byes Ref: HICN-746 Change-Id: I70d526aa81c158a128408cff7e7a2d8e09ceb01a Signed-off-by: Mauro Sardara --- lib/includes/hicn/packet.h | 56 ++++++++++++++++++++++++++++++---------------- lib/src/packet.c | 2 +- 2 files changed, 38 insertions(+), 20 deletions(-) (limited to 'lib') diff --git a/lib/includes/hicn/packet.h b/lib/includes/hicn/packet.h index c64014fe6..85f76d21b 100644 --- a/lib/includes/hicn/packet.h +++ b/lib/includes/hicn/packet.h @@ -38,12 +38,6 @@ typedef struct __attribute__ ((packed)) { - /* Packet format */ - hicn_packet_format_t format; - - /* Packet type */ - hicn_packet_type_t type; - /* * We store an offset to the packet header. * @@ -56,7 +50,24 @@ typedef struct __attribute__ ((packed)) */ int64_t header; - /* Packet len */ + /* + * Packet format [4] + */ + hicn_packet_format_t format; + + /* + * Packet type [2] + */ + uint16_t type; + + /* + * Buffer size [2] + */ + uint16_t buffer_size; + + /* + * Packet len [2] + */ uint16_t len; #ifdef OPAQUE_IP @@ -67,25 +78,32 @@ typedef struct __attribute__ ((packed)) uint16_t ipv6; }; #endif /* OPAQUE_IP */ + /* + * L4 offset [1] + */ union { - uint16_t tcp; - uint16_t udp; - uint16_t icmp; + uint8_t tcp; + uint8_t udp; + uint8_t icmp; }; - uint16_t newhdr; - uint16_t ah; - uint16_t payload; - - uint16_t buffer_size; - // uint16_t len; + /* + * New header offset [1] + */ + uint8_t newhdr; - /* Contiguous copy of the name */ - // hicn_name_t *name; + /* + * AH offset [2] + */ + uint16_t ah; + /* + * Payload offset [2] + */ + uint16_t payload; } hicn_packet_buffer_t; -static_assert (sizeof (hicn_packet_buffer_t) == 28, ""); +static_assert (sizeof (hicn_packet_buffer_t) == 24, ""); static inline uint8_t * _pkbuf_get_ipv4 (const hicn_packet_buffer_t *pkbuf) diff --git a/lib/src/packet.c b/lib/src/packet.c index ccef568cd..ad86afb66 100644 --- a/lib/src/packet.c +++ b/lib/src/packet.c @@ -250,7 +250,7 @@ hicn_packet_analyze (hicn_packet_buffer_t *pkbuf) } pkbuf->payload = offset; - rc = CALL (get_type, pkbuf, &pkbuf->type); + rc = CALL (get_type, pkbuf, (hicn_packet_type_t *) (&pkbuf->type)); if (rc < 0) goto ERR; -- cgit 1.2.3-korg