From: Victor Julien Date: Sat, 25 Nov 2023 06:43:34 +0000 (+0100) Subject: packet: access packet data through flex array X-Git-Tag: suricata-8.0.0-beta1~2022 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ae2cd0c597b9cc6756fc86a502206efa9441ec9;p=thirdparty%2Fsuricata.git packet: access packet data through flex array --- diff --git a/src/decode.h b/src/decode.h index dedfbb09ef..7478134ceb 100644 --- a/src/decode.h +++ b/src/decode.h @@ -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 */