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/ipv4.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/ipv4.h') diff --git a/lib/ipv4.h b/lib/ipv4.h index f258d37e..7fbdf2eb 100644 --- a/lib/ipv4.h +++ b/lib/ipv4.h @@ -52,6 +52,7 @@ typedef u32 ip_addr; #define ipa_mkmask(x) _MI(u32_mkmask(x)) #define ipa_mklen(x) u32_masklen(_I(x)) #define ipa_hash(x) ipv4_hash(_I(x)) +#define ipa_hash32(x) ipv4_hash32(_I(x)) #define ipa_hton(x) x = _MI(htonl(_I(x))) #define ipa_ntoh(x) x = _MI(ntohl(_I(x))) #define ipa_classify(x) ipv4_classify(_I(x)) @@ -86,6 +87,14 @@ static inline unsigned ipv4_hash(u32 a) return a & 0xffff; } +static inline u32 ipv4_hash32(u32 a) +{ + /* Returns a 32-bit value, although low-order bits are not mixed */ + a ^= a << 16; + a ^= a << 12; + return a; +} + static inline int ipv4_compare(u32 x, u32 y) { return (x > y) - (x < y); -- cgit v1.2.3