ref: 18da70ecc034fa8a8d31fd9b69cd5a4642d3a35e
parent: 069c97facc175f2c6ed96bfe10f319d29bf75994
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Dec 22 21:00:09 EST 2015
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 */
--- a/sys/src/cmd/ip/snoopy/main.c
+++ b/sys/src/cmd/ip/snoopy/main.c
@@ -273,7 +273,7 @@
*/
#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_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 @@
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);
--
⑨