e1000: FIX: Stop raw interrupts disabled nag from RT
[pandora-kernel.git] / net / ipv4 / netfilter / ip_nat_tftp.c
1 /* (C) 2001-2002 Magnus Boden <mb@ozaba.mine.nu>
2  *
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.
6  *
7  * Version: 0.0.7
8  *
9  * Thu 21 Mar 2002 Harald Welte <laforge@gnumonks.org>
10  *      - Port to newnat API
11  *
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
14  *
15  * and SNAT:
16  * iptables -t nat -A POSTROUTING { -j MASQUERADE , -j SNAT --to-source x.x.x.x }
17  *
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.
21  *
22  */
23
24 #include <linux/module.h>
25 #include <linux/netfilter_ipv4.h>
26 #include <linux/ip.h>
27 #include <linux/udp.h>
28
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>
36
37 MODULE_AUTHOR("Magnus Boden <mb@ozaba.mine.nu>");
38 MODULE_DESCRIPTION("tftp NAT helper");
39 MODULE_LICENSE("GPL");
40
41 static unsigned int help(struct sk_buff **pskb,
42                          enum ip_conntrack_info ctinfo,
43                          struct ip_conntrack_expect *exp)
44 {
45         struct ip_conntrack *ct = exp->master;
46
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)
52                 return NF_DROP;
53         return NF_ACCEPT;
54 }
55
56 static void __exit ip_nat_tftp_fini(void)
57 {
58         rcu_assign_pointer(ip_nat_tftp_hook, NULL);
59         synchronize_rcu();
60 }
61
62 static int __init ip_nat_tftp_init(void)
63 {
64         BUG_ON(rcu_dereference(ip_nat_tftp_hook));
65         rcu_assign_pointer(ip_nat_tftp_hook, help);
66         return 0;
67 }
68
69 module_init(ip_nat_tftp_init);
70 module_exit(ip_nat_tftp_fini);