[PATCH 09/10] libxtables: min-max option support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jan Engelhardt <jengelh@xxxxxxxxxx>
---
 include/xtables.h.in |    3 +++
 xtoptions.c          |    5 +++++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/include/xtables.h.in b/include/xtables.h.in
index 91a6eaa..14d7b04 100644
--- a/include/xtables.h.in
+++ b/include/xtables.h.in
@@ -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;
 };
 
 /**
diff --git a/xtoptions.c b/xtoptions.c
index 843395b..6a119ec 100644
--- a/xtoptions.c
+++ b/xtoptions.c
@@ -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\", "
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux