Skip to content

Commit

Permalink
Merge branch '0.12' of https://github.com/jaqx0r/filtergen into 0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
jaqx0r committed Feb 14, 2016
2 parents 2dd8232 + 740fdd6 commit 2ea020a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ ylwrap
config.h.in~
debian/autoreconf.after
debian/autoreconf.before
/.sconsign.dblite
/cscope.out
/input/libsourcepos.a
/.sconf_temp/
20 changes: 11 additions & 9 deletions filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
19 changes: 17 additions & 2 deletions filtergen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}};
Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 2ea020a

Please sign in to comment.