5 * Bart De Schuymer <bdschuym@pandora.be>
11 #include <linux/netfilter.h>
12 #include <linux/netfilter_bridge/ebtables.h>
13 #include <linux/netfilter_bridge/ebt_nat.h>
14 #include <linux/module.h>
17 static int ebt_target_dnat(struct sk_buff
*skb
, unsigned int hooknr
,
18 const struct net_device
*in
, const struct net_device
*out
,
19 const void *data
, unsigned int datalen
)
21 const struct ebt_nat_info
*info
= data
;
23 if (!skb_make_writable(skb
, 0))
26 memcpy(eth_hdr(skb
)->h_dest
, info
->mac
, ETH_ALEN
);
30 static int ebt_target_dnat_check(const char *tablename
, unsigned int hookmask
,
31 const struct ebt_entry
*e
, void *data
, unsigned int datalen
)
33 const struct ebt_nat_info
*info
= data
;
35 if (BASE_CHAIN
&& info
->target
== EBT_RETURN
)
38 if ( (strcmp(tablename
, "nat") ||
39 (hookmask
& ~((1 << NF_BR_PRE_ROUTING
) | (1 << NF_BR_LOCAL_OUT
)))) &&
40 (strcmp(tablename
, "broute") || hookmask
& ~(1 << NF_BR_BROUTING
)) )
42 if (datalen
!= EBT_ALIGN(sizeof(struct ebt_nat_info
)))
49 static struct ebt_target dnat __read_mostly
= {
50 .name
= EBT_DNAT_TARGET
,
51 .target
= ebt_target_dnat
,
52 .check
= ebt_target_dnat_check
,
56 static int __init
ebt_dnat_init(void)
58 return ebt_register_target(&dnat
);
61 static void __exit
ebt_dnat_fini(void)
63 ebt_unregister_target(&dnat
);
66 module_init(ebt_dnat_init
);
67 module_exit(ebt_dnat_fini
);
68 MODULE_DESCRIPTION("Ebtables: Destination MAC address translation");
69 MODULE_LICENSE("GPL");