summaryrefslogtreecommitdiff
path: root/lib/ipv6.h
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2013-11-26 22:37:24 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2013-12-01 13:49:42 +0100
commite7d2ac4401be8aaf9629e248cad6a74498a6be24 (patch)
tree43fc2a026bb83c56d614e8551701ce9feaef71f2 /lib/ipv6.h
parent283c7dfada53a6dee6a8a17ecab492ffafd44b66 (diff)
Finishes add-path.
Fixes some bugs and uses generic hash implementation.
Diffstat (limited to 'lib/ipv6.h')
-rw-r--r--lib/ipv6.h8
1 files changed, 8 insertions, 0 deletions
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));