]> git.ipfire.org Git - people/ummeegge/ipfire-2.x.git/blob - src/patches/tcpick/005-set-timestamp-pcap-header-structure.patch
tcpick: Renewed version with several patches.
[people/ummeegge/ipfire-2.x.git] / src / patches / tcpick / 005-set-timestamp-pcap-header-structure.patch
1 Description:Tcpick can display timestamps in the output with the -t and -td switch. It currently computes a timestamp on the fly which has the following consequences
2 * Inaccurate timestamps when it is operated in real time mode (-i switch)
3 * Nonsense when reassembling off-line captures / when reading pcap files
4 Author: Gerard Wagener
5 Bug-Ubuntu:https://bugs.launchpad.net/ubuntu/+source/tcpick/+bug/364688
6
7 --- a/src/extern.h
8 +++ b/src/extern.h
9 @@ -13,6 +13,7 @@
10 extern struct ip *ippacket;
11 extern struct tcphdr *tcppacket;
12 extern struct udphdr *udppacket;
13 +extern struct pcap_pkthdr* phdr;
14 extern u_char *payload;
15 extern int payload_len;
16 extern struct FLAGS flags;
17 --- a/src/globals.h
18 +++ b/src/globals.h
19 @@ -12,6 +12,7 @@
20 struct ip *ippacket;
21 struct tcphdr *tcppacket;
22 struct udphdr *udppacket;
23 +struct pcap_pkthdr* phdr = NULL;
24 u_char *payload;
25 int payload_len = 0;
26 struct FLAGS flags;
27 --- a/src/loop.c
28 +++ b/src/loop.c
29 @@ -38,6 +38,9 @@
30
31 { /* FIXME: this function is too long */
32
33 +/* Keep track of the original pcap header in order to put correct timestamps */
34 + phdr=(struct pcap_pkthdr *)hdr;
35 +
36 /* check if the flag for checking for expired connections
37 is turned on */
38
39 --- a/src/time.c
40 +++ b/src/time.c
41 @@ -32,22 +32,16 @@
42 {
43
44 struct timeval *tp;
45 - struct timezone *tzp;
46 struct tm * brokentime;
47
48 if(flags.displaytime == NOTHING_TIME)
49 goto retNULL;
50
51 - tp = (struct timeval * ) S_malloc( sizeof(struct timeval) );
52 - tzp = (struct timezone * ) S_malloc( sizeof(struct timezone) );
53 + tp = &phdr->ts;
54 + if(!tp) {
55
56 - memset(tp, 0, sizeof(struct timeval));
57 - memset(tzp, 0, sizeof(struct timezone));
58 -
59 - if(gettimeofday(tp, tzp)) {
60 -
61 - perror("gettimeofday returned not 0!");
62 - goto retNULL;
63 + perror("No timestamp was available!");
64 + goto retNULL;
65
66 } else {
67 brokentime = localtime(&(tp->tv_sec));
68 @@ -93,9 +87,6 @@
69 }
70 }
71
72 - S_free ( tp );
73 - S_free ( tzp );
74 -
75 return ret;
76
77 retNULL: