From 960ceb479155146455d8c84c002b964cc0e1d47e Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 1 Jun 2015 17:50:44 -0700 Subject: Rest of GitHub issue #140 implementation. --- node/Switch.hpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'node/Switch.hpp') diff --git a/node/Switch.hpp b/node/Switch.hpp index e944c843..0ba4c138 100644 --- a/node/Switch.hpp +++ b/node/Switch.hpp @@ -111,8 +111,9 @@ public: * * @param packet Packet to send * @param encrypt Encrypt packet payload? (always true except for HELLO) + * @param nwid Network ID or 0 if message is not related to a specific network */ - void send(const Packet &packet,bool encrypt); + void send(const Packet &packet,bool encrypt,uint64_t nwid); /** * Send RENDEZVOUS to two peers to permit them to directly connect @@ -183,15 +184,8 @@ private: void _handleRemotePacketFragment(const InetAddress &fromAddr,const void *data,unsigned int len); void _handleRemotePacketHead(const InetAddress &fromAddr,const void *data,unsigned int len); void _handleBeacon(const InetAddress &fromAddr,const Buffer &data); - - Address _sendWhoisRequest( - const Address &addr, - const Address *peersAlreadyConsulted, - unsigned int numPeersAlreadyConsulted); - - bool _trySend( - const Packet &packet, - bool encrypt); + Address _sendWhoisRequest(const Address &addr,const Address *peersAlreadyConsulted,unsigned int numPeersAlreadyConsulted); + bool _trySend(const Packet &packet,bool encrypt,uint64_t nwid); const RuntimeEnvironment *const RR; volatile uint64_t _lastBeacon; @@ -226,13 +220,15 @@ private: struct TXQueueEntry { TXQueueEntry() {} - TXQueueEntry(uint64_t ct,const Packet &p,bool enc) : + TXQueueEntry(uint64_t ct,const Packet &p,bool enc,uint64_t nw) : creationTime(ct), + nwid(nw), packet(p), encrypt(enc) {} uint64_t creationTime; - Packet packet; // unencrypted/untagged for TX queue + uint64_t nwid; + Packet packet; // unencrypted/unMAC'd packet -- this is done at send time bool encrypt; }; std::multimap< Address,TXQueueEntry > _txQueue; -- cgit v1.2.3