aboutsummaryrefslogtreecommitdiff
path: root/testprogs/filtertest.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-05-03 01:39:39 -0700
committerGuy Harris <guy@alum.mit.edu>2018-05-03 01:39:39 -0700
commit6ea672eb870c4698d34858b17da26104198225ba (patch)
treec957e1db8bdc55bcb26009482f2241d3daf3b143 /testprogs/filtertest.c
parent679a902ca33fe2d6d1d27c315766f2b87090dab2 (diff)
Have separate flags for "optimizer debug" and "print DOT graph".
Instead of having -dddd mean "-ddd and print the CFG as a DOT graph", have a separate -g flag to request the CFG. Also, put the routines to set the "optimizer debug" and "print DOT graph" flags into optimize.c, and make the flags in question static. (And "CFG graph" is redundant, like "ATM machine", "PIN number", and "NT technology"....)
Diffstat (limited to 'testprogs/filtertest.c')
-rw-r--r--testprogs/filtertest.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/testprogs/filtertest.c b/testprogs/filtertest.c
index b9e5737c..8fb8ecba 100644
--- a/testprogs/filtertest.c
+++ b/testprogs/filtertest.c
@@ -58,12 +58,14 @@ The Regents of the University of California. All rights reserved.\n";
#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).
+ * We have pcap_set_optimizer_debug() and pcap_set_print_dot_graph() in
+ * libpcap; declare them (they're not declared by any libpcap header,
+ * because they're special hacks, only available if libpcap was configured
+ * to include them, and only intended for use by libpcap developers trying
+ * to debug the optimizer for filter expressions).
*/
PCAP_API void pcap_set_optimizer_debug(int);
+PCAP_API void pcap_set_print_dot_graph(int);
#endif
static char *program_name;
@@ -194,6 +196,7 @@ main(int argc, char **argv)
char *cp;
int op;
int dflag;
+ int gflag;
char *infile;
int Oflag;
long snaplen;
@@ -210,15 +213,9 @@ main(int argc, char **argv)
return 1;
#endif /* _WIN32 */
-#ifndef BDEBUG
dflag = 1;
-#else
- /* if optimizer debugging is enabled, output DOT graph
- * `dflag=4' is equivalent to -dddd to follow -d/-dd/-ddd
- * convention in tcpdump command line
- */
- dflag = 4;
-#endif
+ gflag = 0;
+
infile = NULL;
Oflag = 1;
snaplen = 68;
@@ -229,13 +226,21 @@ main(int argc, char **argv)
program_name = argv[0];
opterr = 0;
- while ((op = getopt(argc, argv, "dF:m:Os:")) != -1) {
+ while ((op = getopt(argc, argv, "dF:gm:Os:")) != -1) {
switch (op) {
case 'd':
++dflag;
break;
+ case 'g':
+#ifdef BDEBUG
+ ++gflag;
+#else
+ error("libpcap and filtertest not built with optimizer debugging enabled");
+#endif
+ break;
+
case 'F':
infile = optarg;
break;
@@ -302,6 +307,7 @@ main(int argc, char **argv)
#ifdef BDEBUG
pcap_set_optimizer_debug(dflag);
+ pcap_set_print_dot_graph(gflag);
#endif
pd = pcap_open_dead(dlt, snaplen);
@@ -343,7 +349,11 @@ usage(void)
(void)fprintf(stderr, "%s, with %s\n", program_name,
pcap_lib_version());
(void)fprintf(stderr,
+#ifdef BDEBUG
+ "Usage: %s [-dgO] [ -F file ] [ -m netmask] [ -s snaplen ] dlt [ expression ]\n",
+#else
"Usage: %s [-dO] [ -F file ] [ -m netmask] [ -s snaplen ] dlt [ expression ]\n",
+#endif
program_name);
exit(1);
}