diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-04-02 17:54:56 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-04-02 17:54:56 -0700 |
commit | a69e1876f10266e5578be0a469ae7498f705fe96 (patch) | |
tree | 0a1e7e3a0b88ce21ca12ea2f0ccd1ebbfacdab51 /node/Node.hpp | |
parent | 5f51653f9c1f0de3091cb2df0ed25fc28e865aa4 (diff) | |
download | infinitytier-a69e1876f10266e5578be0a469ae7498f705fe96.tar.gz infinitytier-a69e1876f10266e5578be0a469ae7498f705fe96.zip |
The concept of link desperation (escalating to less desirable transports) simplifies a ton of stuff. Loads of spaghetti logic can die since we no longer have to make these decisions down in the core.
Diffstat (limited to 'node/Node.hpp')
-rw-r--r-- | node/Node.hpp | 45 |
1 files changed, 8 insertions, 37 deletions
diff --git a/node/Node.hpp b/node/Node.hpp index 461b9e9a..f7cab5f7 100644 --- a/node/Node.hpp +++ b/node/Node.hpp @@ -105,50 +105,24 @@ public: inline uint64_t now() const throw() { return _now; } /** - * @return Current level of desperation - */ - inline int desperation() const throw() { return (int)((_now - _timeOfLastPrivilgedPacket) / ZT_DESPERATION_INCREMENT); } - - /** - * Called to update last packet receive time whenever a packet is received - * - * @param fromPrivilegedPeer If true, peer is a supernode or federated hub (a.k.a. an upstream link) - */ - inline void packetReceived(bool fromPrivilegedPeer) - throw() - { - const uint64_t n = _now; - _timeOfLastPacketReceived = n; - if (fromPrivilegedPeer) - _timeOfLastPrivilgedPacket = n; - } - - /** - * @return Most recent time of any packet receipt - */ - inline uint64_t timeOfLastPacketReceived() const throw() { return _timeOfLastPacketReceived; } - - /** - * @return Timestamp of last packet received from a supernode or hub (upstream link) - */ - inline uint64_t timeOfLastPrivilgedPacket() const throw() { return _timeOfLastPrivilgedPacket; } - - /** * Enqueue a ZeroTier message to be sent * * @param addr Destination address * @param data Packet data * @param len Packet length + * @param desperation Link desperation for reaching this address + * @param spam If true, flag this packet to be spammed to lower-desperation links + * @return True if packet appears to have been sent */ - inline void putPacket(const InetAddress &addr,const void *data,unsigned int len) + inline bool putPacket(const InetAddress &addr,const void *data,unsigned int len,int desperation,bool spam) { - _wirePacketSendFunction( + return (_wirePacketSendFunction( reinterpret_cast<ZT1_Node *>(this), reinterpret_cast<const struct sockaddr_storage *>(&addr), - this->desperation(), - (int)((++_spamCounter % ZT_DESPERATION_SPAM_EVERY) == 0), + desperation, + (int)spam, data, - len); + len) == 0); } /** @@ -216,9 +190,6 @@ private: Mutex _networks_m; volatile uint64_t _now; // time of last run() - volatile uint64_t _timeOfLastPacketReceived; - volatile _timeOfLastPrivilgedPacket; - volatile unsigned int _spamCounter; // used to "spam" every Nth packet }; } // namespace ZeroTier |