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("IPv6 EUI64 address checking match");
19 MODULE_LICENSE("GPL");
20 MODULE_AUTHOR("Andras Kis-Szabo <kisza@sch.bme.hu>");
23 match(const struct sk_buff *skb,
24 const struct net_device *in,
25 const struct net_device *out,
26 const struct xt_match *match,
27 const void *matchinfo,
32 unsigned char eui64[8];
35 if (!(skb_mac_header(skb) >= skb->head &&
36 skb_mac_header(skb) + ETH_HLEN <= skb->data) &&
42 memset(eui64, 0, sizeof(eui64));
44 if (eth_hdr(skb)->h_proto == htons(ETH_P_IPV6)) {
45 if (ipv6_hdr(skb)->version == 0x6) {
46 memcpy(eui64, eth_hdr(skb)->h_source, 3);
47 memcpy(eui64 + 5, eth_hdr(skb)->h_source + 3, 3);
53 while (ipv6_hdr(skb)->saddr.s6_addr[8 + i] == eui64[i]
65 static struct xt_match eui64_match __read_mostly = {
69 .matchsize = sizeof(int),
70 .hooks = (1 << NF_IP6_PRE_ROUTING) | (1 << NF_IP6_LOCAL_IN) |
71 (1 << NF_IP6_FORWARD),
75 static int __init ip6t_eui64_init(void)
77 return xt_register_match(&eui64_match);
80 static void __exit ip6t_eui64_fini(void)
82 xt_unregister_match(&eui64_match);
85 module_init(ip6t_eui64_init);
86 module_exit(ip6t_eui64_fini);