diff options
author | Patrick McHardy <kaber@trash.net> | 2011-05-12 11:11:51 +0200 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2011-05-12 11:11:51 +0200 |
commit | 59ce5bd1d05225911051a4c46ce5ccdd7c1ed078 (patch) | |
tree | 4e7e079df76eff91b26f1834aac0ef361dc20cbd /xtoptions.c | |
parent | 8075493a00e06857147263574333df4073ea671b (diff) | |
parent | 8d14aeb8c4c3dc8ce9264b04b97f2e8634c1f381 (diff) |
Merge branch 'floating/opts' of git://dev.medozas.de/iptables
Diffstat (limited to 'xtoptions.c')
-rw-r--r-- | xtoptions.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/xtoptions.c b/xtoptions.c index 70370edb..8d54dd8b 100644 --- a/xtoptions.c +++ b/xtoptions.c @@ -672,6 +672,30 @@ static void xtopt_parse_hostmask(struct xt_option_call *cb) cb->arg = orig_arg; } +static void xtopt_parse_ethermac(struct xt_option_call *cb) +{ + const char *arg = cb->arg; + unsigned int i; + char *end; + + for (i = 0; i < ARRAY_SIZE(cb->val.ethermac) - 1; ++i) { + cb->val.ethermac[i] = strtoul(arg, &end, 16); + if (cb->val.ethermac[i] > UINT8_MAX || *end != ':') + goto out; + arg = end + 1; + } + i = ARRAY_SIZE(cb->val.ethermac) - 1; + cb->val.ethermac[i] = strtoul(arg, &end, 16); + if (cb->val.ethermac[i] > UINT8_MAX || *end != '\0') + goto out; + if (cb->entry->flags & XTOPT_PUT) + memcpy(XTOPT_MKPTR(cb), cb->val.ethermac, + sizeof(cb->val.ethermac)); + return; + out: + xt_params->exit_err(PARAMETER_PROBLEM, "ether"); +} + static void (*const xtopt_subparse[])(struct xt_option_call *) = { [XTTYPE_UINT8] = xtopt_parse_int, [XTTYPE_UINT16] = xtopt_parse_int, @@ -695,6 +719,7 @@ static void (*const xtopt_subparse[])(struct xt_option_call *) = { [XTTYPE_PORTRC_NE] = xtopt_parse_mport, [XTTYPE_PLEN] = xtopt_parse_plen, [XTTYPE_PLENMASK] = xtopt_parse_plenmask, + [XTTYPE_ETHERMAC] = xtopt_parse_ethermac, }; static const size_t xtopt_psize[] = { @@ -721,6 +746,7 @@ static const size_t xtopt_psize[] = { [XTTYPE_PORTRC] = sizeof(uint16_t[2]), [XTTYPE_PORTRC_NE] = sizeof(uint16_t[2]), [XTTYPE_PLENMASK] = sizeof(union nf_inet_addr), + [XTTYPE_ETHERMAC] = sizeof(uint8_t[6]), }; /** |