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
/ZeroTier One.zip
/ZeroTier One.dmg
/windows/ZeroTierOne.sdf
/windows/ZeroTierOne.v11.suo

View File

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

View File

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

View File

@ -77,6 +77,8 @@
#define ZT_PATH_SEPARATOR '\\'
#define ZT_PATH_SEPARATOR_S "\\"
#define ZT_EOL_S "\r\n"
#include <WinSock2.h>
#include <Windows.h>
#endif
// 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 <netioapi.h>
#include "..\vsprojects\TapDriver\tap-windows.h"
#include "..\windows\TapDriver\tap-windows.h"
namespace ZeroTier {

View File

@ -25,21 +25,20 @@
* 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 <stdlib.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__
#include <unistd.h>
#include <signal.h>
@ -51,12 +50,15 @@
#include <sys/wait.h>
#endif
#ifdef __WINDOWS__
#include <locale>
#include <codecvt>
#include <Windows.h>
#include <winhttp.h>
#endif
#include <vector>
#include <utility>
#include <algorithm>
#include "HttpClient.hpp"
#include "Thread.hpp"
#include "Utils.hpp"
#include "NonCopyable.hpp"
#include "Defaults.hpp"
namespace ZeroTier {

View File

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

View File

@ -77,7 +77,7 @@ NodeConfig::NodeConfig(const RuntimeEnvironment *renv,const char *authToken,unsi
if (!d->second) {
std::string::size_type dot = d->first.rfind(".conf");
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
if (nwid == 0x6c92786fee000001ULL) {
@ -230,7 +230,7 @@ std::vector<std::string> NodeConfig::execute(const char *command)
}
} else if (cmd[0] == "join") {
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) {
Mutex::Lock _l(_networks_m);
if (_networks.count(nwid)) {
@ -255,7 +255,7 @@ std::vector<std::string> NodeConfig::execute(const char *command)
} else if (cmd[0] == "leave") {
if (cmd.size() > 1) {
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));
if (nw == _networks.end()) {
_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_UNSUPPORTED_OPERATION: return "UNSUPPORTED_OPERATION";
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)";
}

View File

@ -672,7 +672,7 @@ public:
ERROR_NEED_MEMBERSHIP_CERTIFICATE = 6,
/* 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)
network->pushMembershipCertificate(source(),true,Utils::now());
} 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)));
if ((network)&&(network->controller() == source()))
network->forceStatusTo(Network::NETWORK_ACCESS_DENIED);

View File

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

View File

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

View File

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

View File

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