summaryrefslogtreecommitdiff
path: root/lib/ipv4.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/ipv4.h
parent283c7dfada53a6dee6a8a17ecab492ffafd44b66 (diff)
Finishes add-path.
Fixes some bugs and uses generic hash implementation.
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);