Blame include/xtables.h

Packit Service 3880ab
/* SPDX-License-Identifier: GPL-2.0 */
Packit Service 3880ab
#ifndef _XTABLES_H
Packit Service 3880ab
#define _XTABLES_H
Packit Service 3880ab
Packit Service 3880ab
/*
Packit Service 3880ab
 * Changing any structs/functions may incur a needed change
Packit Service 3880ab
 * in libxtables_vcurrent/vage too.
Packit Service 3880ab
 */
Packit Service 3880ab
Packit Service 3880ab
#include <sys/socket.h> /* PF_* */
Packit Service 3880ab
#include <sys/types.h>
Packit Service 3880ab
#include <limits.h>
Packit Service 3880ab
#include <stdbool.h>
Packit Service 3880ab
#include <stddef.h>
Packit Service 3880ab
#include <stdint.h>
Packit Service 3880ab
#include <netinet/in.h>
Packit Service 3880ab
#include <net/if.h>
Packit Service 3880ab
#include <linux/types.h>
Packit Service 3880ab
#include <linux/netfilter.h>
Packit Service 3880ab
#include <linux/netfilter/x_tables.h>
Packit Service 3880ab
Packit Service 3880ab
#ifndef IPPROTO_SCTP
Packit Service 3880ab
#define IPPROTO_SCTP 132
Packit Service 3880ab
#endif
Packit Service 3880ab
#ifndef IPPROTO_DCCP
Packit Service 3880ab
#define IPPROTO_DCCP 33
Packit Service 3880ab
#endif
Packit Service 3880ab
#ifndef IPPROTO_MH
Packit Service 3880ab
#	define IPPROTO_MH 135
Packit Service 3880ab
#endif
Packit Service 3880ab
#ifndef IPPROTO_UDPLITE
Packit Service 3880ab
#define IPPROTO_UDPLITE	136
Packit Service 3880ab
#endif
Packit Service 3880ab
Packit Service 3880ab
#include <xtables-version.h>
Packit Service 3880ab
Packit Service 3880ab
struct in_addr;
Packit Service 3880ab
Packit Service 3880ab
/*
Packit Service 3880ab
 * .size is here so that there is a somewhat reasonable check
Packit Service 3880ab
 * against the chosen .type.
Packit Service 3880ab
 */
Packit Service 3880ab
#define XTOPT_POINTER(stype, member) \
Packit Service 3880ab
	.ptroff = offsetof(stype, member), \
Packit Service 3880ab
	.size = sizeof(((stype *)NULL)->member)
Packit Service 3880ab
#define XTOPT_TABLEEND {.name = NULL}
Packit Service 3880ab
Packit Service 3880ab
/**
Packit Service 3880ab
 * Select the format the input has to conform to, as well as the target type
Packit Service 3880ab
 * (area pointed to with XTOPT_POINTER). Note that the storing is not always
Packit Service 3880ab
 * uniform. @cb->val will be populated with as much as there is space, i.e.
Packit Service 3880ab
 * exactly 2 items for ranges, but the target area can receive more values
Packit Service 3880ab
 * (e.g. in case of ranges), or less values (e.g. %XTTYPE_HOSTMASK).
Packit Service 3880ab
 *
Packit Service 3880ab
 * %XTTYPE_NONE:	option takes no argument
Packit Service 3880ab
 * %XTTYPE_UINT*:	standard integer
Packit Service 3880ab
 * %XTTYPE_UINT*RC:	colon-separated range of standard integers
Packit Service 3880ab
 * %XTTYPE_DOUBLE:	double-precision floating point number
Packit Service 3880ab
 * %XTTYPE_STRING:	arbitrary string
Packit Service 3880ab
 * %XTTYPE_TOSMASK:	8-bit TOS value with optional mask
Packit Service 3880ab
 * %XTTYPE_MARKMASK32:	32-bit mark with optional mask
Packit Service 3880ab
 * %XTTYPE_SYSLOGLEVEL:	syslog level by name or number
Packit Service 3880ab
 * %XTTYPE_HOST:	one host or address (ptr: union nf_inet_addr)
Packit Service 3880ab
 * %XTTYPE_HOSTMASK:	one host or address, with an optional prefix length
Packit Service 3880ab
 * 			(ptr: union nf_inet_addr; only host portion is stored)
Packit Service 3880ab
 * %XTTYPE_PROTOCOL:	protocol number/name from /etc/protocols (ptr: uint8_t)
Packit Service 3880ab
 * %XTTYPE_PORT:	16-bit port name or number (supports %XTOPT_NBO)
Packit Service 3880ab
 * %XTTYPE_PORTRC:	colon-separated port range (names acceptable),
Packit Service 3880ab
 * 			(supports %XTOPT_NBO)
Packit Service 3880ab
 * %XTTYPE_PLEN:	prefix length
Packit Service 3880ab
 * %XTTYPE_PLENMASK:	prefix length (ptr: union nf_inet_addr)
Packit Service 3880ab
 * %XTTYPE_ETHERMAC:	Ethernet MAC address in hex form
Packit Service 3880ab
 */
