summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2007-08-28 12:52:07 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2007-08-28 12:52:07 +0000
commitd2950d6d509d2bea218a97152d35e4c1b10abb5e (patch)
tree7ea213761855c9f755ac08097f84caa09034338f
parent6d80a12ed5b3d4eebc26949ab63013d417e8a604 (diff)
add -I option for printing the interfaces;
ok hshoexer, henning, mcbridge (some time ago)
-rw-r--r--usr.sbin/tcpdump/interface.h6
-rw-r--r--usr.sbin/tcpdump/tcpdump.88
-rw-r--r--usr.sbin/tcpdump/tcpdump.c16
-rw-r--r--usr.sbin/tcpdump/util.c6
4 files changed, 24 insertions, 12 deletions
diff --git a/usr.sbin/tcpdump/interface.h b/usr.sbin/tcpdump/interface.h
index c126e09895d..6ac1ecde5ff 100644
--- a/usr.sbin/tcpdump/interface.h
+++ b/usr.sbin/tcpdump/interface.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: interface.h,v 1.54 2006/06/01 17:18:38 moritz Exp $ */
+/* $OpenBSD: interface.h,v 1.55 2007/08/28 12:52:06 markus Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
@@ -20,7 +20,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/interface.h,v 1.54 2006/06/01 17:18:38 moritz Exp $ (LBL)
+ * @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/interface.h,v 1.55 2007/08/28 12:52:06 markus Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
@@ -40,6 +40,7 @@ extern int aflag; /* translate network and broadcast addresses */
extern int dflag; /* print filter code */
extern int eflag; /* print ethernet header */
extern int fflag; /* don't translate "foreign" IP address */
+extern int Iflag; /* include interface in output */
extern int nflag; /* leave addresses as numbers */
extern int Nflag; /* remove domains from printed host names */
extern int oflag; /* OS fingerprint */
@@ -51,6 +52,7 @@ extern int xflag; /* print packet in hex */
extern int Xflag; /* print packet in hex/ascii */
extern int packettype; /* as specified by -T */
+extern char *device; /* as specified by -i */
#define PT_VAT 1 /* Visual Audio Tool */
#define PT_WB 2 /* distributed White Board */
#define PT_RPC 3 /* Remote Procedure Call */
diff --git a/usr.sbin/tcpdump/tcpdump.8 b/usr.sbin/tcpdump/tcpdump.8
index 9246100b39b..256825331b9 100644
--- a/usr.sbin/tcpdump/tcpdump.8
+++ b/usr.sbin/tcpdump/tcpdump.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tcpdump.8,v 1.64 2007/05/31 19:20:29 jmc Exp $
+.\" $OpenBSD: tcpdump.8,v 1.65 2007/08/28 12:52:06 markus Exp $
.\"
.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996
.\" The Regents of the University of California. All rights reserved.
@@ -19,7 +19,7 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.Dd $Mdocdate: May 31 2007 $
+.Dd $Mdocdate: August 28 2007 $
.Dt TCPDUMP 8
.Os
.Sh NAME
@@ -28,7 +28,7 @@
.Sh SYNOPSIS
.Nm tcpdump
.Bk -words
-.Op Fl adefLlNnOopqStvXx
+.Op Fl adefILlNnOopqStvXx
.Op Fl c Ar count
.Oo Fl E Oo Ar espalg : Oc Ns
.Ar espkey Oc
@@ -104,6 +104,8 @@ internet addresses numerically rather than symbolically.
This option is intended to get around serious brain damage in
Sun's yp server \(em usually it hangs forever translating non-local
internet numbers.
+.It Fl I
+Print the interface on each dump line.
.It Fl i Ar interface
Listen on
.Ar interface .
diff --git a/usr.sbin/tcpdump/tcpdump.c b/usr.sbin/tcpdump/tcpdump.c
index 8aed4dead44..a862f959925 100644
--- a/usr.sbin/tcpdump/tcpdump.c
+++ b/usr.sbin/tcpdump/tcpdump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcpdump.c,v 1.57 2007/08/13 20:27:13 krw Exp $ */
+/* $OpenBSD: tcpdump.c,v 1.58 2007/08/28 12:52:06 markus Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
@@ -26,7 +26,7 @@ static const char copyright[] =
"@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997\n\
The Regents of the University of California. All rights reserved.\n";
static const char rcsid[] =
- "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/tcpdump.c,v 1.57 2007/08/13 20:27:13 krw Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/tcpdump.c,v 1.58 2007/08/28 12:52:06 markus Exp $ (LBL)";
#endif
/*
@@ -71,6 +71,7 @@ int aflag; /* translate network and broadcast addresses */
int dflag; /* print filter code */
int eflag; /* print ethernet header */
int fflag; /* don't translate "foreign" IP address */
+int Iflag; /* include interface in output */
int Lflag; /* List available link types */
int nflag; /* leave addresses as numbers */
int Nflag; /* remove domains from printed host names */
@@ -87,6 +88,7 @@ int Xflag; /* print packet in emacs-hexl style */
int packettype;
char *program_name;
+char *device = NULL;
int32_t thiszone; /* seconds offset from gmt to local time */
@@ -214,7 +216,7 @@ main(int argc, char **argv)
{
int cnt = -1, op, i;
bpf_u_int32 localnet, netmask;
- char *cp, *infile = NULL, *device = NULL, *RFileName = NULL;
+ char *cp, *infile = NULL, *RFileName = NULL;
char ebuf[PCAP_ERRBUF_SIZE], *WFileName = NULL;
pcap_handler printer;
struct bpf_program *fcode;
@@ -235,7 +237,7 @@ main(int argc, char **argv)
opterr = 0;
while ((op = getopt(argc, argv,
- "ac:deE:fF:i:lLnNOopqr:s:StT:vw:xXy:Y")) != -1)
+ "ac:deE:fF:i:IlLnNOopqr:s:StT:vw:xXy:Y")) != -1)
switch (op) {
case 'a':
@@ -267,6 +269,10 @@ main(int argc, char **argv)
device = optarg;
break;
+ case 'I':
+ ++Iflag;
+ break;
+
case 'l':
#ifdef HAVE_SETLINEBUF
setlinebuf(stdout);
@@ -663,7 +669,7 @@ __dead void
usage(void)
{
(void)fprintf(stderr,
-"Usage: %s [-adefLlNnOopqStvXx] [-c count] [-E [espalg:]espkey] [-F file]\n",
+"Usage: %s [-adefILlNnOopqStvXx] [-c count] [-E [espalg:]espkey] [-F file]\n",
program_name);
(void)fprintf(stderr,
"\t [-i interface] [-r file] [-s snaplen] [-T type] [-w file]\n");
diff --git a/usr.sbin/tcpdump/util.c b/usr.sbin/tcpdump/util.c
index 71b64ee1bca..22bea5370ab 100644
--- a/usr.sbin/tcpdump/util.c
+++ b/usr.sbin/tcpdump/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.21 2006/04/22 17:24:33 moritz Exp $ */
+/* $OpenBSD: util.c,v 1.22 2007/08/28 12:52:06 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.21 2006/04/22 17:24:33 moritz Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/util.c,v 1.22 2007/08/28 12:52:06 markus Exp $ (LBL)";
#endif
#include <sys/types.h>
@@ -128,6 +128,8 @@ ts_print(register const struct bpf_timeval *tvp)
struct timeval diff;
time_t t;
+ if (Iflag && device)
+ (void)printf("%s ", device);
switch(tflag){
case 0:
break;