]> The Tcpdump Group git mirrors - libpcap/commitdiff
Use pcap_set_optimizer_debug() to set the optimizer debug level.
authorGuy Harris <[email protected]>
Thu, 3 May 2018 01:58:04 +0000 (18:58 -0700)
committerGuy Harris <[email protected]>
Thu, 3 May 2018 01:58:04 +0000 (18:58 -0700)
testprogs/filtertest.c

index 380cb73e76c48ad842bd5403a3bf1cd31e24f12e..b9e5737c2d611cd86ca5e576619319f549236dd8 100644 (file)
@@ -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");