diff --git a/.gitignore b/.gitignore index d072fbac..4791045e 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,7 @@ ylwrap config.h.in~ debian/autoreconf.after debian/autoreconf.before +/.sconsign.dblite +/cscope.out +/input/libsourcepos.a +/.sconf_temp/ diff --git a/filter.h b/filter.h index bd9e445d..96965b92 100644 --- a/filter.h +++ b/filter.h @@ -73,7 +73,7 @@ enum filtertype { TEXT, /* for F_LOG */ }; -/* Structures which appear in both the parse tree and the output rule */ +/* Structure;s which appear in both the parse tree and the output rule */ struct proto_spec { int num; char *name; @@ -210,14 +210,16 @@ filter_flush flush_iptables, flush_ip6tables, flush_iptrestore, flush_ip6trestore, flush_ipchains; /* ("flags" arguments) */ -#define FF_NOSKEL (1 << 0) /* omit any "skeleton" rules */ -#define FF_LSTATE (1 << 1) /* lightweight state matching */ -#define FF_LOCAL (1 << 2) /* assume packets are local only */ -#define FF_ROUTE (1 << 3) /* assume packets are forwarded */ -#define FF_LOOKUP \ - (1 << 4) /* translate host and service names into \ - * IP addresses and port numbers */ -#define FF_FLUSH (1 << 5) /* just flush the ruleset instead */ +enum flags { + FF_NOSKEL = (1 << 0), /* omit any "skeleton" rules */ + FF_LSTATE = (1 << 1), /* lightweight state matching */ + FF_LOCAL = (1 << 2), /* assume packets are local only */ + FF_ROUTE = (1 << 3), /* assume packets are forwarded */ + FF_LOOKUP = (1 << 4), /* translate host and service names into IP addresses + and port numbers */ + FF_FLUSH = (1 << 5), /* just flush the ruleset instead */ + FF_NORESOLVE = (1 << 6), /* don't resolve hostnames, ports, or services */ +}; /* filtergen.c */ int oputs(const char *s); diff --git a/filtergen.c b/filtergen.c index 4b258950..3a253363 100644 --- a/filtergen.c +++ b/filtergen.c @@ -55,6 +55,14 @@ void usage(char *prog) { fprintf(stderr, " -c compile only, no generate\n"); #endif +#ifdef HAVE_GETOPT_H + fprintf(stderr, + " --no-resolve/-R don't resolve hostnames or portnames\n"); +#else + fprintf(stderr, + " -R don't resolve hostnames or portnames\n"); +#endif + #ifdef HAVE_GETOPT_H fprintf( stderr, @@ -135,6 +143,7 @@ static struct option long_options[] = {{"help", no_argument, 0, 'h'}, {"compile", no_argument, 0, 'c'}, {"target", required_argument, 0, 't'}, {"output", required_argument, 0, 'o'}, + {"no-resolve", no_argument, 0, 'R'}, {"flush", required_argument, 0, 'F'}, {"version", no_argument, 0, 'V'}, {0, 0, 0, 0}}; @@ -157,7 +166,7 @@ int main(int argc, char **argv) { progname = argv[0]; - while ((arg = GETOPT(argc, argv, "hco:t:F:V")) > 0) { + while ((arg = GETOPT(argc, argv, "hco:t:F:VR")) > 0) { switch (arg) { case ':': usage(progname); @@ -173,6 +182,9 @@ int main(int argc, char **argv) { case 'o': ofn = strdup(optarg); break; + case 'R': + flags |= FF_NORESOLVE; + break; case 't': ftn = strdup(optarg); break; @@ -248,7 +260,10 @@ int main(int argc, char **argv) { memset(&o, 0, sizeof o); o.family = ft->family; - resolve(&ast, &o); + if (!(flags & FF_NORESOLVE)) { + resolve(&ast, &o); + } + f = convert(&ast, &o); if (!f) { fprintf(stderr, "couldn't convert file\n");