blob: f1b1482d7200a3a8a1d67e4c6cc41ba62167f125 [file] [log] [blame]
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -08001#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
11static 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
James Morris7c9728c2006-06-09 00:31:46 -070023#ifdef CONFIG_IP_NF_CONNTRACK_SECMARK
24static 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
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080036#ifdef CONFIG_IP_NF_CT_ACCT
37static inline struct ip_conntrack_counter *
38nf_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
50static inline int nf_ct_is_untracked(const struct sk_buff *skb)
51{
52 return (skb->nfct == &ip_conntrack_untracked.ct_general);
53}
54
55static inline void nf_ct_untrack(struct sk_buff *skb)
56{
57 skb->nfct = &ip_conntrack_untracked.ct_general;
58}
59
60static 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#else /* CONFIG_IP_NF_CONNTRACK */
68
69#include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
70#include <net/netfilter/nf_conntrack.h>
71
72#ifdef CONFIG_NF_CONNTRACK_MARK
73
74static inline u_int32_t *nf_ct_get_mark(const struct sk_buff *skb,
75 u_int32_t *ctinfo)
76{
77 struct nf_conn *ct = nf_ct_get(skb, ctinfo);
78
79 if (ct)
80 return &ct->mark;
81 else
82 return NULL;
83}
84#endif /* CONFIG_NF_CONNTRACK_MARK */
85
James Morris7c9728c2006-06-09 00:31:46 -070086#ifdef CONFIG_NF_CONNTRACK_SECMARK
87static inline u_int32_t *nf_ct_get_secmark(const struct sk_buff *skb,
88 u_int32_t *ctinfo)
89{
90 struct nf_conn *ct = nf_ct_get(skb, ctinfo);
91
92 if (ct)
93 return &ct->secmark;
94 else
95 return NULL;
96}
97#endif /* CONFIG_NF_CONNTRACK_MARK */
98
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080099#ifdef CONFIG_NF_CT_ACCT
100static inline struct ip_conntrack_counter *
101nf_ct_get_counters(const struct sk_buff *skb)
102{
103 enum ip_conntrack_info ctinfo;
104 struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
105
106 if (ct)
107 return ct->counters;
108 else
109 return NULL;
110}
111#endif /* CONFIG_NF_CT_ACCT */
112
113static inline int nf_ct_is_untracked(const struct sk_buff *skb)
114{
115 return (skb->nfct == &nf_conntrack_untracked.ct_general);
116}
117
118static inline void nf_ct_untrack(struct sk_buff *skb)
119{
120 skb->nfct = &nf_conntrack_untracked.ct_general;
121}
122
123static inline int nf_ct_get_ctinfo(const struct sk_buff *skb,
124 enum ip_conntrack_info *ctinfo)
125{
126 struct nf_conn *ct = nf_ct_get(skb, ctinfo);
127 return (ct != NULL);
128}
129
130#endif /* CONFIG_IP_NF_CONNTRACK */
131
132#endif /* __KERNEL__ */
133
134#endif /* _NF_CONNTRACK_COMPAT_H */