summaryrefslogtreecommitdiffstats
path: root/include/xtables.h.in
diff options
context:
space:
mode:
Diffstat (limited to 'include/xtables.h.in')
-rw-r--r--include/xtables.h.in111
1 files changed, 111 insertions, 0 deletions
diff --git a/include/xtables.h.in b/include/xtables.h.in
index c71839e1..3bdf7248 100644
--- a/include/xtables.h.in
+++ b/include/xtables.h.in
@@ -10,6 +10,8 @@
#include <sys/types.h>
#include <limits.h>
#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
#include <netinet/in.h>
#include <net/if.h>
#include <linux/types.h>
@@ -34,6 +36,89 @@
struct in_addr;
+/*
+ * .size is here so that there is a somewhat reasonable check
+ * against the chosen .type.
+ */
+#define XTOPT_POINTER(stype, member) \
+ .ptroff = offsetof(stype, member), \
+ .size = sizeof(((stype *)NULL)->member)
+#define XTOPT_TABLEEND {.name = NULL}
+
+/**
+ * %XTTYPE_NONE: option takes no argument
+ * %XTTYPE_UINT*: standard integer
+ */
+enum xt_option_type {
+ XTTYPE_NONE,
+ XTTYPE_UINT32,
+};
+
+/**
+ * %XTOPT_INVERT: option is invertible (usable with !)
+ * %XTOPT_MAND: option is mandatory
+ * %XTOPT_MULTI: option may be specified multiple times
+ * %XTOPT_PUT: store value into memory at @ptroff
+ */
+enum xt_option_flags {
+ XTOPT_INVERT = 1 << 0,
+ XTOPT_MAND = 1 << 1,
+ XTOPT_MULTI = 1 << 2,
+ XTOPT_PUT = 1 << 3,
+};
+
+/**
+ * @name: name of option
+ * @type: type of input and validation method, see %XTTYPE_*
+ * @id: unique number (within extension) for option, 0-31
+ * @excl: bitmask of flags that cannot be used with this option
+ * @also: bitmask of flags that must be used with this option
+ * @flags: bitmask of option flags, see %XTOPT_*
+ * @ptroff: offset into private structure for member
+ * @size: size of the item pointed to by @ptroff; this is a safeguard
+ * @min: lowest allowed value (for singular integral types)
+ * @max: highest allowed value (for singular integral types)
+ */
+struct xt_option_entry {
+ const char *name;
+ enum xt_option_type type;
+ unsigned int id, excl, also, flags;
+ unsigned int ptroff;
+ size_t size;
+ unsigned int min, max;
+};
+
+/**
+ * @arg: input from command line
+ * @ext_name: name of extension currently being processed
+ * @entry: current option being processed
+ * @data: per-extension data block
+ * @xflags: options of the extension that have been used
+ * @invert: whether option was used with !
+ * @val: parsed result
+ */
+struct xt_option_call {
+ const char *arg, *ext_name;
+ const struct xt_option_entry *entry;
+ void *data;
+ unsigned int xflags;
+ bool invert;
+ union {
+ uint32_t u32;
+ } val;
+};
+
+/**
+ * @ext_name: name of extension currently being processed
+ * @data: per-extension data block
+ * @xflags: options of the extension that have been used
+ */
+struct xt_fcheck_call {
+ const char *ext_name;
+ void *data;
+ unsigned int xflags;
+};
+
/* Include file for additions: new matches and targets. */
struct xtables_match
{
@@ -86,6 +171,11 @@ struct xtables_match
/* Pointer to list of extra command-line options */
const struct option *extra_opts;
+ /* New parser */
+ void (*x6_parse)(struct xt_option_call *);
+ void (*x6_fcheck)(struct xt_fcheck_call *);
+ const struct xt_option_entry *x6_options;
+
/* Ignore these men behind the curtain: */
unsigned int option_offset;
struct xt_entry_match *m;
@@ -145,6 +235,11 @@ struct xtables_target
/* Pointer to list of extra command-line options */
const struct option *extra_opts;
+ /* New parser */
+ void (*x6_parse)(struct xt_option_call *);
+ void (*x6_fcheck)(struct xt_fcheck_call *);
+ const struct xt_option_entry *x6_options;
+
/* Ignore these men behind the curtain: */
unsigned int option_offset;
struct xt_entry_target *t;
@@ -293,6 +388,22 @@ extern void xtables_save_string(const char *value);
extern const struct xtables_pprot xtables_chain_protos[];
extern u_int16_t xtables_parse_protocol(const char *s);
+/* xtoptions.c */
+extern void xtables_option_metavalidate(const char *,
+ const struct xt_option_entry *);
+extern struct option *xtables_options_xfrm(struct option *, struct option *,
+ const struct xt_option_entry *,
+ unsigned int *);
+extern void xtables_option_parse(struct xt_option_call *);
+extern void xtables_option_tpcall(unsigned int, char **, bool,
+ struct xtables_target *, void *);
+extern void xtables_option_mpcall(unsigned int, char **, bool,
+ struct xtables_match *, void *);
+extern void xtables_option_tfcall(struct xtables_target *);
+extern void xtables_option_mfcall(struct xtables_match *);
+extern void xtables_options_fcheck(const char *, unsigned int,
+ const struct xt_option_entry *);
+
#ifdef XTABLES_INTERNAL
/* Shipped modules rely on this... */