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

Function hash_priv

freebsd/net/route/nhop.c:210–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208}
209
210static uint32_t
211hash_priv(const struct nhop_priv *priv)
212{
213 struct nhop_object *nh;
214 uint16_t ifindex;
215 struct _hash_data key;
216
217 nh = priv->nh;
218 ifindex = nh->nh_ifp->if_index & 0xFFFF;
219 memset(&key, 0, sizeof(key));
220
221 key.ifindex = ifindex;
222 key.family = nh->gw_sa.sa_family;
223 key.nh_type = priv->nh_type & 0xFF;
224 if (nh->gw_sa.sa_family == AF_INET6)
225 memcpy(&key.gw_addr, &nh->gw6_sa.sin6_addr.s6_addr32[3], 4);
226 else if (nh->gw_sa.sa_family == AF_INET)
227 memcpy(&key.gw_addr, &nh->gw4_sa.sin_addr, 4);
228
229 return (uint32_t)(djb_hash((const unsigned char *)&key, sizeof(key)));
230}
231
232/*
233 * Checks if hash needs resizing and performs this resize if necessary

Callers 2

link_nhopFunction · 0.85
unlink_nhopFunction · 0.85

Calls 3

memsetFunction · 0.85
djb_hashFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected