]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libxtables: min-max option support
authorJan Engelhardt <jengelh@medozas.de>
Sun, 27 Feb 2011 16:38:34 +0000 (17:38 +0100)
committerJan Engelhardt <jengelh@medozas.de>
Wed, 6 Apr 2011 10:54:23 +0000 (12:54 +0200)
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
include/xtables.h.in
xtoptions.c

index 91a6eaaa9d43153f667181e7632fb314047b4e4d..14d7b0436c22452298789446c4535ac9d4a46597 100644 (file)
@@ -76,6 +76,8 @@ enum xt_option_flags {
  * @flags:     bitmask of option flags, see %XTOPT_*
  * @ptroff:    offset into private structure for member
  * @size:      size of the item pointed to by @ptroff; this is a safeguard
+ * @min:       lowest allowed value (for singular integral types)
+ * @max:       highest allowed value (for singular integral types)
  */
 struct xt_option_entry {
        const char *name;
@@ -83,6 +85,7 @@ struct xt_option_entry {
        unsigned int id, excl, also, flags;
        unsigned int ptroff;
        size_t size;
+       unsigned int min, max;
 };
 
 /**
index 843395be2c0cb7c9747443b7785a326bda0092aa..6a119ec7d99c12797f354c062b070335673ed6d7 100644 (file)
@@ -89,6 +89,11 @@ static void xtopt_parse_int(struct xt_option_call *cb)
        unsigned int lmin = 0, lmax = UINT32_MAX;
        unsigned int value;
 
+       if (cb->entry->min != 0)
+               lmin = cb->entry->min;
+       if (cb->entry->max != 0)
+               lmax = cb->entry->max;
+
        if (!xtables_strtoui(cb->arg, NULL, &value, lmin, lmax))
                xt_params->exit_err(PARAMETER_PROBLEM,
                        "%s: bad value for option \"--%s\", "