/*
 *===========================================================================
 *                      ipl2tp_data_obj_hash_tunnel_assigned
 *===========================================================================
 * Description:
 * Parameters:
 * Returns:
 */
IP_STATIC unsigned
ipl2tp_example_obj_hash_key(Ipl2tp_key  *key)
{
    /* Hash the version first */
    unsigned val = ipcom_hash_update(&key->version,
                                     sizeof(key->version), 
                                     0);

    /* Hash the key ID */
    return ipcom_hash_update(&key->ident,
                             sizeof(key->ident), 
                             val);
}
/*
 *===========================================================================
 *                    ipnet_vrrp_obj_hash
 *===========================================================================
 * Description: Computes a hash value for an virtual router address entry.
 * Parameters:  addr - A vrrp address entry.
 * Returns:     The hash value.
 *
 */
IP_STATIC unsigned
ipnet_vrrp_obj_hash(Ipnet_vrrp_addr_t *addr)
{
    return ipcom_hash_update(&addr->netif->ipcom.ifindex,
                             sizeof(addr->netif->ipcom.ifindex),
                             addr->vrid);
}
IP_PUBLIC Ip_u32
ipcom_random(void)
{
    Ip_u32 random_val;

#ifdef IPVALGRIND
    random_val = 0;
#else
#ifdef IPCOM_USE_EGD
    ipcom_egd_random((Ip_u8*)&random_val, sizeof(random_val));
#else
    random_val = ipcom_rnd_state;

#ifdef IPCOM_USE_TIME
    {
        struct Ip_tms tms;
        random_val += (Ip_u32)ipcom_times(&tms);
    }
#endif

    random_val = (Ip_u32)ipcom_hash_update(&random_val,
                                           sizeof(random_val),
                                           ipcom_rnd_seed);
    ipcom_rnd_state = random_val;
#endif
#endif /* IPVALGRIND */

    return random_val;
}
Пример #4
0
/*
 *===========================================================================
 *                    ipcom_sysvar_hash_key
 *===========================================================================
 * Description:
 * Parameters:
 * Returns:
 */
IP_STATIC unsigned
ipcom_sysvar_hash_key(const char *key)
{
    return ipcom_hash_update(key, ipcom_strlen(key), 0);
}