*/
+#ifndef lint
+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.216.2.4 2003-11-18 23:12:11 guy Exp $ (LBL)";
+#endif
/*
* tcpdump - monitor tcp/ip traffic on an ethernet.
#include "gmt2local.h"
#include "pcap-missing.h"
-#ifndef lint
-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.216.2.1 2003-11-15 22:29:19 guy Exp $ (LBL)";
-#endif
int dflag; /* print filter code */
int eflag; /* print ethernet header */
int fflag; /* don't translate "foreign" IP address */
while (--n_dlts >= 0) {
dlt_name = pcap_datalink_val_to_name(dlts[n_dlts]);
if (dlt_name != NULL) {
- (void) fprintf(stderr, " %s", dlt_name);
+ (void) fprintf(stderr, " %s (%s)", dlt_name,
+ pcap_datalink_val_to_description(dlts[n_dlts]));
/*
* OK, does tcpdump handle that type?
break;
case 'l':
+#ifdef WIN32
+ /*
+ * _IOLBF is the same as _IOFBF in Microsoft's C
+ * libraries; the only alternative they offer
+ * is _IONBF.
+ *
+ * XXX - this should really be checking for MSVC++,
+ * not WIN32, if, for example, MinGW has its own
+ * C library that is more UNIX-compatible.
+ */
+ setvbuf(stdout, NULL, _IONBF, 0);
+#else /* WIN32 */
#ifdef HAVE_SETLINEBUF
setlinebuf(stdout);
#else
setvbuf(stdout, NULL, _IOLBF, 0);
#endif
+#endif /* WIN32 */
break;
case 'n':
error("%s", ebuf);
dlt = pcap_datalink(pd);
dlt_name = pcap_datalink_val_to_name(dlt);
- if (dlt_name == NULL)
- dlt_name = "???";
- printf("reading from file %s, link-type %u (%s)\n",
- RFileName, dlt, dlt_name);
+ if (dlt_name == NULL) {
+ printf("reading from file %s, link-type %u\n",
+ RFileName, dlt);
+ } else {
+ printf("reading from file %s, link-type %s (%s)\n",
+ RFileName, dlt_name,
+ pcap_datalink_val_to_description(dlt));
+ }
localnet = 0;
netmask = 0;
if (fflag != 0)
fflush(stderr);
#endif /* WIN32 */
*ebuf = '\0';
- pd = pcap_open_live(device, snaplen, !pflag, 10000, ebuf);
+ pd = pcap_open_live(device, snaplen, !pflag, 1000, ebuf);
if (pd == NULL)
error("%s", ebuf);
else if (*ebuf)
(void)fprintf(stderr, "%s: ", program_name);
dlt = pcap_datalink(pd);
dlt_name = pcap_datalink_val_to_name(dlt);
- if (dlt_name == NULL)
- dlt_name = "???";
- (void)fprintf(stderr, "listening on %s, link-type %u (%s), capture size %u bytes\n",
- device, dlt, dlt_name, snaplen);
+ if (dlt_name == NULL) {
+ (void)fprintf(stderr, "listening on %s, link-type %u, capture size %u bytes\n",
+ device, dlt, snaplen);
+ } else {
+ (void)fprintf(stderr, "listening on %s, link-type %s (%s), capture size %u bytes\n",
+ device, dlt_name,
+ pcap_datalink_val_to_description(dlt), snaplen);
+ }
(void)fflush(stderr);
}
#endif /* WIN32 */