diff options
author | /C=EU/ST=EU/CN=Patrick McHardy/emailAddress=kaber@trash.net </C=EU/ST=EU/CN=Patrick McHardy/emailAddress=kaber@trash.net> | 2007-11-05 19:35:31 +0000 |
---|---|---|
committer | /C=EU/ST=EU/CN=Patrick McHardy/emailAddress=kaber@trash.net </C=EU/ST=EU/CN=Patrick McHardy/emailAddress=kaber@trash.net> | 2007-11-05 19:35:31 +0000 |
commit | 6e717f369766669744de158f97a74b9d1c0274aa (patch) | |
tree | 85dd11f0bfd7db561590d09b889795a372b627df /iptables-restore.c | |
parent | c559e40ff4ce556a6840f7264798cf723c628d06 (diff) |
[PATCH]: iptables-edit: iptables-edit: adds --table to iptables-restore
adds --table to iptables-restore which allows to restore only the supplied table
Signed-off-by: Peter Warasin <peter@endian.com>
Diffstat (limited to 'iptables-restore.c')
-rw-r--r-- | iptables-restore.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/iptables-restore.c b/iptables-restore.c index c0e168e..41d47e7 100644 --- a/iptables-restore.c +++ b/iptables-restore.c @@ -33,6 +33,7 @@ static struct option options[] = { { "help", 0, 0, 'h' }, { "noflush", 0, 0, 'n'}, { "modprobe", 1, 0, 'M'}, + { "table", 1, 0, 'T'}, { 0 } }; @@ -47,6 +48,7 @@ static void print_usage(const char *name, const char *version) " [ --test ]\n" " [ --help ]\n" " [ --noflush ]\n" + " [ --table=<TABLE> ]\n" " [ --modprobe=<command>]\n", name); exit(1); @@ -123,6 +125,7 @@ main(int argc, char *argv[]) FILE *in; const char *modprobe = 0; int in_table = 0, testing = 0; + const char *tablename = 0; program_name = "iptables-restore"; program_version = IPTABLES_VERSION; @@ -136,7 +139,7 @@ main(int argc, char *argv[]) init_extensions(); #endif - while ((c = getopt_long(argc, argv, "bcvthnM:", options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "bcvthnM:T:", options, NULL)) != -1) { switch (c) { case 'b': binary = 1; @@ -160,6 +163,9 @@ main(int argc, char *argv[]) case 'M': modprobe = optarg; break; + case 'T': + tablename = optarg; + break; } } @@ -212,6 +218,8 @@ main(int argc, char *argv[]) strncpy(curtable, table, IPT_TABLE_MAXNAMELEN); curtable[IPT_TABLE_MAXNAMELEN] = '\0'; + if (tablename && (strcmp(tablename, table) != 0)) + continue; if (handle) iptc_free(&handle); @@ -438,6 +446,8 @@ main(int argc, char *argv[]) free_argv(); } + if (tablename && (strcmp(tablename, curtable) != 0)) + continue; if (!ret) { fprintf(stderr, "%s: line %u failed\n", program_name, line); |