diff options
author | Phil Sutter <phil@nwl.cc> | 2020-10-30 12:42:57 +0100 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2020-12-03 00:27:57 +0100 |
commit | 8bd4b4f79b5de483353a8c0d0962e71934b7bdd2 (patch) | |
tree | ba5d05c78d0ee9a45a0711fb386decf63342c119 /iptables/xtables-arp.c | |
parent | 44457c0805905ea22b4ecf9156648e774dd29155 (diff) |
xshared: Merge some command option-related code
Add OPT_FRAGMENT define into the enum of other OPT_* defines at the
right position and adjust the arptables-specific ones that follow
accordingly. Appropriately adjust inverse_for_options array in
xtables-arp.c.
Extend optflags from iptables.c by the arptables values for the sake of
completeness, then move it to xshared.h along with NUMBER_OF_OPT
definition. As a side-effect, this fixes for wrong ordering of entries
in arptables' 'optflags' copy.
Add arptables-specific bits to commands_v_options table (the speicific
options are matches on ARP header fields, just treat them like '-s'
option. This is also just a cosmetic change, arptables doesn't have a
generic_opt_check() implementation and hence doesn't use such a table.
With things potentially ready for common use, move commands_v_options
table along with generic_opt_check() and opt2char() into xshared.c and
drop the local (identical) implementations from iptables.c, ip6tables.c
xtables.c and xtables-arp.c. While doing so, fix ordering of entries in
that table: the row for CMD_ZERO_NUM was in the wrong position. Since
all moved rows though are identical, this had no effect in practice.
Fixes: d960a991350ca ("xtables-arp: Integrate OPT_* defines into xshared.h")
Fixes: 384958620abab ("use nf_tables and nf_tables compatibility interface")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'iptables/xtables-arp.c')
-rw-r--r-- | iptables/xtables-arp.c | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/iptables/xtables-arp.c b/iptables/xtables-arp.c index a557f258..4a89ae95 100644 --- a/iptables/xtables-arp.c +++ b/iptables/xtables-arp.c @@ -53,10 +53,6 @@ #include "nft-arp.h" #include <linux/netfilter_arp/arp_tables.h> -#define NUMBER_OF_OPT 16 -static const char optflags[NUMBER_OF_OPT] -= { 'n', 's', 'd', 2, 3, 7, 8, 4, 5, 6, 'j', 'v', 'i', 'o', '0', 'c'}; - static struct option original_opts[] = { { "append", 1, 0, 'A' }, { "delete", 1, 0, 'D' }, @@ -123,6 +119,7 @@ static int inverse_for_options[] = /* -o */ IPT_INV_VIA_OUT, /*--line*/ 0, /* -c */ 0, +/* -f */ 0, /* 2 */ IPT_INV_SRCDEVADDR, /* 3 */ IPT_INV_TGTDEVADDR, /* -l */ IPT_INV_ARPHLN, @@ -281,15 +278,6 @@ printhelp(void) } } -static char -opt2char(int option) -{ - const char *ptr; - for (ptr = optflags; option > 1; option >>= 1, ptr++); - - return *ptr; -} - static int check_inverse(const char option[], int *invert, int *optidx, int argc) { |