Add Packed attribute on Header structures

Structures that are used to cast packet data into fields need to be packed
so that the compiler doesn't add any padding to these fields. This also helps
Tile-Gx to avoid unaligned loads because the compiler will insert code to
handle the possible unaligned load.
pull/1085/merge
Ken Steele 12 years ago committed by Victor Julien
parent da1fe75975
commit 045966676d

@ -78,12 +78,12 @@ typedef struct DNSHeader_ {
uint16_t answer_rr;
uint16_t authority_rr;
uint16_t additional_rr;
} DNSHeader;
} __attribute__((__packed__)) DNSHeader;
typedef struct DNSQueryTrailer_ {
uint16_t type;
uint16_t class;
} DNSQueryTrailer;
} __attribute__((__packed__)) DNSQueryTrailer;
/** \brief DNS answer header
* packed as we don't want alignment to mess up sizeof() */

@ -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
@ -136,7 +136,7 @@ typedef struct TCPHdr_
uint16_t th_win; /**< pkt window */
uint16_t th_sum; /**< checksum */
uint16_t th_urp; /**< urgent pointer */
} TCPHdr;
} __attribute__((__packed__)) TCPHdr;
typedef struct TCPVars_
{

@ -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
@ -42,7 +42,7 @@ typedef struct UDPHdr_
uint16_t uh_dport; /* destination port */
uint16_t uh_len; /* length */
uint16_t uh_sum; /* checksum */
} UDPHdr;
} __attribute__((__packed__)) UDPHdr;
typedef struct UDPVars_
{

Loading…
Cancel
Save