These structures are cast from raw packet data, so they should be packed.
The case is:
typedef struct Foo_ {
} Foo;
Foo *f = (Foo *)pkt;
typedef struct Unified2ExtraDataHdr_ {
uint32_t event_type;
uint32_t event_length;
-} Unified2ExtraDataHdr;
+} __attribute__((__packed__)) Unified2ExtraDataHdr;
/**
* Unified2 Extra Data (currently used only for XFF)
typedef struct _FakeIPv4Hdr {
IPV4Hdr ip4h;
TCPHdr tcph;
-} FakeIPv4Hdr;
+} __attribute__((__packed__)) FakeIPv4Hdr;
static int Unified2ForgeFakeIPv4Header(FakeIPv4Hdr *fakehdr, const Packet *p, int pkt_len, char invert)
{
typedef struct _FakeIPv6Hdr {
IPV6Hdr ip6h;
TCPHdr tcph;
-} FakeIPv6Hdr;
+} __attribute__((__packed__)) FakeIPv6Hdr;
/**
* \param payload_len length of the payload
uint8_t eth_dst[6];
uint8_t eth_src[6];
uint16_t eth_type;
-} EthernetHdr;
+} __attribute__((__packed__)) EthernetHdr;
#endif /* __DECODE_ETHERNET_H__ */
uint8_t version; /**< GRE version */
uint16_t ether_type; /**< ether type of the encapsulated traffic */
-} GREHdr;
+} __attribute__((__packed__)) GREHdr;
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
uint8_t type;
uint8_t code;
uint16_t checksum;
-} ICMPV4Hdr;
+} __attribute__((__packed__)) ICMPV4Hdr;
/* ICMPv4 header structure */
typedef struct ICMPV4ExtHdr_
-/* 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
} ip4_un1;
uint16_t ip_addrs[4];
} ip4_hdrun1;
-} IPV4Hdr;
+} __attribute__((__packed__)) IPV4Hdr;
#define s_ip_src ip4_hdrun1.ip4_un1.ip_src
-/* 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
} 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
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)
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_
{
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)
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)
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)
uint8_t address;
uint8_t control;
uint16_t protocol;
-} PPPHdr;
+} __attribute__((__packed__)) PPPHdr;
/** PPP Packet header length */
#define PPP_HEADER_LEN 4
{
uint16_t pppoe_tag_type;
uint16_t pppoe_tag_length;
-} PPPOEDiscoveryTag;
+} __attribute__((__packed__)) PPPOEDiscoveryTag;
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
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; \
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__ */
typedef struct VLANHdr_ {
uint16_t vlan_cfi;
uint16_t protocol; /**< protocol field */
-} VLANHdr;
+} __attribute__((__packed__)) VLANHdr;
/** VLAN header length */
#define VLAN_HEADER_LEN 4