From 74f36f5dc0a8e81a53cfeb86c64db4bb9c23fe30 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Sun, 19 Oct 2014 12:56:39 -0700 Subject: [PATCH] Windows build fixes. --- control/NodeControlClient.cpp | 8 ++ control/NodeControlService.cpp | 16 ++-- include/ZeroTierOne.h | 74 +++++++++++------- node/Multicaster.cpp | 4 +- node/Node.cpp | 22 +++--- node/Topology.hpp | 2 +- windows/ZeroTierOne/ZeroTierOne.vcxproj | 41 ++++++---- .../ZeroTierOne/ZeroTierOne.vcxproj.filters | 75 ++++++++++++++----- windows/ZeroTierOne/ZeroTierOneService.cpp | 4 +- 9 files changed, 163 insertions(+), 83 deletions(-) diff --git a/control/NodeControlClient.cpp b/control/NodeControlClient.cpp index 7d0e04e82..6fd7b12ed 100644 --- a/control/NodeControlClient.cpp +++ b/control/NodeControlClient.cpp @@ -33,6 +33,14 @@ #include "IpcListener.hpp" #include "NodeControlService.hpp" +#ifdef __WINDOWS__ +#include +#include +#include +#include +#include +#endif // __WINDOWS__ + namespace ZeroTier { struct _NodeControlClientImpl diff --git a/control/NodeControlService.cpp b/control/NodeControlService.cpp index fc86c54c9..96eabc508 100644 --- a/control/NodeControlService.cpp +++ b/control/NodeControlService.cpp @@ -154,16 +154,16 @@ void NodeControlService::_doCommand(IpcConnection *ipcc,const char *commandLine) default: ipcc->printf("unknown;"); break; - case ZT1_Node_PhysicalPath::ZT1_Node_PhysicalPath_TYPE_UDP: + case ZT1_Node_PhysicalPathType::ZT1_Node_PhysicalPath_TYPE_UDP: ipcc->printf("udp;"); break; - case ZT1_Node_PhysicalPath::ZT1_Node_PhysicalPath_TYPE_TCP_OUT: + case ZT1_Node_PhysicalPathType::ZT1_Node_PhysicalPath_TYPE_TCP_OUT: ipcc->printf("tcp_out;"); break; - case ZT1_Node_PhysicalPath::ZT1_Node_PhysicalPath_TYPE_TCP_IN: + case ZT1_Node_PhysicalPathType::ZT1_Node_PhysicalPath_TYPE_TCP_IN: ipcc->printf("tcp_in;"); break; - case ZT1_Node_PhysicalPath::ZT1_Node_PhysicalPath_TYPE_ETHERNET: + case ZT1_Node_PhysicalPathType::ZT1_Node_PhysicalPath_TYPE_ETHERNET: ipcc->printf("eth;"); break; } @@ -178,9 +178,9 @@ void NodeControlService::_doCommand(IpcConnection *ipcc,const char *commandLine) } const char *rolestr; switch(pl->peers[i].role) { - case ZT1_Node_Peer::ZT1_Node_Peer_SUPERNODE: rolestr = "SUPERNODE"; break; - case ZT1_Node_Peer::ZT1_Node_Peer_HUB: rolestr = "HUB"; break; - case ZT1_Node_Peer::ZT1_Node_Peer_NODE: rolestr = "NODE"; break; + case ZT1_Node_PeerRole::ZT1_Node_Peer_SUPERNODE: rolestr = "SUPERNODE"; break; + case ZT1_Node_PeerRole::ZT1_Node_Peer_HUB: rolestr = "HUB"; break; + case ZT1_Node_PeerRole::ZT1_Node_Peer_NODE: rolestr = "NODE"; break; default: rolestr = "?"; break; } ipcc->printf(" %u %s %s"ZT_EOL_S, @@ -249,7 +249,7 @@ void NodeControlService::_doCommand(IpcConnection *ipcc,const char *commandLine) to.fromString(cmd[3].c_str()); from.copyTo(from2,6); to.copyTo(to2,6); - if (_node->injectPacketFromHost(Utils::hexStrToU64(cmd[1].c_str()),from2,to2,Utils::hexStrToUInt(cmd[4].c_str()),cmd[5].c_str(),cmd[5].length()+1)) { + if (_node->injectPacketFromHost(Utils::hexStrToU64(cmd[1].c_str()),from2,to2,Utils::hexStrToUInt(cmd[4].c_str()),cmd[5].c_str(),(unsigned int)cmd[5].length()+1)) { ipcc->printf("200 OK"ZT_EOL_S); } else { ipcc->printf("500 inject failed or not supported by this tap device"ZT_EOL_S); diff --git a/include/ZeroTierOne.h b/include/ZeroTierOne.h index 2474a3a03..0a7c79847 100644 --- a/include/ZeroTierOne.h +++ b/include/ZeroTierOne.h @@ -95,6 +95,16 @@ struct ZT1_Node_Status bool running; }; +/** + * Physical address type + */ +enum ZT1_Node_PhysicalAddressType { + ZT1_Node_PhysicalAddress_TYPE_NULL = 0, /* none/invalid */ + ZT1_Node_PhysicalAddress_TYPE_IPV4 = 1, /* 32-bit IPv4 address (and port) */ + ZT1_Node_PhysicalAddress_TYPE_IPV6 = 2, /* 128-bit IPv6 address (and port) */ + ZT1_Node_PhysicalAddress_TYPE_ETHERNET = 3 /* 48-bit Ethernet MAC address */ +}; + /** * Physical address result buffer */ @@ -103,12 +113,7 @@ struct ZT1_Node_PhysicalAddress /** * Physical address type */ - enum { - ZT1_Node_PhysicalAddress_TYPE_NULL = 0, /* none/invalid */ - ZT1_Node_PhysicalAddress_TYPE_IPV4 = 1, /* 32-bit IPv4 address (and port) */ - ZT1_Node_PhysicalAddress_TYPE_IPV6 = 2, /* 128-bit IPv6 address (and port) */ - ZT1_Node_PhysicalAddress_TYPE_ETHERNET = 3 /* 48-bit Ethernet MAC address */ - } type; + enum ZT1_Node_PhysicalAddressType type; /** * Address in raw binary form -- length depends on type @@ -131,6 +136,17 @@ struct ZT1_Node_PhysicalAddress char zoneIndex[16]; }; +/** + * Physical path type + */ +enum ZT1_Node_PhysicalPathType { /* These must be numerically the same as type in Path.hpp */ + ZT1_Node_PhysicalPath_TYPE_NULL = 0, /* none/invalid */ + ZT1_Node_PhysicalPath_TYPE_UDP = 1, /* UDP association */ + ZT1_Node_PhysicalPath_TYPE_TCP_OUT = 2, /* outgoing TCP tunnel using pseudo-SSL */ + ZT1_Node_PhysicalPath_TYPE_TCP_IN = 3, /* incoming TCP tunnel using pseudo-SSL */ + ZT1_Node_PhysicalPath_TYPE_ETHERNET = 4 /* raw ethernet frames over trusted backplane */ +}; + /** * Network path result buffer */ @@ -139,13 +155,7 @@ struct ZT1_Node_PhysicalPath /** * Physical path type */ - enum { /* These must be numerically the same as type in Path.hpp */ - ZT1_Node_PhysicalPath_TYPE_NULL = 0, /* none/invalid */ - ZT1_Node_PhysicalPath_TYPE_UDP = 1, /* UDP association */ - ZT1_Node_PhysicalPath_TYPE_TCP_OUT = 2, /* outgoing TCP tunnel using pseudo-SSL */ - ZT1_Node_PhysicalPath_TYPE_TCP_IN = 3, /* incoming TCP tunnel using pseudo-SSL */ - ZT1_Node_PhysicalPath_TYPE_ETHERNET = 4 /* raw ethernet frames over trusted backplane */ - } type; + enum ZT1_Node_PhysicalPathType type; /** * Physical address of endpoint @@ -178,6 +188,15 @@ struct ZT1_Node_PhysicalPath bool fixed; }; +/** + * What trust hierarchy role does this device have? + */ +enum ZT1_Node_PeerRole { + ZT1_Node_Peer_SUPERNODE = 0, // planetary supernode + ZT1_Node_Peer_HUB = 1, // locally federated hub (coming soon) + ZT1_Node_Peer_NODE = 2 // ordinary node +}; + /** * Peer status result buffer */ @@ -206,11 +225,7 @@ struct ZT1_Node_Peer /** * What trust hierarchy role does this device have? */ - enum { - ZT1_Node_Peer_SUPERNODE = 0, // planetary supernode - ZT1_Node_Peer_HUB = 1, // locally federated hub (coming soon) - ZT1_Node_Peer_NODE = 2 // ordinary node - } role; + enum ZT1_Node_PeerRole role; /** * Array of network paths to peer @@ -232,6 +247,19 @@ struct ZT1_Node_PeerList unsigned int numPeers; }; +/** + * Network status code + */ +enum ZT1_Node_NetworkStatus { + ZT1_Node_Network_INITIALIZING = 0, + ZT1_Node_Network_WAITING_FOR_FIRST_AUTOCONF = 1, + ZT1_Node_Network_OK = 2, + ZT1_Node_Network_ACCESS_DENIED = 3, + ZT1_Node_Network_NOT_FOUND = 4, + ZT1_Node_Network_INITIALIZATION_FAILED = 5, + ZT1_Node_Network_NO_MORE_DEVICES = 6 +}; + /** * Network status result buffer */ @@ -299,15 +327,7 @@ struct ZT1_Node_Network /** * Network status code */ - enum { /* Must be same as Status in Network.hpp */ - ZT1_Node_Network_INITIALIZING = 0, - ZT1_Node_Network_WAITING_FOR_FIRST_AUTOCONF = 1, - ZT1_Node_Network_OK = 2, - ZT1_Node_Network_ACCESS_DENIED = 3, - ZT1_Node_Network_NOT_FOUND = 4, - ZT1_Node_Network_INITIALIZATION_FAILED = 5, - ZT1_Node_Network_NO_MORE_DEVICES = 6 - } status; + enum ZT1_Node_NetworkStatus status; /** * True if traffic on network is enabled diff --git a/node/Multicaster.cpp b/node/Multicaster.cpp index ba8258b2c..38bcc237b 100644 --- a/node/Multicaster.cpp +++ b/node/Multicaster.cpp @@ -81,7 +81,7 @@ unsigned int Multicaster::gather(const Address &queryingPeer,uint64_t nwid,const std::map< std::pair,MulticastGroupStatus >::const_iterator gs(_groups.find(std::pair(nwid,mg))); if ((gs != _groups.end())&&(!gs->second.members.empty())) { - totalKnown += gs->second.members.size(); + totalKnown += (unsigned int)gs->second.members.size(); // Members are returned in random order so that repeated gather queries // will return different subsets of a large multicast group. @@ -290,7 +290,7 @@ void Multicaster::send( C25519::Signature sig(RR->identity.sign(outp.field(ZT_PROTO_VERB_P5_MULTICAST_FRAME_IDX__START_OF_SIGNED_PORTION,signedPortionLen),signedPortionLen)); outp.append((uint16_t)sig.size()); - outp.append(sig.data,sig.size()); + outp.append(sig.data,(unsigned int)sig.size()); if (com) com->serialize(outp); diff --git a/node/Node.cpp b/node/Node.cpp index 4673312a6..c6322c316 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -837,7 +837,7 @@ ZT1_Node_PeerList *Node::listPeers() unsigned int returnBufSize = sizeof(ZT1_Node_PeerList); for(std::vector< std::pair< SharedPtr,std::vector > >::iterator p(pp.data.begin());p!=pp.data.end();++p) - returnBufSize += sizeof(ZT1_Node_Peer) + (sizeof(ZT1_Node_PhysicalPath) * p->second.size()); + returnBufSize += sizeof(ZT1_Node_Peer) + (sizeof(ZT1_Node_PhysicalPath) * (unsigned int)p->second.size()); char *buf = (char *)::malloc(returnBufSize); if (!buf) @@ -859,7 +859,7 @@ ZT1_Node_PeerList *Node::listPeers() p->first->address().toString(prec->address,sizeof(prec->address)); prec->rawAddress = p->first->address().toInt(); prec->latency = p->first->latency(); - prec->role = RR->topology->isSupernode(p->first->address()) ? ZT1_Node_Peer::ZT1_Node_Peer_SUPERNODE : ZT1_Node_Peer::ZT1_Node_Peer_NODE; + prec->role = RR->topology->isSupernode(p->first->address()) ? ZT1_Node_PeerRole::ZT1_Node_Peer_SUPERNODE : ZT1_Node_PeerRole::ZT1_Node_Peer_NODE; prec->paths = (ZT1_Node_PhysicalPath *)buf; buf += sizeof(ZT1_Node_PhysicalPath) * p->second.size(); @@ -867,13 +867,13 @@ ZT1_Node_PeerList *Node::listPeers() prec->numPaths = 0; for(std::vector::iterator pi(p->second.begin());pi!=p->second.end();++pi) { ZT1_Node_PhysicalPath *path = &(prec->paths[prec->numPaths++]); - path->type = static_casttype)>(pi->type()); + path->type = (ZT1_Node_PhysicalPathType)pi->type(); if (pi->address().isV6()) { - path->address.type = ZT1_Node_PhysicalAddress::ZT1_Node_PhysicalAddress_TYPE_IPV6; + path->address.type = ZT1_Node_PhysicalAddressType::ZT1_Node_PhysicalAddress_TYPE_IPV6; memcpy(path->address.bits,pi->address().rawIpData(),16); // TODO: zoneIndex not supported yet, but should be once echo-location works w/V6 } else { - path->address.type = ZT1_Node_PhysicalAddress::ZT1_Node_PhysicalAddress_TYPE_IPV4; + path->address.type = ZT1_Node_PhysicalAddressType::ZT1_Node_PhysicalAddress_TYPE_IPV4; memcpy(path->address.bits,pi->address().rawIpData(),4); } path->address.port = pi->address().port(); @@ -906,7 +906,7 @@ static void _fillNetworkQueryResultBuffer(const SharedPtr &network,cons if (lcu > 0) nbuf->configAge = (long)(Utils::now() - lcu); else nbuf->configAge = -1; - nbuf->status = static_caststatus)>(network->status()); + nbuf->status = (ZT1_Node_NetworkStatus)network->status(); nbuf->enabled = network->enabled(); nbuf->isPrivate = (nconf) ? nconf->isPrivate() : true; } @@ -938,10 +938,10 @@ ZT1_Node_Network *Node::getNetworkStatus(uint64_t nwid) for(std::set::iterator ip(ips.begin());ip!=ips.end();++ip) { ZT1_Node_PhysicalAddress *ipb = &(nbuf->ips[nbuf->numIps++]); if (ip->isV6()) { - ipb->type = ZT1_Node_PhysicalAddress::ZT1_Node_PhysicalAddress_TYPE_IPV6; + ipb->type = ZT1_Node_PhysicalAddressType::ZT1_Node_PhysicalAddress_TYPE_IPV6; memcpy(ipb->bits,ip->rawIpData(),16); } else { - ipb->type = ZT1_Node_PhysicalAddress::ZT1_Node_PhysicalAddress_TYPE_IPV4; + ipb->type = ZT1_Node_PhysicalAddressType::ZT1_Node_PhysicalAddress_TYPE_IPV4; memcpy(ipb->bits,ip->rawIpData(),4); } ipb->port = ip->port(); @@ -965,7 +965,7 @@ ZT1_Node_NetworkList *Node::listNetworks() for(unsigned long i=0;iconfig2(); ipsv[i] = networks[i]->ips(); - returnBufSize += sizeof(ZT1_Node_Network) + (sizeof(ZT1_Node_PhysicalAddress) * ipsv[i].size()); + returnBufSize += sizeof(ZT1_Node_Network) + (sizeof(ZT1_Node_PhysicalAddress) * (unsigned int)ipsv[i].size()); } char *buf = (char *)::malloc(returnBufSize); @@ -991,10 +991,10 @@ ZT1_Node_NetworkList *Node::listNetworks() for(std::set::iterator ip(ipsv[i].begin());ip!=ipsv[i].end();++ip) { ZT1_Node_PhysicalAddress *ipb = &(nbuf->ips[nbuf->numIps++]); if (ip->isV6()) { - ipb->type = ZT1_Node_PhysicalAddress::ZT1_Node_PhysicalAddress_TYPE_IPV6; + ipb->type = ZT1_Node_PhysicalAddressType::ZT1_Node_PhysicalAddress_TYPE_IPV6; memcpy(ipb->bits,ip->rawIpData(),16); } else { - ipb->type = ZT1_Node_PhysicalAddress::ZT1_Node_PhysicalAddress_TYPE_IPV4; + ipb->type = ZT1_Node_PhysicalAddressType::ZT1_Node_PhysicalAddress_TYPE_IPV4; memcpy(ipb->bits,ip->rawIpData(),4); } ipb->port = ip->port(); diff --git a/node/Topology.hpp b/node/Topology.hpp index e3e573edd..15e8db3b7 100644 --- a/node/Topology.hpp +++ b/node/Topology.hpp @@ -112,7 +112,7 @@ public: inline unsigned int numSupernodes() const { Mutex::Lock _l(_lock); - return _supernodePeers.size(); + return (unsigned int)_supernodePeers.size(); } /** diff --git a/windows/ZeroTierOne/ZeroTierOne.vcxproj b/windows/ZeroTierOne/ZeroTierOne.vcxproj index 6c6a02622..bdab5aeda 100644 --- a/windows/ZeroTierOne/ZeroTierOne.vcxproj +++ b/windows/ZeroTierOne/ZeroTierOne.vcxproj @@ -19,12 +19,16 @@ + + + + - false - false - false - false + true + true + true + true @@ -32,17 +36,16 @@ + - - + - @@ -60,17 +63,25 @@ - true - true - true - true + false + false + false + false + + + + + + + + @@ -87,9 +98,8 @@ + - - @@ -100,8 +110,8 @@ + - @@ -123,6 +133,9 @@ + + + diff --git a/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters b/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters index 80e786302..4d816c363 100644 --- a/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters +++ b/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters @@ -57,9 +57,6 @@ Source Files - - Source Files - Source Files @@ -99,12 +96,6 @@ Source Files - - Source Files - - - Source Files - Source Files @@ -132,6 +123,33 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + @@ -218,9 +236,6 @@ Header Files - - Header Files - Header Files @@ -272,12 +287,6 @@ Header Files - - Header Files - - - Header Files - Header Files @@ -308,6 +317,36 @@ Header Files + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + diff --git a/windows/ZeroTierOne/ZeroTierOneService.cpp b/windows/ZeroTierOne/ZeroTierOneService.cpp index f0d932804..e7f02544b 100644 --- a/windows/ZeroTierOne/ZeroTierOneService.cpp +++ b/windows/ZeroTierOne/ZeroTierOneService.cpp @@ -106,7 +106,7 @@ restart_node: // Get upgrade path, which will be its reason for termination std::string msiPath; if (n) { - const char *msiPathTmp = n->reasonForTermination(); + const char *msiPathTmp = n->terminationMessage(); if (msiPathTmp) msiPath = msiPathTmp; } @@ -131,7 +131,7 @@ restart_node: case ZeroTier::Node::NODE_UNRECOVERABLE_ERROR: { std::string err("ZeroTier node encountered an unrecoverable error: "); - const char *r = _node->reasonForTermination(); + const char *r = _node->terminationMessage(); if (r) err.append(r); else err.append("(unknown error)");