From: Jan Engelhardt <jengelh@medozas.de>
To: kaber@trash.net
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH 04/26] libxtables: XTTYPE_UINT64 support
Date: Wed, 13 Apr 2011 18:13:25 +0200 [thread overview]
Message-ID: <1302711228-15947-5-git-send-email-jengelh@medozas.de> (raw)
In-Reply-To: <1302711228-15947-1-git-send-email-jengelh@medozas.de>
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
include/xtables.h.in | 2 ++
xtoptions.c | 12 ++++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/include/xtables.h.in b/include/xtables.h.in
index 2fa5977..c361bdb 100644
--- a/include/xtables.h.in
+++ b/include/xtables.h.in
@@ -56,6 +56,7 @@ enum xt_option_type {
XTTYPE_NONE,
XTTYPE_UINT8,
XTTYPE_UINT32,
+ XTTYPE_UINT64,
XTTYPE_UINT32RC,
XTTYPE_STRING,
XTTYPE_MARKMASK32,
@@ -115,6 +116,7 @@ struct xt_option_call {
union {
uint8_t u8;
uint32_t u32, u32_range[2];
+ uint64_t u64;
struct {
uint32_t mark, mask;
};
diff --git a/xtoptions.c b/xtoptions.c
index e9bcaa8..4206314 100644
--- a/xtoptions.c
+++ b/xtoptions.c
@@ -86,11 +86,13 @@ xtables_options_xfrm(struct option *orig_opts, struct option *oldopts,
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 long long lmin = 0, lmax = UINT32_MAX;
unsigned int value;
if (entry->type == XTTYPE_UINT8)
lmax = UINT8_MAX;
+ else if (entry->type == XTTYPE_UINT64)
+ lmax = UINT64_MAX;
if (cb->entry->min != 0)
lmin = cb->entry->min;
if (cb->entry->max != 0)
@@ -99,7 +101,7 @@ static void xtopt_parse_int(struct xt_option_call *cb)
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",
+ "or out of range (%llu-%llu).\n",
cb->ext_name, entry->name, lmin, lmax);
if (entry->type == XTTYPE_UINT8) {
@@ -110,6 +112,10 @@ static void xtopt_parse_int(struct xt_option_call *cb)
cb->val.u32 = value;
if (entry->flags & XTOPT_PUT)
*(uint32_t *)XTOPT_MKPTR(cb) = cb->val.u32;
+ } else if (entry->type == XTTYPE_UINT64) {
+ cb->val.u64 = value;
+ if (entry->flags & XTOPT_PUT)
+ *(uint64_t *)XTOPT_MKPTR(cb) = cb->val.u64;
}
}
@@ -217,6 +223,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_UINT32] = xtopt_parse_int,
+ [XTTYPE_UINT64] = xtopt_parse_int,
[XTTYPE_UINT32RC] = xtopt_parse_mint,
[XTTYPE_STRING] = xtopt_parse_string,
[XTTYPE_MARKMASK32] = xtopt_parse_markmask,
@@ -225,6 +232,7 @@ static void (*const xtopt_subparse[])(struct xt_option_call *) = {
static const size_t xtopt_psize[] = {
[XTTYPE_UINT8] = sizeof(uint8_t),
[XTTYPE_UINT32] = sizeof(uint32_t),
+ [XTTYPE_UINT64] = sizeof(uint64_t),
[XTTYPE_UINT32RC] = sizeof(uint32_t[2]),
[XTTYPE_STRING] = -1,
};
--
1.7.1
next prev parent reply other threads:[~2011-04-13 16:13 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-13 16:13 guided option parser, run 3 Jan Engelhardt
2011-04-13 16:13 ` [PATCH 01/26] libxtables: XTTYPE_MARKMASK32 support Jan Engelhardt
2011-04-13 16:13 ` [PATCH 02/26] libxt_MARK: use guided option parser Jan Engelhardt
2011-04-13 16:13 ` [PATCH 03/26] libxt_CONNMARK: " Jan Engelhardt
2011-04-13 16:13 ` Jan Engelhardt [this message]
2011-04-13 16:13 ` [PATCH 05/26] libxt_quota: " Jan Engelhardt
2011-04-13 16:13 ` [PATCH 06/26] libxtables: linked-list name<->id map Jan Engelhardt
2011-04-13 16:13 ` [PATCH 07/26] libxt_devgroup: use guided option parser Jan Engelhardt
2011-04-13 16:13 ` [PATCH 08/26] libipt_realm: " Jan Engelhardt
2011-04-13 16:13 ` [PATCH 09/26] libxtables: XTTYPE_UINT16RC support Jan Engelhardt
2011-04-13 16:13 ` [PATCH 10/26] libxt_length: use guided option parser Jan Engelhardt
2011-04-13 16:13 ` [PATCH 11/26] libxt_tcpmss: " Jan Engelhardt
2011-04-13 16:13 ` [PATCH 12/26] libxtables: XTTYPE_UINT8RC support Jan Engelhardt
2011-04-13 16:13 ` [PATCH 13/26] libxtables: XTTYPE_UINT64RC support Jan Engelhardt
2011-04-13 16:13 ` [PATCH 14/26] libxt_connbytes: use guided option parser Jan Engelhardt
2011-04-13 16:13 ` [PATCH 15/26] libxtables: XTTYPE_UINT16 support Jan Engelhardt
2011-04-13 16:13 ` [PATCH 16/26] libxt_CT: use guided option parser Jan Engelhardt
2011-04-13 16:13 ` [PATCH 17/26] libxt_NFQUEUE: " Jan Engelhardt
2011-04-13 16:13 ` [PATCH 18/26] libxt_TCPMSS: " Jan Engelhardt
2011-04-13 16:13 ` [PATCH 19/26] libxtables: pass struct xt_entry_{match,target} to x6 parser Jan Engelhardt
2011-04-13 16:13 ` [PATCH 20/26] libxt_string: use guided option parser Jan Engelhardt
2011-04-13 16:13 ` [PATCH 21/26] libxtables: XTTYPE_SYSLOGLEVEL support Jan Engelhardt
2011-04-13 16:13 ` [PATCH 22/26] libip[6]t_LOG: use guided option parser Jan Engelhardt
2011-04-13 16:13 ` [PATCH 23/26] libxtables: XTTYPE_ONEHOST support Jan Engelhardt
2011-04-13 16:13 ` [PATCH 24/26] libxtables: XTTYPE_PORT support Jan Engelhardt
2011-04-13 16:13 ` [PATCH 25/26] libxt_TPROXY: use guided option parser Jan Engelhardt
2011-04-13 16:13 ` [PATCH 26/26] libipt_ULOG: " Jan Engelhardt
2011-04-18 13:05 ` guided option parser, run 3 Patrick McHardy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1302711228-15947-5-git-send-email-jengelh@medozas.de \
--to=jengelh@medozas.de \
--cc=kaber@trash.net \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).