summaryrefslogtreecommitdiff
path: root/epan/tvbuff.h
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-02-08 19:09:41 -0800
committerAnders Broman <a.broman58@gmail.com>2014-03-06 05:53:08 +0000
commite2ed48a8d38e7a885d47ba213e7deb72e18ca3d9 (patch)
treeec2c33d65a7a150aae3f9de9616643469369b26f /epan/tvbuff.h
parentdc7d5f97eb3741af9bd16c0e8335b80f6829d9a6 (diff)
downloadwireshark-e2ed48a8d38e7a885d47ba213e7deb72e18ca3d9.tar.gz
Have NFLOG TLV type and length be in host byte order.
When capturing, they'll be in host byte order. The top of the libpcap trunk and 1.5 branch, when reading a file, will, if necessary, byte-swap the type and length values so that they're in the byte order of the host reading the file (rather than the host that wrote the file). Do the same when we read a file, and have the NFLOG dissector assume host byte order for those fields. Change-Id: I493aed1e07b626af1157d75f3bc293b0a694ad07 Reviewed-on: https://code.wireshark.org/review/148 Reviewed-by: Evan Huus <eapache@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/tvbuff.h')
-rw-r--r--epan/tvbuff.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/epan/tvbuff.h b/epan/tvbuff.h
index cb7d7d21bb..2c691b9f38 100644
--- a/epan/tvbuff.h
+++ b/epan/tvbuff.h
@@ -318,6 +318,23 @@ WS_DLL_PUBLIC gfloat tvb_get_letohieee_float(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC gdouble tvb_get_letohieee_double(tvbuff_t *tvb,
const gint offset);
+/*
+ * Fetch 16-bit and 32-bit values in host byte order.
+ * Used for some pseudo-headers in pcap/pcap-ng files, in which the
+ * headers are, when capturing, in the byte order of the host, and
+ * are converted to the byte order of the host reading the file
+ * when reading a capture file.
+ */
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define tvb_get_h_guint16 tvb_get_letohs
+#define tvb_get_h_guint32 tvb_get_letohl
+#elif G_BYTE_ORDER == G_BIG_ENDIAN
+#define tvb_get_h_guint16 tvb_get_ntohs
+#define tvb_get_h_guint32 tvb_get_ntohl
+#else
+#error "Unsupported byte order"
+#endif
+
/**
* Fetch an IPv4 address, in network byte order.
* We do *not* convert it to host byte order; we leave it in