mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-13 12:48:27 +00:00
.
This commit is contained in:
@ -18,6 +18,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Packet.hpp"
|
||||
#include "Mutex.hpp"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define FORCE_INLINE static __forceinline
|
||||
@ -932,4 +933,16 @@ bool Packet::uncompress()
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t Packet::nextPacketId()
|
||||
{
|
||||
static uint64_t ctr = 0;
|
||||
static Mutex lock;
|
||||
lock.lock();
|
||||
if (unlikely(ctr == 0))
|
||||
Utils::getSecureRandom(&ctr,sizeof(ctr));
|
||||
const uint64_t i = ctr++;
|
||||
lock.unlock();
|
||||
return i;
|
||||
}
|
||||
|
||||
} // namespace ZeroTier
|
||||
|
Reference in New Issue
Block a user