summaryrefslogtreecommitdiff
path: root/node/Switch.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2016-09-01 15:43:07 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2016-09-01 15:43:07 -0700
commita3bdae9735572fd6d888e6bf29b0302983a7c24c (patch)
tree9e427e297db253b7610fc07cb2214281c69a8e3c /node/Switch.cpp
parentd5e6f59004458ee2bddcaa18c6d0a8dfae2a2fc3 (diff)
downloadinfinitytier-a3bdae9735572fd6d888e6bf29b0302983a7c24c.tar.gz
infinitytier-a3bdae9735572fd6d888e6bf29b0302983a7c24c.zip
Work in progress: Path canonicalization refactor.
Diffstat (limited to 'node/Switch.cpp')
-rw-r--r--node/Switch.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/node/Switch.cpp b/node/Switch.cpp
index aae16001..dc238607 100644
--- a/node/Switch.cpp
+++ b/node/Switch.cpp
@@ -73,6 +73,9 @@ void Switch::onRemotePacket(const InetAddress &localAddr,const InetAddress &from
try {
const uint64_t now = RR->node->now();
+ SharedPtr<Path> path(RR->topology->getPath(localAddr,fromAddr));
+ path->received(now);
+
if (len == 13) {
/* LEGACY: before VERB_PUSH_DIRECT_PATHS, peers used broadcast
* announcements on the LAN to solve the 'same network problem.' We
@@ -90,7 +93,7 @@ void Switch::onRemotePacket(const InetAddress &localAddr,const InetAddress &from
_lastBeaconResponse = now;
Packet outp(peer->address(),RR->identity.address(),Packet::VERB_NOP);
outp.armor(peer->key(),true);
- RR->node->putPacket(localAddr,fromAddr,outp.data(),outp.size());
+ path->send(RR,outp.data(),outp.size(),now);
}
}
@@ -259,7 +262,7 @@ void Switch::onRemotePacket(const InetAddress &localAddr,const InetAddress &from
// We have all fragments -- assemble and process full Packet
//TRACE("packet %.16llx is complete, assembling and processing...",pid);
- rq->frag0.init(data,len,localAddr,fromAddr,now);
+ rq->frag0.init(data,len,path,now);
for(unsigned int f=1;f<rq->totalFragments;++f)
rq->frag0.append(rq->frags[f - 1].payload(),rq->frags[f - 1].payloadLength());
@@ -270,12 +273,12 @@ void Switch::onRemotePacket(const InetAddress &localAddr,const InetAddress &from
}
} else {
// Still waiting on more fragments, but keep the head
- rq->frag0.init(data,len,localAddr,fromAddr,now);
+ rq->frag0.init(data,len,path,now);
}
} // else this is a duplicate head, ignore
} else {
// Packet is unfragmented, so just process it
- IncomingPacket packet(data,len,localAddr,fromAddr,now);
+ IncomingPacket packet(data,len,path,now);
if (!packet.tryDecode(RR)) {
Mutex::Lock _l(_rxQueue_m);
RXQueueEntry *rq = &(_rxQueue[ZT_RX_QUEUE_SIZE - 1]);