diff options
Diffstat (limited to 'include/linux/in.h')
-rw-r--r-- | include/linux/in.h | 68 |
1 files changed, 62 insertions, 6 deletions
diff --git a/include/linux/in.h b/include/linux/in.h index 3975cbf52f20..70c6df882694 100644 --- a/include/linux/in.h +++ b/include/linux/in.h | |||
@@ -246,13 +246,69 @@ struct sockaddr_in { | |||
246 | #include <asm/byteorder.h> | 246 | #include <asm/byteorder.h> |
247 | 247 | ||
248 | #ifdef __KERNEL__ | 248 | #ifdef __KERNEL__ |
249 | /* Some random defines to make it easier in the kernel.. */ | ||
250 | #define LOOPBACK(x) (((x) & htonl(0xff000000)) == htonl(0x7f000000)) | ||
251 | #define MULTICAST(x) (((x) & htonl(0xf0000000)) == htonl(0xe0000000)) | ||
252 | #define BADCLASS(x) (((x) & htonl(0xf0000000)) == htonl(0xf0000000)) | ||
253 | #define ZERONET(x) (((x) & htonl(0xff000000)) == htonl(0x00000000)) | ||
254 | #define LOCAL_MCAST(x) (((x) & htonl(0xFFFFFF00)) == htonl(0xE0000000)) | ||
255 | 249 | ||
250 | static inline bool ipv4_is_loopback(__be32 addr) | ||
251 | { | ||
252 | return (addr & htonl(0xff000000)) == htonl(0x7f000000); | ||
253 | } | ||
254 | |||
255 | static inline bool ipv4_is_multicast(__be32 addr) | ||
256 | { | ||
257 | return (addr & htonl(0xf0000000)) == htonl(0xe0000000); | ||
258 | } | ||
259 | |||
260 | static inline bool ipv4_is_local_multicast(__be32 addr) | ||
261 | { | ||
262 | return (addr & htonl(0xffffff00)) == htonl(0xe0000000); | ||
263 | } | ||
264 | |||
265 | static inline bool ipv4_is_lbcast(__be32 addr) | ||
266 | { | ||
267 | /* limited broadcast */ | ||
268 | return addr == INADDR_BROADCAST; | ||
269 | } | ||
270 | |||
271 | static inline bool ipv4_is_zeronet(__be32 addr) | ||
272 | { | ||
273 | return (addr & htonl(0xff000000)) == htonl(0x00000000); | ||
274 | } | ||
275 | |||
276 | /* Special-Use IPv4 Addresses (RFC3330) */ | ||
277 | |||
278 | static inline bool ipv4_is_private_10(__be32 addr) | ||
279 | { | ||
280 | return (addr & htonl(0xff000000)) == htonl(0x0a000000); | ||
281 | } | ||
282 | |||
283 | static inline bool ipv4_is_private_172(__be32 addr) | ||
284 | { | ||
285 | return (addr & htonl(0xfff00000)) == htonl(0xac100000); | ||
286 | } | ||
287 | |||
288 | static inline bool ipv4_is_private_192(__be32 addr) | ||
289 | { | ||
290 | return (addr & htonl(0xffff0000)) == htonl(0xc0a80000); | ||
291 | } | ||
292 | |||
293 | static inline bool ipv4_is_linklocal_169(__be32 addr) | ||
294 | { | ||
295 | return (addr & htonl(0xffff0000)) == htonl(0xa9fe0000); | ||
296 | } | ||
297 | |||
298 | static inline bool ipv4_is_anycast_6to4(__be32 addr) | ||
299 | { | ||
300 | return (addr & htonl(0xffffff00)) == htonl(0xc0586300); | ||
301 | } | ||
302 | |||
303 | static inline bool ipv4_is_test_192(__be32 addr) | ||
304 | { | ||
305 | return (addr & htonl(0xffffff00)) == htonl(0xc0000200); | ||
306 | } | ||
307 | |||
308 | static inline bool ipv4_is_test_198(__be32 addr) | ||
309 | { | ||
310 | return (addr & htonl(0xfffe0000)) == htonl(0xc6120000); | ||
311 | } | ||
256 | #endif | 312 | #endif |
257 | 313 | ||
258 | #endif /* _LINUX_IN_H */ | 314 | #endif /* _LINUX_IN_H */ |