summaryrefslogtreecommitdiff
path: root/tools/iptables-test.c
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2010-10-26 01:25:45 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2010-10-26 01:25:45 +0200
commite6c418226cefcee2a3bebce8fd7fd4372f0e0953 (patch)
treee0176daca79c274616b10610a37e5f38645daa38 /tools/iptables-test.c
parentb034a0686435b9f6f6f79d34924480ca2f3e68e9 (diff)
downloadconnman-e6c418226cefcee2a3bebce8fd7fd4372f0e0953.tar.gz
connman-e6c418226cefcee2a3bebce8fd7fd4372f0e0953.tar.bz2
connman-e6c418226cefcee2a3bebce8fd7fd4372f0e0953.zip
iptables-test: Inversion support
Diffstat (limited to 'tools/iptables-test.c')
-rw-r--r--tools/iptables-test.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/tools/iptables-test.c b/tools/iptables-test.c
index 9df04345..1c46ad72 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;