summaryrefslogtreecommitdiff
path: root/sys/src/cmd
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-12-23 02:00:09 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2015-12-23 02:00:09 +0100
commit46bbeea04060257c6257d14112c6a8d317d7f930 (patch)
tree7e58f5a3b17828381f20bc0aa6dc67e2119830ff /sys/src/cmd
parenta53ae2782a6e8b1996c1d5dea4190eb11d06d056 (diff)
snoopy: fix timestamps for pcap files (thanks BurnZeZ)
the pcap files produced by snoopy had the wrong timestamps because it expected: /* magic=0xa1b2c3d4 */ ulong ts_sec; /* seconds*/ ulong ts_usec; /* microseconds */ but we wrote: uvlong ts; /* nanoseconds */ now, we write: /* magic=0xa1b23c4d */ ulong ts_sec; /* seconds */ ulong ts_nsec; /* nanoseconds */
Diffstat (limited to 'sys/src/cmd')
-rw-r--r--sys/src/cmd/ip/snoopy/main.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/src/cmd/ip/snoopy/main.c b/sys/src/cmd/ip/snoopy/main.c
index da0432959..db8078a3f 100644
--- a/sys/src/cmd/ip/snoopy/main.c
+++ b/sys/src/cmd/ip/snoopy/main.c
@@ -273,7 +273,7 @@ filterpkt(Filter *f, uchar *ps, uchar *pe, Proto *pr, int needroot)
*/
#define PCAP_VERSION_MAJOR 2
#define PCAP_VERSION_MINOR 4
-#define TCPDUMP_MAGIC 0xa1b2c3d4
+#define TCPDUMP_MAGIC 0xa1b23c4d
struct pcap_file_header {
ulong magic;
@@ -286,7 +286,8 @@ struct pcap_file_header {
};
struct pcap_pkthdr {
- uvlong ts; /* time stamp */
+ ulong ts_sec;
+ ulong ts_nsec;
ulong caplen; /* length of portion present */
ulong len; /* length this packet (off wire) */
};
@@ -323,7 +324,8 @@ tracepkt(uchar *ps, int len)
len = Mflag;
if(pcap){
goo = (struct pcap_pkthdr*)(ps-16);
- goo->ts = pkttime;
+ goo->ts_sec = (uvlong)pkttime / 1000000000;
+ goo->ts_nsec = (uvlong)pkttime % 1000000000;
goo->caplen = len;
goo->len = len;
write(1, goo, len+16);