mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-19 03:06:26 +00:00
Rename PacketDecoder to much more descriptive IncomingPacket
This commit is contained in:
parent
9180a30986
commit
557801a09e
@ -35,7 +35,7 @@
|
||||
#include "Defaults.hpp"
|
||||
#include "RuntimeEnvironment.hpp"
|
||||
#include "Topology.hpp"
|
||||
#include "PacketDecoder.hpp"
|
||||
#include "IncomingPacket.hpp"
|
||||
#include "Switch.hpp"
|
||||
#include "Peer.hpp"
|
||||
#include "NodeConfig.hpp"
|
||||
@ -45,7 +45,7 @@
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
bool PacketDecoder::tryDecode(const RuntimeEnvironment *_r)
|
||||
bool IncomingPacket::tryDecode(const RuntimeEnvironment *_r)
|
||||
{
|
||||
if ((!encrypted())&&(verb() == Packet::VERB_HELLO)) {
|
||||
// Unencrypted HELLOs are handled here since they are used to
|
||||
@ -117,7 +117,7 @@ bool PacketDecoder::tryDecode(const RuntimeEnvironment *_r)
|
||||
}
|
||||
}
|
||||
|
||||
bool PacketDecoder::_doERROR(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
bool IncomingPacket::_doERROR(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
{
|
||||
try {
|
||||
Packet::Verb inReVerb = (Packet::Verb)(*this)[ZT_PROTO_VERB_ERROR_IDX_IN_RE_VERB];
|
||||
@ -164,7 +164,7 @@ bool PacketDecoder::_doERROR(const RuntimeEnvironment *_r,const SharedPtr<Peer>
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PacketDecoder::_doHELLO(const RuntimeEnvironment *_r)
|
||||
bool IncomingPacket::_doHELLO(const RuntimeEnvironment *_r)
|
||||
{
|
||||
try {
|
||||
unsigned int protoVersion = (*this)[ZT_PROTO_VERB_HELLO_IDX_PROTOCOL_VERSION];
|
||||
@ -271,7 +271,7 @@ bool PacketDecoder::_doHELLO(const RuntimeEnvironment *_r)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PacketDecoder::_doOK(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
bool IncomingPacket::_doOK(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
{
|
||||
try {
|
||||
Packet::Verb inReVerb = (Packet::Verb)(*this)[ZT_PROTO_VERB_OK_IDX_IN_RE_VERB];
|
||||
@ -332,7 +332,7 @@ bool PacketDecoder::_doOK(const RuntimeEnvironment *_r,const SharedPtr<Peer> &pe
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PacketDecoder::_doWHOIS(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
bool IncomingPacket::_doWHOIS(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
{
|
||||
try {
|
||||
if (payloadLength() == ZT_ADDRESS_LENGTH) {
|
||||
@ -366,7 +366,7 @@ bool PacketDecoder::_doWHOIS(const RuntimeEnvironment *_r,const SharedPtr<Peer>
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PacketDecoder::_doRENDEZVOUS(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
bool IncomingPacket::_doRENDEZVOUS(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
{
|
||||
try {
|
||||
/*
|
||||
@ -410,7 +410,7 @@ bool PacketDecoder::_doRENDEZVOUS(const RuntimeEnvironment *_r,const SharedPtr<P
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PacketDecoder::_doFRAME(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
bool IncomingPacket::_doFRAME(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
{
|
||||
try {
|
||||
SharedPtr<Network> network(_r->nc->network(at<uint64_t>(ZT_PROTO_VERB_FRAME_IDX_NETWORK_ID)));
|
||||
@ -449,7 +449,7 @@ bool PacketDecoder::_doFRAME(const RuntimeEnvironment *_r,const SharedPtr<Peer>
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PacketDecoder::_doEXT_FRAME(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
bool IncomingPacket::_doEXT_FRAME(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
{
|
||||
try {
|
||||
SharedPtr<Network> network(_r->nc->network(at<uint64_t>(ZT_PROTO_VERB_EXT_FRAME_IDX_NETWORK_ID)));
|
||||
@ -518,7 +518,7 @@ bool PacketDecoder::_doEXT_FRAME(const RuntimeEnvironment *_r,const SharedPtr<Pe
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PacketDecoder::_doMULTICAST_FRAME(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
bool IncomingPacket::_doMULTICAST_FRAME(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
{
|
||||
try {
|
||||
Address origin(Address(field(ZT_PROTO_VERB_MULTICAST_FRAME_IDX_ORIGIN,ZT_PROTO_VERB_MULTICAST_FRAME_LEN_ORIGIN),ZT_ADDRESS_LENGTH));
|
||||
@ -767,7 +767,7 @@ bool PacketDecoder::_doMULTICAST_FRAME(const RuntimeEnvironment *_r,const Shared
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PacketDecoder::_doMULTICAST_LIKE(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
bool IncomingPacket::_doMULTICAST_LIKE(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
{
|
||||
try {
|
||||
Address src(source());
|
||||
@ -793,7 +793,7 @@ bool PacketDecoder::_doMULTICAST_LIKE(const RuntimeEnvironment *_r,const SharedP
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PacketDecoder::_doNETWORK_MEMBERSHIP_CERTIFICATE(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
bool IncomingPacket::_doNETWORK_MEMBERSHIP_CERTIFICATE(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
{
|
||||
try {
|
||||
CertificateOfMembership com;
|
||||
@ -829,7 +829,7 @@ bool PacketDecoder::_doNETWORK_MEMBERSHIP_CERTIFICATE(const RuntimeEnvironment *
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PacketDecoder::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
bool IncomingPacket::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
{
|
||||
try {
|
||||
uint64_t nwid = at<uint64_t>(ZT_PROTO_VERB_NETWORK_CONFIG_REQUEST_IDX_NETWORK_ID);
|
||||
@ -872,7 +872,7 @@ bool PacketDecoder::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *_r,const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PacketDecoder::_doNETWORK_CONFIG_REFRESH(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
bool IncomingPacket::_doNETWORK_CONFIG_REFRESH(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer)
|
||||
{
|
||||
try {
|
||||
unsigned int ptr = ZT_PACKET_IDX_PAYLOAD;
|
||||
@ -893,7 +893,7 @@ bool PacketDecoder::_doNETWORK_CONFIG_REFRESH(const RuntimeEnvironment *_r,const
|
||||
return true;
|
||||
}
|
||||
|
||||
void PacketDecoder::_sendErrorNeedCertificate(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer,uint64_t nwid)
|
||||
void IncomingPacket::_sendErrorNeedCertificate(const RuntimeEnvironment *_r,const SharedPtr<Peer> &peer,uint64_t nwid)
|
||||
{
|
||||
Packet outp(source(),_r->identity.address(),Packet::VERB_ERROR);
|
||||
outp.append((unsigned char)verb());
|
||||
|
@ -25,8 +25,8 @@
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
|
||||
#ifndef ZT_PACKETDECODER_HPP
|
||||
#define ZT_PACKETDECODER_HPP
|
||||
#ifndef ZT_INCOMINGPACKET_HPP
|
||||
#define ZT_INCOMINGPACKET_HPP
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
@ -63,9 +63,9 @@ class Network;
|
||||
/**
|
||||
* Subclass of packet that handles the decoding of it
|
||||
*/
|
||||
class PacketDecoder : public Packet
|
||||
class IncomingPacket : public Packet
|
||||
{
|
||||
friend class SharedPtr<PacketDecoder>;
|
||||
friend class SharedPtr<IncomingPacket>;
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -77,7 +77,7 @@ public:
|
||||
* @throws std::out_of_range Range error processing packet
|
||||
*/
|
||||
template<unsigned int C2>
|
||||
PacketDecoder(const Buffer<C2> &b,const SharedPtr<Socket> &fromSock,const InetAddress &remoteAddress)
|
||||
IncomingPacket(const Buffer<C2> &b,const SharedPtr<Socket> &fromSock,const InetAddress &remoteAddress)
|
||||
throw(std::out_of_range) :
|
||||
Packet(b),
|
||||
_receiveTime(Utils::now()),
|
||||
|
@ -166,7 +166,7 @@ public:
|
||||
/**
|
||||
* Set or update this network's configuration
|
||||
*
|
||||
* This is called by PacketDecoder when an update comes over the wire, or
|
||||
* This is called in IncomingPacket when an update comes over the wire, or
|
||||
* internally when an old config is reloaded from disk.
|
||||
*
|
||||
* This also cancels any netconf failure flags.
|
||||
@ -181,7 +181,7 @@ public:
|
||||
bool setConfiguration(const Dictionary &conf,bool saveToDisk = true);
|
||||
|
||||
/**
|
||||
* Set netconf failure to 'access denied' -- called by PacketDecoder when netconf master reports this
|
||||
* Set netconf failure to 'access denied' -- called in IncomingPacket when netconf master reports this
|
||||
*/
|
||||
inline void setAccessDenied()
|
||||
{
|
||||
|
@ -547,7 +547,7 @@ unsigned long Switch::doTimerTasks()
|
||||
|
||||
{
|
||||
Mutex::Lock _l(_rxQueue_m);
|
||||
for(std::list< SharedPtr<PacketDecoder> >::iterator i(_rxQueue.begin());i!=_rxQueue.end();) {
|
||||
for(std::list< SharedPtr<IncomingPacket> >::iterator i(_rxQueue.begin());i!=_rxQueue.end();) {
|
||||
if ((now - (*i)->receiveTime()) > ZT_RECEIVE_QUEUE_TIMEOUT) {
|
||||
TRACE("RX %s -> %s timed out",(*i)->source().toString().c_str(),(*i)->destination().toString().c_str());
|
||||
_rxQueue.erase(i++);
|
||||
@ -664,7 +664,7 @@ void Switch::doAnythingWaitingForPeer(const SharedPtr<Peer> &peer)
|
||||
|
||||
{ // finish processing any packets waiting on peer's public key / identity
|
||||
Mutex::Lock _l(_rxQueue_m);
|
||||
for(std::list< SharedPtr<PacketDecoder> >::iterator rxi(_rxQueue.begin());rxi!=_rxQueue.end();) {
|
||||
for(std::list< SharedPtr<IncomingPacket> >::iterator rxi(_rxQueue.begin());rxi!=_rxQueue.end();) {
|
||||
if ((*rxi)->tryDecode(_r))
|
||||
_rxQueue.erase(rxi++);
|
||||
else ++rxi;
|
||||
@ -755,7 +755,7 @@ void Switch::_handleRemotePacketFragment(const SharedPtr<Socket> &fromSock,const
|
||||
// We have all fragments -- assemble and process full Packet
|
||||
//TRACE("packet %.16llx is complete, assembling and processing...",pid);
|
||||
|
||||
SharedPtr<PacketDecoder> packet(dqe->second.frag0);
|
||||
SharedPtr<IncomingPacket> packet(dqe->second.frag0);
|
||||
for(unsigned int f=1;f<tf;++f)
|
||||
packet->append(dqe->second.frags[f - 1].payload(),dqe->second.frags[f - 1].payloadLength());
|
||||
_defragQueue.erase(dqe);
|
||||
@ -772,7 +772,7 @@ void Switch::_handleRemotePacketFragment(const SharedPtr<Socket> &fromSock,const
|
||||
|
||||
void Switch::_handleRemotePacketHead(const SharedPtr<Socket> &fromSock,const InetAddress &fromAddr,const Buffer<4096> &data)
|
||||
{
|
||||
SharedPtr<PacketDecoder> packet(new PacketDecoder(data,fromSock,fromAddr));
|
||||
SharedPtr<IncomingPacket> packet(new IncomingPacket(data,fromSock,fromAddr));
|
||||
|
||||
Address source(packet->source());
|
||||
Address destination(packet->destination());
|
||||
|
@ -44,7 +44,7 @@
|
||||
#include "Array.hpp"
|
||||
#include "Network.hpp"
|
||||
#include "SharedPtr.hpp"
|
||||
#include "PacketDecoder.hpp"
|
||||
#include "IncomingPacket.hpp"
|
||||
#include "Socket.hpp"
|
||||
|
||||
/* Ethernet frame types that might be relevant to us */
|
||||
@ -246,7 +246,7 @@ private:
|
||||
std::map< Address,WhoisRequest > _outstandingWhoisRequests;
|
||||
Mutex _outstandingWhoisRequests_m;
|
||||
|
||||
std::list< SharedPtr<PacketDecoder> > _rxQueue;
|
||||
std::list< SharedPtr<IncomingPacket> > _rxQueue;
|
||||
Mutex _rxQueue_m;
|
||||
|
||||
struct TXQueueEntry
|
||||
@ -267,7 +267,7 @@ private:
|
||||
struct DefragQueueEntry
|
||||
{
|
||||
uint64_t creationTime;
|
||||
SharedPtr<PacketDecoder> frag0;
|
||||
SharedPtr<IncomingPacket> frag0;
|
||||
Packet::Fragment frags[ZT_MAX_PACKET_FRAGMENTS - 1];
|
||||
unsigned int totalFragments; // 0 if only frag0 received, waiting for frags
|
||||
uint32_t haveFragments; // bit mask, LSB to MSB
|
||||
|
Loading…
Reference in New Issue
Block a user