2013-11-11 03:19:49 +04:00
|
|
|
#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
|
|
|
|
{
|
2014-07-05 04:54:03 +04:00
|
|
|
struct TunnelMessageBlockEx: public TunnelMessageBlock
|
|
|
|
{
|
|
|
|
uint8_t nextFragmentNum;
|
|
|
|
};
|
2014-09-11 05:31:32 +04:00
|
|
|
|
|
|
|
struct Fragment
|
|
|
|
{
|
|
|
|
uint8_t fragmentNum;
|
|
|
|
bool isLastFragment;
|
2015-06-19 21:38:31 +03:00
|
|
|
std::shared_ptr<I2NPMessage> data;
|
2014-09-11 05:31:32 +04:00
|
|
|
};
|
2014-07-05 04:54:03 +04:00
|
|
|
|
2013-11-11 03:19:49 +04:00
|
|
|
public:
|
|
|
|
|
2014-07-10 20:44:49 +04:00
|
|
|
TunnelEndpoint (bool isInbound): m_IsInbound (isInbound), m_NumReceivedBytes (0) {};
|
2014-07-05 16:33:08 +04:00
|
|
|
~TunnelEndpoint ();
|
2013-12-10 17:10:49 +04:00
|
|
|
size_t GetNumReceivedBytes () const { return m_NumReceivedBytes; };
|
|
|
|
|
2015-06-19 21:38:31 +03:00
|
|
|
void HandleDecryptedTunnelDataMsg (std::shared_ptr<I2NPMessage> msg);
|
2013-11-11 03:19:49 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2014-07-05 04:54:03 +04:00
|
|
|
void HandleFollowOnFragment (uint32_t msgID, bool isLastFragment, const TunnelMessageBlockEx& m);
|
2013-11-11 03:19:49 +04:00
|
|
|
void HandleNextMessage (const TunnelMessageBlock& msg);
|
2014-09-11 05:31:32 +04:00
|
|
|
|
2015-06-19 21:38:31 +03:00
|
|
|
void AddOutOfSequenceFragment (uint32_t msgID, uint8_t fragmentNum, bool isLastFragment, std::shared_ptr<I2NPMessage> data);
|
2014-09-11 05:31:32 +04:00
|
|
|
void HandleOutOfSequenceFragment (uint32_t msgID, TunnelMessageBlockEx& msg);
|
2013-11-11 03:19:49 +04:00
|
|
|
|
2014-07-05 04:54:03 +04:00
|
|
|
private:
|
2014-06-11 18:56:20 +04:00
|
|
|
|
|
|
|
std::map<uint32_t, TunnelMessageBlockEx> m_IncompleteMessages;
|
2014-09-11 05:31:32 +04:00
|
|
|
std::map<uint32_t, Fragment> m_OutOfSequenceFragments;
|
2014-07-10 20:44:49 +04:00
|
|
|
bool m_IsInbound;
|
2013-12-10 17:10:49 +04:00
|
|
|
size_t m_NumReceivedBytes;
|
2013-11-11 03:19:49 +04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|