diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-01-30 15:40:22 -0800 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-01-30 15:40:22 -0800 |
commit | eebd271bb1e3ab0d25f48db07a1a3f1154215bc7 (patch) | |
tree | af7e706bd2fd9265441fea70ba6a74224913b634 /node/Cluster.cpp | |
parent | ff74ec248263db8941429e3626738f57b558cbc3 (diff) | |
download | infinitytier-eebd271bb1e3ab0d25f48db07a1a3f1154215bc7.tar.gz infinitytier-eebd271bb1e3ab0d25f48db07a1a3f1154215bc7.zip |
Implement cross cluster sharing of network configs to make clusters able to actually join networks.
Diffstat (limited to 'node/Cluster.cpp')
-rw-r--r-- | node/Cluster.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/node/Cluster.cpp b/node/Cluster.cpp index 2a261e51..55503f63 100644 --- a/node/Cluster.cpp +++ b/node/Cluster.cpp @@ -44,6 +44,7 @@ #include "Packet.hpp" #include "Switch.hpp" #include "Node.hpp" +#include "Network.hpp" #include "Array.hpp" namespace ZeroTier { @@ -469,6 +470,15 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len) RR->sw->send(outp,true); //TRACE("[%u] proxy send %s to %s length %u",(unsigned int)fromMemberId,Packet::verbString(verb),rcpt.toString().c_str(),len); } break; + + case CLUSTER_MESSAGE_NETWORK_CONFIG: { + const SharedPtr<Network> network(RR->node->network(dmsg.at<uint64_t>(ptr))); + if (network) { + // Copy into a Packet just to conform to Network API. Eventually + // will want to refactor. + network->handleConfigChunk(Packet(dmsg),ptr); + } + } break; } } catch ( ... ) { TRACE("invalid message of size %u type %d (inner decode), discarding",mlen,mtype); @@ -494,6 +504,15 @@ void Cluster::broadcastHavePeer(const Identity &id) } } +void Cluster::broadcastNetworkConfigChunk(const void *chunk,unsigned int len) +{ + Mutex::Lock _l(_memberIds_m); + for(std::vector<uint16_t>::const_iterator mid(_memberIds.begin());mid!=_memberIds.end();++mid) { + Mutex::Lock _l2(_members[*mid].lock); + _send(*mid,CLUSTER_MESSAGE_NETWORK_CONFIG,chunk,len); + } +} + void Cluster::sendViaCluster(const Address &fromPeerAddress,const Address &toPeerAddress,const void *data,unsigned int len,bool unite) { if (len > ZT_PROTO_MAX_PACKET_LENGTH) // sanity check |