Pull bugfix into test branch
[pandora-kernel.git] / include / net / netfilter / nf_conntrack_compat.h
1 #ifndef _NF_CONNTRACK_COMPAT_H
2 #define _NF_CONNTRACK_COMPAT_H
3
4 #ifdef __KERNEL__
5
6 #if defined(CONFIG_IP_NF_CONNTRACK) || defined(CONFIG_IP_NF_CONNTRACK_MODULE)
7
8 #include <linux/netfilter_ipv4/ip_conntrack.h>
9
10 #ifdef CONFIG_IP_NF_CONNTRACK_MARK
11 static inline u_int32_t *nf_ct_get_mark(const struct sk_buff *skb,
12                                         u_int32_t *ctinfo)
13 {
14         struct ip_conntrack *ct = ip_conntrack_get(skb, ctinfo);
15
16         if (ct)
17                 return &ct->mark;
18         else
19                 return NULL;
20 }
21 #endif /* CONFIG_IP_NF_CONNTRACK_MARK */
22
23 #ifdef CONFIG_IP_NF_CONNTRACK_SECMARK
24 static inline u_int32_t *nf_ct_get_secmark(const struct sk_buff *skb,
25                                            u_int32_t *ctinfo)
26 {
27         struct ip_conntrack *ct = ip_conntrack_get(skb, ctinfo);
28
29         if (ct)
30                 return &ct->secmark;
31         else
32                 return NULL;
33 }
34 #endif /* CONFIG_IP_NF_CONNTRACK_SECMARK */
35
36 #ifdef CONFIG_IP_NF_CT_ACCT
37 static inline struct ip_conntrack_counter *
38 nf_ct_get_counters(const struct sk_buff *skb)
39 {
40         enum ip_conntrack_info ctinfo;
41         struct ip_conntrack *ct = ip_conntrack_get(skb, &ctinfo);
42
43         if (ct)
44                 return ct->counters;
45         else
46                 return NULL;
47 }
48 #endif /* CONFIG_IP_NF_CT_ACCT */
49
50 static inline int nf_ct_is_untracked(const struct sk_buff *skb)
51 {
52         return (skb->nfct == &ip_conntrack_untracked.ct_general);
53 }
54
55 static inline void nf_ct_untrack(struct sk_buff *skb)
56 {
57         skb->nfct = &ip_conntrack_untracked.ct_general;
58 }
59
60 static inline int nf_ct_get_ctinfo(const struct sk_buff *skb,
61                                    enum ip_conntrack_info *ctinfo)
62 {
63         struct ip_conntrack *ct = ip_conntrack_get(skb, ctinfo);
64         return (ct != NULL);
65 }
66
67 static inline int nf_ct_l3proto_try_module_get(unsigned short l3proto)
68 {
69         need_conntrack();
70         return l3proto == PF_INET ? 0 : -1;
71 }
72
73 static inline void nf_ct_l3proto_module_put(unsigned short l3proto)
74 {
75 }
76
77 #else /* CONFIG_IP_NF_CONNTRACK */
78
79 #include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
80 #include <net/netfilter/nf_conntrack.h>
81
82 #ifdef CONFIG_NF_CONNTRACK_MARK
83
84 static inline u_int32_t *nf_ct_get_mark(const struct sk_buff *skb,
85                                         u_int32_t *ctinfo)
86 {
87         struct nf_conn *ct = nf_ct_get(skb, ctinfo);
88
89         if (ct)
90                 return &ct->mark;
91         else
92                 return NULL;
93 }
94 #endif /* CONFIG_NF_CONNTRACK_MARK */
95
96 #ifdef CONFIG_NF_CONNTRACK_SECMARK
97 static inline u_int32_t *nf_ct_get_secmark(const struct sk_buff *skb,
98                                            u_int32_t *ctinfo)
99 {
100         struct nf_conn *ct = nf_ct_get(skb, ctinfo);
101
102         if (ct)
103                 return &ct->secmark;
104         else
105                 return NULL;
106 }
107 #endif /* CONFIG_NF_CONNTRACK_MARK */
108
109 #ifdef CONFIG_NF_CT_ACCT
110 static inline struct ip_conntrack_counter *
111 nf_ct_get_counters(const struct sk_buff *skb)
112 {
113         enum ip_conntrack_info ctinfo;
114         struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
115
116         if (ct)
117                 return ct->counters;
118         else
119                 return NULL;
120 }
121 #endif /* CONFIG_NF_CT_ACCT */
122
123 static inline int nf_ct_is_untracked(const struct sk_buff *skb)
124 {
125         return (skb->nfct == &nf_conntrack_untracked.ct_general);
126 }
127
128 static inline void nf_ct_untrack(struct sk_buff *skb)
129 {
130         skb->nfct = &nf_conntrack_untracked.ct_general;
131 }
132
133 static inline int nf_ct_get_ctinfo(const struct sk_buff *skb,
134                                    enum ip_conntrack_info *ctinfo)
135 {
136         struct nf_conn *ct = nf_ct_get(skb, ctinfo);
137         return (ct != NULL);
138 }
139
140 #endif /* CONFIG_IP_NF_CONNTRACK */
141
142 #endif /* __KERNEL__ */
143
144 #endif /* _NF_CONNTRACK_COMPAT_H */