mirror of
https://github.com/the-tcpdump-group/tcpdump.git
synced 2025-01-23 16:18:26 +08:00
From Gisle Vanem:
When saving to a file with "-w", have the "-v" flag make tcpdump report, every 10 seconds, the number of packets captured. Include <smi.h> if we're building with libsmi, to declare "smiInit()" and "smiLoadModule()".
This commit is contained in:
parent
c519841be2
commit
d88193ac89
@ -127,6 +127,9 @@
|
||||
/* Define if you have a dnet_htoa declaration in <netdnet/dnetdb.h>. */
|
||||
#undef HAVE_NETDNET_DNETDB_H_DNET_HTOA
|
||||
|
||||
/* Define to 1 if you have the `alarm' function. */
|
||||
#undef HAVE_ALARM
|
||||
|
||||
/* Define to 1 if you have the `bpf_dump' function. */
|
||||
#undef HAVE_BPF_DUMP
|
||||
|
||||
|
5
configure
vendored
5
configure
vendored
@ -1,5 +1,5 @@
|
||||
#! /bin/sh
|
||||
# From configure.in Revision: 1.172 .
|
||||
# From configure.in Revision: 1.173 .
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.57.
|
||||
#
|
||||
@ -6606,7 +6606,8 @@ fi
|
||||
done
|
||||
|
||||
|
||||
for ac_func in setlinebuf
|
||||
|
||||
for ac_func in setlinebuf alarm
|
||||
do
|
||||
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
echo "$as_me:$LINENO: checking for $ac_func" >&5
|
||||
|
@ -1,4 +1,4 @@
|
||||
dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.172 2004-01-14 03:14:29 guy Exp $ (LBL)
|
||||
dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.173 2004-01-15 19:53:48 guy Exp $ (LBL)
|
||||
dnl
|
||||
dnl Copyright (c) 1994, 1995, 1996, 1997
|
||||
dnl The Regents of the University of California. All rights reserved.
|
||||
@ -6,7 +6,7 @@ dnl
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
dnl
|
||||
|
||||
AC_REVISION($Revision: 1.172 $)
|
||||
AC_REVISION($Revision: 1.173 $)
|
||||
AC_PREREQ(2.50)
|
||||
AC_INIT(tcpdump.c)
|
||||
|
||||
@ -498,7 +498,7 @@ AC_CHECK_FUNCS(ether_ntohost, [
|
||||
AC_DEFINE(USE_ETHER_NTOHOST)
|
||||
fi
|
||||
])
|
||||
AC_CHECK_FUNCS(setlinebuf)
|
||||
AC_CHECK_FUNCS(setlinebuf alarm)
|
||||
|
||||
needsnprintf=no
|
||||
AC_CHECK_FUNCS(vsnprintf snprintf,,
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" @(#) $Header: /tcpdump/master/tcpdump/Attic/tcpdump.1,v 1.155 2004-01-07 22:50:40 guy Exp $ (LBL)
|
||||
.\" @(#) $Header: /tcpdump/master/tcpdump/Attic/tcpdump.1,v 1.156 2004-01-15 19:53:49 guy Exp $ (LBL)
|
||||
.\"
|
||||
.\" $NetBSD: tcpdump.8,v 1.9 2003/03/31 00:18:17 perry Exp $
|
||||
.\"
|
||||
@ -486,11 +486,14 @@ that lacks the
|
||||
function.
|
||||
.TP
|
||||
.B \-v
|
||||
(Slightly more) verbose output.
|
||||
When parsing and printing, produce (slightly more) verbose output.
|
||||
For example, the time to live,
|
||||
identification, total length and options in an IP packet are printed.
|
||||
Also enables additional packet integrity checks such as verifying the
|
||||
IP and ICMP header checksum.
|
||||
When writing to a file with the
|
||||
.B \-w
|
||||
option, report, every 10 seconds, the number of packets captured.
|
||||
.TP
|
||||
.B \-vv
|
||||
Even more verbose output.
|
||||
|
64
tcpdump.c
64
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.223 2004-01-14 03:24:29 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.224 2004-01-15 19:53:49 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -56,6 +56,10 @@ extern int SIZE_BUF;
|
||||
#define uint UINT
|
||||
#endif /* WIN32 */
|
||||
|
||||
#ifdef HAVE_SMI_H
|
||||
#include <smi.h>
|
||||
#endif
|
||||
|
||||
#include <pcap.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
@ -117,6 +121,14 @@ static void dump_packet(u_char *, const struct pcap_pkthdr *, const u_char *);
|
||||
RETSIGTYPE requestinfo(int);
|
||||
#endif
|
||||
|
||||
#if defined(USE_WIN32_MM_TIMER)
|
||||
#include <MMsystem.h>
|
||||
static UINT timer_id;
|
||||
static void CALLBACK verbose_stats_dump(UINT, UINT, DWORD_PTR, DWORD_PTR, DWORD_PTR);
|
||||
#elif defined(HAVE_ALARM)
|
||||
static void verbose_stats_dump(int sig);
|
||||
#endif
|
||||
|
||||
static void info(int);
|
||||
static u_int packets_captured;
|
||||
|
||||
@ -777,6 +789,23 @@ main(int argc, char **argv)
|
||||
#ifdef SIGINFO
|
||||
(void)setsignal(SIGINFO, requestinfo);
|
||||
#endif
|
||||
|
||||
if (vflag > 0 && WFileName) {
|
||||
/*
|
||||
* When capturing to a file, "-v" means tcpdump should,
|
||||
* every 10 secodns, "v"erbosely report the number of
|
||||
* packets captured.
|
||||
*/
|
||||
#ifdef USE_WIN32_MM_TIMER
|
||||
/* call requestinfo() each 1000 +/-100msec */
|
||||
timer_id = timeSetEvent(1000, 100, verbose_stats_dump, 0, TIME_PERIODIC);
|
||||
setvbuf(stderr, NULL, _IONBF, 0);
|
||||
#elif defined(HAVE_ALARM)
|
||||
(void)setsignal(SIGALRM, verbose_stats_dump);
|
||||
alarm(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
if (RFileName == NULL) {
|
||||
int dlt;
|
||||
@ -839,6 +868,14 @@ main(int argc, char **argv)
|
||||
static RETSIGTYPE
|
||||
cleanup(int signo _U_)
|
||||
{
|
||||
#ifdef USE_WIN32_MM_TIMER
|
||||
if (timer_id)
|
||||
timeKillEvent(timer_id);
|
||||
timer_id = 0;
|
||||
#elif defined(HAVE_ALARM)
|
||||
alarm(0);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PCAP_BREAKLOOP
|
||||
/*
|
||||
* We have "pcap_breakloop()"; use it, so that we do as little
|
||||
@ -1052,7 +1089,9 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
|
||||
* "Wpcap_version" information on Windows.
|
||||
*/
|
||||
char WDversion[]="current-cvs.tcpdump.org";
|
||||
#if !defined(HAVE_GENERATED_VERSION)
|
||||
char version[]="current-cvs.tcpdump.org";
|
||||
#endif
|
||||
char pcap_version[]="current-cvs.tcpdump.org";
|
||||
char Wpcap_version[]="3.0 alpha";
|
||||
#endif
|
||||
@ -1076,6 +1115,29 @@ RETSIGTYPE requestinfo(int signo _U_)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Called once each second in verbose mode while dumping to file
|
||||
*/
|
||||
#ifdef USE_WIN32_MM_TIMER
|
||||
void CALLBACK verbose_stats_dump (UINT timer_id _U_, UINT msg _U_, DWORD_PTR arg _U_,
|
||||
DWORD_PTR dw1 _U_, DWORD_PTR dw2 _U_)
|
||||
{
|
||||
struct pcap_stat stat;
|
||||
|
||||
if (infodelay == 0 && pcap_stats(pd, &stat) >= 0)
|
||||
fprintf(stderr, "Got %u\r", packets_captured);
|
||||
}
|
||||
#elif defined(HAVE_ALARM)
|
||||
static void verbose_stats_dump(int sig _U_)
|
||||
{
|
||||
struct pcap_stat stat;
|
||||
|
||||
if (infodelay == 0 && pcap_stats(pd, &stat) >= 0)
|
||||
fprintf(stderr, "Got %u\r", packets_captured);
|
||||
alarm(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user