aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/in.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-01-29 06:54:01 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-01-29 06:54:01 -0500
commit0ba6c33bcddc64a54b5f1c25a696c4767dc76292 (patch)
tree62e616f97a4762d8e75bf732e4827af2d15d52c5 /include/linux/in.h
parent21af0297c7e56024a5ccc4d8ad2a590f9ec371ba (diff)
parent85040bcb4643cba578839e953f25e2d1965d83d0 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.25
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.25: (1470 commits) [IPV6] ADDRLABEL: Fix double free on label deletion. [PPP]: Sparse warning fixes. [IPV4] fib_trie: remove unneeded NULL check [IPV4] fib_trie: More whitespace cleanup. [NET_SCHED]: Use nla_policy for attribute validation in ematches [NET_SCHED]: Use nla_policy for attribute validation in actions [NET_SCHED]: Use nla_policy for attribute validation in classifiers [NET_SCHED]: Use nla_policy for attribute validation in packet schedulers [NET_SCHED]: sch_api: introduce constant for rate table size [NET_SCHED]: Use typeful attribute parsing helpers [NET_SCHED]: Use typeful attribute construction helpers [NET_SCHED]: Use NLA_PUT_STRING for string dumping [NET_SCHED]: Use nla_nest_start/nla_nest_end [NET_SCHED]: Propagate nla_parse return value [NET_SCHED]: act_api: use PTR_ERR in tcf_action_init/tcf_action_get [NET_SCHED]: act_api: use nlmsg_parse [NET_SCHED]: act_api: fix netlink API conversion bug [NET_SCHED]: sch_netem: use nla_parse_nested_compat [NET_SCHED]: sch_atm: fix format string warning [NETNS]: Add namespace for ICMP replying code. ...
Diffstat (limited to 'include/linux/in.h')
-rw-r--r--include/linux/in.h68
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
250static inline bool ipv4_is_loopback(__be32 addr)
251{
252 return (addr & htonl(0xff000000)) == htonl(0x7f000000);
253}
254
255static inline bool ipv4_is_multicast(__be32 addr)
256{
257 return (addr & htonl(0xf0000000)) == htonl(0xe0000000);
258}
259
260static inline bool ipv4_is_local_multicast(__be32 addr)
261{
262 return (addr & htonl(0xffffff00)) == htonl(0xe0000000);
263}
264
265static inline bool ipv4_is_lbcast(__be32 addr)
266{
267 /* limited broadcast */
268 return addr == INADDR_BROADCAST;
269}
270
271static inline bool ipv4_is_zeronet(__be32 addr)
272{
273 return (addr & htonl(0xff000000)) == htonl(0x00000000);
274}
275
276/* Special-Use IPv4 Addresses (RFC3330) */
277
278static inline bool ipv4_is_private_10(__be32 addr)
279{
280 return (addr & htonl(0xff000000)) == htonl(0x0a000000);
281}
282
283static inline bool ipv4_is_private_172(__be32 addr)
284{
285 return (addr & htonl(0xfff00000)) == htonl(0xac100000);
286}
287
288static inline bool ipv4_is_private_192(__be32 addr)
289{
290 return (addr & htonl(0xffff0000)) == htonl(0xc0a80000);
291}
292
293static inline bool ipv4_is_linklocal_169(__be32 addr)
294{
295 return (addr & htonl(0xffff0000)) == htonl(0xa9fe0000);
296}
297
298static inline bool ipv4_is_anycast_6to4(__be32 addr)
299{
300 return (addr & htonl(0xffffff00)) == htonl(0xc0586300);
301}
302
303static inline bool ipv4_is_test_192(__be32 addr)
304{
305 return (addr & htonl(0xffffff00)) == htonl(0xc0000200);
306}
307
308static 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 */