netfilter: Change return types of targets/watchers for Ebtables extensions
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / net / bridge / netfilter / ebt_dnat.c
blobd58b9e32338e6ac4c35da19f644179a4769802b2
1 /*
2 * ebt_dnat
4 * Authors:
5 * Bart De Schuymer <bdschuym@pandora.be>
7 * June, 2002
9 */
10 #include <linux/module.h>
11 #include <net/sock.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>
17 static unsigned 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))
24 return EBT_DROP;
26 memcpy(eth_hdr(skb)->h_dest, info->mac, ETH_ALEN);
27 return info->target;
30 static bool 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)
36 return false;
37 CLEAR_BASE_CHAIN_BIT;
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)) )
41 return false;
42 if (INVALID_TARGET)
43 return false;
44 return true;
47 static struct ebt_target dnat __read_mostly = {
48 .name = EBT_DNAT_TARGET,
49 .target = ebt_target_dnat,
50 .check = ebt_target_dnat_check,
51 .targetsize = XT_ALIGN(sizeof(struct ebt_nat_info)),
52 .me = THIS_MODULE,
55 static int __init ebt_dnat_init(void)
57 return ebt_register_target(&dnat);
60 static void __exit ebt_dnat_fini(void)
62 ebt_unregister_target(&dnat);
65 module_init(ebt_dnat_init);
66 module_exit(ebt_dnat_fini);
67 MODULE_DESCRIPTION("Ebtables: Destination MAC address translation");
68 MODULE_LICENSE("GPL");