mirror of
https://github.com/the-tcpdump-group/tcpdump.git
synced 2025-01-23 16:18:26 +08:00
Make "tflag" count the number of "-t"s, to make it more obvious what
tflag values correspond to what output formats (e.g., 4 means "-tttt"). Switch on the tflag value to determine whether to call "gmt2local()" to set "thiszone", just as we switch on it to determine the format for time stamps, to make it more obvious in what cases we call it.
This commit is contained in:
parent
9974f43f2f
commit
791d0e8bb7
12
tcpdump.c
12
tcpdump.c
@ -30,7 +30,7 @@ static const char copyright[] _U_ =
|
||||
"@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.243 2004-06-15 00:00:04 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.244 2004-06-15 23:05:05 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -420,7 +420,6 @@ main(int argc, char **argv)
|
||||
|
||||
gndo->ndo_Oflag=1;
|
||||
gndo->ndo_Rflag=1;
|
||||
gndo->ndo_tflag=1;
|
||||
gndo->ndo_dlt=-1;
|
||||
gndo->ndo_printf=tcpdump_printf;
|
||||
gndo->ndo_error=ndo_error;
|
||||
@ -644,7 +643,7 @@ main(int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 't':
|
||||
--tflag;
|
||||
++tflag;
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
@ -741,8 +740,13 @@ main(int argc, char **argv)
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
if (tflag > 0 || tflag == -3)
|
||||
switch (tflag) {
|
||||
|
||||
case 0: /* Default */
|
||||
case 4: /* Default + Date*/
|
||||
thiszone = gmt2local(0);
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef WITH_CHROOT
|
||||
/* if run as root, prepare for chrooting */
|
||||
|
19
util.c
19
util.c
@ -21,7 +21,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.93 2004-04-29 02:15:16 mcr Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.94 2004-06-15 23:05:06 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -116,19 +116,25 @@ ts_print(register const struct timeval *tvp)
|
||||
static unsigned b_sec;
|
||||
static unsigned b_usec;
|
||||
|
||||
switch(tflag) {
|
||||
case 1: /* Default */
|
||||
switch (tflag) {
|
||||
|
||||
case 0: /* Default */
|
||||
s = (tvp->tv_sec + thiszone) % 86400;
|
||||
(void)printf("%02d:%02d:%02d.%06u ",
|
||||
s / 3600, (s % 3600) / 60, s % 60,
|
||||
(unsigned)tvp->tv_usec);
|
||||
break;
|
||||
case -1: /* Unix timeval style */
|
||||
|
||||
case 1: /* No time stamp */
|
||||
break;
|
||||
|
||||
case 2: /* Unix timeval style */
|
||||
(void)printf("%u.%06u ",
|
||||
(unsigned)tvp->tv_sec,
|
||||
(unsigned)tvp->tv_usec);
|
||||
break;
|
||||
case -2:
|
||||
|
||||
case 3: /* Microseconds since previous packet */
|
||||
if (b_sec == 0) {
|
||||
printf("000000 ");
|
||||
} else {
|
||||
@ -146,7 +152,8 @@ ts_print(register const struct timeval *tvp)
|
||||
b_sec = tvp->tv_sec;
|
||||
b_usec = tvp->tv_usec;
|
||||
break;
|
||||
case -3: /* Default + Date*/
|
||||
|
||||
case 4: /* Default + Date*/
|
||||
s = (tvp->tv_sec + thiszone) % 86400;
|
||||
Time = (tvp->tv_sec + thiszone) - s;
|
||||
tm = gmtime (&Time);
|
||||
|
Loading…
Reference in New Issue
Block a user