summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@medozas.de>2011-02-18 03:22:52 +0100
committerJan Engelhardt <jengelh@medozas.de>2011-04-06 12:54:22 +0200
commit9c5c10554c61f0b22cbc65b27b765fa8172040f7 (patch)
tree1e5b2e4b297dc48255343ef4985099ee70c485f4
parentf92bca9da4ee68f05dbb827a8444804a8edb1b87 (diff)
libxt_socket: use guided option parser
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
-rw-r--r--extensions/libxt_socket.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/extensions/libxt_socket.c b/extensions/libxt_socket.c
index e89d1c56..39016493 100644
--- a/extensions/libxt_socket.c
+++ b/extensions/libxt_socket.c
@@ -3,15 +3,17 @@
*
* Copyright (C) 2007 BalaBit IT Ltd.
*/
-#include <getopt.h>
-#include <stdbool.h>
#include <stdio.h>
#include <xtables.h>
#include <linux/netfilter/xt_socket.h>
-static const struct option socket_mt_opts[] = {
- {.name = "transparent", .has_arg = false, .val = 't'},
- XT_GETOPT_TABLEEND,
+enum {
+ O_TRANSPARENT = 0,
+};
+
+static const struct xt_option_entry socket_mt_opts[] = {
+ {.name = "transparent", .id = O_TRANSPARENT, .type = XTTYPE_NONE},
+ XTOPT_TABLEEND,
};
static void socket_mt_help(void)
@@ -21,17 +23,16 @@ static void socket_mt_help(void)
" --transparent Ignore non-transparent sockets\n\n");
}
-static int socket_mt_parse(int c, char **argv, int invert, unsigned int *flags,
- const void *entry, struct xt_entry_match **match)
+static void socket_mt_parse(struct xt_option_call *cb)
{
- struct xt_socket_mtinfo1 *info = (void *)(*match)->data;
+ struct xt_socket_mtinfo1 *info = cb->data;
- switch (c) {
- case 't':
+ xtables_option_parse(cb);
+ switch (cb->entry->id) {
+ case O_TRANSPARENT:
info->flags |= XT_SOCKET_TRANSPARENT;
- return true;
+ break;
}
- return false;
}
static void
@@ -68,10 +69,10 @@ static struct xtables_match socket_mt_reg[] = {
.size = XT_ALIGN(sizeof(struct xt_socket_mtinfo1)),
.userspacesize = XT_ALIGN(sizeof(struct xt_socket_mtinfo1)),
.help = socket_mt_help,
- .parse = socket_mt_parse,
.print = socket_mt_print,
.save = socket_mt_save,
- .extra_opts = socket_mt_opts,
+ .x6_parse = socket_mt_parse,
+ .x6_options = socket_mt_opts,
},
};