summaryrefslogtreecommitdiffstats
path: root/contrib/tcpdump/tcpdump-stdinc.h
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2012-05-17 05:11:57 +0000
committerdelphij <delphij@FreeBSD.org>2012-05-17 05:11:57 +0000
commit661b9d94414ea6d11d5b7960aef1f172975ce52b (patch)
tree1720d207a135a239a304163c4635810a1094209a /contrib/tcpdump/tcpdump-stdinc.h
parent63ab347efe2621fc79f689a92c4bbda531593626 (diff)
parentd36dcecdb3228d24b199eb51cfd7ac666f5b8eb8 (diff)
downloadFreeBSD-src-661b9d94414ea6d11d5b7960aef1f172975ce52b.zip
FreeBSD-src-661b9d94414ea6d11d5b7960aef1f172975ce52b.tar.gz
Merge tcpdump 4.2.1.
MFC after: 2 weeks
Diffstat (limited to 'contrib/tcpdump/tcpdump-stdinc.h')
-rw-r--r--contrib/tcpdump/tcpdump-stdinc.h39
1 files changed, 36 insertions, 3 deletions
diff --git a/contrib/tcpdump/tcpdump-stdinc.h b/contrib/tcpdump/tcpdump-stdinc.h
index c437cc1..d350d1b 100644
--- a/contrib/tcpdump/tcpdump-stdinc.h
+++ b/contrib/tcpdump/tcpdump-stdinc.h
@@ -131,10 +131,43 @@ typedef char* caddr_t;
#endif /* WIN32 */
-#ifdef INET6
-#include "ip6.h"
+#ifndef HAVE___ATTRIBUTE__
+#define __attribute__(x)
#endif
+/*
+ * Used to declare a structure unaligned, so that the C compiler,
+ * if necessary, generates code that doesn't assume alignment.
+ * This is required because there is no guarantee that the packet
+ * data we get from libpcap/WinPcap is properly aligned.
+ *
+ * This assumes that, for all compilers that support __attribute__:
+ *
+ * 1) they support __attribute__((packed));
+ *
+ * 2) for all instruction set architectures requiring strict
+ * alignment, declaring a structure with that attribute
+ * causes the compiler to generate code that handles
+ * misaligned 2-byte, 4-byte, and 8-byte integral
+ * quantities.
+ *
+ * It does not (yet) handle compilers where you can get the compiler
+ * to generate code of that sort by some other means.
+ *
+ * This is required in order to, for example, keep the compiler from
+ * generating, for
+ *
+ * if (bp->bp_htype == 1 && bp->bp_hlen == 6 && bp->bp_op == BOOTPREQUEST) {
+ *
+ * in print-bootp.c, code that loads the first 4-byte word of a
+ * "struct bootp", masking out the bp_hops field, and comparing the result
+ * against 0x01010600.
+ *
+ * Note: this also requires that padding be put into the structure,
+ * at least for compilers where it's implemented as __attribute__((packed)).
+ */
+#define UNALIGNED __attribute__((packed))
+
#if defined(WIN32) || defined(MSDOS)
#define FOPEN_READ_TXT "rt"
#define FOPEN_READ_BIN "rb"
@@ -147,7 +180,7 @@ typedef char* caddr_t;
#define FOPEN_WRITE_BIN FOPEN_WRITE_TXT
#endif
-#if defined(__GNUC__) && defined(__i386__) && !defined(__ntohl)
+#if defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) && !defined(__ntohl)
#undef ntohl
#undef ntohs
#undef htonl
OpenPOWER on IntegriCloud