From d77ac851c76ff95e6542e93715786d29ba86c51f Mon Sep 17 00:00:00 2001 From: Francois-Xavier Le Bail Date: Tue, 7 Aug 2018 17:11:43 +0200 Subject: Fix local time printing Using seconds offset from GMT to local time to compute local time give errors when printing times outside the same daylight saving time period. Use the localtime() function for default and -tttt cases. Use the gmtime() function for -ttt and -ttttt cases. Rename ts_hmsfrac_print() to ts_date_hmsfrac_print(). Remove some variables now useless. Update some comments. --- tcpdump.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'tcpdump.c') diff --git a/tcpdump.c b/tcpdump.c index 21ead64c..65defd0d 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -132,7 +132,6 @@ The Regents of the University of California. All rights reserved.\n"; #include "interface.h" #include "addrtoname.h" #include "machdep.h" -#include "gmt2local.h" #include "pcap-missing.h" #include "ascii_strcasecmp.h" @@ -1412,7 +1411,6 @@ main(int argc, char **argv) { int cnt, op, i; bpf_u_int32 localnet = 0, netmask = 0; - int timezone_offset = 0; char *cp, *infile, *cmdbuf, *device, *RFileName, *VFileName, *WFileName; char *endp; pcap_handler callback; @@ -1869,14 +1867,11 @@ main(int argc, char **argv) switch (ndo->ndo_tflag) { case 0: /* Default */ - case 4: /* Default + Date*/ - timezone_offset = gmt2local(0); - break; - case 1: /* No time stamp */ case 2: /* Unix timeval style */ - case 3: /* Microseconds since previous packet */ - case 5: /* Microseconds since first packet */ + case 3: /* Microseconds/nanoseconds since previous packet */ + case 4: /* Date + Default */ + case 5: /* Microseconds/nanoseconds since first packet */ break; default: /* Not supported */ @@ -2138,7 +2133,7 @@ main(int argc, char **argv) capdns = capdns_setup(); #endif /* HAVE_CASPER */ - init_print(ndo, localnet, netmask, timezone_offset); + init_print(ndo, localnet, netmask); #ifndef _WIN32 (void)setsignal(SIGPIPE, cleanup); -- cgit v1.2.1