From f17e9eec44a37c71496040d73981d3f74089846c Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Mon, 3 Sep 2001 13:25:54 +0000 Subject: print day and month using -ttt flag; --- usr.sbin/tcpdump/tcpdump.8 | 4 +++- usr.sbin/tcpdump/util.c | 29 +++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) (limited to 'usr.sbin/tcpdump') diff --git a/usr.sbin/tcpdump/tcpdump.8 b/usr.sbin/tcpdump/tcpdump.8 index d7ffd937d92..1874c6185e0 100644 --- a/usr.sbin/tcpdump/tcpdump.8 +++ b/usr.sbin/tcpdump/tcpdump.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tcpdump.8,v 1.27 2001/07/20 19:09:49 mpech Exp $ +.\" $OpenBSD: tcpdump.8,v 1.28 2001/09/03 13:25:53 jakob Exp $ .\" .\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996 .\" The Regents of the University of California. All rights reserved. @@ -200,6 +200,8 @@ sequence numbers. Do not print a timestamp on each dump line. .It Fl tt Print an unformatted timestamp on each dump line. +.It Fl ttt +Print day and month in timestamp. .It Fl v (Slightly more) verbose output. For example, the time to live diff --git a/usr.sbin/tcpdump/util.c b/usr.sbin/tcpdump/util.c index ef472c2bf3f..894254eedbc 100644 --- a/usr.sbin/tcpdump/util.c +++ b/usr.sbin/tcpdump/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.11 2001/03/05 22:34:01 jakob Exp $ */ +/* $OpenBSD: util.c,v 1.12 2001/09/03 13:25:53 jakob Exp $ */ /* * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/util.c,v 1.11 2001/03/05 22:34:01 jakob Exp $ (LBL)"; + "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/util.c,v 1.12 2001/09/03 13:25:53 jakob Exp $ (LBL)"; #endif #include @@ -124,16 +124,29 @@ void ts_print(register const struct timeval *tvp) { register int s; - - if (tflag > 0) { +#define TSBUFLEN 32 + static char buf[TSBUFLEN]; + time_t t; + + switch(tflag){ + case 0: + break; + case -1: + /* Unix timeval style */ + (void)printf("%u.%06u ", + (u_int32_t)tvp->tv_sec, (u_int32_t)tvp->tv_usec); + break; + case -2: + t=tvp->tv_sec; + strftime(buf, TSBUFLEN, "%b %d %T", localtime(&t)); + printf("%s.%06u ", buf, (u_int32_t)tvp->tv_usec); + break; + default: /* Default */ s = (tvp->tv_sec + thiszone) % 86400; (void)printf("%02d:%02d:%02d.%06u ", s / 3600, (s % 3600) / 60, s % 60, (u_int32_t)tvp->tv_usec); - } else if (tflag < 0) { - /* Unix timeval style */ - (void)printf("%u.%06u ", - (u_int32_t)tvp->tv_sec, (u_int32_t)tvp->tv_usec); + break; } } -- cgit v1.2.3