Part 3 of display vs. capture syntax confusion patches: Detect probable
authorjmayer <jmayer@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 11 Oct 2003 21:49:56 +0000 (21:49 +0000)
committerjmayer <jmayer@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 11 Oct 2003 21:49:56 +0000 (21:49 +0000)
use of display filter syntax where capture filter syntax need to be used
in Ethereal.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@8677 f5534014-38df-0310-8fa8-9805f1628bb7

capture.c

index 19a4e35cb36470b1cdaacc2f79dcb263a6b86be6..2f411e0e225f9897831dd6926b5f7235a97a319a 100644 (file)
--- a/capture.c
+++ b/capture.c
@@ -1,7 +1,7 @@
 /* capture.c
  * Routines for packet capture windows
  *
- * $Id: capture.c,v 1.211 2003/09/15 23:48:42 guy Exp $
+ * $Id: capture.c,v 1.212 2003/10/11 21:49:56 jmayer Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
 #endif
 
 #include <epan/packet.h>
+#include <epan/dfilter/dfilter.h>
 #include "file.h"
 #include "capture.h"
 #include "util.h"
@@ -1619,8 +1620,19 @@ capture(gboolean *stats_known, struct pcap_stat *stats)
       netmask = 0;
     }
     if (pcap_compile(pch, &fcode, cfile.cfilter, 1, netmask) < 0) {
-      snprintf(errmsg, sizeof errmsg, "Unable to parse filter string (%s).",
-       pcap_geterr(pch));
+      dfilter_t   *rfcode = NULL;
+      if (dfilter_compile(cfile.cfilter, &rfcode)) {
+        snprintf(errmsg, sizeof errmsg,
+          "Unable to parse capture filter string (%s).\n"
+          "  Interestingly enough, this looks like a valid display filter\n"
+          "  Are you sure you didn't mix them up?",
+          pcap_geterr(pch));
+       dfilter_free(rfcode);
+      } else {
+        snprintf(errmsg, sizeof errmsg,
+          "Unable to parse capture filter string (%s).",
+          pcap_geterr(pch));
+      }
       goto error;
     }
     if (pcap_setfilter(pch, &fcode) < 0) {