blob: 55689f39f77a69523c82221c5696bcb2c54e002b [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
11/* Bridge Hooks */
12/* After promisc drops, checksum checks. */
13#define NF_BR_PRE_ROUTING 0
14/* If the packet is destined for this box. */
15#define NF_BR_LOCAL_IN 1
16/* If the packet is destined for another interface. */
17#define NF_BR_FORWARD 2
18/* Packets coming from a local process. */
19#define NF_BR_LOCAL_OUT 3
20/* Packets about to hit the wire. */
21#define NF_BR_POST_ROUTING 4
22/* Not really a hook, but used for the ebtables broute table */
23#define NF_BR_BROUTING 5
24#define NF_BR_NUMHOOKS 6
25
26#ifdef __KERNEL__
27
28enum nf_br_hook_priorities {
29 NF_BR_PRI_FIRST = INT_MIN,
30 NF_BR_PRI_NAT_DST_BRIDGED = -300,
31 NF_BR_PRI_FILTER_BRIDGED = -200,
32 NF_BR_PRI_BRNF = 0,
33 NF_BR_PRI_NAT_DST_OTHER = 100,
34 NF_BR_PRI_FILTER_OTHER = 200,
35 NF_BR_PRI_NAT_SRC = 300,
36 NF_BR_PRI_LAST = INT_MAX,
37};
38
39#ifdef CONFIG_BRIDGE_NETFILTER
40
41#define BRNF_PKT_TYPE 0x01
42#define BRNF_BRIDGED_DNAT 0x02
43#define BRNF_DONT_TAKE_PARENT 0x04
44#define BRNF_BRIDGED 0x08
45#define BRNF_NF_BRIDGE_PREROUTING 0x10
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
48/* Only used in br_forward.c */
Stephen Hemminger073176212006-08-29 17:48:17 -070049extern int nf_bridge_copy_header(struct sk_buff *skb);
50static inline int nf_bridge_maybe_copy_header(struct sk_buff *skb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070051{
Stephen Hemminger073176212006-08-29 17:48:17 -070052 if (skb->nf_bridge)
53 return nf_bridge_copy_header(skb);
54 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070055}
56
Linus Torvalds1da177e2005-04-16 15:20:36 -070057/* This is called by the IP fragmenting code and it ensures there is
58 * enough room for the encapsulating header (if there is one). */
Stephen Hemminger9bcfcaf2006-08-29 17:48:57 -070059static inline int nf_bridge_pad(const struct sk_buff *skb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060{
Stephen Hemminger9bcfcaf2006-08-29 17:48:57 -070061 return (skb->nf_bridge && skb->protocol == htons(ETH_P_8021Q))
62 ? VLAN_HLEN : 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070063}
64
65struct bridge_skb_cb {
66 union {
Al Viro47c183fa2006-11-14 21:11:51 -080067 __be32 ipv4;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 } daddr;
69};
Patrick McHardy10ea6ac2006-07-24 22:54:55 -070070
Stephen Hemminger073176212006-08-29 17:48:17 -070071#else
72#define nf_bridge_maybe_copy_header(skb) (0)
Stephen Hemminger9bcfcaf2006-08-29 17:48:57 -070073#define nf_bridge_pad(skb) (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070074#endif /* CONFIG_BRIDGE_NETFILTER */
75
76#endif /* __KERNEL__ */
77#endif