diff options
author | bms <bms@FreeBSD.org> | 2007-01-31 14:34:47 +0000 |
---|---|---|
committer | bms <bms@FreeBSD.org> | 2007-01-31 14:34:47 +0000 |
commit | cad0bb8b1623afcd1ac92da90371f8c8c4d101bf (patch) | |
tree | 6269edda216e21e16cd47f5cebbae728eeb340b8 /sys | |
parent | 4577663dd42307d939be4fb44c35bc824aed3a1a (diff) | |
download | FreeBSD-src-cad0bb8b1623afcd1ac92da90371f8c8c4d101bf.zip FreeBSD-src-cad0bb8b1623afcd1ac92da90371f8c8c4d101bf.tar.gz |
Import macros IN_LINKLOCAL(), IN_PRIVATE(), IN_LOCAL_GROUP(), IN_ANY_LOCAL().
This is not a functional change.
IN_LINKLOCAL() tests if an address falls within the IPv4 link-local prefix.
IN_PRIVATE() tests if an address falls within an RFC 1918 private prefix.
IN_LOCAL_GROUP() tests if an address falls within the statically assigned
link-local multicast scope specified in RFC 2365.
IN_ANY_LOCAL() tests for either of IN_LINKLOCAL() or IN_LOCAL_GROUP().
As with the existing macros in the FreeBSD netinet stack, comparisons
are performed in host-byte order.
See also: RFC 1918, RFC 2365, RFC 3927
Obtained from: NetBSD (dyoung@)
MFC after: 2 weeks
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet/in.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sys/netinet/in.h b/sys/netinet/in.h index 321877c..db074ef 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -351,6 +351,16 @@ __END_DECLS #define IN_EXPERIMENTAL(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) #define IN_BADCLASS(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) +#define IN_LINKLOCAL(i) (((u_int32_t)(i) & 0xffff0000) == 0xa9fe0000) + +#define IN_PRIVATE(i) ((((u_int32_t)(i) & 0xff000000) == 0x0a000000) || \ + (((u_int32_t)(i) & 0xfff00000) == 0xac100000) || \ + (((u_int32_t)(i) & 0xffff0000) == 0xc0a80000)) + +#define IN_LOCAL_GROUP(i) (((u_int32_t)(i) & 0xffffff00) == 0xe0000000) + +#define IN_ANY_LOCAL(i) (IN_LINKLOCAL(i) || IN_LOCAL_GROUP(i)) + #define INADDR_LOOPBACK (u_int32_t)0x7f000001 #ifndef _KERNEL #define INADDR_NONE 0xffffffff /* -1 return */ |