/* return the index of the claim */ static inline uint32_t batadv_choose_claim(const void *data, uint32_t size) { struct batadv_bla_claim *claim = (struct batadv_bla_claim *)data; uint32_t hash = 0; hash = batadv_hash_bytes(hash, &claim->addr, sizeof(claim->addr)); hash = batadv_hash_bytes(hash, &claim->vid, sizeof(claim->vid)); hash += (hash << 3); hash ^= (hash >> 11); hash += (hash << 15); return hash % size; }
/** * batadv_hash_dat - compute the hash value for an IP address * @data: data to hash * @size: size of the hash table * * Returns the selected index in the hash table for the given data. */ static uint32_t batadv_hash_dat(const void *data, uint32_t size) { uint32_t hash = 0; const struct batadv_dat_entry *dat = data; hash = batadv_hash_bytes(hash, &dat->ip, sizeof(dat->ip)); hash = batadv_hash_bytes(hash, &dat->vid, sizeof(dat->vid)); hash += (hash << 3); hash ^= (hash >> 11); hash += (hash << 15); return hash % size; }