From e7d2ac4401be8aaf9629e248cad6a74498a6be24 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Tue, 26 Nov 2013 22:37:24 +0100 Subject: Finishes add-path. Fixes some bugs and uses generic hash implementation. --- lib/ipv6.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/ipv6.h') diff --git a/lib/ipv6.h b/lib/ipv6.h index 2247d3fd..b935a6ef 100644 --- a/lib/ipv6.h +++ b/lib/ipv6.h @@ -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)); -- cgit v1.2.3