Blame include/uapi/linux/netfilter_ipv4/ip_tables.h

Packit Service 3880ab
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
Packit Service 3880ab
/*
Packit Service 3880ab
 * 25-Jul-1998 Major changes to allow for ip chain table
Packit Service 3880ab
 *
Packit Service 3880ab
 * 3-Jan-2000 Named tables to allow packet selection for different uses.
Packit Service 3880ab
 */
Packit Service 3880ab
Packit Service 3880ab
/*
Packit Service 3880ab
 * 	Format of an IP firewall descriptor
Packit Service 3880ab
 *
Packit Service 3880ab
 * 	src, dst, src_mask, dst_mask are always stored in network byte order.
Packit Service 3880ab
 * 	flags are stored in host byte order (of course).
Packit Service 3880ab
 * 	Port numbers are stored in HOST byte order.
Packit Service 3880ab
 */
Packit Service 3880ab
Packit Service 3880ab
#ifndef _IPTABLES_H
Packit Service 3880ab
#define _IPTABLES_H
Packit Service 3880ab
Packit Service 3880ab
#include <linux/types.h>
Packit Service 3880ab
Packit Service 3880ab
#include <linux/if.h>
Packit Service 3880ab
#include <linux/netfilter_ipv4.h>
Packit Service 3880ab
Packit Service 3880ab
#include <linux/netfilter/x_tables.h>
Packit Service 3880ab
Packit Service 3880ab
#define IPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN
Packit Service 3880ab
#define IPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN
Packit Service 3880ab
#define ipt_match xt_match
Packit Service 3880ab
#define ipt_target xt_target
Packit Service 3880ab
#define ipt_table xt_table
Packit Service 3880ab
#define ipt_get_revision xt_get_revision
Packit Service 3880ab
#define ipt_entry_match xt_entry_match
Packit Service 3880ab
#define ipt_entry_target xt_entry_target
Packit Service 3880ab
#define ipt_standard_target xt_standard_target
Packit Service 3880ab
#define ipt_error_target xt_error_target
Packit Service 3880ab
#define ipt_counters xt_counters
Packit Service 3880ab
#define IPT_CONTINUE XT_CONTINUE
Packit Service 3880ab
#define IPT_RETURN XT_RETURN
Packit Service 3880ab
Packit Service 3880ab
/* This group is older than old (iptables < v1.4.0-rc1~89) */
Packit Service 3880ab
#include <linux/netfilter/xt_tcpudp.h>
Packit Service 3880ab
#define ipt_udp xt_udp
Packit Service 3880ab
#define ipt_tcp xt_tcp
Packit Service 3880ab
#define IPT_TCP_INV_SRCPT	XT_TCP_INV_SRCPT
Packit Service 3880ab
#define IPT_TCP_INV_DSTPT	XT_TCP_INV_DSTPT
Packit Service 3880ab
#define IPT_TCP_INV_FLAGS	XT_TCP_INV_FLAGS
Packit Service 3880ab
#define IPT_TCP_INV_OPTION	XT_TCP_INV_OPTION
Packit Service 3880ab
#define IPT_TCP_INV_MASK	XT_TCP_INV_MASK
Packit Service 3880ab
#define IPT_UDP_INV_SRCPT	XT_UDP_INV_SRCPT
Packit Service 3880ab
#define IPT_UDP_INV_DSTPT	XT_UDP_INV_DSTPT
Packit Service 3880ab
#define IPT_UDP_INV_MASK	XT_UDP_INV_MASK
Packit Service 3880ab
Packit Service 3880ab
/* The argument to IPT_SO_ADD_COUNTERS. */
Packit Service 3880ab
#define ipt_counters_info xt_counters_info
Packit Service 3880ab
/* Standard return verdict, or do jump. */
Packit Service 3880ab
#define IPT_STANDARD_TARGET XT_STANDARD_TARGET
Packit Service 3880ab
/* Error verdict. */
Packit Service 3880ab
#define IPT_ERROR_TARGET XT_ERROR_TARGET
Packit Service 3880ab
Packit Service 3880ab
/* fn returns 0 to continue iteration */
Packit Service 3880ab
#define IPT_MATCH_ITERATE(e, fn, args...) \
Packit Service 3880ab
	XT_MATCH_ITERATE(struct ipt_entry, e, fn, ## args)
Packit Service 3880ab
Packit Service 3880ab
/* fn returns 0 to continue iteration */
Packit Service 3880ab
#define IPT_ENTRY_ITERATE(entries, size, fn, args...) \
Packit Service 3880ab
	XT_ENTRY_ITERATE(struct ipt_entry, entries, size, fn, ## args)
Packit Service 3880ab
Packit Service 3880ab
/* Yes, Virginia, you have to zero the padding. */
Packit Service 3880ab
struct ipt_ip {
Packit Service 3880ab
	/* Source and destination IP addr */
Packit Service 3880ab
	struct in_addr src, dst;
Packit Service 3880ab
	/* Mask for src and dest IP addr */
Packit Service 3880ab
	struct in_addr smsk, dmsk;
Packit Service 3880ab
	char iniface[IFNAMSIZ], outiface[IFNAMSIZ];
Packit Service 3880ab
	unsigned char iniface_mask[IFNAMSIZ], outiface_mask[IFNAMSIZ];
Packit Service 3880ab
Packit Service 3880ab
	/* Protocol, 0 = ANY */
Packit Service 3880ab
	__u16 proto;
Packit Service 3880ab
Packit Service 3880ab
	/* Flags word */
Packit Service 3880ab
	__u8 flags;
Packit Service 3880ab
	/* Inverse flags */
Packit Service 3880ab
	__u8 invflags;
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
/* Values for "flag" field in struct ipt_ip (general ip structure). */
Packit Service 3880ab
#define IPT_F_FRAG		0x01	/* Set if rule is a fragment rule */
Packit Service 3880ab
#define IPT_F_GOTO		0x02	/* Set if jump is a goto */
Packit Service 3880ab
#define IPT_F_MASK		0x03	/* All possible flag bits mask. */
Packit Service 3880ab
Packit Service 3880ab
/* Values for "inv" field in struct ipt_ip. */
Packit Service 3880ab
#define IPT_INV_VIA_IN		0x01	/* Invert the sense of IN IFACE. */
Packit Service 3880ab
#define IPT_INV_VIA_OUT		0x02	/* Invert the sense of OUT IFACE */
Packit Service 3880ab
#define IPT_INV_TOS		0x04	/* Invert the sense of TOS. */
Packit Service 3880ab
#define IPT_INV_SRCIP		0x08	/* Invert the sense of SRC IP. */
Packit Service 3880ab
#define IPT_INV_DSTIP		0x10	/* Invert the sense of DST OP. */
Packit Service 3880ab
#define IPT_INV_FRAG		0x20	/* Invert the sense of FRAG. */
Packit Service 3880ab
#define IPT_INV_PROTO		XT_INV_PROTO
Packit Service 3880ab
#define IPT_INV_MASK		0x7F	/* All possible flag bits mask. */
Packit Service 3880ab
Packit Service 3880ab
/* This structure defines each of the firewall rules.  Consists of 3
Packit Service 3880ab
   parts which are 1) general IP header stuff 2) match specific
Packit Service 3880ab
   stuff 3) the target to perform if the rule matches */
Packit Service 3880ab
struct ipt_entry {
Packit Service 3880ab
	struct ipt_ip ip;
Packit Service 3880ab
Packit Service 3880ab
	/* Mark with fields that we care about. */
Packit Service 3880ab
	unsigned int nfcache;
Packit Service 3880ab
Packit Service 3880ab
	/* Size of ipt_entry + matches */
Packit Service 3880ab
	__u16 target_offset;
Packit Service 3880ab
	/* Size of ipt_entry + matches + target */
Packit Service 3880ab
	__u16 next_offset;
Packit Service 3880ab
Packit Service 3880ab
	/* Back pointer */
Packit Service 3880ab
	unsigned int comefrom;
Packit Service 3880ab
Packit Service 3880ab
	/* Packet and byte counters. */
Packit Service 3880ab
	struct xt_counters counters;
Packit Service 3880ab
Packit Service 3880ab
	/* The matches (if any), then the target. */
Packit Service 3880ab
	unsigned char elems[0];
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
/*
Packit Service 3880ab
 * New IP firewall options for [gs]etsockopt at the RAW IP level.
Packit Service 3880ab
 * Unlike BSD Linux inherits IP options so you don't have to use a raw
Packit Service 3880ab
 * socket for this. Instead we check rights in the calls.
Packit Service 3880ab
 *
Packit Service 3880ab
 * ATTENTION: check linux/in.h before adding new number here.
Packit Service 3880ab
 */
Packit Service 3880ab
#define IPT_BASE_CTL		64
Packit Service 3880ab
Packit Service 3880ab
#define IPT_SO_SET_REPLACE	(IPT_BASE_CTL)
Packit Service 3880ab
#define IPT_SO_SET_ADD_COUNTERS	(IPT_BASE_CTL + 1)
Packit Service 3880ab
#define IPT_SO_SET_MAX		IPT_SO_SET_ADD_COUNTERS
Packit Service 3880ab
Packit Service 3880ab
#define IPT_SO_GET_INFO			(IPT_BASE_CTL)
Packit Service 3880ab
#define IPT_SO_GET_ENTRIES		(IPT_BASE_CTL + 1)
Packit Service 3880ab
#define IPT_SO_GET_REVISION_MATCH	(IPT_BASE_CTL + 2)
Packit Service 3880ab
#define IPT_SO_GET_REVISION_TARGET	(IPT_BASE_CTL + 3)
Packit Service 3880ab
#define IPT_SO_GET_MAX			IPT_SO_GET_REVISION_TARGET
Packit Service 3880ab
Packit Service 3880ab
/* ICMP matching stuff */
Packit Service 3880ab
struct ipt_icmp {
Packit Service 3880ab
	__u8 type;				/* type to match */
Packit Service 3880ab
	__u8 code[2];				/* range of code */
Packit Service 3880ab
	__u8 invflags;				/* Inverse flags */
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
/* Values for "inv" field for struct ipt_icmp. */
Packit Service 3880ab
#define IPT_ICMP_INV	0x01	/* Invert the sense of type/code test */
Packit Service 3880ab
Packit Service 3880ab
/* The argument to IPT_SO_GET_INFO */
Packit Service 3880ab
struct ipt_getinfo {
Packit Service 3880ab
	/* Which table: caller fills this in. */
Packit Service 3880ab
	char name[XT_TABLE_MAXNAMELEN];
Packit Service 3880ab
Packit Service 3880ab
	/* Kernel fills these in. */
Packit Service 3880ab
	/* Which hook entry points are valid: bitmask */
Packit Service 3880ab
	unsigned int valid_hooks;
Packit Service 3880ab
Packit Service 3880ab
	/* Hook entry points: one per netfilter hook. */
Packit Service 3880ab
	unsigned int hook_entry[NF_INET_NUMHOOKS];
Packit Service 3880ab
Packit Service 3880ab
	/* Underflow points. */
Packit Service 3880ab
	unsigned int underflow[NF_INET_NUMHOOKS];
Packit Service 3880ab
Packit Service 3880ab
	/* Number of entries */
Packit Service 3880ab
	unsigned int num_entries;
Packit Service 3880ab
Packit Service 3880ab
	/* Size of entries. */
Packit Service 3880ab
	unsigned int size;
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
/* The argument to IPT_SO_SET_REPLACE. */
Packit Service 3880ab
struct ipt_replace {
Packit Service 3880ab
	/* Which table. */
Packit Service 3880ab
	char name[XT_TABLE_MAXNAMELEN];
Packit Service 3880ab
Packit Service 3880ab
	/* Which hook entry points are valid: bitmask.  You can't
Packit Service 3880ab
           change this. */
Packit Service 3880ab
	unsigned int valid_hooks;
Packit Service 3880ab
Packit Service 3880ab
	/* Number of entries */
Packit Service 3880ab
	unsigned int num_entries;
Packit Service 3880ab
Packit Service 3880ab
	/* Total size of new entries */
Packit Service 3880ab
	unsigned int size;
Packit Service 3880ab
Packit Service 3880ab
	/* Hook entry points. */
Packit Service 3880ab
	unsigned int hook_entry[NF_INET_NUMHOOKS];
Packit Service 3880ab
Packit Service 3880ab
	/* Underflow points. */
Packit Service 3880ab
	unsigned int underflow[NF_INET_NUMHOOKS];
Packit Service 3880ab
Packit Service 3880ab
	/* Information about old entries: */
Packit Service 3880ab
	/* Number of counters (must be equal to current number of entries). */
Packit Service 3880ab
	unsigned int num_counters;
Packit Service 3880ab
	/* The old entries' counters. */
Packit Service 3880ab
	struct xt_counters *counters;
Packit Service 3880ab
Packit Service 3880ab
	/* The entries (hang off end: not really an array). */
Packit Service 3880ab
	struct ipt_entry entries[0];
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
/* The argument to IPT_SO_GET_ENTRIES. */
Packit Service 3880ab
struct ipt_get_entries {
Packit Service 3880ab
	/* Which table: user fills this in. */
Packit Service 3880ab
	char name[XT_TABLE_MAXNAMELEN];
Packit Service 3880ab
Packit Service 3880ab
	/* User fills this in: total entry size. */
Packit Service 3880ab
	unsigned int size;
Packit Service 3880ab
Packit Service 3880ab
	/* The entries. */
Packit Service 3880ab
	struct ipt_entry entrytable[0];
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
/* Helper functions */
Packit Service 3880ab
static __inline__ struct xt_entry_target *
Packit Service 3880ab
ipt_get_target(struct ipt_entry *e)
Packit Service 3880ab
{
Packit Service 3880ab
	return (struct xt_entry_target *)((char *)e + e->target_offset);
Packit Service 3880ab
}
Packit Service 3880ab
Packit Service 3880ab
/*
Packit Service 3880ab
 *	Main firewall chains definitions and global var's definitions.
Packit Service 3880ab
 */
Packit Service 3880ab
#endif /* _IPTABLES_H */