summaryrefslogtreecommitdiff
path: root/usr.sbin/tcpdump/util.c
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2004-06-23 06:12:08 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2004-06-23 06:12:08 +0000
commit1cc74585ad4c13f00d475c9c3466ffb1709d3fb2 (patch)
tree24b8bce03f997d508c5eba2b6dc1b03880ce5d23 /usr.sbin/tcpdump/util.c
parent7938960da4ac9bd4426a906a27151373ee56d183 (diff)
-tttt prints time between packets; ok deraadt
Diffstat (limited to 'usr.sbin/tcpdump/util.c')
-rw-r--r--usr.sbin/tcpdump/util.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/usr.sbin/tcpdump/util.c b/usr.sbin/tcpdump/util.c
index 6f4c6985ac6..46a4cd7d621 100644
--- a/usr.sbin/tcpdump/util.c
+++ b/usr.sbin/tcpdump/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.16 2004/01/28 19:44:55 canacar Exp $ */
+/* $OpenBSD: util.c,v 1.17 2004/06/23 06:12:07 markus 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.16 2004/01/28 19:44:55 canacar Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/util.c,v 1.17 2004/06/23 06:12:07 markus Exp $ (LBL)";
#endif
#include <sys/types.h>
@@ -124,6 +124,8 @@ ts_print(register const struct bpf_timeval *tvp)
register int s;
#define TSBUFLEN 32
static char buf[TSBUFLEN];
+ static struct bpf_timeval last;
+ struct timeval diff;
time_t t;
switch(tflag){
@@ -139,6 +141,13 @@ ts_print(register const struct bpf_timeval *tvp)
strftime(buf, TSBUFLEN, "%b %d %T", priv_localtime(&t));
printf("%s.%06u ", buf, (u_int32_t)tvp->tv_usec);
break;
+ case -3:
+ /* time since last frame */
+ timersub(tvp, &last, &diff);
+ (void)printf("%u.%06u ",
+ (u_int32_t)diff.tv_sec, (u_int32_t)diff.tv_usec);
+ last = *tvp;
+ break;
default:
/* Default */
s = (tvp->tv_sec + thiszone) % 86400;