Exemplo n.º 1
0
/* http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx#existing 
 * One-at-a-Time hash
 */
static guint
conversation_hash_exact(gconstpointer v)
{
	const conversation_key *key = (const conversation_key *)v;
	guint hash_val;
	address tmp_addr;

	hash_val = 0;
	tmp_addr.len  = 4;

	ADD_ADDRESS_TO_HASH(hash_val, &key->addr1);

	tmp_addr.data = &key->port1;
	ADD_ADDRESS_TO_HASH(hash_val, &tmp_addr);

	ADD_ADDRESS_TO_HASH(hash_val, &key->addr2);

	tmp_addr.data = &key->port2;
	ADD_ADDRESS_TO_HASH(hash_val, &tmp_addr);

	hash_val += ( hash_val << 3 );
	hash_val ^= ( hash_val >> 11 );
	hash_val += ( hash_val << 15 );

	return hash_val;
}
Exemplo n.º 2
0
/*
 * Compute the hash value for two given address/port pairs if the match
 * has a wildcard port 2.
 */
static guint
conversation_hash_no_port2(gconstpointer v)
{
	const conversation_key *key = (const conversation_key *)v;
	guint hash_val;

	hash_val = 0;
	ADD_ADDRESS_TO_HASH(hash_val, &key->addr1);
	hash_val += key->port1;
	ADD_ADDRESS_TO_HASH(hash_val, &key->addr2);

	return hash_val;
}
Exemplo n.º 3
0
/** Compute the hash value for two given address/port pairs.
 * (Parameter type is gconstpointer for GHashTable compatibility.)
 *
 * @param key Conversation. MUST point to a conv_key_t struct.
 * @return Computed key hash.
 */
static guint
conversation_hash(gconstpointer v)
{
    const conv_key_t *key = (const conv_key_t *)v;
    guint hash_val;

    hash_val = 0;
    ADD_ADDRESS_TO_HASH(hash_val, &key->addr1);
    hash_val += key->port1;
    ADD_ADDRESS_TO_HASH(hash_val, &key->addr2);
    hash_val += key->port2;
    hash_val ^= key->conv_id;

    return hash_val;
}
Exemplo n.º 4
0
/*
 * Compute the hash value for a given address/port pairs if the match
 * is to be exact.
 */
static guint
host_hash(gconstpointer v)
{
    const host_key_t *key = (const host_key_t *)v;
    guint hash_val;

    hash_val = 0;
    ADD_ADDRESS_TO_HASH(hash_val, &key->myaddress);
    hash_val += key->port;
    return hash_val;
}