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

TOMOYO Linux Cross Reference
Linux/include/linux/in.h

Version: ~ [ linux-6.6-rc1 ] ~ [ linux-6.5.2 ] ~ [ linux-6.4.15 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.52 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.131 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.194 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.256 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.294 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.325 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ 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  * INET         An implementation of the TCP/IP protocol suite for the LINUX
  3  *              operating system.  INET is implemented using the  BSD Socket
  4  *              interface as the means of communication with the user level.
  5  *
  6  *              Definitions of the Internet Protocol.
  7  *
  8  * Version:     @(#)in.h        1.0.1   04/21/93
  9  *
 10  * Authors:     Original taken from the GNU Project <netinet/in.h> file.
 11  *              Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
 12  *
 13  *              This program is free software; you can redistribute it and/or
 14  *              modify it under the terms of the GNU General Public License
 15  *              as published by the Free Software Foundation; either version
 16  *              2 of the License, or (at your option) any later version.
 17  */
 18 #ifndef _LINUX_IN_H
 19 #define _LINUX_IN_H
 20 
 21 
 22 #include <linux/errno.h>
 23 #include <uapi/linux/in.h>
 24 
 25 static inline int proto_ports_offset(int proto)
 26 {
 27         switch (proto) {
 28         case IPPROTO_TCP:
 29         case IPPROTO_UDP:
 30         case IPPROTO_DCCP:
 31         case IPPROTO_ESP:       /* SPI */
 32         case IPPROTO_SCTP:
 33         case IPPROTO_UDPLITE:
 34                 return 0;
 35         case IPPROTO_AH:        /* SPI */
 36                 return 4;
 37         default:
 38                 return -EINVAL;
 39         }
 40 }
 41 
 42 static inline bool ipv4_is_loopback(__be32 addr)
 43 {
 44         return (addr & htonl(0xff000000)) == htonl(0x7f000000);
 45 }
 46 
 47 static inline bool ipv4_is_multicast(__be32 addr)
 48 {
 49         return (addr & htonl(0xf0000000)) == htonl(0xe0000000);
 50 }
 51 
 52 static inline bool ipv4_is_local_multicast(__be32 addr)
 53 {
 54         return (addr & htonl(0xffffff00)) == htonl(0xe0000000);
 55 }
 56 
 57 static inline bool ipv4_is_lbcast(__be32 addr)
 58 {
 59         /* limited broadcast */
 60         return addr == htonl(INADDR_BROADCAST);
 61 }
 62 
 63 static inline bool ipv4_is_zeronet(__be32 addr)
 64 {
 65         return (addr & htonl(0xff000000)) == htonl(0x00000000);
 66 }
 67 
 68 /* Special-Use IPv4 Addresses (RFC3330) */
 69 
 70 static inline bool ipv4_is_private_10(__be32 addr)
 71 {
 72         return (addr & htonl(0xff000000)) == htonl(0x0a000000);
 73 }
 74 
 75 static inline bool ipv4_is_private_172(__be32 addr)
 76 {
 77         return (addr & htonl(0xfff00000)) == htonl(0xac100000);
 78 }
 79 
 80 static inline bool ipv4_is_private_192(__be32 addr)
 81 {
 82         return (addr & htonl(0xffff0000)) == htonl(0xc0a80000);
 83 }
 84 
 85 static inline bool ipv4_is_linklocal_169(__be32 addr)
 86 {
 87         return (addr & htonl(0xffff0000)) == htonl(0xa9fe0000);
 88 }
 89 
 90 static inline bool ipv4_is_anycast_6to4(__be32 addr)
 91 {
 92         return (addr & htonl(0xffffff00)) == htonl(0xc0586300);
 93 }
 94 
 95 static inline bool ipv4_is_test_192(__be32 addr)
 96 {
 97         return (addr & htonl(0xffffff00)) == htonl(0xc0000200);
 98 }
 99 
100 static inline bool ipv4_is_test_198(__be32 addr)
101 {
102         return (addr & htonl(0xfffe0000)) == htonl(0xc6120000);
103 }
104 #endif  /* _LINUX_IN_H */
105 

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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