From 6de62a9d47624155fa67530bc4a8f0ea647189f6 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Wed, 1 Jun 2022 19:24:41 +0200 Subject: xshared: Make some functions static With all ip(6)tables variants using the same do_parse() function, quite a bunch of functions are not used outside of xshared.c anymore. Make them static. Signed-off-by: Phil Sutter --- iptables/xshared.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'iptables/xshared.c') diff --git a/iptables/xshared.c b/iptables/xshared.c index 9b5e5b5b..bd4e1022 100644 --- a/iptables/xshared.c +++ b/iptables/xshared.c @@ -39,8 +39,8 @@ char *arp_opcodes[] = * to the commandline, and see expected results. So we call help for all * specified matches and targets. */ -void print_extension_helps(const struct xtables_target *t, - const struct xtables_rule_match *m) +static void print_extension_helps(const struct xtables_target *t, + const struct xtables_rule_match *m) { for (; t != NULL; t = t->next) { if (t->used) { @@ -129,8 +129,8 @@ static struct xtables_match *load_proto(struct iptables_command_state *cs) cs->options & OPT_NUMERIC, &cs->matches); } -int command_default(struct iptables_command_state *cs, - struct xtables_globals *gl, bool invert) +static int command_default(struct iptables_command_state *cs, + struct xtables_globals *gl, bool invert) { struct xtables_rule_match *matchp; struct xtables_match *m; @@ -789,7 +789,7 @@ void save_iface(char letter, const char *iface, } } -void command_match(struct iptables_command_state *cs, bool invert) +static void command_match(struct iptables_command_state *cs, bool invert) { struct option *opts = xt_params->opts; struct xtables_match *m; @@ -827,7 +827,7 @@ void command_match(struct iptables_command_state *cs, bool invert) xt_params->opts = opts; } -const char *xt_parse_target(const char *targetname) +static const char *xt_parse_target(const char *targetname) { const char *ptr; @@ -889,7 +889,7 @@ void command_jump(struct iptables_command_state *cs, const char *jumpto) xt_params->opts = opts; } -char cmd2char(int option) +static char cmd2char(int option) { /* cmdflags index corresponds with position of bit in CMD_* values */ static const char cmdflags[] = { 'I', 'D', 'D', 'R', 'A', 'L', 'F', 'Z', @@ -905,8 +905,8 @@ char cmd2char(int option) return cmdflags[i]; } -void add_command(unsigned int *cmd, const int newcmd, - const int othercmds, int invert) +static void add_command(unsigned int *cmd, const int newcmd, + const int othercmds, int invert) { if (invert) xtables_error(PARAMETER_PROBLEM, "unexpected '!' flag"); @@ -917,7 +917,7 @@ void add_command(unsigned int *cmd, const int newcmd, } /* Can't be zero. */ -int parse_rulenumber(const char *rule) +static int parse_rulenumber(const char *rule) { unsigned int rulenum; @@ -928,6 +928,10 @@ int parse_rulenumber(const char *rule) return rulenum; } +#define NUMBER_OF_OPT ARRAY_SIZE(optflags) +static const char optflags[] += { 'n', 's', 'd', 'p', 'j', 'v', 'x', 'i', 'o', '0', 'c', 'f', 2, 3, 'l', 4, 5, 6 }; + /* Table of legal combinations of commands and options. If any of the * given commands make an option legal, that option is legal (applies to * CMD_LIST and CMD_ZERO only). @@ -957,7 +961,7 @@ static const char commands_v_options[NUMBER_OF_CMD][NUMBER_OF_OPT] = /*CHECK*/ {'x',' ',' ',' ',' ',' ','x',' ',' ','x','x',' ',' ',' ',' ',' ',' ',' '}, }; -void generic_opt_check(int command, int options) +static void generic_opt_check(int command, int options) { int i, j, legal = 0; @@ -992,7 +996,7 @@ void generic_opt_check(int command, int options) } } -char opt2char(int option) +static char opt2char(int option) { const char *ptr; @@ -1024,7 +1028,7 @@ static const int inverse_for_options[NUMBER_OF_OPT] = /* 6 */ IPT_INV_PROTO, }; -void +static void set_option(unsigned int *options, unsigned int option, uint16_t *invflg, bool invert) { -- cgit v1.2.3