aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/netfilter/nf_conntrack_compat.h
blob: 6f84c1f7fcd43188e239cf46cd134cf5dc491466 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#ifndef _NF_CONNTRACK_COMPAT_H
#define _NF_CONNTRACK_COMPAT_H

#ifdef __KERNEL__

#if defined(CONFIG_IP_NF_CONNTRACK) || defined(CONFIG_IP_NF_CONNTRACK_MODULE)

#include <linux/netfilter_ipv4/ip_conntrack.h>
#include <linux/socket.h>

#ifdef CONFIG_IP_NF_CONNTRACK_MARK
static inline u_int32_t *nf_ct_get_mark(const struct sk_buff *skb,
					u_int32_t *ctinfo)
{
	struct ip_conntrack *ct = ip_conntrack_get(skb, ctinfo);

	if (ct)
		return &ct->mark;
	else
		return NULL;
}
#endif /* CONFIG_IP_NF_CONNTRACK_MARK */

#ifdef CONFIG_IP_NF_CONNTRACK_SECMARK
static inline u_int32_t *nf_ct_get_secmark(const struct sk_buff *skb,
					   u_int32_t *ctinfo)
{
	struct ip_conntrack *ct = ip_conntrack_get(skb, ctinfo);

	if (ct)
		return &ct->secmark;
	else
		return NULL;
}
#endif /* CONFIG_IP_NF_CONNTRACK_SECMARK */

#ifdef CONFIG_IP_NF_CT_ACCT
static inline struct ip_conntrack_counter *
nf_ct_get_counters(const struct sk_buff *skb)
{
	enum ip_conntrack_info ctinfo;
	struct ip_conntrack *ct = ip_conntrack_get(skb, &ctinfo);

	if (ct)
		return ct->counters;
	else
		return NULL;
}
#endif /* CONFIG_IP_NF_CT_ACCT */

static inline int nf_ct_is_untracked(const struct sk_buff *skb)
{
	return (skb->nfct == &ip_conntrack_untracked.ct_general);
}

static inline void nf_ct_untrack(struct sk_buff *skb)
{
	skb->nfct = &ip_conntrack_untracked.ct_general;
}

static inline int nf_ct_get_ctinfo(const struct sk_buff *skb,
				   enum ip_conntrack_info *ctinfo)
{
	struct ip_conntrack *ct = ip_conntrack_get(skb, ctinfo);
	return (ct != NULL);
}

static inline int nf_ct_l3proto_try_module_get(unsigned short l3proto)
{
	need_conntrack();
	return l3proto == PF_INET ? 0 : -1;
}

static inline void nf_ct_l3proto_module_put(unsigned short l3proto)
{
}

#else /* CONFIG_IP_NF_CONNTRACK */

#include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
#include <net/netfilter/nf_conntrack.h>

#ifdef CONFIG_NF_CONNTRACK_MARK

static inline u_int32_t *nf_ct_get_mark(const struct sk_buff *skb,
					u_int32_t *ctinfo)
{
	struct nf_conn *ct = nf_ct_get(skb, ctinfo);

	if (ct)
		return &ct->mark;
	else
		return NULL;
}
#endif /* CONFIG_NF_CONNTRACK_MARK */

#ifdef CONFIG_NF_CONNTRACK_SECMARK
static inline u_int32_t *nf_ct_get_secmark(const struct sk_buff *skb,
					   u_int32_t *ctinfo)
{
	struct nf_conn *ct = nf_ct_get(skb, ctinfo);

	if (ct)
		return &ct->secmark;
	else
		return NULL;
}
#endif /* CONFIG_NF_CONNTRACK_MARK */

#ifdef CONFIG_NF_CT_ACCT
static inline struct ip_conntrack_counter *
nf_ct_get_counters(const struct sk_buff *skb)
{
	enum ip_conntrack_info ctinfo;
	struct nf_conn *ct = nf_ct_get(skb, &ctinfo);

	if (ct)
		return ct->counters;
	else
		return NULL;
}
#endif /* CONFIG_NF_CT_ACCT */

static inline int nf_ct_is_untracked(const struct sk_buff *skb)
{
	return (skb->nfct == &nf_conntrack_untracked.ct_general);
}

static inline void nf_ct_untrack(struct sk_buff *skb)
{
	skb->nfct = &nf_conntrack_untracked.ct_general;
}

static inline int nf_ct_get_ctinfo(const struct sk_buff *skb,
				   enum ip_conntrack_info *ctinfo)
{
	struct nf_conn *ct = nf_ct_get(skb, ctinfo);
	return (ct != NULL);
}

#endif /* CONFIG_IP_NF_CONNTRACK */

#endif /* __KERNEL__ */

#endif /* _NF_CONNTRACK_COMPAT_H */