diff options
author | Stefan Tomanek <stefan.tomanek@wertarbyte.de> | 2011-03-07 18:30:27 +0100 |
---|---|---|
committer | Jan Engelhardt <jengelh@medozas.de> | 2011-03-07 20:07:55 +0100 |
commit | 9cc4f24e72f87ca191c2e723e7cd293f6477481c (patch) | |
tree | 04d0e4229715449f1c5786535d14e7142c809e24 /xshared.h | |
parent | f96cb8094ceffb9ffe8e94b4ee6800aa581dd021 (diff) |
ip(6)tables-multi: unify subcommand handling
I found the subcommand handling and naming done by iptables-multi and
ip6tables-multi very confusing and complicated; this patch
reorganizes the subcommands in a single table, allowing both variants
of them to be used (iptables/main) and also prints a list of the
allowed commands if an unknown command is entered by the user.
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Diffstat (limited to 'xshared.h')
-rw-r--r-- | xshared.h | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -1,7 +1,10 @@ #ifndef IPTABLES_XSHARED_H #define IPTABLES_XSHARED_H 1 +#include <limits.h> #include <stdint.h> +#include <netinet/in.h> +#include <net/if.h> #include <linux/netfilter_ipv4/ip_tables.h> #include <linux/netfilter_ipv6/ip6_tables.h> @@ -39,6 +42,13 @@ struct iptables_command_state { char **argv; }; +typedef int (*mainfunc_t)(int, char **); + +struct subcommand { + const char *name; + mainfunc_t main; +}; + enum { XT_OPTION_OFFSET_SCALE = 256, }; @@ -47,5 +57,6 @@ extern void print_extension_helps(const struct xtables_target *, const struct xtables_rule_match *); extern const char *proto_to_name(uint8_t, int); extern struct xtables_match *load_proto(struct iptables_command_state *); +extern int subcmd_main(int, char **, const struct subcommand *); #endif /* IPTABLES_XSHARED_H */ |