From 810f8568f44f5863c2350a39f4f5c8d60f762958 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Sun, 17 Dec 2023 15:10:15 +0100 Subject: libxtables: xtoptions: Implement XTTYPE_ETHERMACMASK Accept an Ethernet MAC address with optional mask in the format xtables_parse_mac_and_mask() expects it. Does not support XTOPT_PUT (for now) due to the lack of defined data structure. --- libxtables/xtoptions.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libxtables/xtoptions.c') diff --git a/libxtables/xtoptions.c b/libxtables/xtoptions.c index 5a432ea1..7a0e44b3 100644 --- a/libxtables/xtoptions.c +++ b/libxtables/xtoptions.c @@ -791,6 +791,15 @@ static void xtopt_parse_ethermac(struct xt_option_call *cb) xt_params->exit_err(PARAMETER_PROBLEM, "Invalid MAC address specified."); } +static void xtopt_parse_ethermacmask(struct xt_option_call *cb) +{ + memset(cb->val.ethermacmask, 0xff, ETH_ALEN); + if (xtables_parse_mac_and_mask(cb->arg, cb->val.ethermac, + cb->val.ethermacmask)) + xt_params->exit_err(PARAMETER_PROBLEM, + "Invalid MAC/mask address specified."); +} + static void (*const xtopt_subparse[])(struct xt_option_call *) = { [XTTYPE_UINT8] = xtopt_parse_int, [XTTYPE_UINT16] = xtopt_parse_int, @@ -813,6 +822,7 @@ static void (*const xtopt_subparse[])(struct xt_option_call *) = { [XTTYPE_PLEN] = xtopt_parse_plen, [XTTYPE_PLENMASK] = xtopt_parse_plenmask, [XTTYPE_ETHERMAC] = xtopt_parse_ethermac, + [XTTYPE_ETHERMACMASK]= xtopt_parse_ethermacmask, }; /** -- cgit v1.2.3