From: Samuel Ortiz Date: Mon, 25 Oct 2010 23:25:45 +0000 (+0200) Subject: iptables-test: Inversion support X-Git-Tag: 0.63~68 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e6c418226cefcee2a3bebce8fd7fd4372f0e0953;p=platform%2Fupstream%2Fconnman.git iptables-test: Inversion support --- diff --git a/tools/iptables-test.c b/tools/iptables-test.c index 9df0434..1c46ad7 100644 --- a/tools/iptables-test.c +++ b/tools/iptables-test.c @@ -696,11 +696,12 @@ int main(int argc, char *argv[]) char *table_name, *chain, *new_chain, *match_name, *target_name; int c; size_t size; - gboolean dump; + gboolean dump, invert; xtables_init_all(&connman_iptables_globals, NFPROTO_IPV4); dump = FALSE; + invert = FALSE; table_name = chain = new_chain = match_name = target_name = NULL; table = NULL; xt_m = NULL; @@ -781,13 +782,29 @@ int main(int argc, char *argv[]) table_name = optarg; break; + case 1: + if (optarg[0] == '!' && optarg[1] == '\0') { + if (invert) + printf("Consecutive ! not allowed\n"); + + invert = TRUE; + optarg[0] = '\0'; + continue; + } + + printf("Invalid option\n"); + + return -1; + default: if (xt_t == NULL || xt_t->parse == NULL || - !xt_t->parse(c - xt_t->option_offset, argv, 0, &xt_t->tflags, NULL, &xt_t->t)) { + !xt_t->parse(c - xt_t->option_offset, argv, invert, + &xt_t->tflags, NULL, &xt_t->t)) { if (xt_m == NULL || xt_m->parse == NULL) break; - xt_m->parse(c - xt_m->option_offset, argv, 0, &xt_m->mflags, NULL, &xt_m->m); + xt_m->parse(c - xt_m->option_offset, argv, + invert, &xt_m->mflags, NULL, &xt_m->m); } break; @@ -824,8 +841,7 @@ int main(int argc, char *argv[]) printf("Adding %s to %s (match %s)\n", target_name, chain, match_name); - connman_iptables_add_rule(table, chain, - target_name, xt_t, + connman_iptables_add_rule(table, chain, target_name, xt_t, match_name, xt_m); goto commit;