summaryrefslogtreecommitdiff
path: root/node/IncomingPacket.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-07-06 15:28:48 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-07-06 15:28:48 -0700
commit79e9a8bcc26491a43577082ec7edb86020f7ec00 (patch)
treeb6a834f0f826185c562921260b75bdd6e6659c32 /node/IncomingPacket.cpp
parentfad9dff2db26662e1496329057884b3b928cb1c9 (diff)
downloadinfinitytier-79e9a8bcc26491a43577082ec7edb86020f7ec00.tar.gz
infinitytier-79e9a8bcc26491a43577082ec7edb86020f7ec00.zip
Almost everything for GitHub issue #180 except direct path map setup.
Diffstat (limited to 'node/IncomingPacket.cpp')
-rw-r--r--node/IncomingPacket.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/node/IncomingPacket.cpp b/node/IncomingPacket.cpp
index 7634f54f..87669ba7 100644
--- a/node/IncomingPacket.cpp
+++ b/node/IncomingPacket.cpp
@@ -885,6 +885,36 @@ bool IncomingPacket::_doMULTICAST_FRAME(const RuntimeEnvironment *RR,const Share
bool IncomingPacket::_doPUSH_DIRECT_PATHS(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer)
{
+ try {
+ unsigned int count = at<uint16_t>(ZT_PACKET_IDX_PAYLOAD);
+ unsigned int ptr = ZT_PACKET_IDX_PAYLOAD + 2;
+
+ while (count) { // if ptr overflows Buffer will throw
+ unsigned int flags = (*this)[ptr++];
+ /*int metric = (*this)[ptr++];*/ ++ptr;
+ unsigned int extLen = at<uint16_t>(ptr); ptr += 2;
+ ptr += extLen; // unused right now
+ unsigned int addrType = (*this)[ptr++];
+ unsigned int addrLen = (*this)[ptr++];
+ switch(addrType) {
+ case 4: {
+ InetAddress a(field(ptr,4),4,at<uint16_t>(ptr + 4));
+ if ((flags & (0x01 | 0x02)) == 0)
+ peer->attemptToContactAt(RR,a,RR->node->now());
+ } break;
+ case 6: {
+ InetAddress a(field(ptr,16),16,at<uint16_t>(ptr + 16));
+ if ((flags & (0x01 | 0x02)) == 0)
+ peer->attemptToContactAt(RR,a,RR->node->now());
+ } break;
+ }
+ ptr += addrLen;
+ }
+ } catch (std::exception &exc) {
+ TRACE("dropped PUSH_DIRECT_PATHS from %s(%s): unexpected exception: %s",source().toString().c_str(),_remoteAddress.toString().c_str(),exc.what());
+ } catch ( ... ) {
+ TRACE("dropped PUSH_DIRECT_PATHS from %s(%s): unexpected exception: (unknown)",source().toString().c_str(),_remoteAddress.toString().c_str());
+ }
return true;
}