blob: 533ee351a2738d8ad086fe9ed620b9060c2f1c6d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __LINUX_BRIDGE_NETFILTER_H
2#define __LINUX_BRIDGE_NETFILTER_H
3
4/* bridge-specific defines for netfilter.
5 */
6
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#include <linux/netfilter.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#include <linux/if_ether.h>
Stephen Hemminger9bcfcaf2006-08-29 17:48:57 -07009#include <linux/if_vlan.h>
Michael Milner516299d2007-04-12 22:14:23 -070010#include <linux/if_pppox.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
12/* Bridge Hooks */
13/* After promisc drops, checksum checks. */
14#define NF_BR_PRE_ROUTING 0
15/* If the packet is destined for this box. */
16#define NF_BR_LOCAL_IN 1
17/* If the packet is destined for another interface. */
18#define NF_BR_FORWARD 2
19/* Packets coming from a local process. */
20#define NF_BR_LOCAL_OUT 3
21/* Packets about to hit the wire. */
22#define NF_BR_POST_ROUTING 4
23/* Not really a hook, but used for the ebtables broute table */
24#define NF_BR_BROUTING 5
25#define NF_BR_NUMHOOKS 6
26
27#ifdef __KERNEL__
28
29enum nf_br_hook_priorities {
30 NF_BR_PRI_FIRST = INT_MIN,
31 NF_BR_PRI_NAT_DST_BRIDGED = -300,
32 NF_BR_PRI_FILTER_BRIDGED = -200,
33 NF_BR_PRI_BRNF = 0,
34 NF_BR_PRI_NAT_DST_OTHER = 100,
35 NF_BR_PRI_FILTER_OTHER = 200,
36 NF_BR_PRI_NAT_SRC = 300,
37 NF_BR_PRI_LAST = INT_MAX,
38};
39
40#ifdef CONFIG_BRIDGE_NETFILTER
41
42#define BRNF_PKT_TYPE 0x01
43#define BRNF_BRIDGED_DNAT 0x02
44#define BRNF_DONT_TAKE_PARENT 0x04
45#define BRNF_BRIDGED 0x08
46#define BRNF_NF_BRIDGE_PREROUTING 0x10
47
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
49/* Only used in br_forward.c */
Stephen Hemminger073176212006-08-29 17:48:17 -070050extern int nf_bridge_copy_header(struct sk_buff *skb);
51static inline int nf_bridge_maybe_copy_header(struct sk_buff *skb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070052{
Stephen Hemminger073176212006-08-29 17:48:17 -070053 if (skb->nf_bridge)
54 return nf_bridge_copy_header(skb);
55 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070056}
57
Patrick McHardyfc385822007-05-03 03:36:16 -070058static inline unsigned int nf_bridge_encap_header_len(const struct sk_buff *skb)
59{
60 switch (skb->protocol) {
61 case __constant_htons(ETH_P_8021Q):
62 return VLAN_HLEN;
63 case __constant_htons(ETH_P_PPP_SES):
64 return PPPOE_SES_HLEN;
65 default:
66 return 0;
67 }
68}
69
Linus Torvalds1da177e2005-04-16 15:20:36 -070070/* This is called by the IP fragmenting code and it ensures there is
71 * enough room for the encapsulating header (if there is one). */
Patrick McHardyfc385822007-05-03 03:36:16 -070072static inline unsigned int nf_bridge_pad(const struct sk_buff *skb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070073{
Patrick McHardyfc385822007-05-03 03:36:16 -070074 if (skb->nf_bridge)
75 return nf_bridge_encap_header_len(skb);
76 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070077}
78
79struct bridge_skb_cb {
80 union {
Al Viro47c183fa2006-11-14 21:11:51 -080081 __be32 ipv4;
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 } daddr;
83};
Patrick McHardy10ea6ac2006-07-24 22:54:55 -070084
Stephen Hemminger073176212006-08-29 17:48:17 -070085#else
86#define nf_bridge_maybe_copy_header(skb) (0)
Stephen Hemminger9bcfcaf2006-08-29 17:48:57 -070087#define nf_bridge_pad(skb) (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070088#endif /* CONFIG_BRIDGE_NETFILTER */
89
90#endif /* __KERNEL__ */
91#endif