mirror of https://github.com/PurpleI2P/i2pd.git
I2P: End-to-End encrypted and anonymous Internet
https://i2pd.website/
58 lines
1.5 KiB
58 lines
1.5 KiB
11 years ago
|
#ifndef TUNNEL_ENDPOINT_H__
|
||
|
#define TUNNEL_ENDPOINT_H__
|
||
|
|
||
|
#include <inttypes.h>
|
||
|
#include <map>
|
||
|
#include <string>
|
||
|
#include "I2NPProtocol.h"
|
||
|
#include "TunnelBase.h"
|
||
|
|
||
|
namespace i2p
|
||
|
{
|
||
|
namespace tunnel
|
||
|
{
|
||
|
class TunnelEndpoint
|
||
|
{
|
||
11 years ago
|
struct TunnelMessageBlockEx: public TunnelMessageBlock
|
||
|
{
|
||
8 years ago
|
uint64_t receiveTime; // milliseconds since epoch
|
||
11 years ago
|
uint8_t nextFragmentNum;
|
||
|
};
|
||
10 years ago
|
|
||
|
struct Fragment
|
||
|
{
|
||
|
bool isLastFragment;
|
||
10 years ago
|
std::shared_ptr<I2NPMessage> data;
|
||
8 years ago
|
uint64_t receiveTime; // milliseconds since epoch
|
||
10 years ago
|
};
|
||
11 years ago
|
|
||
11 years ago
|
public:
|
||
|
|
||
11 years ago
|
TunnelEndpoint (bool isInbound): m_IsInbound (isInbound), m_NumReceivedBytes (0) {};
|
||
11 years ago
|
~TunnelEndpoint ();
|
||
11 years ago
|
size_t GetNumReceivedBytes () const { return m_NumReceivedBytes; };
|
||
8 years ago
|
void Cleanup ();
|
||
|
|
||
10 years ago
|
void HandleDecryptedTunnelDataMsg (std::shared_ptr<I2NPMessage> msg);
|
||
11 years ago
|
|
||
|
private:
|
||
|
|
||
11 years ago
|
void HandleFollowOnFragment (uint32_t msgID, bool isLastFragment, const TunnelMessageBlockEx& m);
|
||
11 years ago
|
void HandleNextMessage (const TunnelMessageBlock& msg);
|
||
10 years ago
|
|
||
10 years ago
|
void AddOutOfSequenceFragment (uint32_t msgID, uint8_t fragmentNum, bool isLastFragment, std::shared_ptr<I2NPMessage> data);
|
||
8 years ago
|
bool ConcatNextOutOfSequenceFragment (uint32_t msgID, TunnelMessageBlockEx& msg); // true if something added
|
||
|
void HandleOutOfSequenceFragments (uint32_t msgID, TunnelMessageBlockEx& msg);
|
||
|
|
||
11 years ago
|
private:
|
||
11 years ago
|
|
||
|
std::map<uint32_t, TunnelMessageBlockEx> m_IncompleteMessages;
|
||
8 years ago
|
std::map<std::pair<uint32_t, uint8_t>, Fragment> m_OutOfSequenceFragments; // (msgID, fragment#)->fragment
|
||
11 years ago
|
bool m_IsInbound;
|
||
11 years ago
|
size_t m_NumReceivedBytes;
|
||
11 years ago
|
};
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endif
|