summaryrefslogtreecommitdiff
path: root/pcap-dag.c
diff options
context:
space:
mode:
authorguy <guy>2007-01-29 20:08:06 +0000
committerguy <guy>2007-01-29 20:08:06 +0000
commitb4c382fd7e28aab94f78f1131d2cdc4c0d48d39a (patch)
tree3f60427bfeb0ec693ebae7b4d29ac05915142eb2 /pcap-dag.c
parent6db2ddb56a4d283b7d353409d9c46b647a18a5e3 (diff)
downloadlibpcap-b4c382fd7e28aab94f78f1131d2cdc4c0d48d39a.tar.gz
From Paolo Abeni:
The USB pseudo-header in DLT_USB_LINUX captures is in the host byte order for the machine on which the capture was done. When reading a capture file, convert the pseudo-header to the host byte order of the host on which the file is being read. There's a 64-bit quantity in that pseudo-header; move the 64-bit byte-swap macro from the DAG code to pcap-int.h for use by other code.
Diffstat (limited to 'pcap-dag.c')
-rw-r--r--pcap-dag.c17
1 files changed, 2 insertions, 15 deletions
diff --git a/pcap-dag.c b/pcap-dag.c
index 9bcbc4d7..ae9c7abd 100644
--- a/pcap-dag.c
+++ b/pcap-dag.c
@@ -17,7 +17,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/pcap-dag.c,v 1.26 2006-09-25 18:18:18 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/pcap-dag.c,v 1.27 2007-01-29 20:08:06 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -68,19 +68,6 @@ static const unsigned short endian_test_word = 0x0100;
#define IS_BIGENDIAN() (*((unsigned char *)&endian_test_word))
-/*
- * Swap byte ordering of unsigned long long timestamp on a big endian
- * machine.
- */
-#define SWAP_TS(ull) ((ull & 0xff00000000000000LL) >> 56) | \
- ((ull & 0x00ff000000000000LL) >> 40) | \
- ((ull & 0x0000ff0000000000LL) >> 24) | \
- ((ull & 0x000000ff00000000LL) >> 8) | \
- ((ull & 0x00000000ff000000LL) << 8) | \
- ((ull & 0x0000000000ff0000LL) << 24) | \
- ((ull & 0x000000000000ff00LL) << 40) | \
- ((ull & 0x00000000000000ffLL) << 56)
-
#ifdef DAG_ONLY
/* This code is required when compiling for a DAG device only. */
@@ -417,7 +404,7 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
register unsigned long long ts;
if (IS_BIGENDIAN()) {
- ts = SWAP_TS(header->ts);
+ ts = SWAPLL(header->ts);
} else {
ts = header->ts;
}