/*
- * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.164 2001-06-24 21:55:00 itojun Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.165 2001-07-04 22:03:13 fenner Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
extern const char *tok2str(const struct tok *, const char *, int);
extern char *dnaddr_string(u_short);
-extern void wrapup(int);
+extern void info(int);
+extern int infodelay;
+extern int infoprint;
extern void error(const char *, ...)
__attribute__((noreturn, format (printf, 1, 2)));
/*
- * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.64 2001-06-21 17:56:03 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.65 2001-07-04 22:03:14 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
u_short ether_type;
u_short extracted_ethertype;
+ ++infodelay;
ts_print(&h->ts);
if (caplen < ETHER_HDRLEN) {
default_print(p, caplen);
out:
putchar('\n');
+ --infodelay;
+ if (infoprint)
+ info(0);
}
/*
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.50 2000-12-23 20:48:13 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.51 2001-07-04 22:03:14 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
struct ether_header ehdr;
u_short extracted_ethertype;
+ ++infodelay;
ts_print(&h->ts);
if (caplen < FDDI_HDRLEN) {
default_print(p, caplen);
out:
putchar('\n');
+ --infodelay;
+ if (infoprint)
+ info(0);
}
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.11 2000-12-23 20:48:13 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.12 2001-07-04 22:03:14 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
trp = (struct token_header *)p;
+ ++infodelay;
ts_print(&h->ts);
if (caplen < TOKEN_HDRLEN) {
default_print(p, caplen);
out:
putchar('\n');
+ --infodelay;
+ if (infoprint)
+ info(0);
}
/*
- * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#ifndef lint
static const char copyright[] =
- "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997\n\
+ "@(#) 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.165 2001-06-24 20:38:52 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.166 2001-07-04 22:03:13 fenner Exp $ (LBL)";
#endif
/*
int packettype;
+int infodelay;
+int infoprint;
char *program_name;
/* Forwards */
static RETSIGTYPE cleanup(int);
static void usage(void) __attribute__((noreturn));
+#ifdef SIGINFO
+RETSIGTYPE requestinfo(int);
+#endif
/* Length of saved portion of packet. */
int snaplen = DEFAULT_SNAPLEN;
} else {
printer = lookup_printer(pcap_datalink(pd));
pcap_userdata = 0;
+#ifdef SIGINFO
+ (void)setsignal(SIGINFO, requestinfo);
+#endif
}
if (RFileName == NULL) {
(void)fprintf(stderr, "%s: listening on %s\n",
static RETSIGTYPE
cleanup(int signo)
{
- struct pcap_stat stat;
/* Can't print the summary if reading from a savefile */
if (pd != NULL && pcap_file(pd) == NULL) {
(void)fflush(stdout);
putc('\n', stderr);
- if (pcap_stats(pd, &stat) < 0)
- (void)fprintf(stderr, "pcap_stats: %s\n",
- pcap_geterr(pd));
- else {
- (void)fprintf(stderr, "%d packets received by filter\n",
- stat.ps_recv);
- (void)fprintf(stderr, "%d packets dropped by kernel\n",
- stat.ps_drop);
- }
+ info(1);
}
exit(0);
}
+void
+info(register int verbose)
+{
+ struct pcap_stat stat;
+
+ if (pcap_stats(pd, &stat) < 0) {
+ (void)fprintf(stderr, "pcap_stats: %s\n", pcap_geterr(pd));
+ return;
+ }
+ if (!verbose)
+ fprintf(stderr, "%s: ", program_name);
+ (void)fprintf(stderr, "%d packets received by filter", stat.ps_recv);
+ if (!verbose)
+ fputs(", ", stderr);
+ else
+ putc('\n', stderr);
+ (void)fprintf(stderr, "%d packets dropped by kernel\n", stat.ps_drop);
+ infoprint = 0;
+}
+
/* Like default_print() but data need not be aligned */
void
default_print_unaligned(register const u_char *cp, register u_int length)
default_print_unaligned(bp, length);
}
+#ifdef SIGINFO
+RETSIGTYPE requestinfo(int signo)
+{
+ if (infodelay)
+ ++infoprint;
+ else
+ info(0);
+}
+#endif
+
static void
usage(void)
{