]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libxtables: XTTYPE_UINT8 support
authorJan Engelhardt <jengelh@medozas.de>
Sun, 27 Feb 2011 18:03:28 +0000 (19:03 +0100)
committerJan Engelhardt <jengelh@medozas.de>
Wed, 6 Apr 2011 11:12:55 +0000 (13:12 +0200)
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
include/xtables.h.in
xtoptions.c

index 14d7b0436c22452298789446c4535ac9d4a46597..dc074bc099d1f9f45838c4d3138be501e1cd7cd1 100644 (file)
@@ -51,6 +51,7 @@ struct in_addr;
  */
 enum xt_option_type {
        XTTYPE_NONE,
+       XTTYPE_UINT8,
        XTTYPE_UINT32,
 };
 
@@ -104,6 +105,7 @@ struct xt_option_call {
        unsigned int xflags;
        bool invert;
        union {
+               uint8_t u8;
                uint32_t u32;
        } val;
 };
index 6a119ec7d99c12797f354c062b070335673ed6d7..693c06d65ec61af89ef472346c29002ca8d66793 100644 (file)
@@ -89,6 +89,8 @@ static void xtopt_parse_int(struct xt_option_call *cb)
        unsigned int lmin = 0, lmax = UINT32_MAX;
        unsigned int value;
 
+       if (entry->type == XTTYPE_UINT8)
+               lmax = UINT8_MAX;
        if (cb->entry->min != 0)
                lmin = cb->entry->min;
        if (cb->entry->max != 0)
@@ -100,7 +102,11 @@ static void xtopt_parse_int(struct xt_option_call *cb)
                        "or out of range (%u-%u).\n",
                        cb->ext_name, entry->name, lmin, lmax);
 
-       if (entry->type == XTTYPE_UINT32) {
+       if (entry->type == XTTYPE_UINT8) {
+               cb->val.u8 = value;
+               if (entry->flags & XTOPT_PUT)
+                       *(uint8_t *)XTOPT_MKPTR(cb) = cb->val.u8;
+       } else if (entry->type == XTTYPE_UINT32) {
                cb->val.u32 = value;
                if (entry->flags & XTOPT_PUT)
                        *(uint32_t *)XTOPT_MKPTR(cb) = cb->val.u32;
@@ -108,10 +114,12 @@ static void xtopt_parse_int(struct xt_option_call *cb)
 }
 
 static void (*const xtopt_subparse[])(struct xt_option_call *) = {
+       [XTTYPE_UINT8]       = xtopt_parse_int,
        [XTTYPE_UINT32]      = xtopt_parse_int,
 };
 
 static const size_t xtopt_psize[] = {
+       [XTTYPE_UINT8]       = sizeof(uint8_t),
        [XTTYPE_UINT32]      = sizeof(uint32_t),
 };