summaryrefslogtreecommitdiff
path: root/usr.sbin
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
parent7938960da4ac9bd4426a906a27151373ee56d183 (diff)
-tttt prints time between packets; ok deraadt
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/tcpdump/tcpdump.84
-rw-r--r--usr.sbin/tcpdump/util.c13
2 files changed, 14 insertions, 3 deletions
diff --git a/usr.sbin/tcpdump/tcpdump.8 b/usr.sbin/tcpdump/tcpdump.8
index 4765bbee2fd..154d261d26d 100644
--- a/usr.sbin/tcpdump/tcpdump.8
+++ b/usr.sbin/tcpdump/tcpdump.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tcpdump.8,v 1.46 2004/05/06 11:25:11 jmc Exp $
+.\" $OpenBSD: tcpdump.8,v 1.47 2004/06/23 06:12:07 markus Exp $
.\"
.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996
.\" The Regents of the University of California. All rights reserved.
@@ -193,6 +193,8 @@ Do not print a timestamp on each dump line.
Print an unformatted timestamp on each dump line.
.It Fl ttt
Print day and month in timestamp.
+.It Fl tttt
+Print timestamp difference between packets.
.It Fl T Ar type
Force packets selected by
.Ar expression
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;