fix sdk build
[openwrt.git] / openwrt / package / linux / kernel-patches / 312-netfilter-TTL
1 diff -urN linux-2.4.30.old/Documentation/Configure.help linux-2.4.30.dev/Documentation/Configure.help
2 --- linux-2.4.30.old/Documentation/Configure.help 2005-04-27 11:35:46.000000000 +0200
3 +++ linux-2.4.30.dev/Documentation/Configure.help 2005-04-27 11:43:49.000000000 +0200
4 @@ -3209,6 +3209,15 @@
5 If you want to compile it as a module, say M here and read
6 <file:Documentation/modules.txt>. If unsure, say `N'.
7
8 +TTL target support
9 +CONFIG_IP_NF_TARGET_TTL
10 + This option adds a `TTL' target, which enables the user to set
11 + the TTL value or increment / decrement the TTL value by a given
12 + amount.
13 +
14 + If you want to compile it as a module, say M here and read
15 + Documentation/modules.txt. If unsure, say `N'.
16 +
17 ipchains (2.2-style) support
18 CONFIG_IP_NF_COMPAT_IPCHAINS
19 This option places ipchains (with masquerading and redirection
20 diff -urN linux-2.4.30.old/include/linux/netfilter_ipv4/ipt_TTL.h linux-2.4.30.dev/include/linux/netfilter_ipv4/ipt_TTL.h
21 --- linux-2.4.30.old/include/linux/netfilter_ipv4/ipt_TTL.h 1970-01-01 01:00:00.000000000 +0100
22 +++ linux-2.4.30.dev/include/linux/netfilter_ipv4/ipt_TTL.h 2005-04-27 11:43:49.000000000 +0200
23 @@ -0,0 +1,21 @@
24 +/* TTL modification module for IP tables
25 + * (C) 2000 by Harald Welte <laforge@gnumonks.org> */
26 +
27 +#ifndef _IPT_TTL_H
28 +#define _IPT_TTL_H
29 +
30 +enum {
31 + IPT_TTL_SET = 0,
32 + IPT_TTL_INC,
33 + IPT_TTL_DEC
34 +};
35 +
36 +#define IPT_TTL_MAXMODE IPT_TTL_DEC
37 +
38 +struct ipt_TTL_info {
39 + u_int8_t mode;
40 + u_int8_t ttl;
41 +};
42 +
43 +
44 +#endif
45 diff -urN linux-2.4.30.old/net/ipv4/netfilter/Config.in linux-2.4.30.dev/net/ipv4/netfilter/Config.in
46 --- linux-2.4.30.old/net/ipv4/netfilter/Config.in 2005-04-27 11:35:45.000000000 +0200
47 +++ linux-2.4.30.dev/net/ipv4/netfilter/Config.in 2005-04-27 11:43:49.000000000 +0200
48 @@ -129,6 +129,7 @@
49 dep_tristate ' MARK target support' CONFIG_IP_NF_TARGET_MARK $CONFIG_IP_NF_MANGLE
50 fi
51 dep_tristate ' LOG target support' CONFIG_IP_NF_TARGET_LOG $CONFIG_IP_NF_IPTABLES
52 + dep_tristate ' TTL target support' CONFIG_IP_NF_TARGET_TTL $CONFIG_IP_NF_IPTABLES
53 dep_tristate ' ULOG target support' CONFIG_IP_NF_TARGET_ULOG $CONFIG_IP_NF_IPTABLES
54 dep_tristate ' TCPMSS target support' CONFIG_IP_NF_TARGET_TCPMSS $CONFIG_IP_NF_IPTABLES
55 fi
56 diff -urN linux-2.4.30.old/net/ipv4/netfilter/ipt_TTL.c linux-2.4.30.dev/net/ipv4/netfilter/ipt_TTL.c
57 --- linux-2.4.30.old/net/ipv4/netfilter/ipt_TTL.c 1970-01-01 01:00:00.000000000 +0100
58 +++ linux-2.4.30.dev/net/ipv4/netfilter/ipt_TTL.c 2005-04-27 11:43:49.000000000 +0200
59 @@ -0,0 +1,110 @@
60 +/* TTL modification target for IP tables
61 + * (C) 2000 by Harald Welte <laforge@gnumonks.org>
62 + *
63 + * Version: $Revision$
64 + *
65 + * This software is distributed under the terms of GNU GPL
66 + */
67 +
68 +#include <linux/module.h>
69 +#include <linux/skbuff.h>
70 +#include <linux/ip.h>
71 +#include <net/checksum.h>
72 +
73 +#include <linux/netfilter_ipv4/ip_tables.h>
74 +#include <linux/netfilter_ipv4/ipt_TTL.h>
75 +
76 +MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
77 +MODULE_DESCRIPTION("IP tables TTL modification module");
78 +MODULE_LICENSE("GPL");
79 +
80 +static unsigned int ipt_ttl_target(struct sk_buff **pskb, unsigned int hooknum,
81 + const struct net_device *in, const struct net_device *out,
82 + const void *targinfo, void *userinfo)
83 +{
84 + struct iphdr *iph = (*pskb)->nh.iph;
85 + const struct ipt_TTL_info *info = targinfo;
86 + u_int16_t diffs[2];
87 + int new_ttl;
88 +
89 + switch (info->mode) {
90 + case IPT_TTL_SET:
91 + new_ttl = info->ttl;
92 + break;
93 + case IPT_TTL_INC:
94 + new_ttl = iph->ttl + info->ttl;
95 + if (new_ttl > 255)
96 + new_ttl = 255;
97 + break;
98 + case IPT_TTL_DEC:
99 + new_ttl = iph->ttl - info->ttl;
100 + if (new_ttl < 0)
101 + new_ttl = 0;
102 + break;
103 + default:
104 + new_ttl = iph->ttl;
105 + break;
106 + }
107 +
108 + if (new_ttl != iph->ttl) {
109 + diffs[0] = htons(((unsigned)iph->ttl) << 8) ^ 0xFFFF;
110 + iph->ttl = new_ttl;
111 + diffs[1] = htons(((unsigned)iph->ttl) << 8);
112 + iph->check = csum_fold(csum_partial((char *)diffs,
113 + sizeof(diffs),
114 + iph->check^0xFFFF));
115 + (*pskb)->nfcache |= NFC_ALTERED;
116 + }
117 +
118 + return IPT_CONTINUE;
119 +}
120 +
121 +static int ipt_ttl_checkentry(const char *tablename,
122 + const struct ipt_entry *e,
123 + void *targinfo,
124 + unsigned int targinfosize,
125 + unsigned int hook_mask)
126 +{
127 + struct ipt_TTL_info *info = targinfo;
128 +
129 + if (targinfosize != IPT_ALIGN(sizeof(struct ipt_TTL_info))) {
130 + printk(KERN_WARNING "TTL: targinfosize %u != %Zu\n",
131 + targinfosize,
132 + IPT_ALIGN(sizeof(struct ipt_TTL_info)));
133 + return 0;
134 + }
135 +
136 + if (strcmp(tablename, "mangle")) {
137 + printk(KERN_WARNING "TTL: can only be called from \"mangle\" table, not \"%s\"\n", tablename);
138 + return 0;
139 + }
140 +
141 + if (info->mode > IPT_TTL_MAXMODE) {
142 + printk(KERN_WARNING "TTL: invalid or unknown Mode %u\n",
143 + info->mode);
144 + return 0;
145 + }
146 +
147 + if ((info->mode != IPT_TTL_SET) && (info->ttl == 0)) {
148 + printk(KERN_WARNING "TTL: increment/decrement doesn't make sense with value 0\n");
149 + return 0;
150 + }
151 +
152 + return 1;
153 +}
154 +
155 +static struct ipt_target ipt_TTL = { { NULL, NULL }, "TTL",
156 + ipt_ttl_target, ipt_ttl_checkentry, NULL, THIS_MODULE };
157 +
158 +static int __init init(void)
159 +{
160 + return ipt_register_target(&ipt_TTL);
161 +}
162 +
163 +static void __exit fini(void)
164 +{
165 + ipt_unregister_target(&ipt_TTL);
166 +}
167 +
168 +module_init(init);
169 +module_exit(fini);
170 diff -urN linux-2.4.30.old/net/ipv4/netfilter/Makefile linux-2.4.30.dev/net/ipv4/netfilter/Makefile
171 --- linux-2.4.30.old/net/ipv4/netfilter/Makefile 2005-04-27 11:35:45.000000000 +0200
172 +++ linux-2.4.30.dev/net/ipv4/netfilter/Makefile 2005-04-27 11:43:49.000000000 +0200
173 @@ -112,6 +112,7 @@
174 obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o
175 obj-$(CONFIG_IP_NF_NAT_SNMP_BASIC) += ip_nat_snmp_basic.o
176 obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o
177 +obj-$(CONFIG_IP_NF_TARGET_TTL) += ipt_TTL.o
178 obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o
179 obj-$(CONFIG_IP_NF_TARGET_TCPMSS) += ipt_TCPMSS.o
180
This page took 0.047504 seconds and 5 git commands to generate.