1 /* (C) 2001-2002 Magnus Boden <mb@ozaba.mine.nu>
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 as
5 * published by the Free Software Foundation.
9 * Thu 21 Mar 2002 Harald Welte <laforge@gnumonks.org>
10 * - Port to newnat API
12 * This module currently supports DNAT:
13 * iptables -t nat -A PREROUTING -d x.x.x.x -j DNAT --to-dest x.x.x.y
16 * iptables -t nat -A POSTROUTING { -j MASQUERADE , -j SNAT --to-source x.x.x.x }
18 * It has not been tested with
19 * -j SNAT --to-source x.x.x.x-x.x.x.y since I only have one external ip
20 * If you do test this please let me know if it works or not.
24 #include <linux/module.h>
25 #include <linux/netfilter_ipv4.h>
27 #include <linux/udp.h>
29 #include <linux/netfilter.h>
30 #include <linux/netfilter_ipv4/ip_tables.h>
31 #include <linux/netfilter_ipv4/ip_conntrack_helper.h>
32 #include <linux/netfilter_ipv4/ip_conntrack_tftp.h>
33 #include <linux/netfilter_ipv4/ip_nat_helper.h>
34 #include <linux/netfilter_ipv4/ip_nat_rule.h>
35 #include <linux/moduleparam.h>
37 MODULE_AUTHOR("Magnus Boden <mb@ozaba.mine.nu>");
38 MODULE_DESCRIPTION("tftp NAT helper");
39 MODULE_LICENSE("GPL");
41 static unsigned int help(struct sk_buff
**pskb
,
42 enum ip_conntrack_info ctinfo
,
43 struct ip_conntrack_expect
*exp
)
45 struct ip_conntrack
*ct
= exp
->master
;
47 exp
->saved_proto
.udp
.port
48 = ct
->tuplehash
[IP_CT_DIR_ORIGINAL
].tuple
.src
.u
.udp
.port
;
49 exp
->dir
= IP_CT_DIR_REPLY
;
50 exp
->expectfn
= ip_nat_follow_master
;
51 if (ip_conntrack_expect_related(exp
) != 0)
56 static void __exit
ip_nat_tftp_fini(void)
58 rcu_assign_pointer(ip_nat_tftp_hook
, NULL
);
62 static int __init
ip_nat_tftp_init(void)
64 BUG_ON(rcu_dereference(ip_nat_tftp_hook
));
65 rcu_assign_pointer(ip_nat_tftp_hook
, help
);
69 module_init(ip_nat_tftp_init
);
70 module_exit(ip_nat_tftp_fini
);