summaryrefslogtreecommitdiff
path: root/node/PacketDecoder.hpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-07-11 22:06:25 -0400
committerAdam Ierymenko <adam.ierymenko@gmail.com>2013-07-11 22:06:25 -0400
commit339b2314ea168d302bae4b5f7fbf828b210e5450 (patch)
tree5ba92262bfbeacd58935f7e332557086f6be53a0 /node/PacketDecoder.hpp
parentfd2b383c3e8e1a4b81454611b966c6c775c03913 (diff)
downloadinfinitytier-339b2314ea168d302bae4b5f7fbf828b210e5450.tar.gz
infinitytier-339b2314ea168d302bae4b5f7fbf828b210e5450.zip
More work in progress on Switch / PacketDecoder refactor.
Diffstat (limited to 'node/PacketDecoder.hpp')
-rw-r--r--node/PacketDecoder.hpp38
1 files changed, 29 insertions, 9 deletions
diff --git a/node/PacketDecoder.hpp b/node/PacketDecoder.hpp
index 49d47a51..5da8f9c0 100644
--- a/node/PacketDecoder.hpp
+++ b/node/PacketDecoder.hpp
@@ -36,6 +36,7 @@
#include "Utils.hpp"
#include "SharedPtr.hpp"
#include "AtomicCounter.hpp"
+#include "Peer.hpp"
namespace ZeroTier {
@@ -56,7 +57,7 @@ public:
_receiveTime(Utils::now()),
_localPort(localPort),
_remoteAddress(remoteAddress),
- _step(DECODE_STEP_START),
+ _step(DECODE_STEP_WAITING_FOR_SENDER_LOOKUP),
__refCount()
{
}
@@ -76,21 +77,40 @@ public:
inline uint64_t receiveTime() const throw() { return _receiveTime; }
private:
- bool _doERROR(const RuntimeEnvironment *_r);
+ struct _CBaddPeerFromHello_Data
+ {
+ const RuntimeEnvironment *renv;
+ Address source;
+ InetAddress remoteAddress;
+ int localPort;
+ unsigned int vMajor,vMinor,vRevision;
+ uint64_t helloPacketId;
+ uint64_t helloTimestamp;
+ };
+ static void _CBaddPeerFromHello(
+ void *arg, // _CBaddPeerFromHello_Data
+ const SharedPtr<Peer> &p,
+ Topology::PeerVerifyResult result);
+
+ static void _CBaddPeerFromWhois(
+ void *arg, // RuntimeEnvironment
+ const SharedPtr<Peer> &p,
+ Topology::PeerVerifyResult result);
+
+ bool _doERROR(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
bool _doHELLO(const RuntimeEnvironment *_r);
- bool _doOK(const RuntimeEnvironment *_r);
- bool _doWHOIS(const RuntimeEnvironment *_r);
- bool _doRENDEZVOUS(const RuntimeEnvironment *_r);
- bool _doFRAME(const RuntimeEnvironment *_r);
- bool _doMULTICAST_LIKE(const RuntimeEnvironment *_r);
- bool _doMULTICAST_FRAME(const RuntimeEnvironment *_r);
+ bool _doOK(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
+ bool _doWHOIS(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
+ bool _doRENDEZVOUS(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
+ bool _doFRAME(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
+ bool _doMULTICAST_LIKE(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
+ bool _doMULTICAST_FRAME(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer);
uint64_t _receiveTime;
Demarc::Port _localPort;
InetAddress _remoteAddress;
enum {
- DECODE_STEP_START,
DECODE_STEP_WAITING_FOR_SENDER_LOOKUP, // on initial receipt, we need peer's identity
DECODE_STEP_WAITING_FOR_ORIGINAL_SUBMITTER_LOOKUP // this only applies to MULTICAST_FRAME
} _step;