Windows build fixes.

This commit is contained in:
Adam Ierymenko 2014-01-17 17:09:59 -08:00
parent 7eccc5ebf2
commit 07f505971c
15 changed files with 53 additions and 26 deletions

2
.gitignore vendored
View file

@ -34,3 +34,5 @@
*.autosave *.autosave
/ZeroTier One.zip /ZeroTier One.zip
/ZeroTier One.dmg /ZeroTier One.dmg
/windows/ZeroTierOne.sdf
/windows/ZeroTierOne.v11.suo

View file

@ -34,6 +34,10 @@
#include "Constants.hpp" #include "Constants.hpp"
#include "Utils.hpp" #include "Utils.hpp"
#ifdef __WINDOWS__
#define round(x) ((x-floor(x))>0.5 ? ceil(x) : floor(x))
#endif
namespace ZeroTier { namespace ZeroTier {
/** /**

View file

@ -18,6 +18,10 @@ Derived from public domain code by D. J. Bernstein.
#include "SHA512.hpp" #include "SHA512.hpp"
#include "Buffer.hpp" #include "Buffer.hpp"
#ifdef __WINDOWS__
#pragma warning(disable: 4146)
#endif
namespace ZeroTier { namespace ZeroTier {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////

View file

@ -77,6 +77,8 @@
#define ZT_PATH_SEPARATOR '\\' #define ZT_PATH_SEPARATOR '\\'
#define ZT_PATH_SEPARATOR_S "\\" #define ZT_PATH_SEPARATOR_S "\\"
#define ZT_EOL_S "\r\n" #define ZT_EOL_S "\r\n"
#include <WinSock2.h>
#include <Windows.h>
#endif #endif
// Assume these are little-endian. PPC is not supported for OSX, and ARM // Assume these are little-endian. PPC is not supported for OSX, and ARM

View file

@ -938,7 +938,7 @@ void EthernetTap::threadMain()
#include <nldef.h> #include <nldef.h>
#include <netioapi.h> #include <netioapi.h>
#include "..\vsprojects\TapDriver\tap-windows.h" #include "..\windows\TapDriver\tap-windows.h"
namespace ZeroTier { namespace ZeroTier {

View file

@ -25,21 +25,20 @@
* LLC. Start here: http://www.zerotier.com/ * LLC. Start here: http://www.zerotier.com/
*/ */
#include "Constants.hpp"
#ifdef __WINDOWS__
#include <WinSock2.h>
#include <Windows.h>
#include <winhttp.h>
#include <locale>
#include <codecvt>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <vector>
#include <utility>
#include <algorithm>
#include "Constants.hpp"
#include "HttpClient.hpp"
#include "Thread.hpp"
#include "Utils.hpp"
#include "NonCopyable.hpp"
#include "Defaults.hpp"
#ifdef __UNIX_LIKE__ #ifdef __UNIX_LIKE__
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
@ -51,12 +50,15 @@
#include <sys/wait.h> #include <sys/wait.h>
#endif #endif
#ifdef __WINDOWS__ #include <vector>
#include <locale> #include <utility>
#include <codecvt> #include <algorithm>
#include <Windows.h>
#include <winhttp.h> #include "HttpClient.hpp"
#endif #include "Thread.hpp"
#include "Utils.hpp"
#include "NonCopyable.hpp"
#include "Defaults.hpp"
namespace ZeroTier { namespace ZeroTier {

View file

@ -112,8 +112,8 @@ public:
if ((!etherType)||(etherType > 0xffff)) // sanity checks if ((!etherType)||(etherType > 0xffff)) // sanity checks
return false; return false;
else if ((_etWhitelist[0] & 1)) // prsence of 0 in set inverts sense: whitelist becomes blacklist else if ((_etWhitelist[0] & 1)) // prsence of 0 in set inverts sense: whitelist becomes blacklist
return (!(_etWhitelist[etherType >> 3] & (1 << (etherType & 7)))); return ((_etWhitelist[etherType >> 3] & (1 << (etherType & 7))) == 0);
else return ((_etWhitelist[etherType >> 3] & (1 << (etherType & 7)))); else return ((_etWhitelist[etherType >> 3] & (1 << (etherType & 7))) != 0);
} }
std::set<unsigned int> allowedEtherTypes() const; std::set<unsigned int> allowedEtherTypes() const;

View file

@ -77,7 +77,7 @@ NodeConfig::NodeConfig(const RuntimeEnvironment *renv,const char *authToken,unsi
if (!d->second) { if (!d->second) {
std::string::size_type dot = d->first.rfind(".conf"); std::string::size_type dot = d->first.rfind(".conf");
if (dot != std::string::npos) { if (dot != std::string::npos) {
uint64_t nwid = strtoull(d->first.substr(0,dot).c_str(),(char **)0,16); uint64_t nwid = Utils::hexStrToU64(d->first.substr(0,dot).c_str());
// TODO: remove legacy code once out of beta // TODO: remove legacy code once out of beta
if (nwid == 0x6c92786fee000001ULL) { if (nwid == 0x6c92786fee000001ULL) {
@ -230,7 +230,7 @@ std::vector<std::string> NodeConfig::execute(const char *command)
} }
} else if (cmd[0] == "join") { } else if (cmd[0] == "join") {
if (cmd.size() > 1) { if (cmd.size() > 1) {
uint64_t nwid = strtoull(cmd[1].c_str(),(char **)0,16); uint64_t nwid = Utils::hexStrToU64(cmd[1].c_str());
if (nwid > 0) { if (nwid > 0) {
Mutex::Lock _l(_networks_m); Mutex::Lock _l(_networks_m);
if (_networks.count(nwid)) { if (_networks.count(nwid)) {
@ -255,7 +255,7 @@ std::vector<std::string> NodeConfig::execute(const char *command)
} else if (cmd[0] == "leave") { } else if (cmd[0] == "leave") {
if (cmd.size() > 1) { if (cmd.size() > 1) {
Mutex::Lock _l(_networks_m); Mutex::Lock _l(_networks_m);
uint64_t nwid = strtoull(cmd[1].c_str(),(char **)0,16); uint64_t nwid = Utils::hexStrToU64(cmd[1].c_str());
std::map< uint64_t,SharedPtr<Network> >::iterator nw(_networks.find(nwid)); std::map< uint64_t,SharedPtr<Network> >::iterator nw(_networks.find(nwid));
if (nw == _networks.end()) { if (nw == _networks.end()) {
_P("404 leave %.16llx ERROR: not a member of that network",(unsigned long long)nwid); _P("404 leave %.16llx ERROR: not a member of that network",(unsigned long long)nwid);

View file

@ -64,7 +64,7 @@ const char *Packet::errorString(ErrorCode e)
case ERROR_IDENTITY_COLLISION: return "IDENTITY_COLLISION"; case ERROR_IDENTITY_COLLISION: return "IDENTITY_COLLISION";
case ERROR_UNSUPPORTED_OPERATION: return "UNSUPPORTED_OPERATION"; case ERROR_UNSUPPORTED_OPERATION: return "UNSUPPORTED_OPERATION";
case ERROR_NEED_MEMBERSHIP_CERTIFICATE: return "NEED_MEMBERSHIP_CERTIFICATE"; case ERROR_NEED_MEMBERSHIP_CERTIFICATE: return "NEED_MEMBERSHIP_CERTIFICATE";
case ERROR_NETWORK_ACCESS_DENIED: return "NETWORK_ACCESS_DENIED"; case ERROR_NETWORK_ACCESS_DENIED_: return "NETWORK_ACCESS_DENIED";
} }
return "(unknown)"; return "(unknown)";
} }

View file

@ -672,7 +672,7 @@ public:
ERROR_NEED_MEMBERSHIP_CERTIFICATE = 6, ERROR_NEED_MEMBERSHIP_CERTIFICATE = 6,
/* Tried to join network, but you're not a member */ /* Tried to join network, but you're not a member */
ERROR_NETWORK_ACCESS_DENIED = 7 ERROR_NETWORK_ACCESS_DENIED_ = 7 /* extra _ to avoid Windows name conflict */
}; };
/** /**

View file

@ -151,7 +151,7 @@ bool PacketDecoder::_doERROR(const RuntimeEnvironment *_r,const SharedPtr<Peer>
if (network) if (network)
network->pushMembershipCertificate(source(),true,Utils::now()); network->pushMembershipCertificate(source(),true,Utils::now());
} break; } break;
case Packet::ERROR_NETWORK_ACCESS_DENIED: { case Packet::ERROR_NETWORK_ACCESS_DENIED_: {
SharedPtr<Network> network(_r->nc->network(at<uint64_t>(ZT_PROTO_VERB_ERROR_IDX_PAYLOAD))); SharedPtr<Network> network(_r->nc->network(at<uint64_t>(ZT_PROTO_VERB_ERROR_IDX_PAYLOAD)));
if ((network)&&(network->controller() == source())) if ((network)&&(network->controller() == source()))
network->forceStatusTo(Network::NETWORK_ACCESS_DENIED); network->forceStatusTo(Network::NETWORK_ACCESS_DENIED);

View file

@ -4,8 +4,13 @@ D. J. Bernstein
Public domain. Public domain.
*/ */
#include "Constants.hpp"
#include "Poly1305.hpp" #include "Poly1305.hpp"
#ifdef __WINDOWS__
#pragma warning(disable: 4146)
#endif
namespace ZeroTier { namespace ZeroTier {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////

View file

@ -280,8 +280,12 @@ int64_t Utils::getFileSize(const char *path)
struct stat s; struct stat s;
if (stat(path,&s)) if (stat(path,&s))
return -1; return -1;
#ifdef __WINDOWS__
return s.st_size;
#else
if (S_ISREG(s.st_mode)) if (S_ISREG(s.st_mode))
return s.st_size; return s.st_size;
#endif
return -1; return -1;
} }

View file

@ -91,6 +91,7 @@
<ClCompile Include="..\..\node\Topology.cpp" /> <ClCompile Include="..\..\node\Topology.cpp" />
<ClCompile Include="..\..\node\UdpSocket.cpp" /> <ClCompile Include="..\..\node\UdpSocket.cpp" />
<ClCompile Include="..\..\node\Utils.cpp" /> <ClCompile Include="..\..\node\Utils.cpp" />
<ClCompile Include="..\..\selftest.cpp" />
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{DCD73B97-0F44-4044-8BA4-95B59CCAB4BD}</ProjectGuid> <ProjectGuid>{DCD73B97-0F44-4044-8BA4-95B59CCAB4BD}</ProjectGuid>

View file

@ -223,5 +223,8 @@
<ClCompile Include="..\..\node\Utils.cpp"> <ClCompile Include="..\..\node\Utils.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\selftest.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>