From 09bbe2bde426efe3608cd72cdaf3d7414e434c3c Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 25 Oct 2010 16:15:17 +0200 Subject: [PATCH] iptables-test: Add -t option support This will be needed for masquerading support. --- tools/iptables-test.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tools/iptables-test.c b/tools/iptables-test.c index 891d219..c479618 100644 --- a/tools/iptables-test.c +++ b/tools/iptables-test.c @@ -692,28 +692,25 @@ static struct option connman_iptables_opts[] = { {.name = "jump", .has_arg = 1, .val = 'j'}, {.name = "match", .has_arg = 1, .val = 'm'}, {.name = "out-interface", .has_arg = 1, .val = 'o'}, + {.name = "table", .has_arg = 1, .val = 't'}, {NULL}, }; int main(int argc, char *argv[]) { struct connman_iptables *table; - char *chain, *new_chain, *match_name, *target_name; + char *table_name, *chain, *new_chain, *match_name, *target_name; int c; gboolean dump; xtables_init(); xtables_set_nfproto(NFPROTO_IPV4); - table = connman_iptables_init("filter"); - if (table == NULL) - return -1; - dump = FALSE; - chain = new_chain = match_name = target_name = NULL; + table_name = chain = new_chain = match_name = target_name = NULL; while ((c = getopt_long(argc, argv, - "-A:L::N:j:i:m:o:", connman_iptables_opts, NULL)) != -1) { + "-A:L::N:j:i:m:o:t:", connman_iptables_opts, NULL)) != -1) { switch (c) { case 'A': chain = optarg; @@ -741,12 +738,23 @@ int main(int argc, char *argv[]) case 'o': break; + case 't': + table_name = optarg; + break; + default: printf("default %s\n", optarg); } } + if (table_name == NULL) + table_name = "filter"; + + table = connman_iptables_init(table_name); + if (table == NULL) + return -1; + if (dump) { connman_iptables_dump(table); -- 2.7.4