~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/ipv6/netfilter/ip6t_eui64.c

Version: ~ [ linux-6.0-rc6 ] ~ [ linux-5.19.10 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.69 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.144 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.214 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.259 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.294 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.329 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /* Kernel module to match EUI64 address parameters. */
  3 
  4 /* (C) 2001-2002 Andras Kis-Szabo <kisza@sch.bme.hu>
  5  */
  6 
  7 #include <linux/module.h>
  8 #include <linux/skbuff.h>
  9 #include <linux/ipv6.h>
 10 #include <linux/if_ether.h>
 11 
 12 #include <linux/netfilter/x_tables.h>
 13 #include <linux/netfilter_ipv6/ip6_tables.h>
 14 
 15 MODULE_DESCRIPTION("Xtables: IPv6 EUI64 address match");
 16 MODULE_LICENSE("GPL");
 17 MODULE_AUTHOR("Andras Kis-Szabo <kisza@sch.bme.hu>");
 18 
 19 static bool
 20 eui64_mt6(const struct sk_buff *skb, struct xt_action_param *par)
 21 {
 22         unsigned char eui64[8];
 23 
 24         if (!(skb_mac_header(skb) >= skb->head &&
 25               skb_mac_header(skb) + ETH_HLEN <= skb->data) &&
 26             par->fragoff != 0) {
 27                 par->hotdrop = true;
 28                 return false;
 29         }
 30 
 31         memset(eui64, 0, sizeof(eui64));
 32 
 33         if (eth_hdr(skb)->h_proto == htons(ETH_P_IPV6)) {
 34                 if (ipv6_hdr(skb)->version == 0x6) {
 35                         memcpy(eui64, eth_hdr(skb)->h_source, 3);
 36                         memcpy(eui64 + 5, eth_hdr(skb)->h_source + 3, 3);
 37                         eui64[3] = 0xff;
 38                         eui64[4] = 0xfe;
 39                         eui64[0] ^= 0x02;
 40 
 41                         if (!memcmp(ipv6_hdr(skb)->saddr.s6_addr + 8, eui64,
 42                                     sizeof(eui64)))
 43                                 return true;
 44                 }
 45         }
 46 
 47         return false;
 48 }
 49 
 50 static struct xt_match eui64_mt6_reg __read_mostly = {
 51         .name           = "eui64",
 52         .family         = NFPROTO_IPV6,
 53         .match          = eui64_mt6,
 54         .matchsize      = sizeof(int),
 55         .hooks          = (1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_IN) |
 56                           (1 << NF_INET_FORWARD),
 57         .me             = THIS_MODULE,
 58 };
 59 
 60 static int __init eui64_mt6_init(void)
 61 {
 62         return xt_register_match(&eui64_mt6_reg);
 63 }
 64 
 65 static void __exit eui64_mt6_exit(void)
 66 {
 67         xt_unregister_match(&eui64_mt6_reg);
 68 }
 69 
 70 module_init(eui64_mt6_init);
 71 module_exit(eui64_mt6_exit);
 72 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp