5 * Bart De Schuymer <bdschuym@pandora.be>
10 #include <linux/module.h>
12 #include <linux/netfilter.h>
13 #include <linux/netfilter/x_tables.h>
14 #include <linux/netfilter_bridge/ebtables.h>
15 #include <linux/netfilter_bridge/ebt_nat.h>
18 ebt_dnat_tg(struct sk_buff
*skb
, const struct xt_action_param
*par
)
20 const struct ebt_nat_info
*info
= par
->targinfo
;
22 if (!skb_make_writable(skb
, 0))
25 memcpy(eth_hdr(skb
)->h_dest
, info
->mac
, ETH_ALEN
);
29 static int ebt_dnat_tg_check(const struct xt_tgchk_param
*par
)
31 const struct ebt_nat_info
*info
= par
->targinfo
;
32 unsigned int hook_mask
;
34 if (BASE_CHAIN
&& info
->target
== EBT_RETURN
)
37 hook_mask
= par
->hook_mask
& ~(1 << NF_BR_NUMHOOKS
);
38 if ((strcmp(par
->table
, "nat") != 0 ||
39 (hook_mask
& ~((1 << NF_BR_PRE_ROUTING
) |
40 (1 << NF_BR_LOCAL_OUT
)))) &&
41 (strcmp(par
->table
, "broute") != 0 ||
42 hook_mask
& ~(1 << NF_BR_BROUTING
)))
49 static struct xt_target ebt_dnat_tg_reg __read_mostly
= {
52 .family
= NFPROTO_BRIDGE
,
53 .hooks
= (1 << NF_BR_NUMHOOKS
) | (1 << NF_BR_PRE_ROUTING
) |
54 (1 << NF_BR_LOCAL_OUT
) | (1 << NF_BR_BROUTING
),
55 .target
= ebt_dnat_tg
,
56 .checkentry
= ebt_dnat_tg_check
,
57 .targetsize
= sizeof(struct ebt_nat_info
),
61 static int __init
ebt_dnat_init(void)
63 return xt_register_target(&ebt_dnat_tg_reg
);
66 static void __exit
ebt_dnat_fini(void)
68 xt_unregister_target(&ebt_dnat_tg_reg
);
71 module_init(ebt_dnat_init
);
72 module_exit(ebt_dnat_fini
);
73 MODULE_DESCRIPTION("Ebtables: Destination MAC address translation");
74 MODULE_LICENSE("GPL");