diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2014-02-06 20:15:05 +0100 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2014-02-06 20:15:05 +0100 |
commit | 5c200e0a4d26d183e04fda43de16340521002c40 (patch) | |
tree | b158b42840dbb723d9f34651f2f9971121d99eca /lib/ipv4.h | |
parent | 4a5eb284c9d51441e09976021d1bd93c21408d46 (diff) | |
parent | 080ed4d8c2c1982dd0c81c62703064b620a67a01 (diff) |
Merge branch 'add-path'
Diffstat (limited to 'lib/ipv4.h')
-rw-r--r-- | lib/ipv4.h | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -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); |