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

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

Version: ~ [ linux-5.4-rc3 ] ~ [ linux-5.3.6 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.79 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.149 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.196 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.196 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.75 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ 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