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.
6 * Definitions of the Internet Protocol.
8 * Version: @(#)in.h 1.0.1 04/21/93
10 * Authors: Original taken from the GNU Project <netinet/in.h> file.
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
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.
22 #include <linux/errno.h>
23 #include <uapi/linux/in.h>
25 static inline int proto_ports_offset(int proto
)
31 case IPPROTO_ESP
: /* SPI */
35 case IPPROTO_AH
: /* SPI */
42 static inline bool ipv4_is_loopback(__be32 addr
)
44 return (addr
& htonl(0xff000000)) == htonl(0x7f000000);
47 static inline bool ipv4_is_multicast(__be32 addr
)
49 return (addr
& htonl(0xf0000000)) == htonl(0xe0000000);
52 static inline bool ipv4_is_local_multicast(__be32 addr
)
54 return (addr
& htonl(0xffffff00)) == htonl(0xe0000000);
57 static inline bool ipv4_is_lbcast(__be32 addr
)
59 /* limited broadcast */
60 return addr
== htonl(INADDR_BROADCAST
);
63 static inline bool ipv4_is_zeronet(__be32 addr
)
65 return (addr
& htonl(0xff000000)) == htonl(0x00000000);
68 /* Special-Use IPv4 Addresses (RFC3330) */
70 static inline bool ipv4_is_private_10(__be32 addr
)
72 return (addr
& htonl(0xff000000)) == htonl(0x0a000000);
75 static inline bool ipv4_is_private_172(__be32 addr
)
77 return (addr
& htonl(0xfff00000)) == htonl(0xac100000);
80 static inline bool ipv4_is_private_192(__be32 addr
)
82 return (addr
& htonl(0xffff0000)) == htonl(0xc0a80000);
85 static inline bool ipv4_is_linklocal_169(__be32 addr
)
87 return (addr
& htonl(0xffff0000)) == htonl(0xa9fe0000);
90 static inline bool ipv4_is_anycast_6to4(__be32 addr
)
92 return (addr
& htonl(0xffffff00)) == htonl(0xc0586300);
95 static inline bool ipv4_is_test_192(__be32 addr
)
97 return (addr
& htonl(0xffffff00)) == htonl(0xc0000200);
100 static inline bool ipv4_is_test_198(__be32 addr
)
102 return (addr
& htonl(0xfffe0000)) == htonl(0xc6120000);
104 #endif /* _LINUX_IN_H */
This page took 0.032187 seconds and 5 git commands to generate.