1 /* (C) 1999-2001 Paul `Rusty' Russell
2 * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
9 #include <linux/types.h>
10 #include <linux/jiffies.h>
11 #include <linux/timer.h>
12 #include <linux/netfilter.h>
13 #include <net/netfilter/nf_conntrack_l4proto.h>
14 #include <net/netfilter/nf_conntrack_timeout.h>
16 static const unsigned int nf_ct_generic_timeout
= 600*HZ
;
18 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
20 #include <linux/netfilter/nfnetlink.h>
21 #include <linux/netfilter/nfnetlink_cttimeout.h>
23 static int generic_timeout_nlattr_to_obj(struct nlattr
*tb
[],
24 struct net
*net
, void *data
)
26 struct nf_generic_net
*gn
= nf_generic_pernet(net
);
27 unsigned int *timeout
= data
;
30 timeout
= &gn
->timeout
;
32 if (tb
[CTA_TIMEOUT_GENERIC_TIMEOUT
])
34 ntohl(nla_get_be32(tb
[CTA_TIMEOUT_GENERIC_TIMEOUT
])) * HZ
;
36 /* Set default generic timeout. */
37 *timeout
= gn
->timeout
;
44 generic_timeout_obj_to_nlattr(struct sk_buff
*skb
, const void *data
)
46 const unsigned int *timeout
= data
;
48 if (nla_put_be32(skb
, CTA_TIMEOUT_GENERIC_TIMEOUT
, htonl(*timeout
/ HZ
)))
57 static const struct nla_policy
58 generic_timeout_nla_policy
[CTA_TIMEOUT_GENERIC_MAX
+1] = {
59 [CTA_TIMEOUT_GENERIC_TIMEOUT
] = { .type
= NLA_U32
},
61 #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
63 void nf_conntrack_generic_init_net(struct net
*net
)
65 struct nf_generic_net
*gn
= nf_generic_pernet(net
);
67 gn
->timeout
= nf_ct_generic_timeout
;
70 const struct nf_conntrack_l4proto nf_conntrack_l4proto_generic
=
73 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
75 .nlattr_to_obj
= generic_timeout_nlattr_to_obj
,
76 .obj_to_nlattr
= generic_timeout_obj_to_nlattr
,
77 .nlattr_max
= CTA_TIMEOUT_GENERIC_MAX
,
78 .obj_size
= sizeof(unsigned int),
79 .nla_policy
= generic_timeout_nla_policy
,
81 #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */