From 7e7e28f5f7d53df8f4897b243088d2f664651ae6 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 17 Oct 2013 05:37:01 -0400 Subject: Add support for pushing network config refresh hints from a MEMORY queue table. That ways it will be possible for network changes to take effect almost immediately across all active peers. --- node/PacketDecoder.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'node/PacketDecoder.cpp') diff --git a/node/PacketDecoder.cpp b/node/PacketDecoder.cpp index 2bc61ed0..a8a55602 100644 --- a/node/PacketDecoder.cpp +++ b/node/PacketDecoder.cpp @@ -140,6 +140,10 @@ bool PacketDecoder::_doERROR(const RuntimeEnvironment *_r,const SharedPtr if (inReVerb == Packet::VERB_WHOIS) { if (_r->topology->isSupernode(source())) _r->sw->cancelWhoisRequest(Address(field(ZT_PROTO_VERB_ERROR_IDX_PAYLOAD,ZT_ADDRESS_LENGTH),ZT_ADDRESS_LENGTH)); + } else if (inReVerb == Packet::VERB_NETWORK_CONFIG_REQUEST) { + SharedPtr network(_r->nc->network(at(ZT_PROTO_VERB_ERROR_IDX_PAYLOAD))); + if ((network)&&(network->controller() == source())) + network->forceStatusTo(Network::NETWORK_NOT_FOUND); } break; case Packet::ERROR_IDENTITY_COLLISION: @@ -154,6 +158,11 @@ bool PacketDecoder::_doERROR(const RuntimeEnvironment *_r,const SharedPtr if (network) network->pushMembershipCertificate(source(),true,Utils::now()); } break; + case Packet::ERROR_NETWORK_ACCESS_DENIED: { + SharedPtr network(_r->nc->network(at(ZT_PROTO_VERB_ERROR_IDX_PAYLOAD))); + if ((network)&&(network->controller() == source())) + network->forceStatusTo(Network::NETWORK_ACCESS_DENIED); + } break; default: break; } @@ -732,10 +741,13 @@ bool PacketDecoder::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *_r,const bool PacketDecoder::_doNETWORK_CONFIG_REFRESH(const RuntimeEnvironment *_r,const SharedPtr &peer) { try { - uint64_t nwid = at(ZT_PROTO_VERB_NETWORK_CONFIG_REFRESH_IDX_NETWORK_ID); - SharedPtr nw(_r->nc->network(nwid)); - if ((nw)&&(source() == nw->controller())) // only respond to requests from controller - nw->requestConfiguration(); + unsigned int ptr = ZT_PACKET_IDX_PAYLOAD; + while ((ptr + sizeof(uint64_t)) <= size()) { + uint64_t nwid = at(ptr); ptr += sizeof(uint64_t); + SharedPtr nw(_r->nc->network(nwid)); + if ((nw)&&(source() == nw->controller())) // only respond to requests from controller + nw->requestConfiguration(); + } } catch (std::exception &exc) { TRACE("dropped NETWORK_CONFIG_REFRESH from %s(%s): unexpected exception: %s",source().toString().c_str(),_remoteAddress.toString().c_str(),exc.what()); } catch ( ... ) { -- cgit v1.2.3