More structures that need to be marked Packed.

These structures are cast from raw packet data, so they should be packed.
The case is:

typedef struct Foo_ {
} Foo;

Foo *f = (Foo *)pkt;
pull/1085/merge
Ken Steele 11 years ago committed by Victor Julien
parent 045966676d
commit c91b7fd3bc

@ -92,7 +92,7 @@ static uint32_t sensor_id = 0;
typedef struct Unified2ExtraDataHdr_ {
uint32_t event_type;
uint32_t event_length;
} Unified2ExtraDataHdr;
} __attribute__((__packed__)) Unified2ExtraDataHdr;
/**
* Unified2 Extra Data (currently used only for XFF)
@ -477,7 +477,7 @@ int Unified2Logger(ThreadVars *t, void *data, const Packet *p)
typedef struct _FakeIPv4Hdr {
IPV4Hdr ip4h;
TCPHdr tcph;
} FakeIPv4Hdr;
} __attribute__((__packed__)) FakeIPv4Hdr;
static int Unified2ForgeFakeIPv4Header(FakeIPv4Hdr *fakehdr, const Packet *p, int pkt_len, char invert)
{
@ -507,7 +507,7 @@ static int Unified2ForgeFakeIPv4Header(FakeIPv4Hdr *fakehdr, const Packet *p, in
typedef struct _FakeIPv6Hdr {
IPV6Hdr ip6h;
TCPHdr tcph;
} FakeIPv6Hdr;
} __attribute__((__packed__)) FakeIPv6Hdr;
/**
* \param payload_len length of the payload

@ -45,7 +45,7 @@ typedef struct EthernetHdr_ {
uint8_t eth_dst[6];
uint8_t eth_src[6];
uint16_t eth_type;
} EthernetHdr;
} __attribute__((__packed__)) EthernetHdr;
#endif /* __DECODE_ETHERNET_H__ */

@ -37,7 +37,7 @@ typedef struct GREHdr_
uint8_t version; /**< GRE version */
uint16_t ether_type; /**< ether type of the encapsulated traffic */
} GREHdr;
} __attribute__((__packed__)) GREHdr;
typedef struct GRESreHdr_
{
@ -45,7 +45,7 @@ typedef struct GRESreHdr_
uint8_t sre_offset;
uint8_t sre_length;
uint8_t *routing;
} GRESreHdr;
} __attribute__((__packed__)) GRESreHdr;
#define GRE_VERSION_0 0x0000
#define GRE_VERSION_1 0x0001

