projects
/
external
/
iptables.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tizen 2.3.1 release
[external/iptables.git]
/
extensions
/
libxt_u32.c
diff --git
a/extensions/libxt_u32.c
b/extensions/libxt_u32.c
index
9a61c8a
..
2a7f5d8
100644
(file)
--- a/
extensions/libxt_u32.c
+++ b/
extensions/libxt_u32.c
@@
-10,21
+10,22
@@
* Copyright © CC Computer Consultants GmbH, 2007
* Contact: <jengelh@computergmbh.de>
*/
* Copyright © CC Computer Consultants GmbH, 2007
* Contact: <jengelh@computergmbh.de>
*/
-#include <sys/types.h>
#include <ctype.h>
#include <errno.h>
#include <ctype.h>
#include <errno.h>
-#include <getopt.h>
-#include <netdb.h>
+#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
-#include <string.h>
-
#include <xtables.h>
#include <linux/netfilter/xt_u32.h>
#include <xtables.h>
#include <linux/netfilter/xt_u32.h>
-static const struct option u32_opts[] = {
- {"u32", 1, NULL, 'u'},
- { .name = NULL }
+enum {
+ O_U32 = 0,
+};
+
+static const struct xt_option_entry u32_opts[] = {
+ {.name = "u32", .id = O_U32, .type = XTTYPE_STRING,
+ .flags = XTOPT_MAND | XTOPT_INVERT},
+ XTOPT_TABLEEND,
};
static void u32_help(void)
};
static void u32_help(void)
@@
-44,6
+45,7
@@
static void u32_dump(const struct xt_u32 *data)
const struct xt_u32_test *ct;
unsigned int testind, i;
const struct xt_u32_test *ct;
unsigned int testind, i;
+ printf(" \"");
for (testind = 0; testind < data->ntests; ++testind) {
ct = &data->tests[testind];
for (testind = 0; testind < data->ntests; ++testind) {
ct = &data->tests[testind];
@@
-80,41
+82,34
@@
static void u32_dump(const struct xt_u32 *data)
ct->value[i].max);
}
}
ct->value[i].max);
}
}
- p
rintf(" "
);
+ p
utchar('\"'
);
}
/* string_to_number() is not quite what we need here ... */
}
/* string_to_number() is not quite what we need here ... */
-static u
_int32_t parse_number(
char **s, int pos)
+static u
int32_t parse_number(const
char **s, int pos)
{
{
- u
_int32_
t number;
+ u
nsigned in
t number;
char *end;
char *end;
- errno = 0;
- number = strtoul(*s, &end, 0);
- if (end == *s)
+ if (!xtables_strtoui(*s, &end, &number, 0, UINT32_MAX) ||
+ end == *s)
xtables_error(PARAMETER_PROBLEM,
xtables_error(PARAMETER_PROBLEM,
- "u32: at char %d: expected number", pos);
- if (errno != 0)
- xtables_error(PARAMETER_PROBLEM,
- "u32: at char %d: error reading number", pos);
+ "u32: at char %d: not a number or out of range", pos);
*s = end;
return number;
}
*s = end;
return number;
}
-static int u32_parse(int c, char **argv, int invert, unsigned int *flags,
- const void *entry, struct xt_entry_match **match)
+static void u32_parse(struct xt_option_call *cb)
{
{
- struct xt_u32 *data =
(void *)(*match)
->data;
+ struct xt_u32 *data =
cb
->data;
unsigned int testind = 0, locind = 0, valind = 0;
struct xt_u32_test *ct = &data->tests[testind]; /* current test */
unsigned int testind = 0, locind = 0, valind = 0;
struct xt_u32_test *ct = &data->tests[testind]; /* current test */
- c
har *arg = opt
arg; /* the argument string */
- c
har *start =
arg;
+ c
onst char *arg = cb->
arg; /* the argument string */
+ c
onst char *start = cb->
arg;
int state = 0;
int state = 0;
- if (c != 'u')
- return 0;
-
- data->invert = invert;
+ xtables_option_parse(cb);
+ data->invert = cb->invert;
/*
* states:
/*
* states:
@@
-143,7
+138,7
@@
static int u32_parse(int c, char **argv, int invert, unsigned int *flags,
xtables_error(PARAMETER_PROBLEM,
"u32: at char %u: too many \"&&\"s",
(unsigned int)(arg - start));
xtables_error(PARAMETER_PROBLEM,
"u32: at char %u: too many \"&&\"s",
(unsigned int)(arg - start));
- return
1
;
+ return;
}
if (state == 0) {
}
if (state == 0) {
@@
-250,9
+245,9
@@
static void u32_print(const void *ip, const struct xt_entry_match *match,
int numeric)
{
const struct xt_u32 *data = (const void *)match->data;
int numeric)
{
const struct xt_u32 *data = (const void *)match->data;
- printf("
u32
");
+ printf("
u32
");
if (data->invert)
if (data->invert)
- printf("
!
");
+ printf("
!
");
u32_dump(data);
}
u32_dump(data);
}
@@
-260,8
+255,8
@@
static void u32_save(const void *ip, const struct xt_entry_match *match)
{
const struct xt_u32 *data = (const void *)match->data;
if (data->invert)
{
const struct xt_u32 *data = (const void *)match->data;
if (data->invert)
- printf("
!
");
- printf("
--u32
");
+ printf("
!
");
+ printf("
--u32
");
u32_dump(data);
}
u32_dump(data);
}
@@
-272,10
+267,10
@@
static struct xtables_match u32_match = {
.size = XT_ALIGN(sizeof(struct xt_u32)),
.userspacesize = XT_ALIGN(sizeof(struct xt_u32)),
.help = u32_help,
.size = XT_ALIGN(sizeof(struct xt_u32)),
.userspacesize = XT_ALIGN(sizeof(struct xt_u32)),
.help = u32_help,
- .parse = u32_parse,
.print = u32_print,
.save = u32_save,
.print = u32_print,
.save = u32_save,
- .extra_opts = u32_opts,
+ .x6_parse = u32_parse,
+ .x6_options = u32_opts,
};
void _init(void)
};
void _init(void)