summaryrefslogtreecommitdiff
path: root/lib/ipv4.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ipv4.h')
-rw-r--r--lib/ipv4.h9
1 files changed, 9 insertions, 0 deletions
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);