blob: dbe680af85d2daa2aa3aaceb2c668e48847de643 [file] [log] [blame]
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -08001/* (C) 1999-2001 Paul `Rusty' Russell
2 * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org>
3 *
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.
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -08007 */
8
9#include <linux/types.h>
Tim Schmielaucd354f12007-02-14 00:33:14 -080010#include <linux/jiffies.h>
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080011#include <linux/timer.h>
12#include <linux/netfilter.h>
Martin Josefsson605dcad2006-11-29 02:35:06 +010013#include <net/netfilter/nf_conntrack_l4proto.h>
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080014
Patrick McHardy933a41e2006-11-29 02:35:18 +010015static unsigned int nf_ct_generic_timeout __read_mostly = 600*HZ;
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080016
Jan Engelhardt09f263c2008-04-14 11:15:53 +020017static bool generic_pkt_to_tuple(const struct sk_buff *skb,
18 unsigned int dataoff,
19 struct nf_conntrack_tuple *tuple)
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080020{
21 tuple->src.u.all = 0;
22 tuple->dst.u.all = 0;
23
Jan Engelhardt09f263c2008-04-14 11:15:53 +020024 return true;
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080025}
26
Jan Engelhardt09f263c2008-04-14 11:15:53 +020027static bool generic_invert_tuple(struct nf_conntrack_tuple *tuple,
28 const struct nf_conntrack_tuple *orig)
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080029{
30 tuple->src.u.all = 0;
31 tuple->dst.u.all = 0;
32
Jan Engelhardt09f263c2008-04-14 11:15:53 +020033 return true;
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080034}
35
36/* Print out the per-protocol part of the tuple. */
37static int generic_print_tuple(struct seq_file *s,
38 const struct nf_conntrack_tuple *tuple)
39{
40 return 0;
41}
42
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080043/* Returns verdict for packet, or -1 for invalid. */
Patrick McHardyc88130b2008-01-31 04:42:11 -080044static int packet(struct nf_conn *ct,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080045 const struct sk_buff *skb,
46 unsigned int dataoff,
47 enum ip_conntrack_info ctinfo,
Jan Engelhardt76108ce2008-10-08 11:35:00 +020048 u_int8_t pf,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080049 unsigned int hooknum)
50{
Patrick McHardyc88130b2008-01-31 04:42:11 -080051 nf_ct_refresh_acct(ct, ctinfo, skb, nf_ct_generic_timeout);
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080052 return NF_ACCEPT;
53}
54
55/* Called when a new connection for this protocol found. */
Jan Engelhardt09f263c2008-04-14 11:15:53 +020056static bool new(struct nf_conn *ct, const struct sk_buff *skb,
57 unsigned int dataoff)
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080058{
Jan Engelhardt09f263c2008-04-14 11:15:53 +020059 return true;
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080060}
61
Patrick McHardy933a41e2006-11-29 02:35:18 +010062#ifdef CONFIG_SYSCTL
63static struct ctl_table_header *generic_sysctl_header;
64static struct ctl_table generic_sysctl_table[] = {
65 {
Patrick McHardy933a41e2006-11-29 02:35:18 +010066 .procname = "nf_conntrack_generic_timeout",
67 .data = &nf_ct_generic_timeout,
68 .maxlen = sizeof(unsigned int),
69 .mode = 0644,
70 .proc_handler = &proc_dointvec_jiffies,
71 },
72 {
73 .ctl_name = 0
74 }
75};
Patrick McHardya999e682006-11-29 02:35:20 +010076#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
77static struct ctl_table generic_compat_sysctl_table[] = {
78 {
Patrick McHardya999e682006-11-29 02:35:20 +010079 .procname = "ip_conntrack_generic_timeout",
80 .data = &nf_ct_generic_timeout,
81 .maxlen = sizeof(unsigned int),
82 .mode = 0644,
83 .proc_handler = &proc_dointvec_jiffies,
84 },
85 {
86 .ctl_name = 0
87 }
88};
89#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
Patrick McHardy933a41e2006-11-29 02:35:18 +010090#endif /* CONFIG_SYSCTL */
91
Patrick McHardy61075af2007-07-14 20:48:19 -070092struct nf_conntrack_l4proto nf_conntrack_l4proto_generic __read_mostly =
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080093{
94 .l3proto = PF_UNSPEC,
Martin Josefsson605dcad2006-11-29 02:35:06 +010095 .l4proto = 0,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080096 .name = "unknown",
97 .pkt_to_tuple = generic_pkt_to_tuple,
98 .invert_tuple = generic_invert_tuple,
99 .print_tuple = generic_print_tuple,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800100 .packet = packet,
101 .new = new,
Patrick McHardy933a41e2006-11-29 02:35:18 +0100102#ifdef CONFIG_SYSCTL
103 .ctl_table_header = &generic_sysctl_header,
104 .ctl_table = generic_sysctl_table,
Patrick McHardya999e682006-11-29 02:35:20 +0100105#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
106 .ctl_compat_table = generic_compat_sysctl_table,
107#endif
Patrick McHardy933a41e2006-11-29 02:35:18 +0100108#endif
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800109};