blob: 300ae2209f251e7e669c8c353b8de7fb50b16f55 [file] [log] [blame]
Pablo Neira Ayusoa992ca22011-01-19 16:00:07 +01001#ifndef _NF_CONNTRACK_TSTAMP_H
2#define _NF_CONNTRACK_TSTAMP_H
3
4#include <net/net_namespace.h>
5#include <linux/netfilter/nf_conntrack_common.h>
6#include <linux/netfilter/nf_conntrack_tuple_common.h>
7#include <net/netfilter/nf_conntrack.h>
8#include <net/netfilter/nf_conntrack_extend.h>
9
10struct nf_conn_tstamp {
11 u_int64_t start;
12 u_int64_t stop;
13};
14
15static inline
16struct nf_conn_tstamp *nf_conn_tstamp_find(const struct nf_conn *ct)
17{
18#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
19 return nf_ct_ext_find(ct, NF_CT_EXT_TSTAMP);
20#else
21 return NULL;
22#endif
23}
24
25static inline
26struct nf_conn_tstamp *nf_ct_tstamp_ext_add(struct nf_conn *ct, gfp_t gfp)
27{
28#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
29 struct net *net = nf_ct_net(ct);
30
31 if (!net->ct.sysctl_tstamp)
32 return NULL;
33
34 return nf_ct_ext_add(ct, NF_CT_EXT_TSTAMP, gfp);
35#else
36 return NULL;
37#endif
38};
39
40static inline bool nf_ct_tstamp_enabled(struct net *net)
41{
42 return net->ct.sysctl_tstamp != 0;
43}
44
45static inline void nf_ct_set_tstamp(struct net *net, bool enable)
46{
47 net->ct.sysctl_tstamp = enable;
48}
49
Patrick McHardy2f1e3172011-01-20 20:46:52 +010050#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
Joe Perches4e77be42013-09-23 11:37:48 -070051int nf_conntrack_tstamp_pernet_init(struct net *net);
52void nf_conntrack_tstamp_pernet_fini(struct net *net);
Gao feng73f40012013-01-21 22:10:27 +000053
Joe Perches4e77be42013-09-23 11:37:48 -070054int nf_conntrack_tstamp_init(void);
55void nf_conntrack_tstamp_fini(void);
Patrick McHardy2f1e3172011-01-20 20:46:52 +010056#else
Gao feng73f40012013-01-21 22:10:27 +000057static inline int nf_conntrack_tstamp_pernet_init(struct net *net)
Patrick McHardy2f1e3172011-01-20 20:46:52 +010058{
59 return 0;
60}
61
Gao feng73f40012013-01-21 22:10:27 +000062static inline void nf_conntrack_tstamp_pernet_fini(struct net *net)
63{
64 return;
65}
66
67static inline int nf_conntrack_tstamp_init(void)
68{
69 return 0;
70}
71
72static inline void nf_conntrack_tstamp_fini(void)
Patrick McHardy2f1e3172011-01-20 20:46:52 +010073{
74 return;
75}
76#endif /* CONFIG_NF_CONNTRACK_TIMESTAMP */
Pablo Neira Ayusoa992ca22011-01-19 16:00:07 +010077
78#endif /* _NF_CONNTRACK_TSTAMP_H */