diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2014-02-06 20:15:05 +0100 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2014-02-06 20:15:05 +0100 |
commit | 5c200e0a4d26d183e04fda43de16340521002c40 (patch) | |
tree | b158b42840dbb723d9f34651f2f9971121d99eca /lib/ipv6.h | |
parent | 4a5eb284c9d51441e09976021d1bd93c21408d46 (diff) | |
parent | 080ed4d8c2c1982dd0c81c62703064b620a67a01 (diff) |
Merge branch 'add-path'
Diffstat (limited to 'lib/ipv6.h')
-rw-r--r-- | lib/ipv6.h | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -58,6 +58,7 @@ typedef struct ipv6_addr { #define ipa_mkmask(x) ipv6_mkmask(x) #define ipa_mklen(x) ipv6_mklen(&(x)) #define ipa_hash(x) ipv6_hash(&(x)) +#define ipa_hash32(x) ipv6_hash32(&(x)) #define ipa_hton(x) ipv6_hton(&(x)) #define ipa_ntoh(x) ipv6_ntoh(&(x)) #define ipa_classify(x) ipv6_classify(&(x)) @@ -104,6 +105,13 @@ static inline unsigned ipv6_hash(ip_addr *a) return (x ^ (x >> 16) ^ (x >> 8)) & 0xffff; } +static inline u32 ipv6_hash32(ip_addr *a) +{ + /* Returns a 32-bit hash key, although low-order bits are not ixed */ + u32 x = _I0(*a) ^ _I1(*a) ^ _I2(*a) ^ _I3(*a); + return x ^ (x << 16) ^ (x << 24); +} + static inline u32 ipv6_getbit(ip_addr a, u32 y) { return a.addr[y / 32] & (0x80000000 >> (y % 32)); |