]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef __LINUX_BRIDGE_NETFILTER_H |
2 | #define __LINUX_BRIDGE_NETFILTER_H | |
3 | ||
4 | /* bridge-specific defines for netfilter. | |
5 | */ | |
6 | ||
1da177e4 | 7 | #include <linux/netfilter.h> |
1da177e4 | 8 | #include <linux/if_ether.h> |
9bcfcaf5 | 9 | #include <linux/if_vlan.h> |
516299d2 | 10 | #include <linux/if_pppox.h> |
1da177e4 LT |
11 | |
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 | ||
29 | enum 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 | ||
1da177e4 LT |
48 | |
49 | /* Only used in br_forward.c */ | |
07317621 SH |
50 | extern int nf_bridge_copy_header(struct sk_buff *skb); |
51 | static inline int nf_bridge_maybe_copy_header(struct sk_buff *skb) | |
1da177e4 | 52 | { |
4a9ecd59 PM |
53 | if (skb->nf_bridge && |
54 | skb->nf_bridge->mask & (BRNF_BRIDGED | BRNF_BRIDGED_DNAT)) | |
07317621 SH |
55 | return nf_bridge_copy_header(skb); |
56 | return 0; | |
1da177e4 LT |
57 | } |
58 | ||
fc38582d PM |
59 | static inline unsigned int nf_bridge_encap_header_len(const struct sk_buff *skb) |
60 | { | |
61 | switch (skb->protocol) { | |
f3a7c66b | 62 | case __cpu_to_be16(ETH_P_8021Q): |
fc38582d | 63 | return VLAN_HLEN; |
f3a7c66b | 64 | case __cpu_to_be16(ETH_P_PPP_SES): |
fc38582d PM |
65 | return PPPOE_SES_HLEN; |
66 | default: | |
67 | return 0; | |
68 | } | |
69 | } | |
70 | ||
1da177e4 LT |
71 | /* This is called by the IP fragmenting code and it ensures there is |
72 | * enough room for the encapsulating header (if there is one). */ | |
fc38582d | 73 | static inline unsigned int nf_bridge_pad(const struct sk_buff *skb) |
1da177e4 | 74 | { |
fc38582d PM |
75 | if (skb->nf_bridge) |
76 | return nf_bridge_encap_header_len(skb); | |
77 | return 0; | |
1da177e4 LT |
78 | } |
79 | ||
80 | struct bridge_skb_cb { | |
81 | union { | |
47c183fa | 82 | __be32 ipv4; |
1da177e4 LT |
83 | } daddr; |
84 | }; | |
10ea6ac8 | 85 | |
07317621 SH |
86 | #else |
87 | #define nf_bridge_maybe_copy_header(skb) (0) | |
9bcfcaf5 | 88 | #define nf_bridge_pad(skb) (0) |
1da177e4 LT |
89 | #endif /* CONFIG_BRIDGE_NETFILTER */ |
90 | ||
91 | #endif /* __KERNEL__ */ | |
92 | #endif |