Cleanup, multicast fingerprint, benchmark asymmetric crypto

This commit is contained in:
Adam Ierymenko 2019-08-28 07:31:17 -07:00
parent 199b3345a0
commit 6e730cfad1
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
3 changed files with 111 additions and 264 deletions

View file

@ -43,15 +43,11 @@ class MulticastGroup
public:
ZT_ALWAYS_INLINE MulticastGroup() :
_mac(),
_adi(0)
{
}
_adi(0) {}
ZT_ALWAYS_INLINE MulticastGroup(const MAC &m,uint32_t a) :
_mac(m),
_adi(a)
{
}
_adi(a) {}
/**
* Derive the multicast group used for address resolution (ARP/NDP) for an IP
@ -97,6 +93,42 @@ public:
ZT_ALWAYS_INLINE bool operator<=(const MulticastGroup &g) const { return !(g < *this); }
ZT_ALWAYS_INLINE bool operator>=(const MulticastGroup &g) const { return !(*this < g); }
/**
* Compute a 32-bit fnv1a hash of a multicast group and a network ID
*
* @param mg Multicast group
* @param nwid Network ID
* @return 32-bit relatively-unique ID
*/
static ZT_ALWAYS_INLINE uint32_t id(const MulticastGroup &mg,const uint64_t nwid)
{
const uint32_t fnv1aPrime = 0x01000193;
uint32_t i = 0x811c9dc5;
i = (((uint32_t)(nwid >> 56) & 0xff) ^ i) * fnv1aPrime;
i = (((uint32_t)(nwid >> 48) & 0xff) ^ i) * fnv1aPrime;
i = (((uint32_t)(nwid >> 40) & 0xff) ^ i) * fnv1aPrime;
i = (((uint32_t)(nwid >> 32) & 0xff) ^ i) * fnv1aPrime;
i = (((uint32_t)(nwid >> 24) & 0xff) ^ i) * fnv1aPrime;
i = (((uint32_t)(nwid >> 16) & 0xff) ^ i) * fnv1aPrime;
i = (((uint32_t)(nwid >> 8) & 0xff) ^ i) * fnv1aPrime;
i = (((uint32_t)nwid & 0xff) ^ i) * fnv1aPrime;
const uint64_t mac = mg._mac.toInt();
i = (((uint32_t)(mac >> 56) & 0xff) ^ i) * fnv1aPrime;
i = (((uint32_t)(mac >> 48) & 0xff) ^ i) * fnv1aPrime;
i = (((uint32_t)(mac >> 40) & 0xff) ^ i) * fnv1aPrime;
i = (((uint32_t)(mac >> 32) & 0xff) ^ i) * fnv1aPrime;
i = (((uint32_t)(mac >> 24) & 0xff) ^ i) * fnv1aPrime;
i = (((uint32_t)(mac >> 16) & 0xff) ^ i) * fnv1aPrime;
i = (((uint32_t)(mac >> 8) & 0xff) ^ i) * fnv1aPrime;
i = (((uint32_t)mac & 0xff) ^ i) * fnv1aPrime;
const uint32_t adi = mg._adi;
i = (((adi >> 24) & 0xff) ^ i) * fnv1aPrime;
i = (((adi >> 16) & 0xff) ^ i) * fnv1aPrime;
i = (((adi >> 8) & 0xff) ^ i) * fnv1aPrime;
i = ((adi & 0xff) ^ i) * fnv1aPrime;
return i;
}
private:
MAC _mac;
uint32_t _adi;