ZeroTier now has link quality measurement. We are not using this yet but decided to put it in to prep for future QoS support and SD-WAN stuff.

This commit is contained in:
Adam Ierymenko 2017-03-01 14:36:52 -08:00
parent 2bf9145ae6
commit 1d39be61b2
9 changed files with 111 additions and 22 deletions

View file

@ -252,6 +252,20 @@ public:
return ((((v + (v >> 4)) & (uint32_t)0xF0F0F0F) * (uint32_t)0x1010101) >> 24);
}
/**
* Count the number of bits set in an integer
*
* @param v 64-bit integer
* @return Number of bits set in this integer (0-64)
*/
static inline uint64_t countBits(uint64_t v)
{
v = v - ((v >> 1) & (uint64_t)~(uint64_t)0/3);
v = (v & (uint64_t)~(uint64_t)0/15*3) + ((v >> 2) & (uint64_t)~(uint64_t)0/15*3);
v = (v + (v >> 4)) & (uint64_t)~(uint64_t)0/255*15;
return (uint64_t)(v * ((uint64_t)~(uint64_t)0/255)) >> 56;
}
/**
* Check if a memory buffer is all-zero
*