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

TOMOYO Linux Cross Reference
Linux/net/ipv6/addrconf_core.c

Version: ~ [ linux-6.3-rc3 ] ~ [ linux-6.2.7 ] ~ [ linux-6.1.20 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.103 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.175 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.237 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.278 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.310 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ 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 /*
  2  * IPv6 library code, needed by static components when full IPv6 support is
  3  * not configured or static.
  4  */
  5 
  6 #include <linux/export.h>
  7 #include <net/ipv6.h>
  8 
  9 #define IPV6_ADDR_SCOPE_TYPE(scope)     ((scope) << 16)
 10 
 11 static inline unsigned int ipv6_addr_scope2type(unsigned int scope)
 12 {
 13         switch (scope) {
 14         case IPV6_ADDR_SCOPE_NODELOCAL:
 15                 return (IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_NODELOCAL) |
 16                         IPV6_ADDR_LOOPBACK);
 17         case IPV6_ADDR_SCOPE_LINKLOCAL:
 18                 return (IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_LINKLOCAL) |
 19                         IPV6_ADDR_LINKLOCAL);
 20         case IPV6_ADDR_SCOPE_SITELOCAL:
 21                 return (IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_SITELOCAL) |
 22                         IPV6_ADDR_SITELOCAL);
 23         }
 24         return IPV6_ADDR_SCOPE_TYPE(scope);
 25 }
 26 
 27 int __ipv6_addr_type(const struct in6_addr *addr)
 28 {
 29         __be32 st;
 30 
 31         st = addr->s6_addr32[0];
 32 
 33         /* Consider all addresses with the first three bits different of
 34            000 and 111 as unicasts.
 35          */
 36         if ((st & htonl(0xE0000000)) != htonl(0x00000000) &&
 37             (st & htonl(0xE0000000)) != htonl(0xE0000000))
 38                 return (IPV6_ADDR_UNICAST |
 39                         IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL));
 40 
 41         if ((st & htonl(0xFF000000)) == htonl(0xFF000000)) {
 42                 /* multicast */
 43                 /* addr-select 3.1 */
 44                 return (IPV6_ADDR_MULTICAST |
 45                         ipv6_addr_scope2type(IPV6_ADDR_MC_SCOPE(addr)));
 46         }
 47 
 48         if ((st & htonl(0xFFC00000)) == htonl(0xFE800000))
 49                 return (IPV6_ADDR_LINKLOCAL | IPV6_ADDR_UNICAST |
 50                         IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_LINKLOCAL));               /* addr-select 3.1 */
 51         if ((st & htonl(0xFFC00000)) == htonl(0xFEC00000))
 52                 return (IPV6_ADDR_SITELOCAL | IPV6_ADDR_UNICAST |
 53                         IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_SITELOCAL));               /* addr-select 3.1 */
 54         if ((st & htonl(0xFE000000)) == htonl(0xFC000000))
 55                 return (IPV6_ADDR_UNICAST |
 56                         IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL));                  /* RFC 4193 */
 57 
 58         if ((addr->s6_addr32[0] | addr->s6_addr32[1]) == 0) {
 59                 if (addr->s6_addr32[2] == 0) {
 60                         if (addr->s6_addr32[3] == 0)
 61                                 return IPV6_ADDR_ANY;
 62 
 63                         if (addr->s6_addr32[3] == htonl(0x00000001))
 64                                 return (IPV6_ADDR_LOOPBACK | IPV6_ADDR_UNICAST |
 65                                         IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_LINKLOCAL));       /* addr-select 3.4 */
 66 
 67                         return (IPV6_ADDR_COMPATv4 | IPV6_ADDR_UNICAST |
 68                                 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL));  /* addr-select 3.3 */
 69                 }
 70 
 71                 if (addr->s6_addr32[2] == htonl(0x0000ffff))
 72                         return (IPV6_ADDR_MAPPED |
 73                                 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL));  /* addr-select 3.3 */
 74         }
 75 
 76         return (IPV6_ADDR_UNICAST |
 77                 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL));  /* addr-select 3.4 */
 78 }
 79 EXPORT_SYMBOL(__ipv6_addr_type);
 80 
 81 static ATOMIC_NOTIFIER_HEAD(inet6addr_chain);
 82 
 83 int register_inet6addr_notifier(struct notifier_block *nb)
 84 {
 85         return atomic_notifier_chain_register(&inet6addr_chain, nb);
 86 }
 87 EXPORT_SYMBOL(register_inet6addr_notifier);
 88 
 89 int unregister_inet6addr_notifier(struct notifier_block *nb)
 90 {
 91         return atomic_notifier_chain_unregister(&inet6addr_chain, nb);
 92 }
 93 EXPORT_SYMBOL(unregister_inet6addr_notifier);
 94 
 95 int inet6addr_notifier_call_chain(unsigned long val, void *v)
 96 {
 97         return atomic_notifier_call_chain(&inet6addr_chain, val, v);
 98 }
 99 EXPORT_SYMBOL(inet6addr_notifier_call_chain);
100 

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