2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* ebtables
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Bart De Schuymer <bdschuym@pandora.be>
|
|
|
|
*
|
|
|
|
* ebtables.c,v 2.0, April, 2002
|
|
|
|
*
|
|
|
|
* This code is stongly inspired on the iptables code which is
|
|
|
|
* Copyright (C) 1999 Paul `Rusty' Russell & Michael J. Neuling
|
|
|
|
*/
|
|
|
|
#ifndef __LINUX_BRIDGE_EFF_H
|
|
|
|
#define __LINUX_BRIDGE_EFF_H
|
|
|
|
|
2012-10-09 02:48:58 -06:00
|
|
|
#include <uapi/linux/netfilter_bridge/ebtables.h>
|
2006-11-30 20:28:48 -07:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* return values for match() functions */
|
|
|
|
#define EBT_MATCH 0
|
|
|
|
#define EBT_NOMATCH 1
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
struct ebt_match {
|
2005-04-16 16:20:36 -06:00
|
|
|
struct list_head list;
|
|
|
|
const char name[EBT_FUNCTION_MAXNAMELEN];
|
2008-10-08 03:35:13 -06:00
|
|
|
bool (*match)(const struct sk_buff *skb, const struct net_device *in,
|
2008-10-08 03:35:15 -06:00
|
|
|
const struct net_device *out, const struct xt_match *match,
|
|
|
|
const void *matchinfo, int offset, unsigned int protoff,
|
|
|
|
bool *hotdrop);
|
|
|
|
bool (*checkentry)(const char *table, const void *entry,
|
|
|
|
const struct xt_match *match, void *matchinfo,
|
|
|
|
unsigned int hook_mask);
|
|
|
|
void (*destroy)(const struct xt_match *match, void *matchinfo);
|
2008-10-08 03:35:13 -06:00
|
|
|
unsigned int matchsize;
|
2008-10-08 03:35:14 -06:00
|
|
|
u_int8_t revision;
|
|
|
|
u_int8_t family;
|
2005-04-16 16:20:36 -06:00
|
|
|
struct module *me;
|
|
|
|
};
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
struct ebt_watcher {
|
2005-04-16 16:20:36 -06:00
|
|
|
struct list_head list;
|
|
|
|
const char name[EBT_FUNCTION_MAXNAMELEN];
|
2008-10-08 03:35:15 -06:00
|
|
|
unsigned int (*target)(struct sk_buff *skb,
|
|
|
|
const struct net_device *in, const struct net_device *out,
|
|
|
|
unsigned int hook_num, const struct xt_target *target,
|
|
|
|
const void *targinfo);
|
|
|
|
bool (*checkentry)(const char *table, const void *entry,
|
|
|
|
const struct xt_target *target, void *targinfo,
|
|
|
|
unsigned int hook_mask);
|
|
|
|
void (*destroy)(const struct xt_target *target, void *targinfo);
|
2008-10-08 03:35:13 -06:00
|
|
|
unsigned int targetsize;
|
2008-10-08 03:35:14 -06:00
|
|
|
u_int8_t revision;
|
|
|
|
u_int8_t family;
|
2005-04-16 16:20:36 -06:00
|
|
|
struct module *me;
|
|
|
|
};
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
struct ebt_target {
|
2005-04-16 16:20:36 -06:00
|
|
|
struct list_head list;
|
|
|
|
const char name[EBT_FUNCTION_MAXNAMELEN];
|
2008-10-08 03:35:13 -06:00
|
|
|
/* returns one of the standard EBT_* verdicts */
|
2008-10-08 03:35:15 -06:00
|
|
|
unsigned int (*target)(struct sk_buff *skb,
|
|
|
|
const struct net_device *in, const struct net_device *out,
|
|
|
|
unsigned int hook_num, const struct xt_target *target,
|
|
|
|
const void *targinfo);
|
|
|
|
bool (*checkentry)(const char *table, const void *entry,
|
|
|
|
const struct xt_target *target, void *targinfo,
|
|
|
|
unsigned int hook_mask);
|
|
|
|
void (*destroy)(const struct xt_target *target, void *targinfo);
|
2008-10-08 03:35:13 -06:00
|
|
|
unsigned int targetsize;
|
2008-10-08 03:35:14 -06:00
|
|
|
u_int8_t revision;
|
|
|
|
u_int8_t family;
|
2005-04-16 16:20:36 -06:00
|
|
|
struct module *me;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* used for jumping from and into user defined chains (udc) */
|
2009-11-04 10:50:58 -07:00
|
|
|
struct ebt_chainstack {
|
2005-04-16 16:20:36 -06:00
|
|
|
struct ebt_entries *chaininfo; /* pointer to chain data */
|
|
|
|
struct ebt_entry *e; /* pointer to entry data */
|
|
|
|
unsigned int n; /* n'th entry */
|
|
|
|
};
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
struct ebt_table_info {
|
2005-04-16 16:20:36 -06:00
|
|
|
/* total size of the entries */
|
|
|
|
unsigned int entries_size;
|
|
|
|
unsigned int nentries;
|
|
|
|
/* pointers to the start of the chains */
|
|
|
|
struct ebt_entries *hook_entry[NF_BR_NUMHOOKS];
|
|
|
|
/* room to maintain the stack used for jumping from and into udc */
|
|
|
|
struct ebt_chainstack **chainstack;
|
|
|
|
char *entries;
|
|
|
|
struct ebt_counter counters[0] ____cacheline_aligned;
|
|
|
|
};
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
struct ebt_table {
|
2005-04-16 16:20:36 -06:00
|
|
|
struct list_head list;
|
|
|
|
char name[EBT_TABLE_MAXNAMELEN];
|
2006-11-30 20:28:48 -07:00
|
|
|
struct ebt_replace_kernel *table;
|
2005-04-16 16:20:36 -06:00
|
|
|
unsigned int valid_hooks;
|
|
|
|
rwlock_t lock;
|
|
|
|
/* e.g. could be the table explicitly only allows certain
|
|
|
|
* matches, targets, ... 0 == let it in */
|
|
|
|
int (*check)(const struct ebt_table_info *info,
|
|
|
|
unsigned int valid_hooks);
|
|
|
|
/* the data used by the kernel */
|
|
|
|
struct ebt_table_info *private;
|
|
|
|
struct module *me;
|
|
|
|
};
|
|
|
|
|
2012-02-21 05:26:14 -07:00
|
|
|
#define EBT_ALIGN(s) (((s) + (__alignof__(struct _xt_align)-1)) & \
|
|
|
|
~(__alignof__(struct _xt_align)-1))
|
2008-11-04 06:27:15 -07:00
|
|
|
extern struct ebt_table *ebt_register_table(struct net *net,
|
2009-08-24 06:56:30 -06:00
|
|
|
const struct ebt_table *table);
|
2010-01-18 00:25:47 -07:00
|
|
|
extern void ebt_unregister_table(struct net *net, struct ebt_table *table);
|
2007-10-15 01:53:15 -06:00
|
|
|
extern unsigned int ebt_do_table(unsigned int hook, struct sk_buff *skb,
|
2005-04-16 16:20:36 -06:00
|
|
|
const struct net_device *in, const struct net_device *out,
|
|
|
|
struct ebt_table *table);
|
|
|
|
|
|
|
|
/* Used in the kernel match() functions */
|
|
|
|
#define FWINV(bool,invflg) ((bool) ^ !!(info->invflags & invflg))
|
|
|
|
/* True if the hook mask denotes that the rule is in a base chain,
|
|
|
|
* used in the check() functions */
|
2008-10-08 03:35:19 -06:00
|
|
|
#define BASE_CHAIN (par->hook_mask & (1 << NF_BR_NUMHOOKS))
|
2005-04-16 16:20:36 -06:00
|
|
|
/* Clear the bit in the hook mask that tells if the rule is on a base chain */
|
2008-10-08 03:35:19 -06:00
|
|
|
#define CLEAR_BASE_CHAIN_BIT (par->hook_mask &= ~(1 << NF_BR_NUMHOOKS))
|
2005-04-16 16:20:36 -06:00
|
|
|
/* True if the target is not a standard target */
|
|
|
|
#define INVALID_TARGET (info->target < -NUM_STANDARD_TARGETS || info->target >= 0)
|
|
|
|
|
|
|
|
#endif
|