summaryrefslogtreecommitdiff
path: root/node/Path.hpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-04-03 13:14:37 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-04-03 13:14:37 -0700
commitee0f56355bd7b1d2798a750fb02a975b526dd9cf (patch)
tree4fd593ed94b68cf79996246d1410d89bda9c7aa3 /node/Path.hpp
parenta69e1876f10266e5578be0a469ae7498f705fe96 (diff)
downloadinfinitytier-ee0f56355bd7b1d2798a750fb02a975b526dd9cf.tar.gz
infinitytier-ee0f56355bd7b1d2798a750fb02a975b526dd9cf.zip
Send path simplification.
Diffstat (limited to 'node/Path.hpp')
-rw-r--r--node/Path.hpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/node/Path.hpp b/node/Path.hpp
index df68339e..1adb8f99 100644
--- a/node/Path.hpp
+++ b/node/Path.hpp
@@ -36,8 +36,11 @@
#include <algorithm>
#include "Constants.hpp"
+#include "Node.hpp"
#include "InetAddress.hpp"
#include "Utils.hpp"
+#include "AntiRecursion.hpp"
+#include "RuntimeEnvironment.hpp"
namespace ZeroTier {
@@ -91,6 +94,8 @@ public:
/**
* Called when a packet is sent to this path
*
+ * This is called automatically by Path::send().
+ *
* @param t Time of send
*/
inline void sent(uint64_t t) throw() { _lastSend = t; }
@@ -128,7 +133,7 @@ public:
*/
inline int desperation(uint64_t now) const
{
- if ((_lastSend > _lastReceived)&&(_fixed))
+ if ((_fixed)&&(_lastSend > _lastReceived))
return std::max(_lastReceiveDesperation,(int)((_lastSend - _lastReceived) / ZT_DESPERATION_INCREMENT));
return _lastReceiveDesperation;
}
@@ -144,6 +149,25 @@ public:
}
/**
+ * Send a packet via this path
+ *
+ * @param RR Runtime environment
+ * @param data Packet data
+ * @param len Packet length
+ * @param now Current time
+ * @return True if transport reported success
+ */
+ inline bool send(const RuntimeEnvironment *RR,const void *data,unsigned int len,uint64_t now)
+ {
+ if (RR->node->putPacket(_addr,data,len,desperation(now))) {
+ sent(now);
+ RR->antiRec->logOutgoingZT(data,len);
+ return true;
+ }
+ return false;
+ }
+
+ /**
* @param now Current time
* @return Human-readable address and other information about this path
*/