]> The Tcpdump Group git mirrors - tcpdump/blobdiff - tcpdump.c
Make the default snapshot length the maximum; add a #define for the
[tcpdump] / tcpdump.c
index cea2f85394d5930a2a3018373482d1761f283aa0..d524b0164d1bea3388c2c9f3dd66b7d4a304b7c3 100644 (file)
--- a/tcpdump.c
+++ b/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.279 2008-04-06 20:12:12 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.283 2008-09-25 21:45:50 guy Exp $ (LBL)";
 #endif
 
 /*
@@ -273,7 +273,7 @@ static struct printer printers[] = {
 #ifdef DLT_MFR
        { mfr_if_print, DLT_MFR },
 #endif
-#ifdef DLT_BLUETOOTH_HCI_H4_WITH_PHDR
+#if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H)
        { bt_if_print, DLT_BLUETOOTH_HCI_H4_WITH_PHDR},
 #endif
        { NULL,                 0 },
@@ -545,6 +545,9 @@ main(int argc, char **argv)
                case 'A':
                        ++Aflag;
                        break;
+               case 'b':
+                       ++bflag;
+                       break;
 
 #if defined(HAVE_PCAP_CREATE) || defined(WIN32)
                case 'B':
@@ -708,7 +711,7 @@ main(int argc, char **argv)
 #ifndef HAVE_LIBCRYPTO
                        warning("crypto code not compiled in");
 #endif
-                       tcpmd5secret = optarg;
+                       sigsecret = optarg;
                        break;
 
                case 'n':
@@ -745,10 +748,10 @@ main(int argc, char **argv)
 
                        snaplen = strtol(optarg, &end, 0);
                        if (optarg == end || *end != '\0'
-                           || snaplen < 0 || snaplen > 65535)
+                           || snaplen < 0 || snaplen > MAXIMUM_SNAPLEN)
                                error("invalid snaplen %s", optarg);
                        else if (snaplen == 0)
-                               snaplen = 65535;
+                               snaplen = MAXIMUM_SNAPLEN;
                        break;
                }
 
@@ -960,33 +963,58 @@ main(int argc, char **argv)
                status = pcap_set_snaplen(pd, snaplen);
                if (status != 0)
                        error("%s: pcap_set_snaplen failed: %s",
-                           device, pcap_errtostr(status));
+                           device, pcap_statustostr(status));
                status = pcap_set_promisc(pd, !pflag);
                if (status != 0)
                        error("%s: pcap_set_promisc failed: %s",
-                           device, pcap_errtostr(status));
+                           device, pcap_statustostr(status));
                if (Iflag) {
                        status = pcap_set_rfmon(pd, 1);
                        if (status != 0)
                                error("%s: pcap_set_rfmon failed: %s",
-                                   device, pcap_errtostr(status));
+                                   device, pcap_statustostr(status));
                }
                status = pcap_set_timeout(pd, 1000);
                if (status != 0)
                        error("%s: pcap_set_timeout failed: %s",
-                           device, pcap_errtostr(status));
+                           device, pcap_statustostr(status));
                if (Bflag != 0) {
                        status = pcap_set_buffer_size(pd, Bflag);
                        if (status != 0)
                                error("%s: pcap_set_buffer_size failed: %s",
-                                   device, pcap_errtostr(status));
+                                   device, pcap_statustostr(status));
                }
                status = pcap_activate(pd);
-               if (status != 0) {
+               if (status < 0) {
+                       /*
+                        * pcap_activate() failed.
+                        */
+                       cp = pcap_geterr(pd);
                        if (status == PCAP_ERROR)
-                               error("%s: %s", device, pcap_geterr(pd));
+                               error("%s", cp);
+                       else if ((status == PCAP_ERROR_NO_SUCH_DEVICE ||
+                                 status == PCAP_ERROR_PERM_DENIED) &&
+                                *cp != '\0')
+                               error("%s: %s\n(%s)", device,
+                                   pcap_statustostr(status), cp);
+                       else
+                               error("%s: %s", device,
+                                   pcap_statustostr(status));
+               } else if (status > 0) {
+                       /*
+                        * pcap_activate() succeeded, but it's warning us
+                        * of a problem it had.
+                        */
+                       cp = pcap_geterr(pd);
+                       if (status == PCAP_WARNING)
+                               warning("%s", cp);
+                       else if (status == PCAP_WARNING_PROMISC_NOTSUP &&
+                                *cp != '\0')
+                               warning("%s: %s\n(%s)", device,
+                                   pcap_statustostr(status), cp);
                        else
-                               error("%s: %s", device, pcap_errtostr(status));
+                               warning("%s: %s", device,
+                                   pcap_statustostr(status));
                }
 #else
                *ebuf = '\0';