diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 0e40fe8f5..000000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# Default ignored files -/workspace.xml \ No newline at end of file diff --git a/.idea/ZeroTierOne.iml b/.idea/ZeroTierOne.iml index 44599ced0..f08604bb6 100644 --- a/.idea/ZeroTierOne.iml +++ b/.idea/ZeroTierOne.iml @@ -1,4 +1,2 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index a55e7a179..000000000 --- a/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/dictionaries/api.xml b/.idea/dictionaries/api.xml index 53167764f..a2babde27 100644 --- a/.idea/dictionaries/api.xml +++ b/.idea/dictionaries/api.xml @@ -1,11 +1,9 @@ - apisocket - nwid - secrand - sockaddr - unmarshals + accel + certificateofownership + multicast \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 146ab09b7..000000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 8822db8f1..79b3c9483 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,4 @@ - - \ No newline at end of file diff --git a/.idea/watcherTasks.xml b/.idea/watcherTasks.xml deleted file mode 100644 index 97ad6d2d9..000000000 --- a/.idea/watcherTasks.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/node/AES.hpp b/node/AES.hpp index d8392bcb0..f03fd48cf 100644 --- a/node/AES.hpp +++ b/node/AES.hpp @@ -18,6 +18,8 @@ #include "Utils.hpp" #include "SHA512.hpp" +#include + #if (defined(__amd64) || defined(__amd64__) || defined(__x86_64) || defined(__x86_64__) || defined(__AMD64) || defined(__AMD64__) || defined(_M_X64)) #include @@ -31,9 +33,6 @@ extern "C" void zt_crypt_ctr_aesni(const __m128i key[14],const uint8_t iv[16],co #endif // x64 -#define ZT_AES_KEY_SIZE 32 -#define ZT_AES_BLOCK_SIZE 16 - namespace ZeroTier { /** diff --git a/node/Address.hpp b/node/Address.hpp index 7634a1c36..053707a4d 100644 --- a/node/Address.hpp +++ b/node/Address.hpp @@ -14,11 +14,11 @@ #ifndef ZT_ADDRESS_HPP #define ZT_ADDRESS_HPP -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include @@ -37,8 +37,7 @@ class Address { public: ZT_ALWAYS_INLINE Address() : _a(0) {} - ZT_ALWAYS_INLINE Address(const Address &a) : _a(a._a) {} - ZT_ALWAYS_INLINE Address(uint64_t a) : _a(a & 0xffffffffffULL) {} + explicit ZT_ALWAYS_INLINE Address(uint64_t a) : _a(a & 0xffffffffffULL) {} /** * @param bits Raw address -- 5 bytes, big-endian byte order @@ -46,7 +45,6 @@ public: */ ZT_ALWAYS_INLINE Address(const void *bits,unsigned int len) { setTo(bits,len); } - ZT_ALWAYS_INLINE Address &operator=(const Address &a) { _a = a._a; return *this; } ZT_ALWAYS_INLINE Address &operator=(const uint64_t a) { _a = (a & 0xffffffffffULL); return *this; } /** @@ -137,9 +135,9 @@ public: */ ZT_ALWAYS_INLINE uint8_t operator[](unsigned int i) const { return (uint8_t)(_a >> (32 - (i * 8))); } - ZT_ALWAYS_INLINE operator unsigned int() const { return (unsigned int)_a; } - ZT_ALWAYS_INLINE operator unsigned long() const { return (unsigned long)_a; } - ZT_ALWAYS_INLINE operator unsigned long long() const { return (unsigned long long)_a; } + explicit ZT_ALWAYS_INLINE operator unsigned int() const { return (unsigned int)_a; } + explicit ZT_ALWAYS_INLINE operator unsigned long() const { return (unsigned long)_a; } + explicit ZT_ALWAYS_INLINE operator unsigned long long() const { return (unsigned long long)_a; } ZT_ALWAYS_INLINE void zero() { _a = 0; } diff --git a/node/C25519.cpp b/node/C25519.cpp index aa9fa66c5..3e05859c3 100644 --- a/node/C25519.cpp +++ b/node/C25519.cpp @@ -7,16 +7,11 @@ Derived from public domain code by D. J. Bernstein. // Modified very slightly for ZeroTier One by Adam Ierymenko // This code remains in the public domain. -#include -#include -#include +#include +#include -#include "Constants.hpp" #include "C25519.hpp" #include "SHA512.hpp" -#include "Buffer.hpp" -#include "Hashtable.hpp" -#include "Mutex.hpp" #ifdef __WINDOWS__ #pragma warning(disable: 4146) @@ -28,10 +23,7 @@ Derived from public domain code by D. J. Bernstein. namespace { -#define crypto_int32 int32_t #define crypto_uint32 uint32_t -#define crypto_int64 int64_t -#define crypto_uint64 uint64_t #define crypto_hash_sha512_BYTES 64 ////////////////////////////////////////////////////////////////////////////// diff --git a/node/Capability.hpp b/node/Capability.hpp index 167b575c2..8606cd5d8 100644 --- a/node/Capability.hpp +++ b/node/Capability.hpp @@ -14,9 +14,9 @@ #ifndef ZT_CAPABILITY_HPP #define ZT_CAPABILITY_HPP -#include -#include -#include +#include +#include +#include #include "Constants.hpp" #include "Credential.hpp" diff --git a/node/CertificateOfMembership.hpp b/node/CertificateOfMembership.hpp index 81308a216..976c48b47 100644 --- a/node/CertificateOfMembership.hpp +++ b/node/CertificateOfMembership.hpp @@ -14,8 +14,8 @@ #ifndef ZT_CERTIFICATEOFMEMBERSHIP_HPP #define ZT_CERTIFICATEOFMEMBERSHIP_HPP -#include -#include +#include +#include #include #include diff --git a/node/CertificateOfOwnership.hpp b/node/CertificateOfOwnership.hpp index 7bdcf9eed..336577767 100644 --- a/node/CertificateOfOwnership.hpp +++ b/node/CertificateOfOwnership.hpp @@ -14,10 +14,10 @@ #ifndef ZT_CERTIFICATEOFOWNERSHIP_HPP #define ZT_CERTIFICATEOFOWNERSHIP_HPP -#include -#include -#include -#include +#include +#include +#include +#include #include "Constants.hpp" #include "Credential.hpp" diff --git a/node/Credential.hpp b/node/Credential.hpp index 19ca9e009..6edc41fae 100644 --- a/node/Credential.hpp +++ b/node/Credential.hpp @@ -18,10 +18,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include "Constants.hpp" diff --git a/node/Dictionary.hpp b/node/Dictionary.hpp index 599e5cfde..8099e50e0 100644 --- a/node/Dictionary.hpp +++ b/node/Dictionary.hpp @@ -19,7 +19,7 @@ #include "Buffer.hpp" #include "Address.hpp" -#include +#include namespace ZeroTier { diff --git a/node/ECC384.cpp b/node/ECC384.cpp index 2395fb517..d28cf742d 100644 --- a/node/ECC384.cpp +++ b/node/ECC384.cpp @@ -4,10 +4,9 @@ // This code is under the BSD 2-clause license, not ZeroTier's license ////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include +#include +#include +#include #include "Constants.hpp" #include "ECC384.hpp" diff --git a/node/Endpoint.hpp b/node/Endpoint.hpp index baf1e9697..afb26c34b 100644 --- a/node/Endpoint.hpp +++ b/node/Endpoint.hpp @@ -14,10 +14,10 @@ #ifndef ZT_ENDPOINT_HPP #define ZT_ENDPOINT_HPP -#include -#include -#include -#include +#include +#include +#include +#include #include "Constants.hpp" #include "InetAddress.hpp" @@ -53,7 +53,7 @@ public: ZT_ALWAYS_INLINE const InetAddress *sockaddr() const { return (_t == INETADDR) ? reinterpret_cast(&_v.sa) : nullptr; } ZT_ALWAYS_INLINE const char *dnsName() const { return (_t == DNSNAME) ? _v.dns.name : nullptr; } - ZT_ALWAYS_INLINE const int dnsPort() const { return (_t == DNSNAME) ? _v.dns.port : -1; } + ZT_ALWAYS_INLINE int dnsPort() const { return (_t == DNSNAME) ? _v.dns.port : -1; } ZT_ALWAYS_INLINE Address ztAddress() const { return (_t == ZEROTIER) ? Address(_v.zt.a) : Address(); } ZT_ALWAYS_INLINE const uint8_t *ztIdentityHash() const { return (_t == ZEROTIER) ? _v.zt.idh : nullptr; } ZT_ALWAYS_INLINE const char *url() const { return (_t == URL) ? _v.url : nullptr; } @@ -140,7 +140,7 @@ public: } ++p; if ((p >= (ZT_ENDPOINT_MAX_NAME_SIZE+1))||(p >= (len-2))) - return; + return -1; } _v.dns.port = ((int)data[p++]) << 8; _v.dns.port |= (int)data[p++]; diff --git a/node/Identity.hpp b/node/Identity.hpp index c28da306d..6938bf2d4 100644 --- a/node/Identity.hpp +++ b/node/Identity.hpp @@ -14,8 +14,8 @@ #ifndef ZT_IDENTITY_HPP #define ZT_IDENTITY_HPP -#include -#include +#include +#include #include "Constants.hpp" #include "Utils.hpp" diff --git a/node/IncomingPacket.cpp b/node/IncomingPacket.cpp index 0bd76b7a7..27b7adcb6 100644 --- a/node/IncomingPacket.cpp +++ b/node/IncomingPacket.cpp @@ -29,9 +29,8 @@ #include "Revocation.hpp" #include "Trace.hpp" -#include -#include -#include +#include +#include #include diff --git a/node/IncomingPacket.hpp b/node/IncomingPacket.hpp index 1e7219380..3a72d7cc7 100644 --- a/node/IncomingPacket.hpp +++ b/node/IncomingPacket.hpp @@ -14,8 +14,6 @@ #ifndef ZT_INCOMINGPACKET_HPP #define ZT_INCOMINGPACKET_HPP -#include - #include "Packet.hpp" #include "Path.hpp" #include "Utils.hpp" diff --git a/node/InetAddress.hpp b/node/InetAddress.hpp index 707109a34..5ec3aef1b 100644 --- a/node/InetAddress.hpp +++ b/node/InetAddress.hpp @@ -14,9 +14,9 @@ #ifndef ZT_INETADDRESS_HPP #define ZT_INETADDRESS_HPP -#include -#include -#include +#include +#include +#include #include "Constants.hpp" #include "../include/ZeroTierOne.h" diff --git a/node/MAC.hpp b/node/MAC.hpp index c60186aa9..9ea4ba8c5 100644 --- a/node/MAC.hpp +++ b/node/MAC.hpp @@ -14,9 +14,9 @@ #ifndef ZT_MAC_HPP #define ZT_MAC_HPP -#include -#include -#include +#include +#include +#include #include "Constants.hpp" #include "Utils.hpp" diff --git a/node/Membership.hpp b/node/Membership.hpp index 94248f2a5..5c92d5ea4 100644 --- a/node/Membership.hpp +++ b/node/Membership.hpp @@ -14,10 +14,11 @@ #ifndef ZT_MEMBERSHIP_HPP #define ZT_MEMBERSHIP_HPP -#include +#include + +#include "../include/ZeroTierOne.h" #include "Constants.hpp" -#include "../include/ZeroTierOne.h" #include "Credential.hpp" #include "Hashtable.hpp" #include "CertificateOfMembership.hpp" @@ -97,11 +98,6 @@ public: return nconf.com.agreesWith(_com); // check timestamp agreement window } - /** - * @return True if this peer has sent us a valid certificate within ZT_PEER_ACTIVITY_TIMEOUT - */ - inline bool recentlyAssociated(const int64_t now) const { return ((_com)&&((now - _com.timestamp()) < ZT_PEER_ACTIVITY_TIMEOUT)); } - /** * Check whether the peer represented by this Membership owns a given address * diff --git a/node/MulticastGroup.hpp b/node/MulticastGroup.hpp index e3deebdb6..e98c2321a 100644 --- a/node/MulticastGroup.hpp +++ b/node/MulticastGroup.hpp @@ -14,7 +14,7 @@ #ifndef ZT_MULTICASTGROUP_HPP #define ZT_MULTICASTGROUP_HPP -#include +#include #include "Constants.hpp" #include "MAC.hpp" diff --git a/node/Mutex.hpp b/node/Mutex.hpp index 3dc11108a..69b6d4584 100644 --- a/node/Mutex.hpp +++ b/node/Mutex.hpp @@ -16,10 +16,11 @@ #include "Constants.hpp" +#include +#include + #ifdef __UNIX_LIKE__ -#include -#include #include namespace ZeroTier { @@ -56,7 +57,6 @@ private: #ifdef __WINDOWS__ -#include #include namespace ZeroTier { diff --git a/node/Network.cpp b/node/Network.cpp index 8e3732833..8b30c6ae6 100644 --- a/node/Network.cpp +++ b/node/Network.cpp @@ -11,10 +11,10 @@ */ /****/ -#include -#include -#include -#include +#include +#include +#include +#include #include "../include/ZeroTierDebug.h" diff --git a/node/Network.hpp b/node/Network.hpp index 744ea8066..43333725f 100644 --- a/node/Network.hpp +++ b/node/Network.hpp @@ -14,7 +14,7 @@ #ifndef ZT_NETWORK_HPP #define ZT_NETWORK_HPP -#include +#include #include "../include/ZeroTierOne.h" diff --git a/node/NetworkConfig.cpp b/node/NetworkConfig.cpp index 6b0fe90d4..d94c774f6 100644 --- a/node/NetworkConfig.cpp +++ b/node/NetworkConfig.cpp @@ -11,7 +11,7 @@ */ /****/ -#include +#include #include diff --git a/node/NetworkConfig.hpp b/node/NetworkConfig.hpp index 8e9acd527..bf069721f 100644 --- a/node/NetworkConfig.hpp +++ b/node/NetworkConfig.hpp @@ -14,9 +14,9 @@ #ifndef ZT_NETWORKCONFIG_HPP #define ZT_NETWORKCONFIG_HPP -#include -#include -#include +#include +#include +#include #include #include diff --git a/node/NetworkController.hpp b/node/NetworkController.hpp index b344787b8..5c7734430 100644 --- a/node/NetworkController.hpp +++ b/node/NetworkController.hpp @@ -14,7 +14,7 @@ #ifndef ZT_NETWORKCONFIGMASTER_HPP #define ZT_NETWORKCONFIGMASTER_HPP -#include +#include #include "Constants.hpp" #include "Dictionary.hpp" diff --git a/node/Node.hpp b/node/Node.hpp index 6f6fb99e8..bf9696e38 100644 --- a/node/Node.hpp +++ b/node/Node.hpp @@ -14,9 +14,9 @@ #ifndef ZT_NODE_HPP #define ZT_NODE_HPP -#include -#include -#include +#include +#include +#include #include #include diff --git a/node/Packet.hpp b/node/Packet.hpp index 8fff4be37..b8aeffe3d 100644 --- a/node/Packet.hpp +++ b/node/Packet.hpp @@ -14,9 +14,9 @@ #ifndef ZT_N_PACKET_HPP #define ZT_N_PACKET_HPP -#include -#include -#include +#include +#include +#include #include #include diff --git a/node/Path.hpp b/node/Path.hpp index 06ec917e9..3c7a97e16 100644 --- a/node/Path.hpp +++ b/node/Path.hpp @@ -14,9 +14,9 @@ #ifndef ZT_PATH_HPP #define ZT_PATH_HPP -#include -#include -#include +#include +#include +#include #include #include diff --git a/node/Poly1305.cpp b/node/Poly1305.cpp index bd71cf2ad..c4db0f7f0 100644 --- a/node/Poly1305.cpp +++ b/node/Poly1305.cpp @@ -7,10 +7,7 @@ Public domain. #include "Constants.hpp" #include "Poly1305.hpp" -#include -#include -#include -#include +#include #ifdef __WINDOWS__ #pragma warning(disable: 4146) diff --git a/node/Revocation.hpp b/node/Revocation.hpp index 0371b0ef2..211e6b814 100644 --- a/node/Revocation.hpp +++ b/node/Revocation.hpp @@ -14,10 +14,10 @@ #ifndef ZT_REVOCATION_HPP #define ZT_REVOCATION_HPP -#include -#include -#include -#include +#include +#include +#include +#include #include "Constants.hpp" #include "../include/ZeroTierOne.h" diff --git a/node/RingBuffer.hpp b/node/RingBuffer.hpp index 384022c2f..1839bc710 100644 --- a/node/RingBuffer.hpp +++ b/node/RingBuffer.hpp @@ -16,10 +16,9 @@ #include #include -#include -#include +#include +#include #include -#include namespace ZeroTier { diff --git a/node/SHA512.cpp b/node/SHA512.cpp index f8af9ebb3..2437ba742 100644 --- a/node/SHA512.cpp +++ b/node/SHA512.cpp @@ -1,8 +1,8 @@ // This code is public domain, taken from a PD crypto source file on GitHub. -#include -#include -#include +#include +#include +#include #include "SHA512.hpp" #include "Utils.hpp" diff --git a/node/Salsa20.hpp b/node/Salsa20.hpp index bedfba770..047433e5f 100644 --- a/node/Salsa20.hpp +++ b/node/Salsa20.hpp @@ -7,10 +7,10 @@ #ifndef ZT_SALSA20_HPP #define ZT_SALSA20_HPP -#include -#include -#include -#include +#include +#include +#include +#include #include "Constants.hpp" #include "Utils.hpp" @@ -30,14 +30,14 @@ namespace ZeroTier { class Salsa20 { public: - inline Salsa20() {} - inline ~Salsa20() { Utils::burn(&_state,sizeof(_state)); } + ZT_ALWAYS_INLINE Salsa20() {} + ZT_ALWAYS_INLINE ~Salsa20() { Utils::burn(&_state,sizeof(_state)); } /** * @param key 256-bit (32 byte) key * @param iv 64-bit initialization vector */ - inline Salsa20(const void *key,const void *iv) { init(key,iv); } + ZT_ALWAYS_INLINE Salsa20(const void *key,const void *iv) { init(key,iv); } /** * Initialize cipher diff --git a/node/ScopedPtr.hpp b/node/ScopedPtr.hpp index ff3972dad..d1671d94b 100644 --- a/node/ScopedPtr.hpp +++ b/node/ScopedPtr.hpp @@ -27,12 +27,12 @@ template class ScopedPtr { public: - ZT_ALWAYS_INLINE ScopedPtr(T *const p) : _p(p) {} + explicit ZT_ALWAYS_INLINE ScopedPtr(T *const p) : _p(p) {} ZT_ALWAYS_INLINE ~ScopedPtr() { delete _p; } ZT_ALWAYS_INLINE T *operator->() const { return _p; } ZT_ALWAYS_INLINE T &operator*() const { return *_p; } - ZT_ALWAYS_INLINE operator bool() const { return (_p != (T *)0); } + explicit ZT_ALWAYS_INLINE operator bool() const { return (_p != (T *)0); } ZT_ALWAYS_INLINE T *ptr() const { return _p; } ZT_ALWAYS_INLINE bool operator==(const ScopedPtr &p) const { return (_p == p._p); } diff --git a/node/SelfAwareness.cpp b/node/SelfAwareness.cpp index 57ce7fde3..8cd1399d7 100644 --- a/node/SelfAwareness.cpp +++ b/node/SelfAwareness.cpp @@ -11,12 +11,10 @@ */ /****/ -#include -#include -#include +#include +#include #include -#include #include "Constants.hpp" #include "SelfAwareness.hpp" diff --git a/node/Switch.cpp b/node/Switch.cpp index 39893df27..9ea556f8f 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -11,8 +11,8 @@ */ /****/ -#include -#include +#include +#include #include #include diff --git a/node/Tag.hpp b/node/Tag.hpp index e0405a76d..45df513d0 100644 --- a/node/Tag.hpp +++ b/node/Tag.hpp @@ -14,10 +14,10 @@ #ifndef ZT_TAG_HPP #define ZT_TAG_HPP -#include -#include -#include -#include +#include +#include +#include +#include #include "Constants.hpp" #include "Credential.hpp" diff --git a/node/Topology.hpp b/node/Topology.hpp index 0e44f3ccb..7ca29fefc 100644 --- a/node/Topology.hpp +++ b/node/Topology.hpp @@ -14,8 +14,8 @@ #ifndef ZT_TOPOLOGY_HPP #define ZT_TOPOLOGY_HPP -#include -#include +#include +#include #include #include diff --git a/node/Trace.hpp b/node/Trace.hpp index ffb14682e..5640bbbba 100644 --- a/node/Trace.hpp +++ b/node/Trace.hpp @@ -14,10 +14,10 @@ #ifndef ZT_TRACE_HPP #define ZT_TRACE_HPP -#include -#include -#include -#include +#include +#include +#include +#include #include "../include/ZeroTierOne.h" diff --git a/node/Utils.cpp b/node/Utils.cpp index d2da7d779..094d57cf1 100644 --- a/node/Utils.cpp +++ b/node/Utils.cpp @@ -11,23 +11,16 @@ */ /****/ -#include -#include -#include -#include -#include -#include +#include +#include +#include #include "Constants.hpp" #ifdef __UNIX_LIKE__ #include -#include #include -#include -#include #include -#include #endif #ifdef __WINDOWS__ @@ -36,7 +29,6 @@ #include "Utils.hpp" #include "Mutex.hpp" -#include "Salsa20.hpp" #include "AES.hpp" #include "SHA512.hpp" @@ -105,16 +97,6 @@ char *decimal(unsigned long n,char s[24]) return s; } -unsigned short crc16(const void *buf,unsigned int len) -{ - static const uint16_t crc16tab[256]= { 0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7,0x8108,0x9129,0xa14a,0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef,0x1231,0x0210,0x3273,0x2252,0x52b5,0x4294,0x72f7,0x62d6,0x9339,0x8318,0xb37b,0xa35a,0xd3bd,0xc39c,0xf3ff,0xe3de,0x2462,0x3443,0x0420,0x1401,0x64e6,0x74c7,0x44a4,0x5485,0xa56a,0xb54b,0x8528,0x9509,0xe5ee,0xf5cf,0xc5ac,0xd58d,0x3653,0x2672,0x1611,0x0630,0x76d7,0x66f6,0x5695,0x46b4,0xb75b,0xa77a,0x9719,0x8738,0xf7df,0xe7fe,0xd79d,0xc7bc,0x48c4,0x58e5,0x6886,0x78a7,0x0840,0x1861,0x2802,0x3823,0xc9cc,0xd9ed,0xe98e,0xf9af,0x8948,0x9969,0xa90a,0xb92b,0x5af5,0x4ad4,0x7ab7,0x6a96,0x1a71,0x0a50,0x3a33,0x2a12,0xdbfd,0xcbdc,0xfbbf,0xeb9e,0x9b79,0x8b58,0xbb3b,0xab1a,0x6ca6,0x7c87,0x4ce4,0x5cc5,0x2c22,0x3c03,0x0c60,0x1c41,0xedae,0xfd8f,0xcdec,0xddcd,0xad2a,0xbd0b,0x8d68,0x9d49,0x7e97,0x6eb6,0x5ed5,0x4ef4,0x3e13,0x2e32,0x1e51,0x0e70,0xff9f,0xefbe,0xdfdd,0xcffc,0xbf1b,0xaf3a,0x9f59,0x8f78,0x9188,0x81a9,0xb1ca,0xa1eb,0xd10c,0xc12d,0xf14e,0xe16f,0x1080,0x00a1,0x30c2,0x20e3,0x5004,0x4025,0x7046,0x6067,0x83b9,0x9398,0xa3fb,0xb3da,0xc33d,0xd31c,0xe37f,0xf35e,0x02b1,0x1290,0x22f3,0x32d2,0x4235,0x5214,0x6277,0x7256,0xb5ea,0xa5cb,0x95a8,0x8589,0xf56e,0xe54f,0xd52c,0xc50d,0x34e2,0x24c3,0x14a0,0x0481,0x7466,0x6447,0x5424,0x4405,0xa7db,0xb7fa,0x8799,0x97b8,0xe75f,0xf77e,0xc71d,0xd73c,0x26d3,0x36f2,0x0691,0x16b0,0x6657,0x7676,0x4615,0x5634,0xd94c,0xc96d,0xf90e,0xe92f,0x99c8,0x89e9,0xb98a,0xa9ab,0x5844,0x4865,0x7806,0x6827,0x18c0,0x08e1,0x3882,0x28a3,0xcb7d,0xdb5c,0xeb3f,0xfb1e,0x8bf9,0x9bd8,0xabbb,0xbb9a,0x4a75,0x5a54,0x6a37,0x7a16,0x0af1,0x1ad0,0x2ab3,0x3a92,0xfd2e,0xed0f,0xdd6c,0xcd4d,0xbdaa,0xad8b,0x9de8,0x8dc9,0x7c26,0x6c07,0x5c64,0x4c45,0x3ca2,0x2c83,0x1ce0,0x0cc1,0xef1f,0xff3e,0xcf5d,0xdf7c,0xaf9b,0xbfba,0x8fd9,0x9ff8,0x6e17,0x7e36,0x4e55,0x5e74,0x2e93,0x3eb2,0x0ed1,0x1ef0 }; - uint16_t crc = 0; - const uint8_t *p = (const uint8_t *)buf; - for(unsigned int i=0;i> 8) ^ *(p++)) & 0x00ff]; - return crc; -} - char *hex10(uint64_t i,char s[11]) { s[0] = HEXCHARS[(i >> 36) & 0xf]; diff --git a/node/Utils.hpp b/node/Utils.hpp index 89f30e905..0e0c226cb 100644 --- a/node/Utils.hpp +++ b/node/Utils.hpp @@ -14,11 +14,11 @@ #ifndef ZT_UTILS_HPP #define ZT_UTILS_HPP -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include @@ -34,7 +34,7 @@ namespace Utils { /** * Hexadecimal characters 0-f */ -const char HEXCHARS[16]; +extern const char HEXCHARS[16]; /** * Perform a time-invariant binary comparison @@ -58,11 +58,6 @@ void burn(void *ptr,unsigned int len); */ char *decimal(unsigned long n,char s[24]); -/** - * Compute CRC16-CCITT - */ -uint16_t crc16(const void *buf,unsigned int len); - /** * Convert an unsigned integer into hex *