]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
xshared: Introduce print_help callback (again)
authorPhil Sutter <phil@nwl.cc>
Sun, 19 Nov 2023 11:23:47 +0000 (12:23 +0100)
committerPhil Sutter <phil@nwl.cc>
Tue, 5 Dec 2023 15:35:37 +0000 (16:35 +0100)
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>
iptables/ip6tables.c
iptables/iptables.c
iptables/nft-arp.c
iptables/nft-ipv4.c
iptables/nft-ipv6.c
iptables/xshared.c
iptables/xshared.h

index 96603756324a51cf58aa94e62d5cdee35d4f37f4..4b5d4ac6878b707e79f46b9917ea733c214c7679 100644 (file)
@@ -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,
index b57483ef445147bc839b2131719f3f2e872d3853..5ae28fe04a5f50d18ddd2d2cd54b0a113fb90395 100644 (file)
@@ -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,
index f3e2920ac6d15aabc453a022661d8280c6434abf..6011620cf52a77ac2fbfbfc4b746e2d5b0b2dbd7 100644 (file)
@@ -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,
index 754c7764731431f748af004b28318637b2aab83d..979880a3e770233c2381acbaf143d1bdba285d9a 100644 (file)
@@ -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,
index b1b5891013577fa983e77bba6ca422193b6a203b..e4b1714d00c2f900f19507d62373f6de8d031b99 100644 (file)
@@ -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,
index 29b3992904e688892677c7be351ffba1b4ad34e5..177f3ddd1c19e22e802a682a8a9e295a6ed94cb1 100644 (file)
@@ -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();
index bf24fd568a6f52fa68c1db1d609143ecbcf7913f..69f50e505cb9be49a4d44347c2257e29c4a94bc6 100644 (file)
@@ -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,