summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@zerotier.com>2013-08-12 16:57:34 -0400
committerAdam Ierymenko <adam.ierymenko@zerotier.com>2013-08-12 16:57:34 -0400
commit5076c75b079fe02c843ca85dc20821e468b2d7b8 (patch)
tree0483b8122b9e627b1237e6d8e63e1c48c31497ee
parent36af3d92ecb4148a74c14896f5b6a9dcea0c1700 (diff)
downloadinfinitytier-5076c75b079fe02c843ca85dc20821e468b2d7b8.tar.gz
infinitytier-5076c75b079fe02c843ca85dc20821e468b2d7b8.zip
More Windows port work.
-rw-r--r--ZeroTierOne.vcxproj2
-rw-r--r--ext/bin/libcrypto/win32-vs2012/libeay32.libbin0 -> 14318836 bytes
-rw-r--r--ext/bin/libcrypto/win32-vs2012/libeay32d.libbin0 -> 14317172 bytes
-rw-r--r--ext/bin/libcrypto/win32-vs2012/ssleay32.libbin0 -> 2168206 bytes
-rw-r--r--ext/bin/libcrypto/win32-vs2012/ssleay32d.libbin0 -> 2168206 bytes
-rw-r--r--ext/bin/libcrypto/win64-vs2012/libeay32.libbin0 -> 15008866 bytes
-rw-r--r--ext/bin/libcrypto/win64-vs2012/libeay32d.libbin0 -> 15097128 bytes
-rw-r--r--ext/bin/libcrypto/win64-vs2012/ssleay32.libbin0 -> 2130452 bytes
-rw-r--r--ext/bin/libcrypto/win64-vs2012/ssleay32d.libbin0 -> 2234938 bytes
-rw-r--r--node/EllipticCurveKeyPair.cpp1
-rw-r--r--node/Identity.cpp1
-rw-r--r--node/Node.cpp4
-rw-r--r--node/NodeConfig.cpp4
-rw-r--r--node/Switch.cpp1
-rw-r--r--node/SysEnv.cpp27
-rw-r--r--node/Topology.cpp1
-rw-r--r--node/Utils.cpp57
-rw-r--r--node/Utils.hpp31
18 files changed, 113 insertions, 16 deletions
diff --git a/ZeroTierOne.vcxproj b/ZeroTierOne.vcxproj
index 28ba129b..866c9d50 100644
--- a/ZeroTierOne.vcxproj
+++ b/ZeroTierOne.vcxproj
@@ -35,11 +35,13 @@
<Optimization>Disabled</Optimization>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
+ <AdditionalIncludeDirectories>ext\bin\libcrypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
+ <AdditionalDependencies>ext\bin\libcrypto\win32-vs2012\libeay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
diff --git a/ext/bin/libcrypto/win32-vs2012/libeay32.lib b/ext/bin/libcrypto/win32-vs2012/libeay32.lib
new file mode 100644
index 00000000..53d90bf3
--- /dev/null
+++ b/ext/bin/libcrypto/win32-vs2012/libeay32.lib
Binary files differ
diff --git a/ext/bin/libcrypto/win32-vs2012/libeay32d.lib b/ext/bin/libcrypto/win32-vs2012/libeay32d.lib
new file mode 100644
index 00000000..02d4eaf9
--- /dev/null
+++ b/ext/bin/libcrypto/win32-vs2012/libeay32d.lib
Binary files differ
diff --git a/ext/bin/libcrypto/win32-vs2012/ssleay32.lib b/ext/bin/libcrypto/win32-vs2012/ssleay32.lib
new file mode 100644
index 00000000..ef99d18d
--- /dev/null
+++ b/ext/bin/libcrypto/win32-vs2012/ssleay32.lib
Binary files differ
diff --git a/ext/bin/libcrypto/win32-vs2012/ssleay32d.lib b/ext/bin/libcrypto/win32-vs2012/ssleay32d.lib
new file mode 100644
index 00000000..5d42119c
--- /dev/null
+++ b/ext/bin/libcrypto/win32-vs2012/ssleay32d.lib
Binary files differ
diff --git a/ext/bin/libcrypto/win64-vs2012/libeay32.lib b/ext/bin/libcrypto/win64-vs2012/libeay32.lib
new file mode 100644
index 00000000..bbc8edbc
--- /dev/null
+++ b/ext/bin/libcrypto/win64-vs2012/libeay32.lib
Binary files differ
diff --git a/ext/bin/libcrypto/win64-vs2012/libeay32d.lib b/ext/bin/libcrypto/win64-vs2012/libeay32d.lib
new file mode 100644
index 00000000..9b3bb518
--- /dev/null
+++ b/ext/bin/libcrypto/win64-vs2012/libeay32d.lib
Binary files differ
diff --git a/ext/bin/libcrypto/win64-vs2012/ssleay32.lib b/ext/bin/libcrypto/win64-vs2012/ssleay32.lib
new file mode 100644
index 00000000..1a7daa51
--- /dev/null
+++ b/ext/bin/libcrypto/win64-vs2012/ssleay32.lib
Binary files differ
diff --git a/ext/bin/libcrypto/win64-vs2012/ssleay32d.lib b/ext/bin/libcrypto/win64-vs2012/ssleay32d.lib
new file mode 100644
index 00000000..aa9ed5f7
--- /dev/null
+++ b/ext/bin/libcrypto/win64-vs2012/ssleay32d.lib
Binary files differ
diff --git a/node/EllipticCurveKeyPair.cpp b/node/EllipticCurveKeyPair.cpp
index 66acf320..d2e2920a 100644
--- a/node/EllipticCurveKeyPair.cpp
+++ b/node/EllipticCurveKeyPair.cpp
@@ -25,7 +25,6 @@
* LLC. Start here: http://www.zerotier.com/
*/
-#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/node/Identity.cpp b/node/Identity.cpp
index 1f5448a9..66ddae04 100644
--- a/node/Identity.cpp
+++ b/node/Identity.cpp
@@ -25,7 +25,6 @@
* LLC. Start here: http://www.zerotier.com/
*/
-#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/node/Node.cpp b/node/Node.cpp
index 2cacab56..f01f4659 100644
--- a/node/Node.cpp
+++ b/node/Node.cpp
@@ -343,7 +343,11 @@ Node::ReasonForTermination Node::run()
Utils::rm((_r->homePath + ZT_PATH_SEPARATOR_S + "thisdeviceismine"));
// Make sure networks.d exists
+#ifdef __WINDOWS__
+ CreateDirectory((_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d").c_str(),NULL);
+#else
mkdir((_r->homePath + ZT_PATH_SEPARATOR_S + "networks.d").c_str(),0700);
+#endif
// Load or generate config authentication secret
std::string configAuthTokenPath(_r->homePath + ZT_PATH_SEPARATOR_S + "authtoken.secret");
diff --git a/node/NodeConfig.cpp b/node/NodeConfig.cpp
index 87f85c22..427f963b 100644
--- a/node/NodeConfig.cpp
+++ b/node/NodeConfig.cpp
@@ -49,6 +49,10 @@
#include "Salsa20.hpp"
#include "HMAC.hpp"
+#ifdef __WINDOWS__
+#define strtoull _strtoui64
+#endif
+
namespace ZeroTier {
NodeConfig::NodeConfig(const RuntimeEnvironment *renv,const char *authToken)
diff --git a/node/Switch.cpp b/node/Switch.cpp
index 0b3cdf6d..d5c62994 100644
--- a/node/Switch.cpp
+++ b/node/Switch.cpp
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <stdlib.h>
+
#include <algorithm>
#include <utility>
#include <stdexcept>
diff --git a/node/SysEnv.cpp b/node/SysEnv.cpp
index 016e9caa..20b8e7d1 100644
--- a/node/SysEnv.cpp
+++ b/node/SysEnv.cpp
@@ -30,17 +30,23 @@
#include <string.h>
#include <fcntl.h>
#include <errno.h>
-#include <sys/socket.h>
#include <sys/types.h>
-#include <arpa/inet.h>
#include <set>
#include <string>
+#include "Constants.hpp"
#include "SysEnv.hpp"
#include "Utils.hpp"
#include "RuntimeEnvironment.hpp"
#include "NodeConfig.hpp"
+#ifdef __UNIX_LIKE__
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <unistd.h>
+#include <signal.h>
+#endif
+
#ifdef __APPLE__
#include <sys/sysctl.h>
#include <sys/uio.h>
@@ -48,11 +54,9 @@
#include <net/route.h>
#endif
-#ifdef _WIN32
+#ifdef __WINDOWS__
#include <Windows.h>
-#else
-#include <unistd.h>
-#include <signal.h>
+#include <WinSock2.h>
#endif
namespace ZeroTier {
@@ -210,10 +214,15 @@ uint64_t SysEnv::getNetworkConfigurationFingerprint()
#endif // __linux__
-#ifdef _WIN32
+#ifdef __WINDOWS__
-not implemented yet;
+uint64_t SysEnv::getNetworkConfigurationFingerprint()
+ throw()
+{
+ // TODO: windows version
+ return 1;
+}
-#endif // _WIN32
+#endif // __WINDOWS__
} // namespace ZeroTier
diff --git a/node/Topology.cpp b/node/Topology.cpp
index 0745c8f6..71d73a9d 100644
--- a/node/Topology.cpp
+++ b/node/Topology.cpp
@@ -26,6 +26,7 @@
*/
#include <algorithm>
+
#include "Topology.hpp"
#include "NodeConfig.hpp"
#include "CMWC4096.hpp"
diff --git a/node/Utils.cpp b/node/Utils.cpp
index 83328556..e8561b4c 100644
--- a/node/Utils.cpp
+++ b/node/Utils.cpp
@@ -221,9 +221,20 @@ static const char *MONTH_NAMES[12] = { "Jan","Feb","Mar","Apr","May","Jun","Jul"
std::map<std::string,bool> Utils::listDirectory(const char *path)
{
+ std::map<std::string,bool> r;
+
+#ifdef __WINDOWS__
+ HANDLE hFind;
+ WIN32_FIND_DATA ffd;
+ if ((hFind = FindFirstFile((std::string(path) + "\\*").c_str(),&ffd)) != INVALID_HANDLE_VALUE) {
+ do {
+ r[std::string(ffd.cFileName)] = ((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
+ } while (FindNextFile(hFind,&ffd));
+ FindClose(hFind);
+ }
+#else
struct dirent de;
struct dirent *dptr;
- std::map<std::string,bool> r;
DIR *d = opendir(path);
if (!d)
@@ -238,6 +249,7 @@ std::map<std::string,bool> Utils::listDirectory(const char *path)
r[std::string(dptr->d_name)] = (dptr->d_type == DT_DIR);
} else break;
}
+#endif
return r;
}
@@ -434,11 +446,43 @@ std::string Utils::toRfc1123(uint64_t t64)
struct tm t;
char buf[128];
time_t utc = (time_t)(t64 / 1000ULL);
+#ifdef __WINDOWS__
+ gmtime_s(&t,&utc);
+#else
gmtime_r(&utc,&t);
+#endif
sprintf(buf,"%3s, %02d %3s %4d %02d:%02d:%02d GMT",DAY_NAMES[t.tm_wday],t.tm_mday,MONTH_NAMES[t.tm_mon],t.tm_year + 1900,t.tm_hour,t.tm_min,t.tm_sec);
return std::string(buf);
}
+#ifdef __WINDOWS__
+static int is_leap(unsigned y) {
+ y += 1900;
+ return (y % 4) == 0 && ((y % 100) != 0 || (y % 400) == 0);
+}
+static time_t timegm(struct tm *tm) {
+ static const unsigned ndays[2][12] = {
+ {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
+ {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
+ };
+ time_t res = 0;
+ int i;
+ for (i = 70; i < tm->tm_year; ++i)
+ res += is_leap(i) ? 366 : 365;
+
+ for (i = 0; i < tm->tm_mon; ++i)
+ res += ndays[is_leap(tm->tm_year)][i];
+ res += tm->tm_mday - 1;
+ res *= 24;
+ res += tm->tm_hour;
+ res *= 60;
+ res += tm->tm_min;
+ res *= 60;
+ res += tm->tm_sec;
+ return res;
+}
+#endif
+
uint64_t Utils::fromRfc1123(const char *tstr)
{
struct tm t;
@@ -453,15 +497,25 @@ uint64_t Utils::fromRfc1123(const char *tstr)
wdays[3] = '\0';
for(t.tm_wday=0;t.tm_wday<7;++t.tm_wday) {
+#ifdef __WINDOWS__
+ if (!_stricmp(DAY_NAMES[t.tm_wday],wdays))
+ break;
+#else
if (!strcasecmp(DAY_NAMES[t.tm_wday],wdays))
break;
+#endif
}
if (t.tm_wday == 7)
return 0;
mons[3] = '\0';
for(t.tm_mon=0;t.tm_mon<12;++t.tm_mon) {
+#ifdef __WINDOWS__
+ if (!_stricmp(MONTH_NAMES[t.tm_mday],mons))
+ break;
+#else
if (!strcasecmp(MONTH_NAMES[t.tm_mday],mons))
break;
+#endif
}
if (t.tm_mon == 12)
return 0;
@@ -471,6 +525,7 @@ uint64_t Utils::fromRfc1123(const char *tstr)
t.tm_isdst = 0; // ignored by timegm
time_t utc = timegm(&t);
+
return ((utc > 0) ? (1000ULL * (uint64_t)utc) : 0ULL);
}
diff --git a/node/Utils.hpp b/node/Utils.hpp
index 8f5e7006..00564ae6 100644
--- a/node/Utils.hpp
+++ b/node/Utils.hpp
@@ -32,8 +32,6 @@
#include <stdlib.h>
#include <stdint.h>
#include <time.h>
-#include <sys/time.h>
-#include <arpa/inet.h>
#include <string>
#include <stdexcept>
@@ -44,9 +42,12 @@
#include "../ext/lz4/lz4hc.h"
#ifdef __WINDOWS__
-#include <windows.h>
+#include <Windows.h>
+#include <WinSock2.h>
#else
#include <unistd.h>
+#include <sys/time.h>
+#include <arpa/inet.h>
#endif
#include "Constants.hpp"
@@ -74,7 +75,7 @@ public:
throw()
{
#ifdef __WINDOWS__
- foo;
+ DeleteFile(path);
#else
return (unlink(path) == 0);
#endif
@@ -342,9 +343,20 @@ public:
static inline uint64_t now()
throw()
{
+#ifdef __WINDOWS__
+ FILETIME ft;
+ SYSTEMTIME st;
+ ULARGE_INTEGER tmp;
+ GetSystemTime(&st);
+ SystemTimeToFileTime(&st,&ft);
+ tmp.LowPart = ft.dwLowDateTime;
+ tmp.HighPart = ft.dwHighDateTime;
+ return ( ((tmp.QuadPart - 116444736000000000ULL) / 10000L) + st.wMilliseconds );
+#else
struct timeval tv;
gettimeofday(&tv,(struct timezone *)0);
return ( (1000ULL * (uint64_t)tv.tv_sec) + (uint64_t)(tv.tv_usec / 1000) );
+#endif
};
/**
@@ -353,9 +365,20 @@ public:
static inline double nowf()
throw()
{
+#ifdef __WINDOWS__
+ FILETIME ft;
+ SYSTEMTIME st;
+ ULARGE_INTEGER tmp;
+ GetSystemTime(&st);
+ SystemTimeToFileTime(&st,&ft);
+ tmp.LowPart = ft.dwLowDateTime;
+ tmp.HighPart = ft.dwHighDateTime;
+ return (((double)(tmp.QuadPart - 116444736000000000ULL)) / 10000000.0);
+#else
struct timeval tv;
gettimeofday(&tv,(struct timezone *)0);
return ( ((double)tv.tv_sec) + (((double)tv.tv_usec) / 1000000.0) );
+#endif
}
/**