@ -162,7 +162,7 @@ typedef struct ICMPV4Hdr_
uint8_t type;
uint8_t code;
uint16_t checksum;
} ICMPV4Hdr;
} __attribute__((__packed__)) ICMPV4Hdr;
/* ICMPv4 header structure */
typedef struct ICMPV4ExtHdr_

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -84,7 +84,7 @@ typedef struct IPV4Hdr_
} ip4_un1;
uint16_t ip_addrs[4];
} ip4_hdrun1;
} IPV4Hdr;
} __attribute__((__packed__)) IPV4Hdr;
#define s_ip_src ip4_hdrun1.ip4_un1.ip_src

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -47,7 +47,7 @@ typedef struct IPV6Hdr_
} ip6_un2;
uint16_t ip6_addrs[16];
} ip6_hdrun2;
} IPV6Hdr;
} __attribute__((__packed__)) IPV6Hdr;
#define s_ip6_src ip6_hdrun2.ip6_un2.ip6_src
#define s_ip6_dst ip6_hdrun2.ip6_un2.ip6_dst
@ -126,7 +126,7 @@ typedef struct IPV6FragHdr_
uint8_t ip6fh_reserved; /* reserved field */
uint16_t ip6fh_offlg; /* offset, reserved, and flag */
uint32_t ip6fh_ident; /* identification */
} IPV6FragHdr;
} __attribute__((__packed__)) IPV6FragHdr;
#define IPV6_EXTHDR_GET_RAW_FH_NH(p) ((p)->ip6eh.ip6fh->ip6fh_nxt)
#define IPV6_EXTHDR_GET_RAW_FH_HDRLEN(p) sizeof(IPV6FragHdr)
@ -149,13 +149,13 @@ typedef struct IPV6AuthHdr_
uint16_t ip6ah_reserved; /* reserved for future use */
uint32_t ip6ah_spi; /* SECURITY PARAMETERS INDEX (SPI) */
uint32_t ip6ah_seq; /* sequence number */
} IPV6AuthHdr;
} __attribute__((__packed__)) IPV6AuthHdr;
typedef struct IPV6EspHdr_
{
uint32_t ip6esph_spi; /* SECURITY PARAMETERS INDEX (SPI) */
uint32_t ip6esph_seq; /* sequence number */
} IPV6EspHdr;
} __attribute__((__packed__)) IPV6EspHdr;
typedef struct IPV6RouteHdr_
{
@ -168,7 +168,7 @@ typedef struct IPV6RouteHdr_
uint8_t ip6rh0_num_addrs; /* number of actual addresses in the
array/packet. The array is guarranteed
to be filled up to this number. */
} IPV6RouteHdr;
} __attribute__((__packed__)) IPV6RouteHdr;
#define IPV6_EXTHDR_GET_RAW_RH_NH(p) ((p)->ip6eh.ip6rh->ip6rh_nxt)
#define IPV6_EXTHDR_GET_RAW_RH_HDRLEN(p) ((p)->ip6eh.ip6rh->ip6rh_len)
@ -219,7 +219,7 @@ typedef struct IPV6HopOptsHdr_
uint8_t ip6hh_nxt; /* next header */
uint8_t ip6hh_len; /* header length in units of 8 bytes, not
including first 8 bytes. */
} IPV6HopOptsHdr;
} __attribute__((__packed__)) IPV6HopOptsHdr;
#define IPV6_EXTHDR_GET_RAW_HH_NH(p) ((p)->ip6eh.ip6hh->ip6hh_nxt)
#define IPV6_EXTHDR_GET_RAW_HH_HDRLEN(p) ((p)->ip6eh.ip6hh->ip6hh_len)
@ -234,7 +234,7 @@ typedef struct IPV6DstOptsHdr_
uint8_t ip6dh_nxt; /* next header */
uint8_t ip6dh_len; /* header length in units of 8 bytes, not
including first 8 bytes. */
} IPV6DstOptsHdr;
} __attribute__((__packed__)) IPV6DstOptsHdr;
#define IPV6_EXTHDR_GET_RAW_DH1_NH(p) ((p)->ip6eh.ip6dh1->ip6dh_nxt)
#define IPV6_EXTHDR_GET_RAW_DH1_HDRLEN(p) ((p)->ip6eh.ip6dh1->ip6dh_len)

@ -65,7 +65,7 @@ typedef struct PPPHdr_ {
uint8_t address;
uint8_t control;
uint16_t protocol;
} PPPHdr;
} __attribute__((__packed__)) PPPHdr;
/** PPP Packet header length */
#define PPP_HEADER_LEN 4

@ -47,7 +47,7 @@ typedef struct PPPOEDiscoveryTag_
{
uint16_t pppoe_tag_type;
uint16_t pppoe_tag_length;
} PPPOEDiscoveryTag;
} __attribute__((__packed__)) PPPOEDiscoveryTag;
typedef struct PPPOEDiscoveryHdr_
{
@ -55,7 +55,7 @@ typedef struct PPPOEDiscoveryHdr_
uint8_t pppoe_code;
uint16_t discovery_id;
uint16_t pppoe_length;
} PPPOEDiscoveryHdr;
} __attribute__((__packed__)) PPPOEDiscoveryHdr;
/* see RFC 2516 - discovery codes */
#define PPPOE_CODE_PADI 0x09

@ -40,7 +40,7 @@ typedef struct SCTPHdr_
uint16_t sh_dport; /* destination port */
uint32_t sh_vtag; /* verification tag, defined per flow */
uint32_t sh_sum; /* checksum, computed via crc32 */
} SCTPHdr;
} __attribute__((__packed__)) SCTPHdr;
#define CLEAR_SCTP_PACKET(p) { \
(p)->sctph = NULL; \

@ -32,7 +32,7 @@ typedef struct SllHdr_ {
uint16_t sll_halen; /* link-layer address length */
uint8_t sll_addr[8]; /* link-layer address */
uint16_t sll_protocol; /* protocol */
} SllHdr;
} __attribute__((__packed__)) SllHdr;
#endif /* __DECODE_SLL_H__ */

@ -44,7 +44,7 @@ uint16_t DecodeVLANGetId(const struct Packet_ *, uint8_t layer);
typedef struct VLANHdr_ {
uint16_t vlan_cfi;
uint16_t protocol; /**< protocol field */
} VLANHdr;
} __attribute__((__packed__)) VLANHdr;
/** VLAN header length */
#define VLAN_HEADER_LEN 4

Loading…
Cancel
Save