diff options
author | Jan Engelhardt <jengelh@medozas.de> | 2011-02-16 01:22:25 +0100 |
---|---|---|
committer | Jan Engelhardt <jengelh@medozas.de> | 2011-04-06 12:54:23 +0200 |
commit | a93142d5f55db74ebd7d49be9bd88f7a499ded40 (patch) | |
tree | ac7f1917715b6e69b8700e6065e119ffbb4af550 /xtoptions.c | |
parent | 97265fb806dffc6fd87ee5e0f0963dfbe7a094f6 (diff) |
libxtables: XTTYPE_UINT32 support
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Diffstat (limited to 'xtoptions.c')
-rw-r--r-- | xtoptions.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/xtoptions.c b/xtoptions.c index df917b67..843395be 100644 --- a/xtoptions.c +++ b/xtoptions.c @@ -80,12 +80,34 @@ xtables_options_xfrm(struct option *orig_opts, struct option *oldopts, return merge; } +/** + * Require a simple integer. + */ +static void xtopt_parse_int(struct xt_option_call *cb) +{ + const struct xt_option_entry *entry = cb->entry; + unsigned int lmin = 0, lmax = UINT32_MAX; + unsigned int value; + + if (!xtables_strtoui(cb->arg, NULL, &value, lmin, lmax)) + xt_params->exit_err(PARAMETER_PROBLEM, + "%s: bad value for option \"--%s\", " + "or out of range (%u-%u).\n", + cb->ext_name, entry->name, lmin, lmax); + + if (entry->type == XTTYPE_UINT32) { + cb->val.u32 = value; + if (entry->flags & XTOPT_PUT) + *(uint32_t *)XTOPT_MKPTR(cb) = cb->val.u32; + } +} + static void (*const xtopt_subparse[])(struct xt_option_call *) = { - [XTTYPE_NONE] = NULL, + [XTTYPE_UINT32] = xtopt_parse_int, }; static const size_t xtopt_psize[] = { - [XTTYPE_NONE] = 0, + [XTTYPE_UINT32] = sizeof(uint32_t), }; /** |