summaryrefslogtreecommitdiff
path: root/node/PacketDecoder.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-08-03 12:53:46 -0400
committerAdam Ierymenko <adam.ierymenko@gmail.com>2013-08-03 12:53:46 -0400
commitbf5c07f79a0f78e714fe47a5d1e09330022261ea (patch)
tree99b41a9e4f006a2ae742fb1d6eb66e0be2a19742 /node/PacketDecoder.cpp
parent63fa4a684d15409e185422e7641e7c4680d19ec3 (diff)
downloadinfinitytier-bf5c07f79a0f78e714fe47a5d1e09330022261ea.tar.gz
infinitytier-bf5c07f79a0f78e714fe47a5d1e09330022261ea.zip
Scratch that... more work wiring up netconf. Got to handle OK.
Diffstat (limited to 'node/PacketDecoder.cpp')
-rw-r--r--node/PacketDecoder.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/node/PacketDecoder.cpp b/node/PacketDecoder.cpp
index 518ed9e7..8d02b425 100644
--- a/node/PacketDecoder.cpp
+++ b/node/PacketDecoder.cpp
@@ -298,6 +298,20 @@ bool PacketDecoder::_doOK(const RuntimeEnvironment *_r,const SharedPtr<Peer> &pe
if (_r->topology->isSupernode(source()))
_r->topology->addPeer(SharedPtr<Peer>(new Peer(_r->identity,Identity(*this,ZT_PROTO_VERB_WHOIS__OK__IDX_IDENTITY))),&PacketDecoder::_CBaddPeerFromWhois,const_cast<void *>((const void *)_r));
break;
+ case Packet::VERB_NETWORK_CONFIG_REQUEST: {
+ SharedPtr<Network> nw(_r->nc->network(at<uint64_t>(ZT_PROTO_VERB_NETWORK_CONFIG_REQUEST__OK__IDX_NETWORK_ID)));
+ if ((nw)&&(nw->controller() == source())) {
+ unsigned int dictlen = at<uint16_t>(ZT_PROTO_VERB_NETWORK_CONFIG_REQUEST__OK__IDX_DICT_LEN);
+ std::string dict((const char *)field(ZT_PROTO_VERB_NETWORK_CONFIG_REQUEST__OK__IDX_DICT,dictlen),dictlen);
+ if (dict.length()) {
+ Network::Config netconf(dict);
+ if ((netconf.networkId() == nw->id())&&(netconf.peerAddress() == _r->identity.address())) { // sanity check
+ LOG("got network configuration for network %.16llx from %s",(unsigned long long)nw->id(),source().toString().c_str());
+ nw->setConfiguration(netconf);
+ }
+ }
+ }
+ } break;
default:
//TRACE("%s(%s): OK(%s)",source().toString().c_str(),_remoteAddress.toString().c_str(),Packet::verbString(inReVerb));
break;