MCPcopy Create free account
hub / github.com/F-Stack/f-stack / toeplitz_hash

Function toeplitz_hash

freebsd/net/toeplitz.c:37–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35#include <sys/systm.h>
36
37uint32_t
38toeplitz_hash(u_int keylen, const uint8_t *key, u_int datalen,
39 const uint8_t *data)
40{
41 uint32_t hash = 0, v;
42 u_int i, b;
43
44 /* XXXRW: Perhaps an assertion about key length vs. data length? */
45
46 v = (key[0]<<24) + (key[1]<<16) + (key[2] <<8) + key[3];
47 for (i = 0; i < datalen; i++) {
48 for (b = 0; b < 8; b++) {
49 if (data[i] & (1<<(7-b)))
50 hash ^= v;
51 v <<= 1;
52 if ((i + 4) < RSS_KEYSIZE &&
53 (key[i+4] & (1<<(7-b))))
54 v |= 1;
55 }
56 }
57 return (hash);
58}

Callers 3

rss_hashFunction · 0.70
fib4_calc_software_hashFunction · 0.50
fib6_calc_software_hashFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected