diff options
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)); |