2 * Copyright (c) 2011 Patrick McHardy <kaber@trash.net>
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.
8 * Based on Rusty Russell's IPv6 MASQUERADE target. Development of IPv6
9 * NAT funded by Astaro.
12 #include <linux/kernel.h>
13 #include <linux/module.h>
14 #include <linux/netdevice.h>
15 #include <linux/ipv6.h>
16 #include <linux/netfilter.h>
17 #include <linux/netfilter_ipv6.h>
18 #include <linux/netfilter/x_tables.h>
19 #include <net/netfilter/nf_nat.h>
20 #include <net/addrconf.h>
22 #include <net/netfilter/ipv6/nf_nat_masquerade.h>
25 masquerade_tg6(struct sk_buff *skb, const struct xt_action_param *par)
27 return nf_nat_masquerade_ipv6(skb, par->targinfo, par->out);
30 static int masquerade_tg6_checkentry(const struct xt_tgchk_param *par)
32 const struct nf_nat_range *range = par->targinfo;
34 if (range->flags & NF_NAT_RANGE_MAP_IPS)
39 static struct xt_target masquerade_tg6_reg __read_mostly = {
41 .family = NFPROTO_IPV6,
42 .checkentry = masquerade_tg6_checkentry,
43 .target = masquerade_tg6,
44 .targetsize = sizeof(struct nf_nat_range),
46 .hooks = 1 << NF_INET_POST_ROUTING,
50 static int __init masquerade_tg6_init(void)
54 err = xt_register_target(&masquerade_tg6_reg);
56 nf_nat_masquerade_ipv6_register_notifier();
60 static void __exit masquerade_tg6_exit(void)
62 nf_nat_masquerade_ipv6_unregister_notifier();
63 xt_unregister_target(&masquerade_tg6_reg);
66 module_init(masquerade_tg6_init);
67 module_exit(masquerade_tg6_exit);
69 MODULE_LICENSE("GPL");
70 MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
71 MODULE_DESCRIPTION("Xtables: automatic address SNAT");