Esempio n. 1
0
void ipv4check() {
    printf("Value = %lu\n", hash_sockaddr(&ipv4a, 0));
    printf("Value = %lu\n", hash_sockaddr(&ipv4b, 0));
    printf("Value = %lu\n", hash_sockaddr(&ipv4c, 0));
    EQUALS(hash_sockaddr(&ipv4a, IGNORE_PORT), 17107466, "ipv4a doesn't hash as expected");
    EQUALS(hash_sockaddr(&ipv4b, IGNORE_PORT), 17107466, "ipv4b doesn't hash as expected");
    EQUALS(hash_sockaddr(&ipv4c, IGNORE_PORT), 33884682, "ipv4c doesn't hash as expected");
    EQUALS(hash_sockaddr(&ipv4a, CHECK_PORT), 151325194, "ipv4a doesn't hash as expected");
    EQUALS(hash_sockaddr(&ipv4b, CHECK_PORT), 151259658, "ipv4b doesn't hash as expected");
    EQUALS(hash_sockaddr(&ipv4c, CHECK_PORT), 168102410, "ipv4c doesn't hash as expected");
}
Esempio n. 2
0
uint64_t nsm_client_rbt_hash_func(hash_parameter_t * p_hparam,
                                      hash_buffer_t * buffclef)
{
  unsigned long        res;
  state_nsm_client_t * pkey = (state_nsm_client_t *)buffclef->pdata;

  if(nfs_param.core_param.nsm_use_caller_name)
    {
      unsigned int sum = 0;
      unsigned int i;

      /* Compute the sum of all the characters */
      for(i = 0; i < pkey->ssc_nlm_caller_name_len; i++)
        sum +=(unsigned char) pkey->ssc_nlm_caller_name[i];

      res = (unsigned long) sum +
            (unsigned long) pkey->ssc_nlm_caller_name_len;
    }
  else
    {
      res = hash_sockaddr(&pkey->ssc_client_addr, IGNORE_PORT);
    }

  if(isDebug(COMPONENT_HASHTABLE))
    LogFullDebug(COMPONENT_STATE, "rbt = %lu", res);

  return res;
}                               /* nsm_client_rbt_hash_func */
Esempio n. 3
0
/**
 *
 *  dupreq_rbt_hash_func: computes the rbt value for the entry in dupreq cache.
 *
 * Computes the rbt value for the entry in dupreq cache. In fact, it just use the Xid
 * itself (which is an unsigned integer) as the rbt value.
 * This function is called internal in the HasTable_* function
 *
 * @param hparam [IN] hash table parameter.
 * @param buffcleff[in] pointer to the hash key buffer
 *
 * @return the computed rbt value.
 *
 * @see HashTable_Init
 *
 */
unsigned long dupreq_rbt_hash_func(hash_parameter_t * p_hparam, hash_buffer_t * buffclef)
{
  dupreq_key_t *pdupkey = (dupreq_key_t *)(buffclef->pdata);

  unsigned long addr_hash = hash_sockaddr((sockaddr_t *) &pdupkey->addr, CHECK_PORT);

  return (((unsigned long)pdupkey->xid + addr_hash)^(pdupkey->checksum)) % p_hparam->index_size;
}                               /* dupreq_rbt_hash_func */
Esempio n. 4
0
void ipv6check() {
    printf("Value = %lu\n", hash_sockaddr(&ipv6a, 0));
    printf("Value = %lu\n", hash_sockaddr(&ipv6b, 0));
    printf("Value = %lu\n", hash_sockaddr(&ipv6c, 0));
    EQUALS(hash_sockaddr(&ipv6a, CHECK_PORT), 150995232, "ipv6a doesn't hash as expected");
    EQUALS(hash_sockaddr(&ipv6b, CHECK_PORT), 151060768, "ipv6b doesn't hash as expected");
    EQUALS(hash_sockaddr(&ipv6c, CHECK_PORT), 150998560, "ipv6c doesn't hash as expected");
}
Esempio n. 5
0
/**
 *
 *  ip_stats_rbt_hash_func: computes the hash value for the entry in IP stats cache.
 * 
 * Computes the hash value for the entry in IP stats cache. 
 * This function is called internal in the HasTable_* function
 *
 * @param hparam [IN] hash table parameter.
 * @param buffcleff[in] pointer to the hash key buffer
 *
 * @return the computed hash value.
 *
 * @see HashTable_Init
 *
 */
