5 * Bart De Schuymer <bdschuym@pandora.be>
11 #include <linux/netfilter_bridge/ebtables.h>
12 #include <linux/netfilter_bridge/ebt_nat.h>
13 #include <linux/module.h>
16 static int ebt_target_snat(struct sk_buff
**pskb
, unsigned int hooknr
,
17 const struct net_device
*in
, const struct net_device
*out
,
18 const void *data
, unsigned int datalen
)
20 struct ebt_nat_info
*info
= (struct ebt_nat_info
*) data
;
22 if (skb_shared(*pskb
) || skb_cloned(*pskb
)) {
25 nskb
= skb_copy(*pskb
, GFP_ATOMIC
);
29 skb_set_owner_w(nskb
, (*pskb
)->sk
);
33 memcpy(eth_hdr(*pskb
)->h_source
, info
->mac
, ETH_ALEN
);
37 static int ebt_target_snat_check(const char *tablename
, unsigned int hookmask
,
38 const struct ebt_entry
*e
, void *data
, unsigned int datalen
)
40 struct ebt_nat_info
*info
= (struct ebt_nat_info
*) data
;
42 if (datalen
!= EBT_ALIGN(sizeof(struct ebt_nat_info
)))
44 if (BASE_CHAIN
&& info
->target
== EBT_RETURN
)
47 if (strcmp(tablename
, "nat"))
49 if (hookmask
& ~(1 << NF_BR_POST_ROUTING
))
56 static struct ebt_target snat
=
58 .name
= EBT_SNAT_TARGET
,
59 .target
= ebt_target_snat
,
60 .check
= ebt_target_snat_check
,
64 static int __init
init(void)
66 return ebt_register_target(&snat
);
69 static void __exit
fini(void)
71 ebt_unregister_target(&snat
);
76 MODULE_LICENSE("GPL");