예제 #1
0
/**
 * Secondary key hashing routine.
 */
static uint
g2_rpc_key_hash2(const void *key)
{
	const struct g2_rpc_key *rk = key;

	return integer_hash2(rk->type) ^ host_addr_hash2(rk->addr);
}
예제 #2
0
/**
 * Alternate hashing of host_addr_t.
 */
unsigned
host_addr_hash2(host_addr_t ha)
{
	switch (ha.net) {
	case NET_TYPE_IPV6:
		{
			host_addr_t ha_ipv4;

			if (!host_addr_convert(ha, &ha_ipv4, NET_TYPE_IPV4))
				return binary_hash2(&ha.addr.ipv6[0], sizeof ha.addr.ipv6);
			ha = ha_ipv4;
		}
		/* FALL THROUGH */
	case NET_TYPE_IPV4:
		return ha.net ^ integer_hash2(host_addr_ipv4(ha));
	case NET_TYPE_LOCAL:
	case NET_TYPE_NONE:
		return ha.net;
	}
	g_assert_not_reached();
	return (unsigned) -1;
}