1 /* Kernel module to match EUI64 address parameters. */
3 /* (C) 2001-2002 Andras Kis-Szabo <kisza@sch.bme.hu>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
10 #include <linux/module.h>
11 #include <linux/skbuff.h>
12 #include <linux/ipv6.h>
13 #include <linux/if_ether.h>
15 #include <linux/netfilter/x_tables.h>
16 #include <linux/netfilter_ipv6/ip6_tables.h>
18 MODULE_DESCRIPTION("Xtables: IPv6 EUI64 address match");
19 MODULE_LICENSE("GPL");
20 MODULE_AUTHOR("Andras Kis-Szabo <kisza@sch.bme.hu>");
23 eui64_mt6(const struct sk_buff
*skb
, const struct xt_match_param
*par
)
25 unsigned char eui64
[8];
27 if (!(skb_mac_header(skb
) >= skb
->head
&&
28 skb_mac_header(skb
) + ETH_HLEN
<= skb
->data
) &&
34 memset(eui64
, 0, sizeof(eui64
));
36 if (eth_hdr(skb
)->h_proto
== htons(ETH_P_IPV6
)) {
37 if (ipv6_hdr(skb
)->version
== 0x6) {
38 memcpy(eui64
, eth_hdr(skb
)->h_source
, 3);
39 memcpy(eui64
+ 5, eth_hdr(skb
)->h_source
+ 3, 3);
44 if (!memcmp(ipv6_hdr(skb
)->saddr
.s6_addr
+ 8, eui64
,
53 static struct xt_match eui64_mt6_reg __read_mostly
= {
55 .family
= NFPROTO_IPV6
,
57 .matchsize
= sizeof(int),
58 .hooks
= (1 << NF_INET_PRE_ROUTING
) | (1 << NF_INET_LOCAL_IN
) |
59 (1 << NF_INET_FORWARD
),
63 static int __init
eui64_mt6_init(void)
65 return xt_register_match(&eui64_mt6_reg
);
68 static void __exit
eui64_mt6_exit(void)
70 xt_unregister_match(&eui64_mt6_reg
);
73 module_init(eui64_mt6_init
);
74 module_exit(eui64_mt6_exit
);