summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
Diffstat (limited to 'node')
-rw-r--r--node/IncomingPacket.cpp27
-rw-r--r--node/IncomingPacket.hpp1
-rw-r--r--node/Packet.hpp3
3 files changed, 27 insertions, 4 deletions
diff --git a/node/IncomingPacket.cpp b/node/IncomingPacket.cpp
index a5875d1e..5e5d1d72 100644
--- a/node/IncomingPacket.cpp
+++ b/node/IncomingPacket.cpp
@@ -1192,7 +1192,7 @@ bool IncomingPacket::_doPUSH_DIRECT_PATHS(const RuntimeEnvironment *RR,void *tPt
bool IncomingPacket::_doUSER_MESSAGE(const RuntimeEnvironment *RR,void *tPtr,const SharedPtr<Peer> &peer)
{
try {
- if (size() >= (ZT_PACKET_IDX_PAYLOAD + 8)) {
+ if (likely(size() >= (ZT_PACKET_IDX_PAYLOAD + 8))) {
ZT_UserMessage um;
um.origin = peer->address().toInt();
um.typeId = at<uint64_t>(ZT_PACKET_IDX_PAYLOAD);
@@ -1207,6 +1207,31 @@ bool IncomingPacket::_doUSER_MESSAGE(const RuntimeEnvironment *RR,void *tPtr,con
return true;
}
+bool IncomingPacket::_doREMOTE_TRACE(const RuntimeEnvironment *RR,void *tPtr,const SharedPtr<Peer> &peer)
+{
+ ZT_RemoteTrace rt;
+ try {
+ const char *ptr = reinterpret_cast<const char *>(data()) + ZT_PACKET_IDX_PAYLOAD;
+ const char *const eof = reinterpret_cast<const char *>(data()) + size();
+ rt.origin = peer->address().toInt();
+ rt.data = const_cast<char *>(ptr); // start of first string
+ while (ptr < eof) {
+ if (!*ptr) { // end of string
+ rt.len = (unsigned int)(ptr - rt.data);
+ if ((rt.len > 0)&&(rt.len <= ZT_MAX_REMOTE_TRACE_SIZE))
+ RR->node->postEvent(tPtr,ZT_EVENT_REMOTE_TRACE,&rt);
+ rt.data = const_cast<char *>(++ptr); // start of next string, if any
+ } else {
+ ++ptr;
+ }
+ }
+ peer->received(tPtr,_path,hops(),packetId(),Packet::VERB_REMOTE_TRACE,0,Packet::VERB_NOP,false,0);
+ } catch ( ... ) {
+ RR->t->incomingPacketInvalid(tPtr,_path,packetId(),source(),hops(),Packet::VERB_REMOTE_TRACE,"unexpected exception");
+ }
+ return true;
+}
+
void IncomingPacket::_sendErrorNeedCredentials(const RuntimeEnvironment *RR,void *tPtr,const SharedPtr<Peer> &peer,const uint64_t nwid)
{
const uint64_t now = RR->node->now();
diff --git a/node/IncomingPacket.hpp b/node/IncomingPacket.hpp
index 11b60712..692c63df 100644
--- a/node/IncomingPacket.hpp
+++ b/node/IncomingPacket.hpp
@@ -139,6 +139,7 @@ private:
bool _doMULTICAST_FRAME(const RuntimeEnvironment *RR,void *tPtr,const SharedPtr<Peer> &peer);
bool _doPUSH_DIRECT_PATHS(const RuntimeEnvironment *RR,void *tPtr,const SharedPtr<Peer> &peer);
bool _doUSER_MESSAGE(const RuntimeEnvironment *RR,void *tPtr,const SharedPtr<Peer> &peer);
+ bool _doREMOTE_TRACE(const RuntimeEnvironment *RR,void *tPtr,const SharedPtr<Peer> &peer);
void _sendErrorNeedCredentials(const RuntimeEnvironment *RR,void *tPtr,const SharedPtr<Peer> &peer,const uint64_t nwid);
diff --git a/node/Packet.hpp b/node/Packet.hpp
index a1ea73e1..b8e69fa9 100644
--- a/node/Packet.hpp
+++ b/node/Packet.hpp
@@ -978,9 +978,6 @@ public:
* The instance ID is a random 64-bit value generated by each ZeroTier
* node on startup. This is helpful in identifying traces from different
* members of a cluster.
- *
- * The Dictionary serialization format is the same as used for network
- * configurations. The maximum size of a trace is 10000 bytes.
*/
VERB_REMOTE_TRACE = 0x15
};