summaryrefslogtreecommitdiff
path: root/testprogs/filtertest.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-05-02 18:58:04 -0700
committerGuy Harris <guy@alum.mit.edu>2018-05-02 18:58:04 -0700
commitba47a8071238209d2d353f01f5fffd1d810dabb9 (patch)
tree4d420a30e77c36ee447ad7ea794d8331a26bd216 /testprogs/filtertest.c
parenta8f6db8064371583ae9d77a9d142e383e5fed8a6 (diff)
downloadlibpcap-ba47a8071238209d2d353f01f5fffd1d810dabb9.tar.gz
Use pcap_set_optimizer_debug() to set the optimizer debug level.
Diffstat (limited to 'testprogs/filtertest.c')
-rw-r--r--testprogs/filtertest.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/testprogs/filtertest.c b/testprogs/filtertest.c
index 380cb73e..b9e5737c 100644
--- a/testprogs/filtertest.c
+++ b/testprogs/filtertest.c
@@ -56,6 +56,16 @@ The Regents of the University of California. All rights reserved.\n";
#include "pcap/funcattrs.h"
+#ifdef BDEBUG
+/*
+ * We have pcap_set_optimizer_debug() in libpcap; declare it (it's not declared
+ * by any libpcap header, because it's a special hack, only available if
+ * libpcap was configured to include it, and only intended for use by
+ * libpcap developers trying to debug the optimizer for filter expressions).
+ */
+PCAP_API void pcap_set_optimizer_debug(int);
+#endif
+
static char *program_name;
/* Forwards */
@@ -63,10 +73,6 @@ static void PCAP_NORETURN usage(void);
static void PCAP_NORETURN error(const char *, ...) PCAP_PRINTFLIKE(1, 2);
static void warn(const char *, ...) PCAP_PRINTFLIKE(1, 2);
-#ifdef BDEBUG
-int dflag;
-#endif
-
/*
* On Windows, we need to open the file in binary mode, so that
* we get all the bytes specified by the size we get from "fstat()".
@@ -187,9 +193,7 @@ main(int argc, char **argv)
{
char *cp;
int op;
-#ifndef BDEBUG
int dflag;
-#endif
char *infile;
int Oflag;
long snaplen;
@@ -296,6 +300,10 @@ main(int argc, char **argv)
else
cmdbuf = copy_argv(&argv[optind+1]);
+#ifdef BDEBUG
+ pcap_set_optimizer_debug(dflag);
+#endif
+
pd = pcap_open_dead(dlt, snaplen);
if (pd == NULL)
error("Can't open fake pcap_t");