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

Function pf_hash

freebsd/netpfil/pf/pf_lb.c:85–124  ·  view source on GitHub ↗

* hash function based on bridge_hash in if_bridge.c */

Source from the content-addressed store, hash-verified

83 * hash function based on bridge_hash in if_bridge.c
84 */
85static void
86pf_hash(struct pf_addr *inaddr, struct pf_addr *hash,
87 struct pf_poolhashkey *key, sa_family_t af)
88{
89 u_int32_t a = 0x9e3779b9, b = 0x9e3779b9, c = key->key32[0];
90
91 switch (af) {
92#ifdef INET
93 case AF_INET:
94 a += inaddr->addr32[0];
95 b += key->key32[1];
96 mix(a, b, c);
97 hash->addr32[0] = c + key->key32[2];
98 break;
99#endif /* INET */
100#ifdef INET6
101 case AF_INET6:
102 a += inaddr->addr32[0];
103 b += inaddr->addr32[2];
104 mix(a, b, c);
105 hash->addr32[0] = c;
106 a += inaddr->addr32[1];
107 b += inaddr->addr32[3];
108 c += key->key32[1];
109 mix(a, b, c);
110 hash->addr32[1] = c;
111 a += inaddr->addr32[2];
112 b += inaddr->addr32[1];
113 c += key->key32[2];
114 mix(a, b, c);
115 hash->addr32[2] = c;
116 a += inaddr->addr32[3];
117 b += inaddr->addr32[0];
118 c += key->key32[3];
119 mix(a, b, c);
120 hash->addr32[3] = c;
121 break;
122#endif /* INET6 */
123 }
124}
125
126static struct pf_krule *
127pf_match_translation(struct pf_pdesc *pd, struct mbuf *m, int off,

Callers 1

pf_map_addrFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected