From b974ece24f31b948a1bf0b446c03bcffde9f1833 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 28 Aug 2019 13:59:23 -0700 Subject: [PATCH] . --- root/root.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/root/root.cpp b/root/root.cpp index 025f42433..85e95bbec 100644 --- a/root/root.cpp +++ b/root/root.cpp @@ -102,9 +102,8 @@ static std::mutex peersByIdentity_l; static std::mutex peersByVirtAddr_l; static std::mutex peersByPhysAddr_l; -static void handlePacket(const int sock,const InetAddress *const ip,const Packet *const inpkt) +static void handlePacket(const int sock,const InetAddress *const ip,Packet &pkt) { - Packet pkt(*inpkt); char ipstr[128],ipstr2[128],astr[32],tmpstr[256]; const bool fragment = pkt[ZT_PACKET_FRAGMENT_IDX_FRAGMENT_INDICATOR] == ZT_PACKET_FRAGMENT_INDICATOR; @@ -171,8 +170,6 @@ static void handlePacket(const int sock,const InetAddress *const ip,const Packet peer = (*p); //printf("%s has %s (known (2))" ZT_EOL_S,ip->toString(ipstr),pkt.source().toString(astr)); break; - } else { - pkt = *inpkt; // dearmor() destroys contents of pkt } } } @@ -239,7 +236,7 @@ static void handlePacket(const int sock,const InetAddress *const ip,const Packet std::vector toAddrs; { std::lock_guard pbv_l(peersByVirtAddr_l); - auto peers = peersByVirtAddr.find(inpkt->destination()); + auto peers = peersByVirtAddr.find(pkt.destination()); if (peers != peersByVirtAddr.end()) { for(auto p=peers->second.begin();p!=peers->second.end();++p) { if ((*p)->ip6) @@ -379,8 +376,9 @@ int main(int argc,char **argv) if (pl > 0) { try { pkt.setSize((unsigned int)pl); - handlePacket(s6,reinterpret_cast(&in6),&pkt); + handlePacket(s6,reinterpret_cast(&in6),pkt); } catch ( ... ) { + printf("* unexpected exception" ZT_EOL_S); } } else { break; @@ -398,8 +396,9 @@ int main(int argc,char **argv) if (pl > 0) { try { pkt.setSize((unsigned int)pl); - handlePacket(s4,reinterpret_cast(&in4),&pkt); + handlePacket(s4,reinterpret_cast(&in4),pkt); } catch ( ... ) { + printf("* unexpected exception" ZT_EOL_S); } } else { break;