unsigned long int ip_stats_value_hash_func(hash_parameter_t * p_hparam,
                                           hash_buffer_t * buffclef)
{
  return hash_sockaddr((sockaddr_t *)buffclef->pdata, IGNORE_PORT) % p_hparam->index_size;
}
Esempio n. 6
0
/**
 *
 *  ip_stats_rbt_hash_func: computes the rbt value for the entry in IP stats cache.
 * 
 * Computes the rbt value for the entry in IP stats cache.
 * This function is called internal in the HasTable_* function
 *
 * @param hparam [IN] hash table parameter.
 * @param buffcleff[in] pointer to the hash key buffer
 *
 * @return the computed rbt value.
 *
 * @see HashTable_Init
 *
 */
unsigned long int ip_stats_rbt_hash_func(hash_parameter_t * p_hparam,
                                         hash_buffer_t * buffclef)
{
  return hash_sockaddr((sockaddr_t *)buffclef->pdata, IGNORE_PORT);
}
Esempio n. 7
0
/**
 * @brief Compute the rbt value for the entry in IP/name cache
 *
 * @param[in] hparam   Hash table parameter
 * @param[in] buffclef Hash key buffer
 *
 * @return the computed rbt value.
 *
 * @see hashtable_init
 *
 */
uint64_t ip_name_rbt_hash_func(hash_parameter_t *hparam,
			       struct gsh_buffdesc *buffclef)
{
	return hash_sockaddr(buffclef->addr, true);
}
Esempio n. 8
0
/**
 * @name Compute the hash value for the entry in IP/name cache
 *
 * @param[in] hparam    Hash table parameter.
 * @param[in] buffcleff The hash key buffer
 *
 * @return the computed hash value.
 *
 * @see hashtable_init
 *
 */
uint32_t ip_name_value_hash_func(hash_parameter_t *hparam,
				 struct gsh_buffdesc *buffclef)
{
	return hash_sockaddr(buffclef->addr, true) % hparam->index_size;
}
Esempio n. 9
0
/**
 *
 *  ip_name_rbt_hash_func: computes the rbt value for the entry in IP/name cache.
 * 
 * Computes the rbt value for the entry in IP/name cache.
 * This function is called internal in the HasTable_* function
 *
 * @param hparam [IN] hash table parameter.
 * @param buffcleff[in] pointer to the hash key buffer
 *
 * @return the computed rbt value.
 *
 * @see HashTable_Init
 *
 */
uint64_t ip_name_rbt_hash_func(hash_parameter_t * p_hparam,
                                        hash_buffer_t * buffclef)
{
  return hash_sockaddr((sockaddr_t *)buffclef->pdata, IGNORE_PORT);
}
Esempio n. 10
0
/**
 *
 *  ip_name_rbt_hash_func: computes the hash value for the entry in IP/name cache.
 * 
 * Computes the hash value for the entry in IP/name cache.
 * This function is called internal in the HasTable_* function
 *
 * @param hparam [IN] hash table parameter.
 * @param buffcleff[in] pointer to the hash key buffer
 *
 * @return the computed hash value.
 *
 * @see HashTable_Init
 *
 */
uint32_t ip_name_value_hash_func(hash_parameter_t * p_hparam,
                                          hash_buffer_t * buffclef)
{
  return hash_sockaddr((sockaddr_t *)buffclef->pdata, IGNORE_PORT) % p_hparam->index_size;
}