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