diff options
-rw-r--r-- | include/ZeroTierOne.h | 16 | ||||
-rw-r--r-- | node/Node.cpp | 25 | ||||
-rw-r--r-- | node/RuntimeEnvironment.hpp | 2 |
3 files changed, 27 insertions, 16 deletions
diff --git a/include/ZeroTierOne.h b/include/ZeroTierOne.h index ac2684f0..10b6d37f 100644 --- a/include/ZeroTierOne.h +++ b/include/ZeroTierOne.h @@ -96,22 +96,17 @@ extern "C" { /** * Maximum number of multicast group subscriptions per network */ -#define ZT1_MAX_NETWORK_MULTICAST_SUBSCRIPTIONS 8194 - -/** - * Feature flag: this is an official ZeroTier, Inc. binary build (built with ZT_OFFICIAL_RELEASE) - */ -#define ZT1_FEATURE_FLAG_OFFICIAL 0x00000001 +#define ZT1_MAX_NETWORK_MULTICAST_SUBSCRIPTIONS 4096 /** * Feature flag: ZeroTier One was built to be thread-safe -- concurrent processXXX() calls are okay */ -#define ZT1_FEATURE_FLAG_THREAD_SAFE 0x00000002 +#define ZT1_FEATURE_FLAG_THREAD_SAFE 0x00000001 /** * Feature flag: FIPS compliant build (not available yet, but reserved for future use if we ever do this) */ -#define ZT1_FEATURE_FLAG_FIPS 0x00000004 +#define ZT1_FEATURE_FLAG_FIPS 0x00000002 /****************************************************************************/ /* Structures and other types */ @@ -298,11 +293,6 @@ typedef struct * True if some kind of connectivity appears available */ int online; - - /** - * Current maximum link desperation metric - */ - unsigned int desperation; } ZT1_NodeStatus; /** diff --git a/node/Node.cpp b/node/Node.cpp index 59b8091a..e0eb0c6c 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -92,6 +92,8 @@ Node::Node( throw std::runtime_error("unable to write identity.public"); } } + RR->publicIdentityStr = RR->identity.toString(false); + RR->secretIdentityStr = RR->identity.toString(true); try { RR->prng = new CMWC4096(); @@ -291,6 +293,7 @@ ZT1_ResultCode Node::leave(uint64_t nwid) nw->second->destroy(); _networks.erase(nw); } + return ZT1_RESULT_OK; } ZT1_ResultCode Node::multicastSubscribe(uint64_t nwid,uint64_t multicastGroup,unsigned long multicastAdi) @@ -299,6 +302,7 @@ ZT1_ResultCode Node::multicastSubscribe(uint64_t nwid,uint64_t multicastGroup,un std::map< uint64_t,SharedPtr<Network> >::iterator nw(_networks.find(nwid)); if (nw != _networks.end()) nw->second->multicastSubscribe(MulticastGroup(MAC(multicastGroup),(uint32_t)(multicastAdi & 0xffffffff))); + return ZT1_RESULT_OK; } ZT1_ResultCode Node::multicastUnsubscribe(uint64_t nwid,uint64_t multicastGroup,unsigned long multicastAdi) @@ -307,10 +311,15 @@ ZT1_ResultCode Node::multicastUnsubscribe(uint64_t nwid,uint64_t multicastGroup, std::map< uint64_t,SharedPtr<Network> >::iterator nw(_networks.find(nwid)); if (nw != _networks.end()) nw->second->multicastUnsubscribe(MulticastGroup(MAC(multicastGroup),(uint32_t)(multicastAdi & 0xffffffff))); + return ZT1_RESULT_OK; } void Node::status(ZT1_NodeStatus *status) { + status->address = RR->identity.address().toInt(); + status->publicIdentity = RR->publicIdentityStr.c_str(); + status->secretIdentity = RR->secretIdentityStr.c_str(); + status->online = _online ? 1 : 0; } ZT1_PeerList *Node::peers() @@ -331,6 +340,19 @@ ZT1_VirtualNetworkConfig *Node::networkConfig(uint64_t nwid) ZT1_VirtualNetworkList *Node::networks() { + Mutex::Lock _l(_networks_m); + + char *buf = (char *)::malloc(sizeof(ZT1_VirtualNetworkList) + (sizeof(ZT1_VirtualNetworkConfig) * _networks.size())); + if (!buf) + return (ZT1_VirtualNetworkList *)0; + ZT1_VirtualNetworkList *nl = (ZT1_VirtualNetworkList *)buf; + nl->networks = (ZT1_VirtualNetworkConfig *)(buf + sizeof(ZT1_VirtualNetworkList)); + + nl->networkCount = 0; + for(std::map< uint64_t,SharedPtr<Network> >::const_iterator n(_networks.begin());n!=_networks.end();++n) + n->second->externalConfig(&(nl->networks[nl->networkCount++])); + + return nl; } void Node::freeQueryResult(void *qr) @@ -589,9 +611,6 @@ void ZT1_version(int *major,int *minor,int *revision,unsigned long *featureFlags if (featureFlags) { *featureFlags = ( ZT1_FEATURE_FLAG_THREAD_SAFE -#ifdef ZT_OFFICIAL_BUILD - | ZT1_FEATURE_FLAG_OFFICIAL -#endif ); } } diff --git a/node/RuntimeEnvironment.hpp b/node/RuntimeEnvironment.hpp index ada51381..6bb8c3cf 100644 --- a/node/RuntimeEnvironment.hpp +++ b/node/RuntimeEnvironment.hpp @@ -69,6 +69,8 @@ public: // This node's identity Identity identity; + std::string publicIdentityStr; + std::string secretIdentityStr; // This is set externally to an instance of this base class if netconf functionality is enabled NetworkConfigMaster *netconfMaster; |