mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 20:13:44 +02:00
Rename version constants to something more canonical, and more cleanup.
This commit is contained in:
parent
b824ea7bcf
commit
da5b11bf2d
8 changed files with 53 additions and 50 deletions
|
@ -15,10 +15,10 @@ if(WIN32)
|
|||
endif(WIN32)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X Deployment Version")
|
||||
|
||||
set(ZEROTIER_ONE_VERSION_MAJOR 1 CACHE INTERNAL "")
|
||||
set(ZEROTIER_ONE_VERSION_MINOR 9 CACHE INTERNAL "")
|
||||
set(ZEROTIER_ONE_VERSION_REVISION 0 CACHE INTERNAL "")
|
||||
set(ZEROTIER_ONE_VERSION_BUILD 0 CACHE INTERNAL "")
|
||||
set(ZEROTIER_VERSION_MAJOR 1 CACHE INTERNAL "")
|
||||
set(ZEROTIER_VERSION_MINOR 9 CACHE INTERNAL "")
|
||||
set(ZEROTIER_VERSION_REVISION 0 CACHE INTERNAL "")
|
||||
set(ZEROTIER_VERSION_BUILD 0 CACHE INTERNAL "")
|
||||
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/version.h.in
|
||||
|
|
|
@ -707,7 +707,7 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpPOST(
|
|||
for(unsigned long i=0;i<ipa.size();++i) {
|
||||
std::string ips = ipa[i];
|
||||
InetAddress ip(ips.c_str());
|
||||
if ((ip.ss_family == AF_INET)||(ip.ss_family == AF_INET6)) {
|
||||
if ((ip.family() == AF_INET)||(ip.family() == AF_INET6)) {
|
||||
char tmpip[64];
|
||||
mipa.push_back(ip.toIpString(tmpip));
|
||||
if (mipa.size() >= ZT_CONTROLLER_MAX_ARRAY_SIZE)
|
||||
|
@ -870,11 +870,11 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpPOST(
|
|||
InetAddress t(target.get<std::string>().c_str());
|
||||
InetAddress v;
|
||||
if (via.is_string()) v.fromString(via.get<std::string>().c_str());
|
||||
if ( ((t.ss_family == AF_INET)||(t.ss_family == AF_INET6)) && (t.netmaskBitsValid()) ) {
|
||||
if ( ((t.family() == AF_INET)||(t.family() == AF_INET6)) && (t.netmaskBitsValid()) ) {
|
||||
json tmp;
|
||||
char tmp2[64];
|
||||
tmp["target"] = t.toString(tmp2);
|
||||
if (v.ss_family == t.ss_family)
|
||||
if (v.family() == t.family())
|
||||
tmp["via"] = v.toIpString(tmp2);
|
||||
else tmp["via"] = json();
|
||||
nrts.push_back(tmp);
|
||||
|
@ -897,7 +897,7 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpPOST(
|
|||
if ((ip.is_object())&&(ip.count("ipRangeStart"))&&(ip.count("ipRangeEnd"))) {
|
||||
InetAddress f(OSUtils::jsonString(ip["ipRangeStart"],"").c_str());
|
||||
InetAddress t(OSUtils::jsonString(ip["ipRangeEnd"],"").c_str());
|
||||
if ( ((f.ss_family == AF_INET)||(f.ss_family == AF_INET6)) && (f.ss_family == t.ss_family) ) {
|
||||
if ( ((f.family() == AF_INET)||(f.family() == AF_INET6)) && (f.family() == t.family()) ) {
|
||||
json tmp = json::object();
|
||||
char tmp2[64];
|
||||
tmp["ipRangeStart"] = f.toIpString(tmp2);
|
||||
|
@ -1295,7 +1295,7 @@ void EmbeddedNetworkController::_request(
|
|||
nc->credentialTimeMaxDelta = credentialtmd;
|
||||
nc->revision = OSUtils::jsonInt(network["revision"],0ULL);
|
||||
nc->issuedTo = identity.address();
|
||||
memcpy(nc->issuedToIdentityHash,identity.fingerprint(),sizeof(nc->issuedToIdentityHash));
|
||||
memcpy(nc->issuedToFingerprintHash,identity.fingerprint().hash(),sizeof(nc->issuedToFingerprintHash));
|
||||
if (OSUtils::jsonBool(network["enableBroadcast"],true)) nc->flags |= ZT_NETWORKCONFIG_FLAG_ENABLE_BROADCAST;
|
||||
Utils::scopy(nc->name,sizeof(nc->name),OSUtils::jsonString(network["name"],"").c_str());
|
||||
nc->mtu = std::max(std::min((unsigned int)OSUtils::jsonInt(network["mtu"],ZT_DEFAULT_MTU),(unsigned int)ZT_MAX_MTU),(unsigned int)ZT_MIN_MTU);
|
||||
|
@ -1423,10 +1423,10 @@ void EmbeddedNetworkController::_request(
|
|||
const InetAddress t(target.get<std::string>().c_str());
|
||||
InetAddress v;
|
||||
if (via.is_string()) v.fromString(via.get<std::string>().c_str());
|
||||
if ((t.ss_family == AF_INET)||(t.ss_family == AF_INET6)) {
|
||||
if ((t.family() == AF_INET)||(t.family() == AF_INET6)) {
|
||||
ZT_VirtualNetworkRoute *r = &(nc->routes[nc->routeCount]);
|
||||
*(reinterpret_cast<InetAddress *>(&(r->target))) = t;
|
||||
if (v.ss_family == t.ss_family)
|
||||
if (v.family() == t.family())
|
||||
*(reinterpret_cast<InetAddress *>(&(r->via))) = v;
|
||||
++nc->routeCount;
|
||||
}
|
||||
|
@ -1471,9 +1471,9 @@ void EmbeddedNetworkController::_request(
|
|||
ip.setPort(routedNetmaskBits);
|
||||
nc->staticIps[nc->staticIpCount++] = ip;
|
||||
}
|
||||
if (ip.ss_family == AF_INET)
|
||||
if (ip.family() == AF_INET)
|
||||
haveManagedIpv4AutoAssignment = true;
|
||||
else if (ip.ss_family == AF_INET6)
|
||||
else if (ip.family() == AF_INET6)
|
||||
haveManagedIpv6AutoAssignment = true;
|
||||
}
|
||||
}
|
||||
|
@ -1488,7 +1488,7 @@ void EmbeddedNetworkController::_request(
|
|||
if (pool.is_object()) {
|
||||
InetAddress ipRangeStart(OSUtils::jsonString(pool["ipRangeStart"],"").c_str());
|
||||
InetAddress ipRangeEnd(OSUtils::jsonString(pool["ipRangeEnd"],"").c_str());
|
||||
if ( (ipRangeStart.ss_family == AF_INET6) && (ipRangeEnd.ss_family == AF_INET6) ) {
|
||||
if ( (ipRangeStart.family() == AF_INET6) && (ipRangeEnd.family() == AF_INET6) ) {
|
||||
uint64_t s[2],e[2],x[2],xx[2];
|
||||
memcpy(s,ipRangeStart.rawIpData(),16);
|
||||
memcpy(e,ipRangeEnd.rawIpData(),16);
|
||||
|
@ -1552,7 +1552,7 @@ void EmbeddedNetworkController::_request(
|
|||
if (pool.is_object()) {
|
||||
InetAddress ipRangeStartIA(OSUtils::jsonString(pool["ipRangeStart"],"").c_str());
|
||||
InetAddress ipRangeEndIA(OSUtils::jsonString(pool["ipRangeEnd"],"").c_str());
|
||||
if ( (ipRangeStartIA.ss_family == AF_INET) && (ipRangeEndIA.ss_family == AF_INET) ) {
|
||||
if ( (ipRangeStartIA.family() == AF_INET) && (ipRangeEndIA.family() == AF_INET) ) {
|
||||
uint32_t ipRangeStart = Utils::ntoh((uint32_t)(reinterpret_cast<struct sockaddr_in *>(&ipRangeStartIA)->sin_addr.s_addr));
|
||||
uint32_t ipRangeEnd = Utils::ntoh((uint32_t)(reinterpret_cast<struct sockaddr_in *>(&ipRangeEndIA)->sin_addr.s_addr));
|
||||
|
||||
|
|
|
@ -179,6 +179,11 @@ public:
|
|||
*/
|
||||
ZT_ALWAYS_INLINE Buf() noexcept : __nextInPool(0),__refCount(0) {}
|
||||
|
||||
/**
|
||||
* Create a new buffer and copy data into it
|
||||
*/
|
||||
ZT_ALWAYS_INLINE Buf(const void *const data,const unsigned int len) noexcept : __nextInPool(0),__refCount(0) { memcpy(unsafeData,data,len); }
|
||||
|
||||
ZT_ALWAYS_INLINE Buf(const Buf &b2) noexcept : __nextInPool(0),__refCount(0) { memcpy(unsafeData,b2.unsafeData,ZT_BUF_MEM_SIZE); }
|
||||
|
||||
ZT_ALWAYS_INLINE Buf &operator=(const Buf &b2) noexcept
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
#if __has_include("version.h")
|
||||
#include "version.h"
|
||||
#else /* dummy values for use inside IDEs, etc. */
|
||||
#define ZEROTIER_ONE_VERSION_MAJOR 255
|
||||
#define ZEROTIER_ONE_VERSION_MINOR 255
|
||||
#define ZEROTIER_ONE_VERSION_REVISION 255
|
||||
#define ZEROTIER_ONE_VERSION_BUILD 255
|
||||
#define ZEROTIER_VERSION_MAJOR 255
|
||||
#define ZEROTIER_VERSION_MINOR 255
|
||||
#define ZEROTIER_VERSION_REVISION 255
|
||||
#define ZEROTIER_VERSION_BUILD 255
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include "VL2.hpp"
|
||||
#include "Buf.hpp"
|
||||
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
namespace {
|
||||
|
@ -809,14 +808,25 @@ void Node::ncSendError(uint64_t nwid,uint64_t requestPacketId,const Address &des
|
|||
|
||||
} // namespace ZeroTier
|
||||
|
||||
// C API exports
|
||||
// C API --------------------------------------------------------------------------------------------------------------
|
||||
|
||||
extern "C" {
|
||||
|
||||
// These macros make the idiom of passing buffers to outside code via the API work properly even
|
||||
// if the first address of Buf does not overlap with its data field, since the C++ standard does
|
||||
// not absolutely guarantee this.
|
||||
#define _ZT_PTRTOBUF(p) ((ZeroTier::Buf *)( ((uintptr_t)(p)) - ((uintptr_t)&(((ZeroTier::Buf *)0)->unsafeData[0])) ))
|
||||
#define _ZT_BUFTOPTR(b) ((void *)(&((b)->unsafeData[0])))
|
||||
|
||||
void *ZT_getBuffer()
|
||||
{
|
||||
// When external code requests a Buf, grab one from the pool (or freshly allocated)
|
||||
// and return it with its reference count left at zero. It's the responsibility of
|
||||
// external code to bring it back via freeBuffer() or one of the processX() calls.
|
||||
// When this occurs it's either sent back to the pool with Buf's delete operator or
|
||||
// wrapped in a SharedPtr<> to be passed into the core.
|
||||
try {
|
||||
return (void *)(new ZeroTier::Buf()); // __refCount is left at zero
|
||||
return _ZT_BUFTOPTR(new ZeroTier::Buf());
|
||||
} catch ( ... ) {
|
||||
return nullptr; // can only happen on out of memory condition
|
||||
}
|
||||
|
@ -825,7 +835,7 @@ void *ZT_getBuffer()
|
|||
ZT_SDK_API void ZT_freeBuffer(void *b)
|
||||
{
|
||||
if (b)
|
||||
delete ((ZeroTier::Buf *)b);
|
||||
delete _ZT_PTRTOBUF(b);
|
||||
}
|
||||
|
||||
enum ZT_ResultCode ZT_Node_new(ZT_Node **node,void *uptr,void *tptr,const struct ZT_Node_Callbacks *callbacks,int64_t now)
|
||||
|
@ -863,13 +873,7 @@ enum ZT_ResultCode ZT_Node_processWirePacket(
|
|||
volatile int64_t *nextBackgroundTaskDeadline)
|
||||
{
|
||||
try {
|
||||
ZeroTier::SharedPtr<ZeroTier::Buf> buf;
|
||||
if (isZtBuffer) {
|
||||
buf.set((ZeroTier::Buf *)packetData);
|
||||
} else {
|
||||
buf.set(new ZeroTier::Buf());
|
||||
memcpy(buf->unsafeData,packetData,std::min((unsigned int)ZT_BUF_MEM_SIZE,packetLength));
|
||||
}
|
||||
ZeroTier::SharedPtr<ZeroTier::Buf> buf((isZtBuffer) ? _ZT_PTRTOBUF(packetData) : new ZeroTier::Buf(packetData,packetLength & ZT_BUF_MEM_MASK));
|
||||
return reinterpret_cast<ZeroTier::Node *>(node)->processWirePacket(tptr,now,localSocket,remoteAddress,buf,packetLength,nextBackgroundTaskDeadline);
|
||||
} catch (std::bad_alloc &exc) {
|
||||
return ZT_RESULT_FATAL_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -893,13 +897,7 @@ enum ZT_ResultCode ZT_Node_processVirtualNetworkFrame(
|
|||
volatile int64_t *nextBackgroundTaskDeadline)
|
||||
{
|
||||
try {
|
||||
ZeroTier::SharedPtr<ZeroTier::Buf> buf;
|
||||
if (isZtBuffer) {
|
||||
buf.set((ZeroTier::Buf *)frameData);
|
||||
} else {
|
||||
buf.set(new ZeroTier::Buf());
|
||||
memcpy(buf->unsafeData,frameData,std::min((unsigned int)ZT_BUF_MEM_SIZE,frameLength));
|
||||
}
|
||||
ZeroTier::SharedPtr<ZeroTier::Buf> buf((isZtBuffer) ? _ZT_PTRTOBUF(frameData) : new ZeroTier::Buf(frameData,frameLength & ZT_BUF_MEM_MASK));
|
||||
return reinterpret_cast<ZeroTier::Node *>(node)->processVirtualNetworkFrame(tptr,now,nwid,sourceMac,destMac,etherType,vlanId,buf,frameLength,nextBackgroundTaskDeadline);
|
||||
} catch (std::bad_alloc &exc) {
|
||||
return ZT_RESULT_FATAL_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -1078,11 +1076,11 @@ enum ZT_ResultCode ZT_Node_setPhysicalPathConfiguration(ZT_Node *node,const stru
|
|||
void ZT_version(int *major,int *minor,int *revision)
|
||||
{
|
||||
if (major)
|
||||
*major = ZEROTIER_ONE_VERSION_MAJOR;
|
||||
*major = ZEROTIER_VERSION_MAJOR;
|
||||
if (minor)
|
||||
*minor = ZEROTIER_ONE_VERSION_MINOR;
|
||||
*minor = ZEROTIER_VERSION_MINOR;
|
||||
if (revision)
|
||||
*revision = ZEROTIER_ONE_VERSION_REVISION;
|
||||
*revision = ZEROTIER_VERSION_REVISION;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
|
|
@ -213,9 +213,9 @@ unsigned int Peer::sendHELLO(void *tPtr,const int64_t localSocket,const InetAddr
|
|||
Packet outp(_id.address(),RR->identity.address(),Packet::VERB_HELLO);
|
||||
|
||||
outp.append((unsigned char)ZT_PROTO_VERSION);
|
||||
outp.append((unsigned char)ZEROTIER_ONE_VERSION_MAJOR);
|
||||
outp.append((unsigned char)ZEROTIER_ONE_VERSION_MINOR);
|
||||
outp.append((uint16_t)ZEROTIER_ONE_VERSION_REVISION);
|
||||
outp.append((unsigned char)ZEROTIER_VERSION_MAJOR);
|
||||
outp.append((unsigned char)ZEROTIER_VERSION_MINOR);
|
||||
outp.append((uint16_t)ZEROTIER_VERSION_REVISION);
|
||||
outp.append(now);
|
||||
RR->identity.serialize(outp,false);
|
||||
atAddress.serialize(outp);
|
||||
|
|
|
@ -645,9 +645,9 @@ bool VL1::_HELLO(void *tPtr,const SharedPtr<Path> &path,SharedPtr<Peer> &peer,Bu
|
|||
|
||||
ok.timestampEcho = p.timestamp;
|
||||
ok.versionProtocol = ZT_PROTO_VERSION;
|
||||
ok.versionMajor = ZEROTIER_ONE_VERSION_MAJOR;
|
||||
ok.versionMinor = ZEROTIER_ONE_VERSION_MINOR;
|
||||
ok.versionRev = ZT_CONST_TO_BE_UINT16(ZEROTIER_ONE_VERSION_REVISION);
|
||||
ok.versionMajor = ZEROTIER_VERSION_MAJOR;
|
||||
ok.versionMinor = ZEROTIER_VERSION_MINOR;
|
||||
ok.versionRev = ZT_CONST_TO_BE_UINT16(ZEROTIER_VERSION_REVISION);
|
||||
|
||||
int outl = sizeof(Protocol::OK::HELLO);
|
||||
outp.wO(outl,path->address());
|
||||
|
|
|
@ -17,17 +17,17 @@
|
|||
/**
|
||||
* Major version
|
||||
*/
|
||||
#define ZEROTIER_ONE_VERSION_MAJOR @ZEROTIER_ONE_VERSION_MAJOR@
|
||||
#define ZEROTIER_VERSION_MAJOR @ZEROTIER_VERSION_MAJOR@
|
||||
|
||||
/**
|
||||
* Minor version
|
||||
*/
|
||||
#define ZEROTIER_ONE_VERSION_MINOR @ZEROTIER_ONE_VERSION_MINOR@
|
||||
#define ZEROTIER_VERSION_MINOR @ZEROTIER_VERSION_MINOR@
|
||||
|
||||
/**
|
||||
* Revision
|
||||
*/
|
||||
#define ZEROTIER_ONE_VERSION_REVISION @ZEROTIER_ONE_VERSION_REVISION@
|
||||
#define ZEROTIER_VERSION_REVISION @ZEROTIER_VERSION_REVISION@
|
||||
|
||||
/**
|
||||
* Build version
|
||||
|
@ -36,6 +36,6 @@
|
|||
* to force a minor update without an actual version number change. It's
|
||||
* not part of the actual release version number.
|
||||
*/
|
||||
#define ZEROTIER_ONE_VERSION_BUILD @ZEROTIER_ONE_VERSION_BUILD@
|
||||
#define ZEROTIER_VERSION_BUILD @ZEROTIER_VERSION_BUILD@
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue