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_dnat(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_dest
, info
->mac
, ETH_ALEN
);
37 static int ebt_target_dnat_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 (BASE_CHAIN
&& info
->target
== EBT_RETURN
)
45 if ( (strcmp(tablename
, "nat") ||
46 (hookmask
& ~((1 << NF_BR_PRE_ROUTING
) | (1 << NF_BR_LOCAL_OUT
)))) &&
47 (strcmp(tablename
, "broute") || hookmask
& ~(1 << NF_BR_BROUTING
)) )
49 if (datalen
!= EBT_ALIGN(sizeof(struct ebt_nat_info
)))
56 static struct ebt_target dnat
=
58 .name
= EBT_DNAT_TARGET
,
59 .target
= ebt_target_dnat
,
60 .check
= ebt_target_dnat_check
,
64 static int __init
init(void)
66 return ebt_register_target(&dnat
);
69 static void __exit
fini(void)
71 ebt_unregister_target(&dnat
);
76 MODULE_LICENSE("GPL");