Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 1 | /* (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 Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <linux/types.h> |
Tim Schmielau | cd354f1 | 2007-02-14 00:33:14 -0800 | [diff] [blame] | 10 | #include <linux/jiffies.h> |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 11 | #include <linux/timer.h> |
| 12 | #include <linux/netfilter.h> |
Martin Josefsson | 605dcad | 2006-11-29 02:35:06 +0100 | [diff] [blame] | 13 | #include <net/netfilter/nf_conntrack_l4proto.h> |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 14 | |
Patrick McHardy | 933a41e | 2006-11-29 02:35:18 +0100 | [diff] [blame] | 15 | static unsigned int nf_ct_generic_timeout __read_mostly = 600*HZ; |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 16 | |
| 17 | static int generic_pkt_to_tuple(const struct sk_buff *skb, |
| 18 | unsigned int dataoff, |
| 19 | struct nf_conntrack_tuple *tuple) |
| 20 | { |
| 21 | tuple->src.u.all = 0; |
| 22 | tuple->dst.u.all = 0; |
| 23 | |
| 24 | return 1; |
| 25 | } |
| 26 | |
| 27 | static int generic_invert_tuple(struct nf_conntrack_tuple *tuple, |
| 28 | const struct nf_conntrack_tuple *orig) |
| 29 | { |
| 30 | tuple->src.u.all = 0; |
| 31 | tuple->dst.u.all = 0; |
| 32 | |
| 33 | return 1; |
| 34 | } |
| 35 | |
| 36 | /* Print out the per-protocol part of the tuple. */ |
| 37 | static int generic_print_tuple(struct seq_file *s, |
| 38 | const struct nf_conntrack_tuple *tuple) |
| 39 | { |
| 40 | return 0; |
| 41 | } |
| 42 | |
| 43 | /* Print out the private part of the conntrack. */ |
| 44 | static int generic_print_conntrack(struct seq_file *s, |
| 45 | const struct nf_conn *state) |
| 46 | { |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | /* Returns verdict for packet, or -1 for invalid. */ |
| 51 | static int packet(struct nf_conn *conntrack, |
| 52 | const struct sk_buff *skb, |
| 53 | unsigned int dataoff, |
| 54 | enum ip_conntrack_info ctinfo, |
| 55 | int pf, |
| 56 | unsigned int hooknum) |
| 57 | { |
| 58 | nf_ct_refresh_acct(conntrack, ctinfo, skb, nf_ct_generic_timeout); |
| 59 | return NF_ACCEPT; |
| 60 | } |
| 61 | |
| 62 | /* Called when a new connection for this protocol found. */ |
| 63 | static int new(struct nf_conn *conntrack, const struct sk_buff *skb, |
| 64 | unsigned int dataoff) |
| 65 | { |
| 66 | return 1; |
| 67 | } |
| 68 | |
Patrick McHardy | 933a41e | 2006-11-29 02:35:18 +0100 | [diff] [blame] | 69 | #ifdef CONFIG_SYSCTL |
| 70 | static struct ctl_table_header *generic_sysctl_header; |
| 71 | static struct ctl_table generic_sysctl_table[] = { |
| 72 | { |
| 73 | .ctl_name = NET_NF_CONNTRACK_GENERIC_TIMEOUT, |
| 74 | .procname = "nf_conntrack_generic_timeout", |
| 75 | .data = &nf_ct_generic_timeout, |
| 76 | .maxlen = sizeof(unsigned int), |
| 77 | .mode = 0644, |
| 78 | .proc_handler = &proc_dointvec_jiffies, |
| 79 | }, |
| 80 | { |
| 81 | .ctl_name = 0 |
| 82 | } |
| 83 | }; |
Patrick McHardy | a999e68 | 2006-11-29 02:35:20 +0100 | [diff] [blame] | 84 | #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT |
| 85 | static struct ctl_table generic_compat_sysctl_table[] = { |
| 86 | { |
| 87 | .ctl_name = NET_IPV4_NF_CONNTRACK_GENERIC_TIMEOUT, |
| 88 | .procname = "ip_conntrack_generic_timeout", |
| 89 | .data = &nf_ct_generic_timeout, |
| 90 | .maxlen = sizeof(unsigned int), |
| 91 | .mode = 0644, |
| 92 | .proc_handler = &proc_dointvec_jiffies, |
| 93 | }, |
| 94 | { |
| 95 | .ctl_name = 0 |
| 96 | } |
| 97 | }; |
| 98 | #endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */ |
Patrick McHardy | 933a41e | 2006-11-29 02:35:18 +0100 | [diff] [blame] | 99 | #endif /* CONFIG_SYSCTL */ |
| 100 | |
Patrick McHardy | 61075af | 2007-07-14 20:48:19 -0700 | [diff] [blame^] | 101 | struct nf_conntrack_l4proto nf_conntrack_l4proto_generic __read_mostly = |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 102 | { |
| 103 | .l3proto = PF_UNSPEC, |
Martin Josefsson | 605dcad | 2006-11-29 02:35:06 +0100 | [diff] [blame] | 104 | .l4proto = 0, |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 105 | .name = "unknown", |
| 106 | .pkt_to_tuple = generic_pkt_to_tuple, |
| 107 | .invert_tuple = generic_invert_tuple, |
| 108 | .print_tuple = generic_print_tuple, |
| 109 | .print_conntrack = generic_print_conntrack, |
| 110 | .packet = packet, |
| 111 | .new = new, |
Patrick McHardy | 933a41e | 2006-11-29 02:35:18 +0100 | [diff] [blame] | 112 | #ifdef CONFIG_SYSCTL |
| 113 | .ctl_table_header = &generic_sysctl_header, |
| 114 | .ctl_table = generic_sysctl_table, |
Patrick McHardy | a999e68 | 2006-11-29 02:35:20 +0100 | [diff] [blame] | 115 | #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT |
| 116 | .ctl_compat_table = generic_compat_sysctl_table, |
| 117 | #endif |
Patrick McHardy | 933a41e | 2006-11-29 02:35:18 +0100 | [diff] [blame] | 118 | #endif |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 119 | }; |