diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-06-30 17:32:07 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-06-30 17:32:07 -0700 |
| commit | baa10c2995b7e0e49b49fe63a264a20982b817cf (patch) | |
| tree | 81f823995d933258eb02cca3a227a1da2fcb2ef4 /node/Path.hpp | |
| parent | 1a40f35fd4aadaa1279665be6bfb42600d2569e1 (diff) | |
| download | infinitytier-baa10c2995b7e0e49b49fe63a264a20982b817cf.tar.gz infinitytier-baa10c2995b7e0e49b49fe63a264a20982b817cf.zip | |
.
Diffstat (limited to 'node/Path.hpp')
| -rw-r--r-- | node/Path.hpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/node/Path.hpp b/node/Path.hpp index 32bceae0..74b31d8d 100644 --- a/node/Path.hpp +++ b/node/Path.hpp @@ -46,6 +46,11 @@ */ #define ZT_PATH_MAX_PREFERENCE_RANK ((ZT_INETADDRESS_MAX_SCOPE << 1) | 1) +/** + * Maximum distance for a path + */ +#define ZT_PATH_DISTANCE_MAX 0xffff + namespace ZeroTier { class RuntimeEnvironment; @@ -120,6 +125,7 @@ public: _incomingLinkQualitySlowLogCounter(-64), // discard first fast log _incomingLinkQualityPreviousPacketCounter(0), _outgoingPacketCounter(0), + _distance(ZT_PATH_DISTANCE_MAX), _addr(), _localAddress(), _ipScope(InetAddress::IP_SCOPE_NONE) @@ -137,6 +143,7 @@ public: _incomingLinkQualitySlowLogCounter(-64), // discard first fast log _incomingLinkQualityPreviousPacketCounter(0), _outgoingPacketCounter(0), + _distance(ZT_PATH_DISTANCE_MAX), _addr(addr), _localAddress(localAddress), _ipScope(addr.ipScope()) @@ -300,6 +307,28 @@ public: inline uint64_t lastIn() const { return _lastIn; } /** + * @return Time last trust-established packet was received + */ + inline uint64_t lastTrustEstablishedPacketReceived() const { return _lastTrustEstablishedPacketReceived; } + + /** + * @return Distance (higher is further) + */ + inline unsigned int distance() const { return _distance; } + + /** + * @param lo Last out send + * @param li Last in send + * @param lt Last trust established packet received + */ + inline void updateFromRemoteState(const uint64_t lo,const uint64_t li,const uint64_t lt) + { + _lastOut = lo; + _lastIn = li; + _lastTrustEstablishedPacketReceived = lt; + } + + /** * Return and increment outgoing packet counter (used with Packet::armor()) * * @return Next value that should be used for outgoing packet counter (only least significant 3 bits are used) @@ -315,6 +344,7 @@ private: volatile signed int _incomingLinkQualitySlowLogCounter; volatile unsigned int _incomingLinkQualityPreviousPacketCounter; volatile unsigned int _outgoingPacketCounter; + volatile unsigned int _distance; InetAddress _addr; InetAddress _localAddress; InetAddress::IpScope _ipScope; // memoize this since it's a computed value checked often |
