]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
packet: access packet data through flex array
authorVictor Julien <vjulien@oisf.net>
Sat, 25 Nov 2023 06:43:34 +0000 (07:43 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 1 Dec 2023 13:55:37 +0000 (14:55 +0100)
src/decode.h

index dedfbb09efd070fc36d6c5c17460c3c6448fc218..7478134ceb5e80abb01fc5f3fa46de9959b57052 100644 (file)
@@ -217,8 +217,8 @@ typedef struct Address_ {
 #define GET_TCP_DST_PORT(p)  ((p)->dp)
 
 #define GET_PKT_LEN(p) ((p)->pktlen)
-#define GET_PKT_DATA(p) ((((p)->ext_pkt) == NULL ) ? (uint8_t *)((p) + 1) : (p)->ext_pkt)
-#define GET_PKT_DIRECT_DATA(p) (uint8_t *)((p) + 1)
+#define GET_PKT_DATA(p)            ((((p)->ext_pkt) == NULL) ? GET_PKT_DIRECT_DATA(p) : (p)->ext_pkt)
+#define GET_PKT_DIRECT_DATA(p)     (p)->pkt_data
 #define GET_PKT_DIRECT_MAX_SIZE(p) (default_packet_size)
 
 #define SET_PKT_LEN(p, len) do { \
@@ -651,6 +651,11 @@ typedef struct Packet_
          */
         SCSpinlock tunnel_lock;
     } persistent;
+
+    /** flex array accessor to allocated packet data. Size of the additional
+     *  data is `default_packet_size`. If this is insufficient,
+     *  Packet::ext_pkt will be used instead. */
+    uint8_t pkt_data[];
 } Packet;
 
 /** highest mtu of the interfaces we monitor */