Packit Service 3880ab
enum xt_option_type {
Packit Service 3880ab
	XTTYPE_NONE,
Packit Service 3880ab
	XTTYPE_UINT8,
Packit Service 3880ab
	XTTYPE_UINT16,
Packit Service 3880ab
	XTTYPE_UINT32,
Packit Service 3880ab
	XTTYPE_UINT64,
Packit Service 3880ab
	XTTYPE_UINT8RC,
Packit Service 3880ab
	XTTYPE_UINT16RC,
Packit Service 3880ab
	XTTYPE_UINT32RC,
Packit Service 3880ab
	XTTYPE_UINT64RC,
Packit Service 3880ab
	XTTYPE_DOUBLE,
Packit Service 3880ab
	XTTYPE_STRING,
Packit Service 3880ab
	XTTYPE_TOSMASK,
Packit Service 3880ab
	XTTYPE_MARKMASK32,
Packit Service 3880ab
	XTTYPE_SYSLOGLEVEL,
Packit Service 3880ab
	XTTYPE_HOST,
Packit Service 3880ab
	XTTYPE_HOSTMASK,
Packit Service 3880ab
	XTTYPE_PROTOCOL,
Packit Service 3880ab
	XTTYPE_PORT,
Packit Service 3880ab
	XTTYPE_PORTRC,
Packit Service 3880ab
	XTTYPE_PLEN,
Packit Service 3880ab
	XTTYPE_PLENMASK,
Packit Service 3880ab
	XTTYPE_ETHERMAC,
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
/**
Packit Service 3880ab
 * %XTOPT_INVERT:	option is invertible (usable with !)
Packit Service 3880ab
 * %XTOPT_MAND:		option is mandatory
Packit Service 3880ab
 * %XTOPT_MULTI:	option may be specified multiple times
Packit Service 3880ab
 * %XTOPT_PUT:		store value into memory at @ptroff
Packit Service 3880ab
 * %XTOPT_NBO:		store value in network-byte order
Packit Service 3880ab
 * 			(only certain XTTYPEs recognize this)
Packit Service 3880ab
 */
Packit Service 3880ab
enum xt_option_flags {
Packit Service 3880ab
	XTOPT_INVERT = 1 << 0,
Packit Service 3880ab
	XTOPT_MAND   = 1 << 1,
Packit Service 3880ab
	XTOPT_MULTI  = 1 << 2,
Packit Service 3880ab
	XTOPT_PUT    = 1 << 3,
Packit Service 3880ab
	XTOPT_NBO    = 1 << 4,
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
/**
Packit Service 3880ab
 * @name:	name of option
Packit Service 3880ab
 * @type:	type of input and validation method, see %XTTYPE_*
Packit Service 3880ab
 * @id:		unique number (within extension) for option, 0-31
Packit Service 3880ab
 * @excl:	bitmask of flags that cannot be used with this option
Packit Service 3880ab
 * @also:	bitmask of flags that must be used with this option
Packit Service 3880ab
 * @flags:	bitmask of option flags, see %XTOPT_*
Packit Service 3880ab
 * @ptroff:	offset into private structure for member
Packit Service 3880ab
 * @size:	size of the item pointed to by @ptroff; this is a safeguard
Packit Service 3880ab
 * @min:	lowest allowed value (for singular integral types)
Packit Service 3880ab
 * @max:	highest allowed value (for singular integral types)
Packit Service 3880ab
 */
Packit Service 3880ab
struct xt_option_entry {
Packit Service 3880ab
	const char *name;
Packit Service 3880ab
	enum xt_option_type type;
Packit Service 3880ab
	unsigned int id, excl, also, flags;
Packit Service 3880ab
	unsigned int ptroff;
Packit Service 3880ab
	size_t size;
Packit Service 3880ab
	unsigned int min, max;
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
/**
Packit Service 3880ab
 * @arg:	input from command line
Packit Service 3880ab
 * @ext_name:	name of extension currently being processed
Packit Service 3880ab
 * @entry:	current option being processed
Packit Service 3880ab
 * @data:	per-extension kernel data block
Packit Service 3880ab
 * @xflags:	options of the extension that have been used
Packit Service 3880ab
 * @invert:	whether option was used with !
Packit Service 3880ab
 * @nvals:	number of results in uXX_multi
Packit Service 3880ab
 * @val:	parsed result
Packit Service 3880ab
 * @udata:	per-extension private scratch area
Packit Service 3880ab
 * 		(cf. xtables_{match,target}->udata_size)
Packit Service 3880ab
 */
Packit Service 3880ab
struct xt_option_call {
Packit Service 3880ab
	const char *arg, *ext_name;
Packit Service 3880ab
	const struct xt_option_entry *entry;
Packit Service 3880ab
	void *data;
Packit Service 3880ab
	unsigned int xflags;
Packit Service 3880ab
	bool invert;
Packit Service 3880ab
	uint8_t nvals;
Packit Service 3880ab
	union {
Packit Service 3880ab
		uint8_t u8, u8_range[2], syslog_level, protocol;
Packit Service 3880ab
		uint16_t u16, u16_range[2], port, port_range[2];
Packit Service 3880ab
		uint32_t u32, u32_range[2];
Packit Service 3880ab
		uint64_t u64, u64_range[2];
Packit Service 3880ab
		double dbl;
Packit Service 3880ab
		struct {
Packit Service 3880ab
			union nf_inet_addr haddr, hmask;
Packit Service 3880ab
			uint8_t hlen;
Packit Service 3880ab
		};
Packit Service 3880ab
		struct {
Packit Service 3880ab
			uint8_t tos_value, tos_mask;
Packit Service 3880ab
		};
Packit Service 3880ab
		struct {
Packit Service 3880ab
			uint32_t mark, mask;
Packit Service 3880ab
		};
Packit Service 3880ab
		uint8_t ethermac[6];
Packit Service 3880ab
	} val;
Packit Service 3880ab
	/* Wished for a world where the ones below were gone: */
Packit Service 3880ab
	union {
Packit Service 3880ab
		struct xt_entry_match **match;
Packit Service 3880ab
		struct xt_entry_target **target;
Packit Service 3880ab
	};
Packit Service 3880ab
	void *xt_entry;
Packit Service 3880ab
	void *udata;
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
/**
Packit Service 3880ab
 * @ext_name:	name of extension currently being processed
Packit Service 3880ab
 * @data:	per-extension (kernel) data block
Packit Service 3880ab
 * @udata:	per-extension private scratch area
Packit Service 3880ab
 * 		(cf. xtables_{match,target}->udata_size)
Packit Service 3880ab
 * @xflags:	options of the extension that have been used
Packit Service 3880ab
 */
Packit Service 3880ab
struct xt_fcheck_call {
Packit Service 3880ab
	const char *ext_name;
Packit Service 3880ab
	void *data, *udata;
Packit Service 3880ab
	unsigned int xflags;
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
/**
Packit Service 3880ab
 * A "linear"/linked-list based name<->id map, for files similar to
Packit Service 3880ab
 * /etc/iproute2/.
Packit Service 3880ab
 */
Packit Service 3880ab
struct xtables_lmap {
Packit Service 3880ab
	char *name;
Packit Service 3880ab
	int id;
Packit Service 3880ab
	struct xtables_lmap *next;
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
enum xtables_ext_flags {
Packit Service 3880ab
	XTABLES_EXT_ALIAS = 1 << 0,
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
#if XTABLES_VERSION_CODE >= 12
Packit Service 3880ab
struct xt_xlate;
Packit Service 3880ab
Packit Service 3880ab
struct xt_xlate_mt_params {
Packit Service 3880ab
	const void			*ip;
Packit Service 3880ab
	const struct xt_entry_match	*match;
Packit Service 3880ab
	int				numeric;
Packit Service 3880ab
	bool				escape_quotes;
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
struct xt_xlate_tg_params {
Packit Service 3880ab
	const void			*ip;
Packit Service 3880ab
	const struct xt_entry_target	*target;
Packit Service 3880ab
	int				numeric;
Packit Service 3880ab
	bool				escape_quotes;
Packit Service 3880ab
};
Packit Service 3880ab
#endif
Packit Service 3880ab
Packit Service 3880ab
/* Include file for additions: new matches and targets. */
Packit Service 3880ab
struct xtables_match
Packit Service 3880ab
{
Packit Service 3880ab
	/*
Packit Service 3880ab
	 * ABI/API version this module requires. Must be first member,
Packit Service 3880ab
	 * as the rest of this struct may be subject to ABI changes.
Packit Service 3880ab
	 */
Packit Service 3880ab
	const char *version;
Packit Service 3880ab
Packit Service 3880ab
	struct xtables_match *next;
Packit Service 3880ab
Packit Service 3880ab
	const char *name;
Packit Service 3880ab
	const char *real_name;
Packit Service 3880ab
Packit Service 3880ab
	/* Revision of match (0 by default). */
Packit Service 3880ab
	uint8_t revision;
Packit Service 3880ab
Packit Service 3880ab
	/* Extension flags */
Packit Service 3880ab
	uint8_t ext_flags;
Packit Service 3880ab
Packit Service 3880ab
	uint16_t family;
Packit Service 3880ab
Packit Service 3880ab
	/* Size of match data. */
Packit Service 3880ab
	size_t size;
Packit Service 3880ab
Packit Service 3880ab
	/* Size of match data relevant for userspace comparison purposes */
Packit Service 3880ab
	size_t userspacesize;
Packit Service 3880ab
Packit Service 3880ab
	/* Function which prints out usage message. */
Packit Service 3880ab
	void (*help)(void);
Packit Service 3880ab
Packit Service 3880ab
	/* Initialize the match. */
Packit Service 3880ab
	void (*init)(struct xt_entry_match *m);
Packit Service 3880ab
Packit Service 3880ab
	/* Function which parses command options; returns true if it
Packit Service 3880ab
           ate an option */
Packit Service 3880ab
	/* entry is struct ipt_entry for example */
Packit Service 3880ab
	int (*parse)(int c, char **argv, int invert, unsigned int *flags,
Packit Service 3880ab
		     const void *entry,
Packit Service 3880ab
		     struct xt_entry_match **match);
Packit Service 3880ab
Packit Service 3880ab
	/* Final check; exit if not ok. */
Packit Service 3880ab
	void (*final_check)(unsigned int flags);
Packit Service 3880ab
Packit Service 3880ab
	/* Prints out the match iff non-NULL: put space at end */
Packit Service 3880ab
	/* ip is struct ipt_ip * for example */
Packit Service 3880ab
	void (*print)(const void *ip,
Packit Service 3880ab
		      const struct xt_entry_match *match, int numeric);
Packit Service 3880ab
Packit Service 3880ab
	/* Saves the match info in parsable form to stdout. */
Packit Service 3880ab
	/* ip is struct ipt_ip * for example */
Packit Service 3880ab
	void (*save)(const void *ip, const struct xt_entry_match *match);
Packit Service 3880ab
Packit Service 3880ab
	/* Print match name or alias */
Packit Service 3880ab
	const char *(*alias)(const struct xt_entry_match *match);
Packit Service 3880ab
Packit Service 3880ab
	/* Pointer to list of extra command-line options */
Packit Service 3880ab
	const struct option *extra_opts;
Packit Service 3880ab
Packit Service 3880ab
	/* New parser */
Packit Service 3880ab
	void (*x6_parse)(struct xt_option_call *);
Packit Service 3880ab
	void (*x6_fcheck)(struct xt_fcheck_call *);
Packit Service 3880ab
	const struct xt_option_entry *x6_options;
Packit Service 3880ab
Packit Service 3880ab
#if XTABLES_VERSION_CODE >= 12
Packit Service 3880ab
	/* Translate iptables to nft */
Packit Service 3880ab
	int (*xlate)(struct xt_xlate *xl,
Packit Service 3880ab
		     const struct xt_xlate_mt_params *params);
Packit Service 3880ab
#endif
Packit Service 3880ab
Packit Service 3880ab
	/* Size of per-extension instance extra "global" scratch space */
Packit Service 3880ab
	size_t udata_size;
Packit Service 3880ab
Packit Service 3880ab
	/* Ignore these men behind the curtain: */
Packit Service 3880ab
	void *udata;
Packit Service 3880ab
	unsigned int option_offset;
Packit Service 3880ab
	struct xt_entry_match *m;
Packit Service 3880ab
	unsigned int mflags;
Packit Service 3880ab
	unsigned int loaded; /* simulate loading so options are merged properly */
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
struct xtables_target
Packit Service 3880ab
{
Packit Service 3880ab
	/*
Packit Service 3880ab
	 * ABI/API version this module requires. Must be first member,
Packit Service 3880ab
	 * as the rest of this struct may be subject to ABI changes.
Packit Service 3880ab
	 */
Packit Service 3880ab
	const char *version;
Packit Service 3880ab
Packit Service 3880ab
	struct xtables_target *next;
Packit Service 3880ab
Packit Service 3880ab
Packit Service 3880ab
	const char *name;
Packit Service 3880ab
Packit Service 3880ab
	/* Real target behind this, if any. */
Packit Service 3880ab
	const char *real_name;
Packit Service 3880ab
Packit Service 3880ab
	/* Revision of target (0 by default). */
Packit Service 3880ab
	uint8_t revision;
Packit Service 3880ab
Packit Service 3880ab
	/* Extension flags */
Packit Service 3880ab
	uint8_t ext_flags;
Packit Service 3880ab
Packit Service 3880ab
	uint16_t family;
Packit Service 3880ab
Packit Service 3880ab
Packit Service 3880ab
	/* Size of target data. */
Packit Service 3880ab
	size_t size;
Packit Service 3880ab
Packit Service 3880ab
	/* Size of target data relevant for userspace comparison purposes */
Packit Service 3880ab
	size_t userspacesize;
Packit Service 3880ab
Packit Service 3880ab
	/* Function which prints out usage message. */
Packit Service 3880ab
	void (*help)(void);
Packit Service 3880ab
Packit Service 3880ab
	/* Initialize the target. */
Packit Service 3880ab
	void (*init)(struct xt_entry_target *t);
Packit Service 3880ab
Packit Service 3880ab
	/* Function which parses command options; returns true if it
Packit Service 3880ab
           ate an option */
Packit Service 3880ab
	/* entry is struct ipt_entry for example */
Packit Service 3880ab
	int (*parse)(int c, char **argv, int invert, unsigned int *flags,
Packit Service 3880ab
		     const void *entry,
Packit Service 3880ab
		     struct xt_entry_target **targetinfo);
Packit Service 3880ab
Packit Service 3880ab
	/* Final check; exit if not ok. */
Packit Service 3880ab
	void (*final_check)(unsigned int flags);
Packit Service 3880ab
Packit Service 3880ab
	/* Prints out the target iff non-NULL: put space at end */
Packit Service 3880ab
	void (*print)(const void *ip,
Packit Service 3880ab
		      const struct xt_entry_target *target, int numeric);
Packit Service 3880ab
Packit Service 3880ab
	/* Saves the targinfo in parsable form to stdout. */
Packit Service 3880ab
	void (*save)(const void *ip,
Packit Service 3880ab
		     const struct xt_entry_target *target);
Packit Service 3880ab
Packit Service 3880ab
	/* Print target name or alias */
Packit Service 3880ab
	const char *(*alias)(const struct xt_entry_target *target);
Packit Service 3880ab
Packit Service 3880ab
	/* Pointer to list of extra command-line options */
Packit Service 3880ab
	const struct option *extra_opts;
Packit Service 3880ab
Packit Service 3880ab
	/* New parser */
Packit Service 3880ab
	void (*x6_parse)(struct xt_option_call *);
Packit Service 3880ab
	void (*x6_fcheck)(struct xt_fcheck_call *);
Packit Service 3880ab
	const struct xt_option_entry *x6_options;
Packit Service 3880ab
Packit Service 3880ab
#if XTABLES_VERSION_CODE >= 12
Packit Service 3880ab
	/* Translate iptables to nft */
Packit Service 3880ab
	int (*xlate)(struct xt_xlate *xl,
Packit Service 3880ab
		     const struct xt_xlate_tg_params *params);
Packit Service 3880ab
#endif
Packit Service 3880ab
Packit Service 3880ab
	size_t udata_size;
Packit Service 3880ab
Packit Service 3880ab
	/* Ignore these men behind the curtain: */
Packit Service 3880ab
	void *udata;
Packit Service 3880ab
	unsigned int option_offset;
Packit Service 3880ab
	struct xt_entry_target *t;
Packit Service 3880ab
	unsigned int tflags;
Packit Service 3880ab
	unsigned int used;
Packit Service 3880ab
	unsigned int loaded; /* simulate loading so options are merged properly */
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
struct xtables_rule_match {
Packit Service 3880ab
	struct xtables_rule_match *next;
Packit Service 3880ab
	struct xtables_match *match;
Packit Service 3880ab
	/* Multiple matches of the same type: the ones before
Packit Service 3880ab
	   the current one are completed from parsing point of view */
Packit Service 3880ab
	bool completed;
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
/**
Packit Service 3880ab
 * struct xtables_pprot -
Packit Service 3880ab
 *
Packit Service 3880ab
 * A few hardcoded protocols for 'all' and in case the user has no
Packit Service 3880ab
 * /etc/protocols.
Packit Service 3880ab
 */
Packit Service 3880ab
struct xtables_pprot {
Packit Service 3880ab
	const char *name;
Packit Service 3880ab
	uint8_t num;
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
enum xtables_tryload {
Packit Service 3880ab
	XTF_DONT_LOAD,
Packit Service 3880ab
	XTF_DURING_LOAD,
Packit Service 3880ab
	XTF_TRY_LOAD,
Packit Service 3880ab
	XTF_LOAD_MUST_SUCCEED,
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
enum xtables_exittype {
Packit Service 3880ab
	OTHER_PROBLEM = 1,
Packit Service 3880ab
	PARAMETER_PROBLEM,
Packit Service 3880ab
	VERSION_PROBLEM,
Packit Service 3880ab
	RESOURCE_PROBLEM,
Packit Service 3880ab
	XTF_ONLY_ONCE,
Packit Service 3880ab
	XTF_NO_INVERT,
Packit Service 3880ab
	XTF_BAD_VALUE,
Packit Service 3880ab
	XTF_ONE_ACTION,
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
struct xtables_globals
Packit Service 3880ab
{
Packit Service 3880ab
	unsigned int option_offset;
Packit Service 3880ab
	const char *program_name, *program_version;
Packit Service 3880ab
	struct option *orig_opts;
Packit Service 3880ab
	struct option *opts;
Packit Service 3880ab
	void (*exit_err)(enum xtables_exittype status, const char *msg, ...) __attribute__((noreturn, format(printf,2,3)));
Packit Service 3880ab
	int (*compat_rev)(const char *name, uint8_t rev, int opt);
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
#define XT_GETOPT_TABLEEND {.name = NULL, .has_arg = false}
Packit Service 3880ab
Packit Service 3880ab
#ifdef __cplusplus
Packit Service 3880ab
extern "C" {
Packit Service 3880ab
#endif
Packit Service 3880ab
Packit Service 3880ab
extern const char *xtables_modprobe_program;
Packit Service 3880ab
extern struct xtables_match *xtables_matches;
Packit Service 3880ab
extern struct xtables_target *xtables_targets;
Packit Service 3880ab
Packit Service 3880ab
extern void xtables_init(void);
Packit Service 3880ab
extern void xtables_set_nfproto(uint8_t);
Packit Service 3880ab
extern void *xtables_calloc(size_t, size_t);
Packit Service 3880ab
extern void *xtables_malloc(size_t);
Packit Service 3880ab
extern void *xtables_realloc(void *, size_t);
Packit Service 3880ab
Packit Service 3880ab
extern int xtables_insmod(const char *, const char *, bool);
Packit Service 3880ab
extern int xtables_load_ko(const char *, bool);
Packit Service 3880ab
extern int xtables_set_params(struct xtables_globals *xtp);
Packit Service 3880ab
extern void xtables_free_opts(int reset_offset);
Packit Service 3880ab
extern struct option *xtables_merge_options(struct option *origopts,
Packit Service 3880ab
	struct option *oldopts, const struct option *newopts,
Packit Service 3880ab
	unsigned int *option_offset);
Packit Service 3880ab
Packit Service 3880ab
extern int xtables_init_all(struct xtables_globals *xtp, uint8_t nfproto);
Packit Service 3880ab
extern struct xtables_match *xtables_find_match(const char *name,
Packit Service 3880ab
	enum xtables_tryload, struct xtables_rule_match **match);
Packit Service 3880ab
extern struct xtables_target *xtables_find_target(const char *name,
Packit Service 3880ab
	enum xtables_tryload);
Packit Service 3880ab
extern int xtables_compatible_revision(const char *name, uint8_t revision,
Packit Service 3880ab
				       int opt);
Packit Service 3880ab
Packit Service 3880ab
extern void xtables_rule_matches_free(struct xtables_rule_match **matches);
Packit Service 3880ab
Packit Service 3880ab
/* Your shared library should call one of these. */
Packit Service 3880ab
extern void xtables_register_match(struct xtables_match *me);
Packit Service 3880ab
extern void xtables_register_matches(struct xtables_match *, unsigned int);
Packit Service 3880ab
extern void xtables_register_target(struct xtables_target *me);
Packit Service 3880ab
extern void xtables_register_targets(struct xtables_target *, unsigned int);
Packit Service 3880ab
Packit Service 3880ab
extern bool xtables_strtoul(const char *, char **, uintmax_t *,
Packit Service 3880ab
	uintmax_t, uintmax_t);
Packit Service 3880ab
extern bool xtables_strtoui(const char *, char **, unsigned int *,
Packit Service 3880ab
	unsigned int, unsigned int);
Packit Service 3880ab
extern int xtables_service_to_port(const char *name, const char *proto);
Packit Service 3880ab
extern uint16_t xtables_parse_port(const char *port, const char *proto);
Packit Service 3880ab
extern void
Packit Service 3880ab
xtables_parse_interface(const char *arg, char *vianame, unsigned char *mask);
Packit Service 3880ab
Packit Service 3880ab
/* this is a special 64bit data type that is 8-byte aligned */
Packit Service 3880ab
#define aligned_u64 uint64_t __attribute__((aligned(8)))
Packit Service 3880ab
Packit Service 3880ab
extern struct xtables_globals *xt_params;
Packit Service 3880ab
#define xtables_error (xt_params->exit_err)
Packit Service 3880ab
Packit Service 3880ab
extern void xtables_param_act(unsigned int, const char *, ...);
Packit Service 3880ab
Packit Service 3880ab
extern const char *xtables_ipaddr_to_numeric(const struct in_addr *);
Packit Service 3880ab
extern const char *xtables_ipaddr_to_anyname(const struct in_addr *);
Packit Service 3880ab
extern const char *xtables_ipmask_to_numeric(const struct in_addr *);
Packit Service 3880ab
extern struct in_addr *xtables_numeric_to_ipaddr(const char *);
Packit Service 3880ab
extern struct in_addr *xtables_numeric_to_ipmask(const char *);
Packit Service 3880ab
extern int xtables_ipmask_to_cidr(const struct in_addr *);
Packit Service 3880ab
extern void xtables_ipparse_any(const char *, struct in_addr **,
Packit Service 3880ab
	struct in_addr *, unsigned int *);
Packit Service 3880ab
extern void xtables_ipparse_multiple(const char *, struct in_addr **,
Packit Service 3880ab
	struct in_addr **, unsigned int *);
Packit Service 3880ab
Packit Service 3880ab
extern struct in6_addr *xtables_numeric_to_ip6addr(const char *);
Packit Service 3880ab
extern const char *xtables_ip6addr_to_numeric(const struct in6_addr *);
Packit Service 3880ab
extern const char *xtables_ip6addr_to_anyname(const struct in6_addr *);
Packit Service 3880ab
extern const char *xtables_ip6mask_to_numeric(const struct in6_addr *);
Packit Service 3880ab
extern int xtables_ip6mask_to_cidr(const struct in6_addr *);
Packit Service 3880ab
extern void xtables_ip6parse_any(const char *, struct in6_addr **,
Packit Service 3880ab
	struct in6_addr *, unsigned int *);
Packit Service 3880ab
extern void xtables_ip6parse_multiple(const char *, struct in6_addr **,
Packit Service 3880ab
	struct in6_addr **, unsigned int *);
Packit Service 3880ab
Packit Service 3880ab
/**
Packit Service 3880ab
 * Print the specified value to standard output, quoting dangerous
Packit Service 3880ab
 * characters if required.
Packit Service 3880ab
 */
Packit Service 3880ab
extern void xtables_save_string(const char *value);
Packit Service 3880ab
Packit Service 3880ab
#define FMT_NUMERIC		0x0001
Packit Service 3880ab
#define FMT_NOCOUNTS		0x0002
Packit Service 3880ab
#define FMT_KILOMEGAGIGA	0x0004
Packit Service 3880ab
#define FMT_OPTIONS		0x0008
Packit Service 3880ab
#define FMT_NOTABLE		0x0010
Packit Service 3880ab
#define FMT_NOTARGET		0x0020
Packit Service 3880ab
#define FMT_VIA			0x0040
Packit Service 3880ab
#define FMT_NONEWLINE		0x0080
Packit Service 3880ab
#define FMT_LINENUMBERS		0x0100
Packit Service 3880ab
Packit Service 3880ab
#define FMT_PRINT_RULE (FMT_NOCOUNTS | FMT_OPTIONS | FMT_VIA \
Packit Service 3880ab
                        | FMT_NUMERIC | FMT_NOTABLE)
Packit Service 3880ab
#define FMT(tab,notab) ((format) & FMT_NOTABLE ? (notab) : (tab))
Packit Service 3880ab
Packit Service 3880ab
extern void xtables_print_num(uint64_t number, unsigned int format);
Packit Service 3880ab
Packit Service 3880ab
#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
Packit Service 3880ab
#	ifdef _INIT
Packit Service 3880ab
#		undef _init
Packit Service 3880ab
#		define _init _INIT
Packit Service 3880ab
#	endif
Packit Service 3880ab
	extern void init_extensions(void);
Packit Service 3880ab
	extern void init_extensions4(void);
Packit Service 3880ab
	extern void init_extensions6(void);
Packit Service 3880ab
#else
Packit Service 3880ab
#	define _init __attribute__((constructor)) _INIT
Packit Service 3880ab
#endif
Packit Service 3880ab
Packit Service 3880ab
extern const struct xtables_pprot xtables_chain_protos[];
Packit Service 3880ab
extern uint16_t xtables_parse_protocol(const char *s);
Packit Service 3880ab
Packit Service 3880ab
/* kernel revision handling */
Packit Service 3880ab
extern int kernel_version;
Packit Service 3880ab
extern void get_kernel_version(void);
Packit Service 3880ab
#define LINUX_VERSION(x,y,z)	(0x10000*(x) + 0x100*(y) + z)
Packit Service 3880ab
#define LINUX_VERSION_MAJOR(x)	(((x)>>16) & 0xFF)
Packit Service 3880ab
#define LINUX_VERSION_MINOR(x)	(((x)>> 8) & 0xFF)
Packit Service 3880ab
#define LINUX_VERSION_PATCH(x)	( (x)      & 0xFF)
Packit Service 3880ab
Packit Service 3880ab
/* xtoptions.c */
Packit Service 3880ab
extern void xtables_option_metavalidate(const char *,
Packit Service 3880ab
					const struct xt_option_entry *);
Packit Service 3880ab
extern struct option *xtables_options_xfrm(struct option *, struct option *,
Packit Service 3880ab
					   const struct xt_option_entry *,
Packit Service 3880ab
					   unsigned int *);
Packit Service 3880ab
extern void xtables_option_parse(struct xt_option_call *);
Packit Service 3880ab
extern void xtables_option_tpcall(unsigned int, char **, bool,
Packit Service 3880ab
				  struct xtables_target *, void *);
Packit Service 3880ab
extern void xtables_option_mpcall(unsigned int, char **, bool,
Packit Service 3880ab
				  struct xtables_match *, void *);
Packit Service 3880ab
extern void xtables_option_tfcall(struct xtables_target *);
Packit Service 3880ab
extern void xtables_option_mfcall(struct xtables_match *);
Packit Service 3880ab
extern void xtables_options_fcheck(const char *, unsigned int,
Packit Service 3880ab
				   const struct xt_option_entry *);
Packit Service 3880ab
Packit Service 3880ab
extern struct xtables_lmap *xtables_lmap_init(const char *);
Packit Service 3880ab
extern void xtables_lmap_free(struct xtables_lmap *);
Packit Service 3880ab
extern int xtables_lmap_name2id(const struct xtables_lmap *, const char *);
Packit Service 3880ab
extern const char *xtables_lmap_id2name(const struct xtables_lmap *, int);
Packit Service 3880ab
Packit Service 3880ab
#ifdef XTABLES_INTERNAL
Packit Service 3880ab
Packit Service 3880ab
/* Shipped modules rely on this... */
Packit Service 3880ab
Packit Service 3880ab
#	ifndef ARRAY_SIZE
Packit Service 3880ab
#		define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
Packit Service 3880ab
#	endif
Packit Service 3880ab
Packit Service 3880ab
extern void _init(void);
Packit Service 3880ab
Packit Service 3880ab
#endif
Packit Service 3880ab
Packit Service 3880ab
#ifdef __cplusplus
Packit Service 3880ab
} /* extern "C" */
Packit Service 3880ab
#endif
Packit Service 3880ab
Packit Service 3880ab
#endif /* _XTABLES_H */