License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-2.6-block.git] / include / linux / netfilter_bridge / ebtables.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
1da177e4
LT
2/*
3 * ebtables
4 *
5 * Authors:
6 * Bart De Schuymer <bdschuym@pandora.be>
7 *
8 * ebtables.c,v 2.0, April, 2002
9 *
069d4a7b 10 * This code is strongly inspired by the iptables code which is
1da177e4
LT
11 * Copyright (C) 1999 Paul `Rusty' Russell & Michael J. Neuling
12 */
1da177e4
LT
13#ifndef __LINUX_BRIDGE_EFF_H
14#define __LINUX_BRIDGE_EFF_H
1da177e4 15
24477e57
PNA
16#include <linux/if.h>
17#include <linux/if_ether.h>
55c5cd3c 18#include <uapi/linux/netfilter_bridge/ebtables.h>
1e419cd9 19
1da177e4
LT
20/* return values for match() functions */
21#define EBT_MATCH 0
22#define EBT_NOMATCH 1
23
d94d9fee 24struct ebt_match {
1da177e4
LT
25 struct list_head list;
26 const char name[EBT_FUNCTION_MAXNAMELEN];
8cc784ee 27 bool (*match)(const struct sk_buff *skb, const struct net_device *in,
2d06d4a5
JE
28 const struct net_device *out, const struct xt_match *match,
29 const void *matchinfo, int offset, unsigned int protoff,
30 bool *hotdrop);
31 bool (*checkentry)(const char *table, const void *entry,
32 const struct xt_match *match, void *matchinfo,
33 unsigned int hook_mask);
34 void (*destroy)(const struct xt_match *match, void *matchinfo);
18219d3f 35 unsigned int matchsize;
001a18d3
JE
36 u_int8_t revision;
37 u_int8_t family;
1da177e4
LT
38 struct module *me;
39};
40
d94d9fee 41struct ebt_watcher {
1da177e4
LT
42 struct list_head list;
43 const char name[EBT_FUNCTION_MAXNAMELEN];
2d06d4a5
JE
44 unsigned int (*target)(struct sk_buff *skb,
45 const struct net_device *in, const struct net_device *out,
46 unsigned int hook_num, const struct xt_target *target,
47 const void *targinfo);
48 bool (*checkentry)(const char *table, const void *entry,
49 const struct xt_target *target, void *targinfo,
50 unsigned int hook_mask);
51 void (*destroy)(const struct xt_target *target, void *targinfo);
18219d3f 52 unsigned int targetsize;
001a18d3
JE
53 u_int8_t revision;
54 u_int8_t family;
1da177e4
LT
55 struct module *me;
56};
57
d94d9fee 58struct ebt_target {
1da177e4
LT
59 struct list_head list;
60 const char name[EBT_FUNCTION_MAXNAMELEN];
0ac6ab1f 61 /* returns one of the standard EBT_* verdicts */
2d06d4a5
JE
62 unsigned int (*target)(struct sk_buff *skb,
63 const struct net_device *in, const struct net_device *out,
64 unsigned int hook_num, const struct xt_target *target,
65 const void *targinfo);
66 bool (*checkentry)(const char *table, const void *entry,
67 const struct xt_target *target, void *targinfo,
68 unsigned int hook_mask);
69 void (*destroy)(const struct xt_target *target, void *targinfo);
18219d3f 70 unsigned int targetsize;
001a18d3
JE
71 u_int8_t revision;
72 u_int8_t family;
1da177e4
LT
73 struct module *me;
74};
75
76/* used for jumping from and into user defined chains (udc) */
d94d9fee 77struct ebt_chainstack {
1da177e4
LT
78 struct ebt_entries *chaininfo; /* pointer to chain data */
79 struct ebt_entry *e; /* pointer to entry data */
80 unsigned int n; /* n'th entry */
81};
82
d94d9fee 83struct ebt_table_info {
1da177e4
LT
84 /* total size of the entries */
85 unsigned int entries_size;
86 unsigned int nentries;
87 /* pointers to the start of the chains */
88 struct ebt_entries *hook_entry[NF_BR_NUMHOOKS];
89 /* room to maintain the stack used for jumping from and into udc */
90 struct ebt_chainstack **chainstack;
91 char *entries;
92 struct ebt_counter counters[0] ____cacheline_aligned;
93};
94
d94d9fee 95struct ebt_table {
1da177e4
LT
96 struct list_head list;
97 char name[EBT_TABLE_MAXNAMELEN];
1e419cd9 98 struct ebt_replace_kernel *table;
1da177e4
LT
99 unsigned int valid_hooks;
100 rwlock_t lock;
101 /* e.g. could be the table explicitly only allows certain
102 * matches, targets, ... 0 == let it in */
103 int (*check)(const struct ebt_table_info *info,
104 unsigned int valid_hooks);
105 /* the data used by the kernel */
106 struct ebt_table_info *private;
107 struct module *me;
108};
109
88ba136d
JW
110#define EBT_ALIGN(s) (((s) + (__alignof__(struct _xt_align)-1)) & \
111 ~(__alignof__(struct _xt_align)-1))
e6b72ee8
AS
112extern int ebt_register_table(struct net *net,
113 const struct ebt_table *table,
114 const struct nf_hook_ops *ops,
115 struct ebt_table **res);
aee12a0a
FW
116extern void ebt_unregister_table(struct net *net, struct ebt_table *table,
117 const struct nf_hook_ops *);
97b59c3a
EB
118extern unsigned int ebt_do_table(struct sk_buff *skb,
119 const struct nf_hook_state *state,
120 struct ebt_table *table);
1da177e4 121
1da177e4
LT
122/* True if the hook mask denotes that the rule is in a base chain,
123 * used in the check() functions */
af5d6dc2 124#define BASE_CHAIN (par->hook_mask & (1 << NF_BR_NUMHOOKS))
1da177e4 125/* Clear the bit in the hook mask that tells if the rule is on a base chain */
af5d6dc2 126#define CLEAR_BASE_CHAIN_BIT (par->hook_mask &= ~(1 << NF_BR_NUMHOOKS))
1da177e4 127
c953d635
GF
128static inline bool ebt_invalid_target(int target)
129{
130 return (target < -NUM_STANDARD_TARGETS || target >= 0);
131}
132
1da177e4 133#endif