summaryrefslogtreecommitdiff
path: root/node/Path.hpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2016-09-13 14:27:18 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2016-09-13 14:27:18 -0700
commit5b6d27e65919cf0429feb2d8a9ce0b6164153efd (patch)
treec39d4abc138eb2cfe1b46df7154c298156ba020b /node/Path.hpp
parentced8dfc639f73939aacd2bae3002daa11661a14f (diff)
downloadinfinitytier-5b6d27e65919cf0429feb2d8a9ce0b6164153efd.tar.gz
infinitytier-5b6d27e65919cf0429feb2d8a9ce0b6164153efd.zip
Implement relay policy, and setting multicast limit to 0 now disables multicast on the network as would be expected.
Diffstat (limited to 'node/Path.hpp')
-rw-r--r--node/Path.hpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/node/Path.hpp b/node/Path.hpp
index 27cff645..5993be69 100644
--- a/node/Path.hpp
+++ b/node/Path.hpp
@@ -104,6 +104,7 @@ public:
Path() :
_lastOut(0),
_lastIn(0),
+ _lastTrustEstablishedPacketReceived(0),
_addr(),
_localAddress(),
_ipScope(InetAddress::IP_SCOPE_NONE)
@@ -113,6 +114,7 @@ public:
Path(const InetAddress &localAddress,const InetAddress &addr) :
_lastOut(0),
_lastIn(0),
+ _lastTrustEstablishedPacketReceived(0),
_addr(addr),
_localAddress(localAddress),
_ipScope(addr.ipScope())
@@ -127,6 +129,11 @@ public:
inline void received(const uint64_t t) { _lastIn = t; }
/**
+ * Set time last trusted packet was received (done in Peer::received())
+ */
+ inline void trustedPacketReceived(const uint64_t t) { _lastTrustEstablishedPacketReceived = t; }
+
+ /**
* Send a packet via this path (last out time is also updated)
*
* @param RR Runtime environment
@@ -160,6 +167,11 @@ public:
inline InetAddress::IpScope ipScope() const { return _ipScope; }
/**
+ * @return True if path has received a trust established packet (e.g. common network membership) in the past ZT_TRUST_EXPIRATION ms
+ */
+ inline bool trustEstablished(const uint64_t now) const { return ((now - _lastTrustEstablishedPacketReceived) < ZT_TRUST_EXPIRATION); }
+
+ /**
* @return Preference rank, higher == better
*/
inline unsigned int preferenceRank() const
@@ -232,6 +244,7 @@ public:
private:
uint64_t _lastOut;
uint64_t _lastIn;
+ uint64_t _lastTrustEstablishedPacketReceived;
InetAddress _addr;
InetAddress _localAddress;
InetAddress::IpScope _ipScope; // memoize this since it's a computed value checked often