Utils.hpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. /*
  2. * Copyright (c)2013-2020 ZeroTier, Inc.
  3. *
  4. * Use of this software is governed by the Business Source License included
  5. * in the LICENSE.TXT file in the project's root directory.
  6. *
  7. * Change Date: 2024-01-01
  8. *
  9. * On the date above, in accordance with the Business Source License, use
  10. * of this software will be governed by version 2.0 of the Apache License.
  11. */
  12. /****/
  13. #ifndef ZT_UTILS_HPP
  14. #define ZT_UTILS_HPP
  15. #include "Constants.hpp"
  16. namespace ZeroTier {
  17. namespace Utils {
  18. #ifndef __WINDOWS__
  19. #include <sys/mman.h>
  20. #endif
  21. // Macros to convert endian-ness at compile time for constants.
  22. #if __BYTE_ORDER == __LITTLE_ENDIAN
  23. #define ZT_CONST_TO_BE_UINT16(x) ((uint16_t)((uint16_t)((uint16_t)(x) << 8U) | (uint16_t)((uint16_t)(x) >> 8U)))
  24. #define ZT_CONST_TO_BE_UINT64(x) ( \
  25. (((uint64_t)(x) & 0x00000000000000ffULL) << 56U) | \
  26. (((uint64_t)(x) & 0x000000000000ff00ULL) << 40U) | \
  27. (((uint64_t)(x) & 0x0000000000ff0000ULL) << 24U) | \
  28. (((uint64_t)(x) & 0x00000000ff000000ULL) << 8U) | \
  29. (((uint64_t)(x) & 0x000000ff00000000ULL) >> 8U) | \
  30. (((uint64_t)(x) & 0x0000ff0000000000ULL) >> 24U) | \
  31. (((uint64_t)(x) & 0x00ff000000000000ULL) >> 40U) | \
  32. (((uint64_t)(x) & 0xff00000000000000ULL) >> 56U))
  33. #else
  34. #define ZT_CONST_TO_BE_UINT16(x) ((uint16_t)(x))
  35. #define ZT_CONST_TO_BE_UINT64(x) ((uint64_t)(x))
  36. #endif
  37. #ifdef ZT_ARCH_X64
  38. struct CPUIDRegisters
  39. {
  40. uint32_t eax,ebx,ecx,edx;
  41. bool rdrand;
  42. bool aes;
  43. CPUIDRegisters();
  44. };
  45. extern const CPUIDRegisters CPUID;
  46. #endif
  47. /**
  48. * 256 zero bits / 32 zero bytes
  49. */
  50. extern const uint64_t ZERO256[4];
  51. /**
  52. * Hexadecimal characters 0-f
  53. */
  54. extern const char HEXCHARS[16];
  55. /**
  56. * Lock memory to prevent swapping out to secondary storage (if possible)
  57. *
  58. * This is used to attempt to prevent the swapping out of long-term stored secure
  59. * credentials like secret keys. It isn't supported on all platforms and may not
  60. * be absolutely guaranteed to work, but it's a countermeasure.
  61. *
  62. * @param p Memory to lock
  63. * @param l Size of memory
  64. */
  65. static ZT_INLINE void memoryLock(const void *const p,const unsigned int l) noexcept
  66. {
  67. #ifndef __WINDOWS__
  68. mlock(p,l);
  69. #endif
  70. }
  71. /**
  72. * Unlock memory locked with memoryLock()
  73. *
  74. * @param p Memory to unlock
  75. * @param l Size of memory
  76. */
  77. static ZT_INLINE void memoryUnlock(const void *const p,const unsigned int l) noexcept
  78. {
  79. #ifndef __WINDOWS__
  80. munlock(p,l);
  81. #endif
  82. }
  83. /**
  84. * Perform a time-invariant binary comparison
  85. *
  86. * @param a First binary string
  87. * @param b Second binary string
  88. * @param len Length of strings
  89. * @return True if strings are equal
  90. */
  91. bool secureEq(const void *a,const void *b,unsigned int len) noexcept;
  92. /**
  93. * Be absolutely sure to zero memory
  94. *
  95. * This uses some hacks to be totally sure the compiler does not optimize it out.
  96. *
  97. * @param ptr Memory to zero
  98. * @param len Length of memory in bytes
  99. */
  100. void burn(void *ptr,unsigned int len);
  101. /**
  102. * @param n Number to convert
  103. * @param s Buffer, at least 24 bytes in size
  104. * @return String containing 'n' in base 10 form
  105. */
  106. char *decimal(unsigned long n,char s[24]) noexcept;
  107. /**
  108. * Convert an unsigned integer into hex
  109. *
  110. * @param i Any unsigned integer
  111. * @param s Buffer to receive hex, must be at least (2*sizeof(i))+1 in size or overflow will occur.
  112. * @return Pointer to s containing hex string with trailing zero byte
  113. */
  114. char *hex(uint8_t i,char s[3]) noexcept;
  115. /**
  116. * Convert an unsigned integer into hex
  117. *
  118. * @param i Any unsigned integer
  119. * @param s Buffer to receive hex, must be at least (2*sizeof(i))+1 in size or overflow will occur.
  120. * @return Pointer to s containing hex string with trailing zero byte
  121. */
  122. char *hex(uint16_t i,char s[5]) noexcept;
  123. /**
  124. * Convert an unsigned integer into hex
  125. *
  126. * @param i Any unsigned integer
  127. * @param s Buffer to receive hex, must be at least (2*sizeof(i))+1 in size or overflow will occur.
  128. * @return Pointer to s containing hex string with trailing zero byte
  129. */
  130. char *hex(uint32_t i,char s[9]) noexcept;
  131. /**
  132. * Convert an unsigned integer into hex
  133. *
  134. * @param i Any unsigned integer
  135. * @param s Buffer to receive hex, must be at least (2*sizeof(i))+1 in size or overflow will occur.
  136. * @return Pointer to s containing hex string with trailing zero byte
  137. */
  138. char *hex(uint64_t i,char s[17]) noexcept;
  139. /**
  140. * Decode an unsigned integer in hex format
  141. *
  142. * @param s String to decode, non-hex chars are ignored
  143. * @return Unsigned integer
  144. */
  145. uint64_t unhex(const char *s) noexcept;
  146. /**
  147. * Convert a byte array into hex
  148. *
  149. * @param d Bytes
  150. * @param l Length of bytes
  151. * @param s String buffer, must be at least (l*2)+1 in size or overflow will occur
  152. * @return Pointer to filled string buffer
  153. */
  154. char *hex(const void *d,unsigned int l,char *s) noexcept;
  155. /**
  156. * Decode a hex string
  157. *
  158. * @param h Hex C-string (non hex chars are ignored)
  159. * @param hlen Maximum length of string (will stop at terminating zero)
  160. * @param buf Output buffer
  161. * @param buflen Length of output buffer
  162. * @return Number of written bytes
  163. */
  164. unsigned int unhex(const char *h,unsigned int hlen,void *buf,unsigned int buflen) noexcept;
  165. /**
  166. * Generate secure random bytes
  167. *
  168. * This will try to use whatever OS sources of entropy are available. It's
  169. * guarded by an internal mutex so it's thread-safe.
  170. *
  171. * @param buf Buffer to fill
  172. * @param bytes Number of random bytes to generate
  173. */
  174. void getSecureRandom(void *buf,unsigned int bytes) noexcept;
  175. /**
  176. * @return Secure random 64-bit integer
  177. */
  178. uint64_t getSecureRandomU64() noexcept;
  179. /**
  180. * Encode string to base32
  181. *
  182. * @param data Binary data to encode
  183. * @param length Length of data in bytes
  184. * @param result Result buffer
  185. * @param bufSize Size of result buffer
  186. * @return Number of bytes written
  187. */
  188. int b32e(const uint8_t *data,int length,char *result,int bufSize) noexcept;
  189. /**
  190. * Decode base32 string
  191. *
  192. * @param encoded C-string in base32 format (non-base32 characters are ignored)
  193. * @param result Result buffer
  194. * @param bufSize Size of result buffer
  195. * @return Number of bytes written or -1 on error
  196. */
  197. int b32d(const char *encoded, uint8_t *result, int bufSize) noexcept;
  198. /**
  199. * Get a non-cryptographic random integer
  200. */
  201. uint64_t random() noexcept;
  202. /**
  203. * Perform a safe C string copy, ALWAYS null-terminating the result
  204. *
  205. * This will never ever EVER result in dest[] not being null-terminated
  206. * regardless of any input parameter (other than len==0 which is invalid).
  207. *
  208. * @param dest Destination buffer (must not be NULL)
  209. * @param len Length of dest[] (if zero, false is returned and nothing happens)
  210. * @param src Source string (if NULL, dest will receive a zero-length string and true is returned)
  211. * @return True on success, false on overflow (buffer will still be 0-terminated)
  212. */
  213. bool scopy(char *dest,unsigned int len,const char *src) noexcept;
  214. /**
  215. * Mix bits in a 64-bit integer (non-cryptographic)
  216. *
  217. * https://nullprogram.com/blog/2018/07/31/
  218. *
  219. * @param x Integer to mix
  220. * @return Hashed value
  221. */
  222. static ZT_INLINE uint64_t hash64(uint64_t x) noexcept
  223. {
  224. x ^= x >> 30U;
  225. x *= 0xbf58476d1ce4e5b9ULL;
  226. x ^= x >> 27U;
  227. x *= 0x94d049bb133111ebULL;
  228. x ^= x >> 31U;
  229. return x;
  230. }
  231. /**
  232. * Check if a buffer's contents are all zero
  233. */
  234. static ZT_INLINE bool allZero(const void *const b,unsigned int l) noexcept
  235. {
  236. for(unsigned int i=0;i<l;++i) {
  237. if (reinterpret_cast<const uint8_t *>(b)[i] != 0)
  238. return false;
  239. }
  240. return true;
  241. }
  242. /**
  243. * Wrapper around reentrant strtok functions, which differ in name by platform
  244. *
  245. * @param str String to tokenize or NULL for subsequent calls
  246. * @param delim Delimiter
  247. * @param saveptr Pointer to pointer where function can save state
  248. * @return Next token or NULL if none
  249. */
  250. static ZT_INLINE char *stok(char *str,const char *delim,char **saveptr) noexcept
  251. {
  252. #ifdef __WINDOWS__
  253. return strtok_s(str,delim,saveptr);
  254. #else
  255. return strtok_r(str,delim,saveptr);
  256. #endif
  257. }
  258. static ZT_INLINE unsigned int strToUInt(const char *s) noexcept
  259. {
  260. return (unsigned int)strtoul(s,nullptr,10);
  261. }
  262. static ZT_INLINE unsigned long long hexStrToU64(const char *s) noexcept
  263. {
  264. #ifdef __WINDOWS__
  265. return (unsigned long long)_strtoui64(s,nullptr,16);
  266. #else
  267. return strtoull(s,nullptr,16);
  268. #endif
  269. }
  270. /**
  271. * Compute 32-bit FNV-1a checksum
  272. *
  273. * See: http://www.isthe.com/chongo/tech/comp/fnv/
  274. *
  275. * @param data Data to checksum
  276. * @param len Length of data
  277. * @return FNV1a checksum
  278. */
  279. static ZT_INLINE uint32_t fnv1a32(const void *const data,const unsigned int len) noexcept
  280. {
  281. uint32_t h = 0x811c9dc5;
  282. const uint32_t p = 0x01000193;
  283. for(unsigned int i=0;i<len;++i)
  284. h = (h ^ (uint32_t)reinterpret_cast<const uint8_t *>(data)[i]) * p;
  285. return h;
  286. }
  287. #ifdef __GNUC__
  288. static ZT_INLINE unsigned int countBits(const uint8_t v) noexcept { return (unsigned int)__builtin_popcount((unsigned int)v); }
  289. static ZT_INLINE unsigned int countBits(const uint16_t v) noexcept { return (unsigned int)__builtin_popcount((unsigned int)v); }
  290. static ZT_INLINE unsigned int countBits(const uint32_t v) noexcept { return (unsigned int)__builtin_popcountl((unsigned long)v); }
  291. static ZT_INLINE unsigned int countBits(const uint64_t v) noexcept{ return (unsigned int)__builtin_popcountll((unsigned long long)v); }
  292. #else
  293. template<typename T>
  294. static ZT_INLINE unsigned int countBits(T v) noexcept
  295. {
  296. v = v - ((v >> 1) & (T)~(T)0/3);
  297. v = (v & (T)~(T)0/15*3) + ((v >> 2) & (T)~(T)0/15*3);
  298. v = (v + (v >> 4)) & (T)~(T)0/255*15;
  299. return (unsigned int)((v * ((~((T)0))/((T)255))) >> ((sizeof(T) - 1) * 8));
  300. }
  301. #endif
  302. /**
  303. * Unconditionally swap bytes regardless of host byte order
  304. *
  305. * @param n Integer to swap
  306. * @return Integer with bytes reversed
  307. */
  308. static ZT_INLINE uint64_t swapBytes(const uint64_t n) noexcept
  309. {
  310. #ifdef __GNUC__
  311. return __builtin_bswap64(n);
  312. #else
  313. #ifdef _MSC_VER
  314. return (uint64_t)_byteswap_uint64((unsigned __int64)n);
  315. #else
  316. return (
  317. ((n & 0x00000000000000ffULL) << 56) |
  318. ((n & 0x000000000000ff00ULL) << 40) |
  319. ((n & 0x0000000000ff0000ULL) << 24) |
  320. ((n & 0x00000000ff000000ULL) << 8) |
  321. ((n & 0x000000ff00000000ULL) >> 8) |
  322. ((n & 0x0000ff0000000000ULL) >> 24) |
  323. ((n & 0x00ff000000000000ULL) >> 40) |
  324. ((n & 0xff00000000000000ULL) >> 56)
  325. );
  326. #endif
  327. #endif
  328. }
  329. /**
  330. * Unconditionally swap bytes regardless of host byte order
  331. *
  332. * @param n Integer to swap
  333. * @return Integer with bytes reversed
  334. */
  335. static ZT_INLINE uint32_t swapBytes(const uint32_t n) noexcept
  336. {
  337. #if defined(__GNUC__)
  338. return __builtin_bswap32(n);
  339. #else
  340. #ifdef _MSC_VER
  341. return (uint32_t)_byteswap_ulong((unsigned long)n);
  342. #else
  343. return htonl(n);
  344. #endif
  345. #endif
  346. }
  347. /**
  348. * Unconditionally swap bytes regardless of host byte order
  349. *
  350. * @param n Integer to swap
  351. * @return Integer with bytes reversed
  352. */
  353. static ZT_INLINE uint16_t swapBytes(const uint16_t n) noexcept
  354. {
  355. #if defined(__GNUC__)
  356. return __builtin_bswap16(n);
  357. #else
  358. #ifdef _MSC_VER
  359. return (uint16_t)_byteswap_ushort((unsigned short)n);
  360. #else
  361. return htons(n);
  362. #endif
  363. #endif
  364. }
  365. // These are helper adapters to load and swap integer types special cased by size
  366. // to work with all typedef'd variants, signed/unsigned, etc.
  367. template<typename I,unsigned int S>
  368. class _swap_bytes_bysize;
  369. template<typename I>
  370. class _swap_bytes_bysize<I,1> { public: static ZT_INLINE I s(const I n) noexcept { return n; } };
  371. template<typename I>
  372. class _swap_bytes_bysize<I,2> { public: static ZT_INLINE I s(const I n) noexcept { return (I)swapBytes((uint16_t)n); } };
  373. template<typename I>
  374. class _swap_bytes_bysize<I,4> { public: static ZT_INLINE I s(const I n) noexcept { return (I)swapBytes((uint32_t)n); } };
  375. template<typename I>
  376. class _swap_bytes_bysize<I,8> { public: static ZT_INLINE I s(const I n) noexcept { return (I)swapBytes((uint64_t)n); } };
  377. template<typename I,unsigned int S>
  378. class _load_be_bysize;
  379. template<typename I>
  380. class _load_be_bysize<I,1> { public: static ZT_INLINE I l(const uint8_t *const p) noexcept { return p[0]; }};
  381. template<typename I>
  382. class _load_be_bysize<I,2> { public: static ZT_INLINE I l(const uint8_t *const p) noexcept { return (I)(((unsigned int)p[0] << 8U) | (unsigned int)p[1]); }};
  383. template<typename I>
  384. class _load_be_bysize<I,4> { public: static ZT_INLINE I l(const uint8_t *const p) noexcept { return (I)(((uint32_t)p[0] << 24U) | ((uint32_t)p[1] << 16U) | ((uint32_t)p[2] << 8U) | (uint32_t)p[3]); }};
  385. template<typename I>
  386. class _load_be_bysize<I,8> { public: static ZT_INLINE I l(const uint8_t *const p) noexcept { return (I)(((uint64_t)p[0] << 56U) | ((uint64_t)p[1] << 48U) | ((uint64_t)p[2] << 40U) | ((uint64_t)p[3] << 32U) | ((uint64_t)p[4] << 24U) | ((uint64_t)p[5] << 16U) | ((uint64_t)p[6] << 8U) | (uint64_t)p[7]); }};
  387. template<typename I,unsigned int S>
  388. class _load_le_bysize;
  389. template<typename I>
  390. class _load_le_bysize<I,1> { public: static ZT_INLINE I l(const uint8_t *const p) noexcept { return p[0]; }};
  391. template<typename I>
  392. class _load_le_bysize<I,2> { public: static ZT_INLINE I l(const uint8_t *const p) noexcept { return (I)((unsigned int)p[0] | ((unsigned int)p[1] << 8U)); }};
  393. template<typename I>
  394. class _load_le_bysize<I,4> { public: static ZT_INLINE I l(const uint8_t *const p) noexcept { return (I)((uint32_t)p[0] | ((uint32_t)p[1] << 8U) | ((uint32_t)p[2] << 16U) | ((uint32_t)p[3] << 24U)); }};
  395. template<typename I>
  396. class _load_le_bysize<I,8> { public: static ZT_INLINE I l(const uint8_t *const p) noexcept { return (I)((uint64_t)p[0] | ((uint64_t)p[1] << 8U) | ((uint64_t)p[2] << 16U) | ((uint64_t)p[3] << 24U) | ((uint64_t)p[4] << 32U) | ((uint64_t)p[5] << 40U) | ((uint64_t)p[6] << 48U) | ((uint64_t)p[7]) << 56U); }};
  397. /**
  398. * Convert any signed or unsigned integer type to big-endian ("network") byte order
  399. *
  400. * @tparam I Integer type (usually inferred)
  401. * @param n Value to convert
  402. * @return Value in big-endian order
  403. */
  404. template<typename I>
  405. static ZT_INLINE I hton(const I n) noexcept
  406. {
  407. #if __BYTE_ORDER == __LITTLE_ENDIAN
  408. return _swap_bytes_bysize<I,sizeof(I)>::s(n);
  409. #else
  410. return n;
  411. #endif
  412. }
  413. /**
  414. * Convert any signed or unsigned integer type to host byte order from big-endian ("network") byte order
  415. *
  416. * @tparam I Integer type (usually inferred)
  417. * @param n Value to convert
  418. * @return Value in host byte order
  419. */
  420. template<typename I>
  421. static ZT_INLINE I ntoh(const I n) noexcept
  422. {
  423. #if __BYTE_ORDER == __LITTLE_ENDIAN
  424. return _swap_bytes_bysize<I,sizeof(I)>::s(n);
  425. #else
  426. return n;
  427. #endif
  428. }
  429. /**
  430. * Copy bits from memory into an integer type without modifying their order
  431. *
  432. * @tparam I Type to load
  433. * @param p Byte stream, must be at least sizeof(I) in size
  434. * @return Loaded raw integer
  435. */
  436. template<typename I>
  437. static ZT_INLINE I loadAsIsEndian(const void *const p) noexcept
  438. {
  439. #ifdef ZT_NO_UNALIGNED_ACCESS
  440. I tmp;
  441. for(int i=0;i<(int)sizeof(I);++i)
  442. reinterpret_cast<uint8_t *>(&tmp)[i] = reinterpret_cast<const uint8_t *>(p)[i];
  443. return tmp;
  444. #else
  445. return *reinterpret_cast<const I *>(p);
  446. #endif
  447. }
  448. /**
  449. * Copy bits from memory into an integer type without modifying their order
  450. *
  451. * @tparam I Type to store
  452. * @param p Byte array (must be at least sizeof(I))
  453. * @param i Integer to store
  454. */
  455. template<typename I>
  456. static ZT_INLINE void storeAsIsEndian(void *const p,const I i) noexcept
  457. {
  458. #ifdef ZT_NO_UNALIGNED_ACCESS
  459. for(unsigned int k=0;k<sizeof(I);++k)
  460. reinterpret_cast<uint8_t *>(p)[k] = reinterpret_cast<const uint8_t *>(&i)[k];
  461. #else
  462. *reinterpret_cast<I *>(p) = i;
  463. #endif
  464. }
  465. /**
  466. * Decode a big-endian value from a byte stream
  467. *
  468. * @tparam I Type to decode (should be unsigned e.g. uint32_t or uint64_t)
  469. * @param p Byte stream, must be at least sizeof(I) in size
  470. * @return Decoded integer
  471. */
  472. template<typename I>
  473. static ZT_INLINE I loadBigEndian(const void *const p) noexcept
  474. {
  475. #ifdef ZT_NO_UNALIGNED_ACCESS
  476. return _load_be_bysize<I,sizeof(I)>::l(reinterpret_cast<const uint8_t *>(p));
  477. #else
  478. return ntoh(*reinterpret_cast<const I *>(p));
  479. #endif
  480. }
  481. /**
  482. * Save an integer in big-endian format
  483. *
  484. * @tparam I Integer type to store (usually inferred)
  485. * @param p Byte stream to write (must be at least sizeof(I))
  486. * #param i Integer to write
  487. */
  488. template<typename I>
  489. static ZT_INLINE void storeBigEndian(void *const p,I i) noexcept
  490. {
  491. #ifdef ZT_NO_UNALIGNED_ACCESS
  492. storeAsIsEndian(p,hton(i));
  493. #else
  494. *reinterpret_cast<I *>(p) = hton(i);
  495. #endif
  496. }
  497. /**
  498. * Decode a little-endian value from a byte stream
  499. *
  500. * @tparam I Type to decode
  501. * @param p Byte stream, must be at least sizeof(I) in size
  502. * @return Decoded integer
  503. */
  504. template<typename I>
  505. static ZT_INLINE I loadLittleEndian(const void *const p) noexcept
  506. {
  507. #if __BYTE_ORDER == __BIG_ENDIAN || defined(ZT_NO_UNALIGNED_ACCESS)
  508. return _load_le_bysize<I,sizeof(I)>::l(reinterpret_cast<const uint8_t *>(p));
  509. #else
  510. return *reinterpret_cast<const I *>(p);
  511. #endif
  512. }
  513. /**
  514. * Save an integer in little-endian format
  515. *
  516. * @tparam I Integer type to store (usually inferred)
  517. * @param p Byte stream to write (must be at least sizeof(I))
  518. * #param i Integer to write
  519. */
  520. template<typename I>
  521. static ZT_INLINE void storeLittleEndian(void *const p,const I i) noexcept
  522. {
  523. #if __BYTE_ORDER == __BIG_ENDIAN
  524. storeAsIsEndian(p,_swap_bytes_bysize<I,sizeof(I)>::s(i));
  525. #else
  526. #ifdef ZT_NO_UNALIGNED_ACCESS
  527. storeAsIsEndian(p,i);
  528. #else
  529. *reinterpret_cast<I *>(p) = i;
  530. #endif
  531. #endif
  532. }
  533. } // namespace Utils
  534. } // namespace ZeroTier
  535. #endif