From 9cc4f24e72f87ca191c2e723e7cd293f6477481c Mon Sep 17 00:00:00 2001 From: Stefan Tomanek Date: Mon, 7 Mar 2011 18:30:27 +0100 Subject: 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 --- xshared.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'xshared.h') diff --git a/xshared.h b/xshared.h index a08e6d98..94abb392 100644 --- a/xshared.h +++ b/xshared.h @@ -1,7 +1,10 @@ #ifndef IPTABLES_XSHARED_H #define IPTABLES_XSHARED_H 1 +#include #include +#include +#include #include #include @@ -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 */ -- cgit v1.2.3