mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-30 20:52:30 +02:00
Reformat code
This commit is contained in:
parent
3ddb370718
commit
55534ea002
140 changed files with 46068 additions and 48277 deletions
|
@ -15,68 +15,70 @@
|
|||
#include "I2NPProtocol.h"
|
||||
#include "Identity.h"
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
namespace tunnel
|
||||
{
|
||||
const size_t TUNNEL_DATA_MSG_SIZE = 1028;
|
||||
const size_t TUNNEL_DATA_ENCRYPTED_SIZE = 1008;
|
||||
const size_t TUNNEL_DATA_MAX_PAYLOAD_SIZE = 1003;
|
||||
namespace i2p {
|
||||
namespace tunnel {
|
||||
const size_t TUNNEL_DATA_MSG_SIZE = 1028;
|
||||
const size_t TUNNEL_DATA_ENCRYPTED_SIZE = 1008;
|
||||
const size_t TUNNEL_DATA_MAX_PAYLOAD_SIZE = 1003;
|
||||
|
||||
enum TunnelDeliveryType
|
||||
{
|
||||
eDeliveryTypeLocal = 0,
|
||||
eDeliveryTypeTunnel = 1,
|
||||
eDeliveryTypeRouter = 2
|
||||
};
|
||||
struct TunnelMessageBlock
|
||||
{
|
||||
TunnelDeliveryType deliveryType;
|
||||
i2p::data::IdentHash hash;
|
||||
uint32_t tunnelID;
|
||||
std::shared_ptr<I2NPMessage> data;
|
||||
};
|
||||
enum TunnelDeliveryType {
|
||||
eDeliveryTypeLocal = 0,
|
||||
eDeliveryTypeTunnel = 1,
|
||||
eDeliveryTypeRouter = 2
|
||||
};
|
||||
struct TunnelMessageBlock {
|
||||
TunnelDeliveryType deliveryType;
|
||||
i2p::data::IdentHash hash;
|
||||
uint32_t tunnelID;
|
||||
std::shared_ptr<I2NPMessage> data;
|
||||
};
|
||||
|
||||
class TunnelBase
|
||||
{
|
||||
public:
|
||||
class TunnelBase {
|
||||
public:
|
||||
|
||||
TunnelBase (uint32_t tunnelID, uint32_t nextTunnelID, i2p::data::IdentHash nextIdent):
|
||||
m_TunnelID (tunnelID), m_NextTunnelID (nextTunnelID), m_NextIdent (nextIdent),
|
||||
m_CreationTime (i2p::util::GetSecondsSinceEpoch ()) {};
|
||||
virtual ~TunnelBase () {};
|
||||
virtual void Cleanup () {};
|
||||
TunnelBase(uint32_t tunnelID, uint32_t nextTunnelID, i2p::data::IdentHash nextIdent) :
|
||||
m_TunnelID(tunnelID), m_NextTunnelID(nextTunnelID), m_NextIdent(nextIdent),
|
||||
m_CreationTime(i2p::util::GetSecondsSinceEpoch()) {};
|
||||
|
||||
virtual void HandleTunnelDataMsg (std::shared_ptr<i2p::I2NPMessage>&& tunnelMsg) = 0;
|
||||
virtual void SendTunnelDataMsg (std::shared_ptr<i2p::I2NPMessage> msg) = 0;
|
||||
virtual void FlushTunnelDataMsgs () {};
|
||||
virtual void EncryptTunnelMsg (std::shared_ptr<const I2NPMessage> in, std::shared_ptr<I2NPMessage> out) = 0;
|
||||
uint32_t GetNextTunnelID () const { return m_NextTunnelID; };
|
||||
const i2p::data::IdentHash& GetNextIdentHash () const { return m_NextIdent; };
|
||||
virtual uint32_t GetTunnelID () const { return m_TunnelID; }; // as known at our side
|
||||
virtual ~TunnelBase() {};
|
||||
|
||||
uint32_t GetCreationTime () const { return m_CreationTime; };
|
||||
void SetCreationTime (uint32_t t) { m_CreationTime = t; };
|
||||
virtual void Cleanup() {};
|
||||
|
||||
private:
|
||||
virtual void HandleTunnelDataMsg(std::shared_ptr<i2p::I2NPMessage> &&tunnelMsg) = 0;
|
||||
|
||||
uint32_t m_TunnelID, m_NextTunnelID;
|
||||
i2p::data::IdentHash m_NextIdent;
|
||||
uint32_t m_CreationTime; // seconds since epoch
|
||||
};
|
||||
virtual void SendTunnelDataMsg(std::shared_ptr<i2p::I2NPMessage> msg) = 0;
|
||||
|
||||
struct TunnelCreationTimeCmp
|
||||
{
|
||||
template<typename T>
|
||||
bool operator() (const std::shared_ptr<T> & t1, const std::shared_ptr<T> & t2) const
|
||||
{
|
||||
if (t1->GetCreationTime () != t2->GetCreationTime ())
|
||||
return t1->GetCreationTime () > t2->GetCreationTime ();
|
||||
else
|
||||
return t1 < t2;
|
||||
}
|
||||
};
|
||||
}
|
||||
virtual void FlushTunnelDataMsgs() {};
|
||||
|
||||
virtual void EncryptTunnelMsg(std::shared_ptr<const I2NPMessage> in, std::shared_ptr<I2NPMessage> out) = 0;
|
||||
|
||||
uint32_t GetNextTunnelID() const { return m_NextTunnelID; };
|
||||
|
||||
const i2p::data::IdentHash &GetNextIdentHash() const { return m_NextIdent; };
|
||||
|
||||
virtual uint32_t GetTunnelID() const { return m_TunnelID; }; // as known at our side
|
||||
|
||||
uint32_t GetCreationTime() const { return m_CreationTime; };
|
||||
|
||||
void SetCreationTime(uint32_t t) { m_CreationTime = t; };
|
||||
|
||||
private:
|
||||
|
||||
uint32_t m_TunnelID, m_NextTunnelID;
|
||||
i2p::data::IdentHash m_NextIdent;
|
||||
uint32_t m_CreationTime; // seconds since epoch
|
||||
};
|
||||
|
||||
struct TunnelCreationTimeCmp {
|
||||
template<typename T>
|
||||
bool operator()(const std::shared_ptr<T> &t1, const std::shared_ptr<T> &t2) const {
|
||||
if (t1->GetCreationTime() != t2->GetCreationTime())
|
||||
return t1->GetCreationTime() > t2->GetCreationTime();
|
||||
else
|
||||
return t1 < t2;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue