]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libxtables: XTTYPE_UINT16 support
authorJan Engelhardt <jengelh@medozas.de>
Sun, 6 Mar 2011 16:42:51 +0000 (17:42 +0100)
committerJan Engelhardt <jengelh@medozas.de>
Wed, 13 Apr 2011 16:09:26 +0000 (18:09 +0200)
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
include/xtables.h.in
xtoptions.c

index 325c04c4b6a8fcd54230414283aa7dc6220edb38..6167f4da3e5ec8b9fe6b4013d035702095d70e7e 100644 (file)
@@ -55,6 +55,7 @@ struct in_addr;
 enum xt_option_type {
        XTTYPE_NONE,
        XTTYPE_UINT8,
+       XTTYPE_UINT16,
        XTTYPE_UINT32,
        XTTYPE_UINT64,
        XTTYPE_UINT8RC,
@@ -118,7 +119,7 @@ struct xt_option_call {
        uint8_t nvals;
        union {
                uint8_t u8, u8_range[2];
-               uint16_t u16_range[2];
+               uint16_t u16, u16_range[2];
                uint32_t u32, u32_range[2];
                uint64_t u64, u64_range[2];
                struct {
index a74938fa06e92fb3bf2985c7d42bebca83313f91..939e68603e8813a90977f009448b2998ed977a7b 100644 (file)
@@ -92,6 +92,8 @@ static void xtopt_parse_int(struct xt_option_call *cb)
 
        if (entry->type == XTTYPE_UINT8)
                lmax = UINT8_MAX;
+       else if (entry->type == XTTYPE_UINT16)
+               lmax = UINT16_MAX;
        else if (entry->type == XTTYPE_UINT64)
                lmax = UINT64_MAX;
        if (cb->entry->min != 0)
@@ -109,6 +111,10 @@ static void xtopt_parse_int(struct xt_option_call *cb)
                cb->val.u8 = value;
                if (entry->flags & XTOPT_PUT)
                        *(uint8_t *)XTOPT_MKPTR(cb) = cb->val.u8;
+       } else if (entry->type == XTTYPE_UINT16) {
+               cb->val.u16 = value;
+               if (entry->flags & XTOPT_PUT)
+                       *(uint16_t *)XTOPT_MKPTR(cb) = cb->val.u16;
        } else if (entry->type == XTTYPE_UINT32) {
                cb->val.u32 = value;
                if (entry->flags & XTOPT_PUT)
@@ -247,6 +253,7 @@ static void xtopt_parse_markmask(struct xt_option_call *cb)
 
 static void (*const xtopt_subparse[])(struct xt_option_call *) = {
        [XTTYPE_UINT8]       = xtopt_parse_int,
+       [XTTYPE_UINT16]      = xtopt_parse_int,
        [XTTYPE_UINT32]      = xtopt_parse_int,
        [XTTYPE_UINT64]      = xtopt_parse_int,
        [XTTYPE_UINT8RC]     = xtopt_parse_mint,
@@ -259,6 +266,7 @@ static void (*const xtopt_subparse[])(struct xt_option_call *) = {
 
 static const size_t xtopt_psize[] = {
        [XTTYPE_UINT8]       = sizeof(uint8_t),
+       [XTTYPE_UINT16]      = sizeof(uint16_t),
        [XTTYPE_UINT32]      = sizeof(uint32_t),
        [XTTYPE_UINT64]      = sizeof(uint64_t),
        [XTTYPE_UINT8RC]     = sizeof(uint8_t[2]),