summarylogtreecommitdiffstats
path: root/tcpslice-1.2a3-time.patch
blob: c59448d2362755e04da5737c97271ac8f2401ee7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
--- tcpslice-1.2a3.orig/search.c	2000-09-10 10:52:40.000000000 +0200
+++ tcpslice-1.2a3/search.c	2006-07-28 14:56:55.000000000 +0200
@@ -53,7 +53,7 @@
 /* Size of a packet header in bytes; easier than typing the sizeof() all
  * the time ...
  */
-#define PACKET_HDR_LEN (sizeof( struct pcap_pkthdr ))
+#define PACKET_HDR_LEN (sizeof( struct pcap_sf_pkthdr ))
 
 extern int snaplen;
 
@@ -111,16 +111,24 @@
 static void
 extract_header( pcap_t *p, u_char *buf, struct pcap_pkthdr *hdr )
 	{
-	memcpy((char *) hdr, (char *) buf, sizeof(struct pcap_pkthdr));
+	struct pcap_sf_pkthdr hdri;
+
+	memcpy((char *) &hdri, (char *) buf, sizeof(struct pcap_sf_pkthdr));
 
 	if ( pcap_is_swapped( p ) )
 		{
-		hdr->ts.tv_sec = SWAPLONG(hdr->ts.tv_sec);
-		hdr->ts.tv_usec = SWAPLONG(hdr->ts.tv_usec);
-		hdr->len = SWAPLONG(hdr->len);
-		hdr->caplen = SWAPLONG(hdr->caplen);
+		hdr->ts.tv_sec = SWAPLONG(hdri.ts.tv_sec);
+		hdr->ts.tv_usec = SWAPLONG(hdri.ts.tv_usec);
+		hdr->len = SWAPLONG(hdri.len);
+		hdr->caplen = SWAPLONG(hdri.caplen);
+		}
+	else
+		{
+		hdr->ts.tv_sec = hdri.ts.tv_sec;
+		hdr->ts.tv_usec = hdri.ts.tv_usec;
+		hdr->len = hdri.len;
+		hdr->caplen = hdri.caplen;
 		}
-
 	/*
 	 * From bpf/libpcap/savefile.c:
 	 *
--- tcpslice-1.2a3.orig/tcpslice.h	1995-11-02 00:40:53.000000000 +0100
+++ tcpslice-1.2a3/tcpslice.h	2006-07-28 14:56:55.000000000 +0200
@@ -20,6 +20,26 @@
  */
 
 
+#include <time.h>
+/* #include <net/bpf.h> */
+
+/*
+ * This is a timeval as stored in disk in a dumpfile.
+ * It has to use the same types everywhere, independent of the actual
+ * `struct timeval'
+ */
+                                                                                
+struct pcap_timeval {
+    bpf_int32 tv_sec;           /* seconds */
+    bpf_int32 tv_usec;          /* microseconds */
+};
+
+struct pcap_sf_pkthdr {
+    struct pcap_timeval ts;     /* time stamp */
+    bpf_u_int32 caplen;         /* length of portion present */
+    bpf_u_int32 len;            /* length this packet (off wire) */
+};
+
 time_t	gwtm2secs( struct tm *tm );
 
 int	sf_find_end( struct pcap *p, struct timeval *first_timestamp,