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

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

Version: ~ [ linux-5.15-rc1 ] ~ [ linux-5.14.5 ] ~ [ linux-5.13.18 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.66 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.147 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.206 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.246 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.282 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.283 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ 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.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-or-later */
  2 /*
  3  * INET         An implementation of the TCP/IP protocol suite for the LINUX
  4  *              operating system.  INET is implemented using the  BSD Socket
  5  *              interface as the means of communication with the user level.
  6  *
  7  *              Definitions of the Internet Protocol.
  8  *
  9  * Version:     @(#)in.h        1.0.1   04/21/93
 10  *
 11  * Authors:     Original taken from the GNU Project <netinet/in.h> file.
 12  *              Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
 13  */
 14 #ifndef _LINUX_IN_H
 15 #define _LINUX_IN_H
 16 
 17 
 18 #include <linux/errno.h>
 19 #include <uapi/linux/in.h>
 20 
 21 static inline int proto_ports_offset(int proto)
 22 {
 23         switch (proto) {
 24         case IPPROTO_TCP:
 25         case IPPROTO_UDP:
 26         case IPPROTO_DCCP:
 27         case IPPROTO_ESP:       /* SPI */
 28         case IPPROTO_SCTP:
 29         case IPPROTO_UDPLITE:
 30                 return 0;
 31         case IPPROTO_AH:        /* SPI */
 32                 return 4;
 33         default:
 34                 return -EINVAL;
 35         }
 36 }
 37 
 38 static inline bool ipv4_is_loopback(__be32 addr)
 39 {
 40         return (addr & htonl(0xff000000)) == htonl(0x7f000000);
 41 }
 42 
 43 static inline bool ipv4_is_multicast(__be32 addr)
 44 {
 45         return (addr & htonl(0xf0000000)) == htonl(0xe0000000);
 46 }
 47 
 48 static inline bool ipv4_is_local_multicast(__be32 addr)
 49 {
 50         return (addr & htonl(0xffffff00)) == htonl(0xe0000000);
 51 }
 52 
 53 static inline bool ipv4_is_lbcast(__be32 addr)
 54 {
 55         /* limited broadcast */
 56         return addr == htonl(INADDR_BROADCAST);
 57 }
 58 
 59 static inline bool ipv4_is_all_snoopers(__be32 addr)
 60 {
 61         return addr == htonl(INADDR_ALLSNOOPERS_GROUP);
 62 }
 63 
 64 static inline bool ipv4_is_zeronet(__be32 addr)
 65 {
 66         return (addr == 0);
 67 }
 68 
 69 /* Special-Use IPv4 Addresses (RFC3330) */
 70 
 71 static inline bool ipv4_is_private_10(__be32 addr)
 72 {
 73         return (addr & htonl(0xff000000)) == htonl(0x0a000000);
 74 }
 75 
 76 static inline bool ipv4_is_private_172(__be32 addr)
 77 {
 78         return (addr & htonl(0xfff00000)) == htonl(0xac100000);
 79 }
 80 
 81 static inline bool ipv4_is_private_192(__be32 addr)
 82 {
 83         return (addr & htonl(0xffff0000)) == htonl(0xc0a80000);
 84 }
 85 
 86 static inline bool ipv4_is_linklocal_169(__be32 addr)
 87 {
 88         return (addr & htonl(0xffff0000)) == htonl(0xa9fe0000);
 89 }
 90 
 91 static inline bool ipv4_is_anycast_6to4(__be32 addr)
 92 {
 93         return (addr & htonl(0xffffff00)) == htonl(0xc0586300);
 94 }
 95 
 96 static inline bool ipv4_is_test_192(__be32 addr)
 97 {
 98         return (addr & htonl(0xffffff00)) == htonl(0xc0000200);
 99 }
100 
101 static inline bool ipv4_is_test_198(__be32 addr)
102 {
103         return (addr & htonl(0xfffe0000)) == htonl(0xc6120000);
104 }
105 #endif  /* _LINUX_IN_H */
106 

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