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 --- hicn-plugin/src/CMakeLists.txt | 2 +- hicn-plugin/src/hicn.h | 30 +++++++++++----------- lib/includes/hicn/packet.h | 56 ++++++++++++++++++++++++++++-------------- lib/src/packet.c | 2 +- 4 files changed, 54 insertions(+), 36 deletions(-) diff --git a/hicn-plugin/src/CMakeLists.txt b/hicn-plugin/src/CMakeLists.txt index 3b89e4b53..e05ba1fec 100644 --- a/hicn-plugin/src/CMakeLists.txt +++ b/hicn-plugin/src/CMakeLists.txt @@ -180,7 +180,7 @@ set(COMPILE_DEFINITIONS if (${CMAKE_BUILD_TYPE} MATCHES "Debug") list(APPEND COMPILE_DEFINITIONS "-DHICN_DDEBUG" - # "-DCLIB_DEBUG" + "-DCLIB_DEBUG" ) endif() diff --git a/hicn-plugin/src/hicn.h b/hicn-plugin/src/hicn.h index 84d268357..3d8aa2998 100644 --- a/hicn-plugin/src/hicn.h +++ b/hicn-plugin/src/hicn.h @@ -68,31 +68,31 @@ typedef struct u32 dpo_ctx_id; /** - * hICN buffer flags (1) + * Cached packet info */ - u8 flags; + u16 port; + u16 payload_type; + hicn_lifetime_t lifetime; /** * Ingress face (4) */ hicn_face_id_t face_id; - /* - hicn_packet_type_t type; - hicn_packet_format_t format; - hicn_name_t name; - */ - u16 port; - u16 payload_type; - hicn_lifetime_t lifetime; + /** + * hICN buffer flags (1) + */ + u8 flags; } hicn_buffer_t; -STATIC_ASSERT (offsetof (hicn_buffer_t, pcs_entry_id) == 28, ""); -STATIC_ASSERT (offsetof (hicn_buffer_t, vft_id) == 32, ""); -STATIC_ASSERT (offsetof (hicn_buffer_t, dpo_ctx_id) == 36, ""); -STATIC_ASSERT (offsetof (hicn_buffer_t, flags) == 40, ""); +STATIC_ASSERT (offsetof (hicn_buffer_t, pcs_entry_id) == 24, ""); +STATIC_ASSERT (offsetof (hicn_buffer_t, vft_id) == 28, ""); +STATIC_ASSERT (offsetof (hicn_buffer_t, dpo_ctx_id) == 32, ""); +STATIC_ASSERT (offsetof (hicn_buffer_t, port) == 36, ""); +STATIC_ASSERT (offsetof (hicn_buffer_t, payload_type) == 38, ""); +STATIC_ASSERT (offsetof (hicn_buffer_t, lifetime) == 40, ""); STATIC_ASSERT (offsetof (hicn_buffer_t, face_id) == 44, ""); -// STATIC_ASSERT (offsetof (hicn_buffer_t, name) == 48, ""); +STATIC_ASSERT (offsetof (hicn_buffer_t, flags) == 48, ""); // + name = 16+4 = 20 // opaque : u32[14] = 56 STATIC_ASSERT (sizeof (hicn_buffer_t) <= 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