summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrant Limberg <grant.limberg@zerotier.com>2018-02-12 09:30:12 -0800
committerGrant Limberg <grant.limberg@zerotier.com>2018-02-12 09:30:12 -0800
commitf9b07c63db322b1ce0b95ef2844dccb7b9554eea (patch)
treebb8aecad727970a85bb51261f3f7b4b8f3eab039
parent8828fc75209fb998bb1ba76b69a37969ec843527 (diff)
parent978d8fcd4a3a890ecf5598d949b1c50a97de1cae (diff)
downloadinfinitytier-f9b07c63db322b1ce0b95ef2844dccb7b9554eea.tar.gz
infinitytier-f9b07c63db322b1ce0b95ef2844dccb7b9554eea.zip
Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev
-rw-r--r--node/Dictionary.hpp53
-rw-r--r--node/Switch.cpp1
-rw-r--r--service/OneService.cpp6
3 files changed, 24 insertions, 36 deletions
diff --git a/node/Dictionary.hpp b/node/Dictionary.hpp
index 59afb7c6..f89b6ffc 100644
--- a/node/Dictionary.hpp
+++ b/node/Dictionary.hpp
@@ -62,40 +62,24 @@ template<unsigned int C>
class Dictionary
{
public:
- Dictionary()
- {
- _d[0] = (char)0;
- }
-
- Dictionary(const char *s)
- {
- if (s) {
- Utils::scopy(_d,sizeof(_d),s);
- } else {
- _d[0] = (char)0;
- }
- }
-
+ Dictionary() { memset(_d,0,sizeof(_d)); }
+ Dictionary(const char *s) { this->load(s); }
Dictionary(const char *s,unsigned int len)
{
- if (s) {
- if (len > (C-1))
- len = C-1;
- ZT_FAST_MEMCPY(_d,s,len);
- _d[len] = (char)0;
- } else {
- _d[0] = (char)0;
+ for(unsigned int i=0;i<C;++i) {
+ if ((s)&&(i < len)) {
+ if (!(_d[i] = *s))
+ s = (const char *)0;
+ else ++s;
+ } else _d[i] = (char)0;
}
+ _d[C - 1] = (char)0;
}
-
- Dictionary(const Dictionary &d)
- {
- Utils::scopy(_d,sizeof(_d),d._d);
- }
+ Dictionary(const Dictionary &d) { memcpy(_d,d._d,C); }
inline Dictionary &operator=(const Dictionary &d)
{
- Utils::scopy(_d,sizeof(_d),d._d);
+ memcpy(_d,d._d,C);
return *this;
}
@@ -109,12 +93,15 @@ public:
*/
inline bool load(const char *s)
{
- if (s) {
- return Utils::scopy(_d,sizeof(_d),s);
- } else {
- _d[0] = (char)0;
- return true;
+ for(unsigned int i=0;i<C;++i) {
+ if (s) {
+ if (!(_d[i] = *s))
+ s = (const char *)0;
+ else ++s;
+ } else _d[i] = (char)0;
}
+ _d[C - 1] = (char)0;
+ return (!s);
}
/**
@@ -122,7 +109,7 @@ public:
*/
inline void clear()
{
- _d[0] = (char)0;
+ memset(_d,0,sizeof(_d));
}
/**
diff --git a/node/Switch.cpp b/node/Switch.cpp
index 5c5130f4..eb1ebadb 100644
--- a/node/Switch.cpp
+++ b/node/Switch.cpp
@@ -50,6 +50,7 @@ namespace ZeroTier {
Switch::Switch(const RuntimeEnvironment *renv) :
RR(renv),
_lastBeaconResponse(0),
+ _lastCheckedQueues(0),
_lastUniteAttempt(8) // only really used on root servers and upstreams, and it'll grow there just fine
{
}
diff --git a/service/OneService.cpp b/service/OneService.cpp
index 27b71141..4854d68d 100644
--- a/service/OneService.cpp
+++ b/service/OneService.cpp
@@ -1593,7 +1593,7 @@ public:
if (syncRoutes) {
char tapdev[64];
-#ifdef __WINDOWS__
+#if defined(__WINDOWS__) && !defined(ZT_SDK)
OSUtils::ztsnprintf(tapdev,sizeof(tapdev),"%.16llx",(unsigned long long)n.tap->luid().Value);
#else
Utils::scopy(tapdev,sizeof(tapdev),n.tap->deviceName().c_str());
@@ -1998,7 +1998,7 @@ public:
case ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE:
ZT_FAST_MEMCPY(&(n.config),nwc,sizeof(ZT_VirtualNetworkConfig));
if (n.tap) { // sanity check
-#ifdef __WINDOWS__
+#if defined(__WINDOWS__) && !defined(ZT_SDK)
// wait for up to 5 seconds for the WindowsEthernetTap to actually be initialized
//
// without WindowsEthernetTap::isInitialized() returning true, the won't actually
@@ -2019,7 +2019,7 @@ public:
case ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN:
case ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY:
if (n.tap) { // sanity check
-#ifdef __WINDOWS__
+#if defined(__WINDOWS__) && !defined(ZT_SDK)
std::string winInstanceId(n.tap->instanceId());
#endif
*nuptr = (void *)0;