summaryrefslogtreecommitdiffstats
path: root/iptables/ip6tables-restore.c
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2017-04-10 12:31:56 -0500
committerPablo Neira Ayuso <pablo@netfilter.org>2017-04-14 01:05:01 +0200
commit9cd3adbed2fd8cdb6366293f3799573b811be89b (patch)
tree219c1df65890b2378d94ce6031b7978d98139a07 /iptables/ip6tables-restore.c
parent1ec1fb7af08121d974416a1a23cd2d329fc0e29e (diff)
iptables-restore/ip6tables-restore: add --version/-V argument
Prints program version just like iptables/ip6tables. Signed-off-by: Dan Williams <dcbw@redhat.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'iptables/ip6tables-restore.c')
-rw-r--r--iptables/ip6tables-restore.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/iptables/ip6tables-restore.c b/iptables/ip6tables-restore.c
index 30a4ade7..419a2b0e 100644
--- a/iptables/ip6tables-restore.c
+++ b/iptables/ip6tables-restore.c
@@ -36,6 +36,7 @@ static struct timeval wait_interval = {
static const struct option options[] = {
{.name = "counters", .has_arg = 0, .val = 'c'},
{.name = "verbose", .has_arg = 0, .val = 'v'},
+ {.name = "version", .has_arg = 0, .val = 'V'},
{.name = "test", .has_arg = 0, .val = 't'},
{.name = "help", .has_arg = 0, .val = 'h'},
{.name = "noflush", .has_arg = 0, .val = 'n'},
@@ -48,11 +49,15 @@ static const struct option options[] = {
static void print_usage(const char *name, const char *version) __attribute__((noreturn));
+#define prog_name ip6tables_globals.program_name
+#define prog_vers ip6tables_globals.program_version
+
static void print_usage(const char *name, const char *version)
{
- fprintf(stderr, "Usage: %s [-c] [-v] [-t] [-h] [-n] [-w secs] [-W usecs] [-T table] [-M command]\n"
+ fprintf(stderr, "Usage: %s [-c] [-v] [-V] [-t] [-h] [-n] [-w secs] [-W usecs] [-T table] [-M command]\n"
" [ --counters ]\n"
" [ --verbose ]\n"
+ " [ --version]\n"
" [ --test ]\n"
" [ --help ]\n"
" [ --noflush ]\n"
@@ -78,8 +83,7 @@ static struct xtc_handle *create_handle(const char *tablename)
if (!handle) {
xtables_error(PARAMETER_PROBLEM, "%s: unable to initialize "
- "table '%s'\n", ip6tables_globals.program_name,
- tablename);
+ "table '%s'\n", prog_name, tablename);
exit(1);
}
return handle;
@@ -213,7 +217,7 @@ int ip6tables_restore_main(int argc, char *argv[])
init_extensions6();
#endif
- while ((c = getopt_long(argc, argv, "bcvthnwWM:T:", options, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "bcvVthnwWM:T:", options, NULL)) != -1) {
switch (c) {
case 'b':
fprintf(stderr, "-b/--binary option is not implemented\n");
@@ -224,6 +228,9 @@ int ip6tables_restore_main(int argc, char *argv[])
case 'v':
verbose = 1;
break;
+ case 'V':
+ printf("%s v%s\n", prog_name, prog_vers);
+ exit(0);
case 't':
testing = 1;
break;