diff options
author | Phil Sutter <phil@nwl.cc> | 2022-05-05 23:48:50 +0200 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2022-05-11 12:02:35 +0200 |
commit | fd64a5871b671a66f1ba6d6e3aa83ed24d92c099 (patch) | |
tree | 433b4f605c9108c6576aa9539fbab1efb3385f01 /iptables/xshared.c | |
parent | 3b8a6a6fa870c5ed4a2c533fcec9524bc98e5709 (diff) |
libxtables: Drop xtables_globals 'optstring' field
Define the different optstrings in xshared.h instead, they are not
relevant for other libxtables users.
This is a partial revert of commit 65b150ae382a8 ("xshared: Store
optstring in xtables_globals") to avoid breaking libxtables' ABI
compatibility.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'iptables/xshared.c')
-rw-r--r-- | iptables/xshared.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/iptables/xshared.c b/iptables/xshared.c index e959f203..fae5ddd5 100644 --- a/iptables/xshared.c +++ b/iptables/xshared.c @@ -1340,6 +1340,20 @@ static void check_inverse(struct xtables_args *args, const char option[], } } +static const char *optstring_lookup(int family) +{ + switch (family) { + case AF_INET: + case AF_INET6: + return IPT_OPTSTRING; + case NFPROTO_ARP: + return ARPT_OPTSTRING; + case NFPROTO_BRIDGE: + return EBT_OPTSTRING; + } + return ""; +} + void do_parse(int argc, char *argv[], struct xt_cmd_parse *p, struct iptables_command_state *cs, struct xtables_args *args) @@ -1370,7 +1384,8 @@ void do_parse(int argc, char *argv[], opterr = 0; xt_params->opts = xt_params->orig_opts; - while ((cs->c = getopt_long(argc, argv, xt_params->optstring, + while ((cs->c = getopt_long(argc, argv, + optstring_lookup(afinfo->family), xt_params->opts, NULL)) != -1) { switch (cs->c) { /* |