diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-07-06 15:05:04 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-07-06 15:05:04 -0700 |
commit | fad9dff2db26662e1496329057884b3b928cb1c9 (patch) | |
tree | 57880248cddc550459d795d987a850c268e5f362 /node | |
parent | 1632aec102f6cd03006bfa1c296f266928a0d9c4 (diff) | |
download | infinitytier-fad9dff2db26662e1496329057884b3b928cb1c9.tar.gz infinitytier-fad9dff2db26662e1496329057884b3b928cb1c9.zip |
Almost all of GitHub issue #180
Diffstat (limited to 'node')
-rw-r--r-- | node/IncomingPacket.cpp | 6 | ||||
-rw-r--r-- | node/IncomingPacket.hpp | 1 | ||||
-rw-r--r-- | node/Node.hpp | 10 | ||||
-rw-r--r-- | node/Switch.cpp | 10 |
4 files changed, 26 insertions, 1 deletions
diff --git a/node/IncomingPacket.cpp b/node/IncomingPacket.cpp index f45a1279..7634f54f 100644 --- a/node/IncomingPacket.cpp +++ b/node/IncomingPacket.cpp @@ -84,6 +84,7 @@ bool IncomingPacket::tryDecode(const RuntimeEnvironment *RR) case Packet::VERB_NETWORK_CONFIG_REFRESH: return _doNETWORK_CONFIG_REFRESH(RR,peer); case Packet::VERB_MULTICAST_GATHER: return _doMULTICAST_GATHER(RR,peer); case Packet::VERB_MULTICAST_FRAME: return _doMULTICAST_FRAME(RR,peer); + case Packet::VERB_PUSH_DIRECT_PATHS: return _doPUSH_DIRECT_PATHS(RR,peer); } } else { RR->sw->requestWhois(source()); @@ -882,6 +883,11 @@ bool IncomingPacket::_doMULTICAST_FRAME(const RuntimeEnvironment *RR,const Share return true; } +bool IncomingPacket::_doPUSH_DIRECT_PATHS(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer) +{ + return true; +} + void IncomingPacket::_sendErrorNeedCertificate(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer,uint64_t nwid) { Packet outp(source(),RR->identity.address(),Packet::VERB_ERROR); diff --git a/node/IncomingPacket.hpp b/node/IncomingPacket.hpp index 174fa38d..3bf7737d 100644 --- a/node/IncomingPacket.hpp +++ b/node/IncomingPacket.hpp @@ -121,6 +121,7 @@ private: bool _doNETWORK_CONFIG_REFRESH(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer); bool _doMULTICAST_GATHER(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer); bool _doMULTICAST_FRAME(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer); + bool _doPUSH_DIRECT_PATHS(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer); // Send an ERROR_NEED_MEMBERSHIP_CERTIFICATE to a peer indicating that an updated cert is needed to join void _sendErrorNeedCertificate(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer,uint64_t nwid); diff --git a/node/Node.hpp b/node/Node.hpp index 2d2898b5..5c7cfae2 100644 --- a/node/Node.hpp +++ b/node/Node.hpp @@ -43,6 +43,7 @@ #include "Mutex.hpp" #include "MAC.hpp" #include "Network.hpp" +#include "Path.hpp" #undef TRACE #ifdef ZT_TRACE @@ -171,6 +172,12 @@ public: return nw; } + inline std::vector<Path> directPaths() const + { + Mutex::Lock _l(_directPaths_m); + return _directPaths; + } + inline bool dataStorePut(const char *name,const void *data,unsigned int len,bool secure) { return (_dataStorePutFunction(reinterpret_cast<ZT1_Node *>(this),_uPtr,name,data,len,(int)secure) == 0); } inline bool dataStorePut(const char *name,const std::string &data,bool secure) { return dataStorePut(name,(const void *)data.data(),(unsigned int)data.length(),secure); } inline void dataStoreDelete(const char *name) { _dataStorePutFunction(reinterpret_cast<ZT1_Node *>(this),_uPtr,name,(const void *)0,0,0); } @@ -236,6 +243,9 @@ private: std::vector< std::pair< uint64_t, SharedPtr<Network> > > _networks; Mutex _networks_m; + std::vector<Path> _directPaths; + Mutex _directPaths_m; + Mutex _backgroundTasksLock; uint64_t _now; diff --git a/node/Switch.cpp b/node/Switch.cpp index 891c4a45..7600624f 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -733,10 +733,16 @@ bool Switch::_trySend(const Packet &packet,bool encrypt,uint64_t nwid) if (peer) { const uint64_t now = RR->node->now(); + if (nwid) { + // If this packet has an associated network, give the peer additional hints for direct connectivity + peer->pushDirectPaths(RR,RR->node->directPaths(),now,false); + } + RemotePath *viaPath = peer->getBestPath(now); if (!viaPath) { SharedPtr<Peer> relay; + // See if this network has a preferred relay (if packet has an associated network) if (nwid) { SharedPtr<Network> network(RR->node->network(nwid)); if (network) { @@ -754,6 +760,7 @@ bool Switch::_trySend(const Packet &packet,bool encrypt,uint64_t nwid) } } + // Otherwise relay off a root server if (!relay) relay = RR->topology->getBestRoot(); @@ -770,7 +777,7 @@ bool Switch::_trySend(const Packet &packet,bool encrypt,uint64_t nwid) if (viaPath->send(RR,tmp.data(),chunkSize,now)) { if (chunkSize < tmp.size()) { - // Too big for one bite, fragment the rest + // Too big for one packet, fragment the rest unsigned int fragStart = chunkSize; unsigned int remaining = tmp.size() - chunkSize; unsigned int fragsRemaining = (remaining / (ZT_UDP_DEFAULT_PAYLOAD_MTU - ZT_PROTO_MIN_FRAGMENT_LENGTH)); @@ -786,6 +793,7 @@ bool Switch::_trySend(const Packet &packet,bool encrypt,uint64_t nwid) remaining -= chunkSize; } } + return true; } } else { |