Module Name:    src
Committed By:   pooka
Date:           Sat Mar 12 18:27:42 UTC 2011

Modified Files:
        src/usr.bin/shmif_dumpbus: shmif_dumpbus.c

Log Message:
Apropos, pcap doesn't export the on-disk pcap packet header but
only the in-memory one.  Since the in-memory one uses struct timeval
and the on-disk one uses 32bit time_t, things didn't work so well
on -current.  Generate a suitable local packetheader to fix things.
(don't think it's worth writing via libpcap for something as simple
as this)

noticed both by bouyer and the shmif_dumpbus test


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/shmif_dumpbus/shmif_dumpbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/shmif_dumpbus/shmif_dumpbus.c
diff -u src/usr.bin/shmif_dumpbus/shmif_dumpbus.c:1.3 src/usr.bin/shmif_dumpbus/shmif_dumpbus.c:1.4
--- src/usr.bin/shmif_dumpbus/shmif_dumpbus.c:1.3	Thu Mar 10 10:11:25 2011
+++ src/usr.bin/shmif_dumpbus/shmif_dumpbus.c	Sat Mar 12 18:27:42 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: shmif_dumpbus.c,v 1.3 2011/03/10 10:11:25 pooka Exp $	*/
+/*	$NetBSD: shmif_dumpbus.c,v 1.4 2011/03/12 18:27:42 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2010 Antti Kantee.  All Rights Reserved.
@@ -55,6 +55,19 @@
 	exit(1);
 }
 
+/*
+ * Apparently pcap uses a non-exported structure as the on-disk
+ * packet header.  Since that format isn't very likely to change
+ * soon, just define a local version
+ */
+struct ondisk_pcaphdr {
+	uint32_t ts_sec;
+	uint32_t ts_usec;
+	uint32_t caplen;
+	uint32_t len;
+
+};
+
 #define BUFSIZE 64*1024
 int
 main(int argc, char *argv[])
@@ -153,7 +166,7 @@
 
 	i = 0;
 	while (curbus <= buslast || bonus) {
-		struct pcap_pkthdr packhdr;
+		struct ondisk_pcaphdr packhdr;
 		struct shmif_pkthdr sp;
 		uint32_t oldoff;
 		bool wrap;
@@ -187,8 +200,8 @@
 
 		memset(&packhdr, 0, sizeof(packhdr));
 		packhdr.caplen = packhdr.len = sp.sp_len;
-		packhdr.ts.tv_sec = sp.sp_sec;
-		packhdr.ts.tv_usec = sp.sp_usec;
+		packhdr.ts_sec = sp.sp_sec;
+		packhdr.ts_usec = sp.sp_usec;
 		assert(sp.sp_len <= BUFSIZE);
 
 		if (write(pfd, &packhdr, sizeof(packhdr)) != sizeof(packhdr))

Reply via email to