summaryrefslogtreecommitdiffstats
path: root/iptables
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2023-11-19 12:23:47 +0100
committerPhil Sutter <phil@nwl.cc>2023-12-05 16:35:37 +0100
commit6e870112174289840867605a245ea07d5f704e44 (patch)
tree9b2924bfa63623ec8790daf8914fb6d65cf06a78 /iptables
parente224f0b10ef01e3e2081054e7fa4f64601726646 (diff)
xshared: Introduce print_help callback (again)
Prep work for ebtables parser to use do_parse(). Adding more special casing to xtables_printhelp() causes a mess, so work with a callback again. Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'iptables')
-rw-r--r--iptables/ip6tables.c1
-rw-r--r--iptables/iptables.c1
-rw-r--r--iptables/nft-arp.c1
-rw-r--r--iptables/nft-ipv4.c1
-rw-r--r--iptables/nft-ipv6.c1
-rw-r--r--iptables/xshared.c6
-rw-r--r--iptables/xshared.h2
7 files changed, 10 insertions, 3 deletions
diff --git a/iptables/ip6tables.c b/iptables/ip6tables.c
index 96603756..4b5d4ac6 100644
--- a/iptables/ip6tables.c
+++ b/iptables/ip6tables.c
@@ -671,6 +671,7 @@ int do_command6(int argc, char *argv[], char **table,
.option_name = ip46t_option_name,
.option_invert = ip46t_option_invert,
.command_default = command_default,
+ .print_help = xtables_printhelp,
};
struct xt_cmd_parse p = {
.table = *table,
diff --git a/iptables/iptables.c b/iptables/iptables.c
index b57483ef..5ae28fe0 100644
--- a/iptables/iptables.c
+++ b/iptables/iptables.c
@@ -665,6 +665,7 @@ int do_command4(int argc, char *argv[], char **table,
.option_name = ip46t_option_name,
.option_invert = ip46t_option_invert,
.command_default = command_default,
+ .print_help = xtables_printhelp,
};
struct xt_cmd_parse p = {
.table = *table,
diff --git a/iptables/nft-arp.c b/iptables/nft-arp.c
index f3e2920a..6011620c 100644
--- a/iptables/nft-arp.c
+++ b/iptables/nft-arp.c
@@ -859,6 +859,7 @@ struct nft_family_ops nft_family_ops_arp = {
.option_name = nft_arp_option_name,
.option_invert = nft_arp_option_invert,
.command_default = command_default,
+ .print_help = xtables_printhelp,
},
.rule_to_cs = nft_rule_to_iptables_command_state,
.init_cs = nft_arp_init_cs,
diff --git a/iptables/nft-ipv4.c b/iptables/nft-ipv4.c
index 754c7764..979880a3 100644
--- a/iptables/nft-ipv4.c
+++ b/iptables/nft-ipv4.c
@@ -355,6 +355,7 @@ struct nft_family_ops nft_family_ops_ipv4 = {
.option_name = ip46t_option_name,
.option_invert = ip46t_option_invert,
.command_default = command_default,
+ .print_help = xtables_printhelp,
},
.rule_to_cs = nft_rule_to_iptables_command_state,
.clear_cs = xtables_clear_iptables_command_state,
diff --git a/iptables/nft-ipv6.c b/iptables/nft-ipv6.c
index b1b58910..e4b1714d 100644
--- a/iptables/nft-ipv6.c
+++ b/iptables/nft-ipv6.c
@@ -346,6 +346,7 @@ struct nft_family_ops nft_family_ops_ipv6 = {
.option_name = ip46t_option_name,
.option_invert = ip46t_option_invert,
.command_default = command_default,
+ .print_help = xtables_printhelp,
},
.rule_to_cs = nft_rule_to_iptables_command_state,
.clear_cs = xtables_clear_iptables_command_state,
diff --git a/iptables/xshared.c b/iptables/xshared.c
index 29b39929..177f3ddd 100644
--- a/iptables/xshared.c
+++ b/iptables/xshared.c
@@ -1108,9 +1108,9 @@ int print_match_save(const struct xt_entry_match *e, const void *ip)
return 0;
}
-static void
-xtables_printhelp(const struct xtables_rule_match *matches)
+void xtables_printhelp(struct iptables_command_state *cs)
{
+ const struct xtables_rule_match *matches = cs->matches;
const char *prog_name = xt_params->program_name;
const char *prog_vers = xt_params->program_version;
@@ -1527,7 +1527,7 @@ void do_parse(int argc, char *argv[],
xtables_find_match(cs->protocol,
XTF_TRY_LOAD, &cs->matches);
- xtables_printhelp(cs->matches);
+ p->ops->print_help(cs);
xtables_clear_iptables_command_state(cs);
xtables_free_opts(1);
xtables_fini();
diff --git a/iptables/xshared.h b/iptables/xshared.h
index bf24fd56..69f50e50 100644
--- a/iptables/xshared.h
+++ b/iptables/xshared.h
@@ -274,6 +274,7 @@ struct xt_cmd_parse_ops {
int (*option_invert)(int option);
int (*command_default)(struct iptables_command_state *cs,
struct xtables_globals *gl, bool invert);
+ void (*print_help)(struct iptables_command_state *cs);
};
struct xt_cmd_parse {
@@ -289,6 +290,7 @@ struct xt_cmd_parse {
struct xt_cmd_parse_ops *ops;
};
+void xtables_printhelp(struct iptables_command_state *cs);
const char *ip46t_option_name(int option);
int ip46t_option_invert(int option);
int command_default(struct iptables_command_state *cs,