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
5 If you want to compile it as a module, say M here and read
6 <file:Documentation/modules.txt>. If unsure, say `N'.
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
14 + If you want to compile it as a module, say M here and read
15 + Documentation/modules.txt. If unsure, say `N'.
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
24 +/* TTL modification module for IP tables
25 + * (C) 2000 by Harald Welte <laforge@gnumonks.org> */
36 +#define IPT_TTL_MAXMODE IPT_TTL_DEC
38 +struct ipt_TTL_info {
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
49 dep_tristate ' MARK target support' CONFIG_IP_NF_TARGET_MARK $CONFIG_IP_NF_MANGLE
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
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
60 +/* TTL modification target for IP tables
61 + * (C) 2000 by Harald Welte <laforge@gnumonks.org>
63 + * Version: $Revision$
65 + * This software is distributed under the terms of GNU GPL
68 +#include <linux/module.h>
69 +#include <linux/skbuff.h>
70 +#include <linux/ip.h>
71 +#include <net/checksum.h>
73 +#include <linux/netfilter_ipv4/ip_tables.h>
74 +#include <linux/netfilter_ipv4/ipt_TTL.h>
76 +MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
77 +MODULE_DESCRIPTION("IP tables TTL modification module");
78 +MODULE_LICENSE("GPL");
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)
84 + struct iphdr *iph = (*pskb)->nh.iph;
85 + const struct ipt_TTL_info *info = targinfo;
89 + switch (info->mode) {
91 + new_ttl = info->ttl;
94 + new_ttl = iph->ttl + info->ttl;
99 + new_ttl = iph->ttl - info->ttl;
104 + new_ttl = iph->ttl;
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,
114 + iph->check^0xFFFF));
115 + (*pskb)->nfcache |= NFC_ALTERED;
118 + return IPT_CONTINUE;
121 +static int ipt_ttl_checkentry(const char *tablename,
122 + const struct ipt_entry *e,
124 + unsigned int targinfosize,
125 + unsigned int hook_mask)
127 + struct ipt_TTL_info *info = targinfo;
129 + if (targinfosize != IPT_ALIGN(sizeof(struct ipt_TTL_info))) {
130 + printk(KERN_WARNING "TTL: targinfosize %u != %Zu\n",
132 + IPT_ALIGN(sizeof(struct ipt_TTL_info)));
136 + if (strcmp(tablename, "mangle")) {
137 + printk(KERN_WARNING "TTL: can only be called from \"mangle\" table, not \"%s\"\n", tablename);
141 + if (info->mode > IPT_TTL_MAXMODE) {
142 + printk(KERN_WARNING "TTL: invalid or unknown Mode %u\n",
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");
155 +static struct ipt_target ipt_TTL = { { NULL, NULL }, "TTL",
156 + ipt_ttl_target, ipt_ttl_checkentry, NULL, THIS_MODULE };
158 +static int __init init(void)
160 + return ipt_register_target(&ipt_TTL);
163 +static void __exit fini(void)
165 + ipt_unregister_target(&ipt_TTL);
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
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