2013-11-11 03:19:49 +04:00
|
|
|
#ifndef TUNNEL_GATEWAY_H__
|
|
|
|
#define TUNNEL_GATEWAY_H__
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <vector>
|
|
|
|
#include "I2NPProtocol.h"
|
|
|
|
#include "TunnelBase.h"
|
|
|
|
|
|
|
|
namespace i2p
|
|
|
|
{
|
|
|
|
namespace tunnel
|
|
|
|
{
|
|
|
|
class TunnelGatewayBuffer
|
|
|
|
{
|
|
|
|
public:
|
2014-01-06 06:25:48 +04:00
|
|
|
TunnelGatewayBuffer (uint32_t tunnelID): m_TunnelID (tunnelID),
|
|
|
|
m_CurrentTunnelDataMsg (nullptr), m_RemainingSize (0) {};
|
2015-02-05 05:24:48 +03:00
|
|
|
~TunnelGatewayBuffer ();
|
2014-02-20 06:24:55 +04:00
|
|
|
void PutI2NPMsg (const TunnelMessageBlock& block);
|
2014-06-26 22:45:34 +04:00
|
|
|
const std::vector<I2NPMessage *>& GetTunnelDataMsgs () const { return m_TunnelDataMsgs; };
|
|
|
|
void ClearTunnelDataMsgs ();
|
|
|
|
void CompleteCurrentTunnelDataMessage ();
|
2013-11-11 03:19:49 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2014-01-06 06:25:48 +04:00
|
|
|
void CreateCurrentTunnelDataMessage ();
|
2013-11-11 03:19:49 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2013-11-29 16:52:09 +04:00
|
|
|
uint32_t m_TunnelID;
|
2014-01-06 06:25:48 +04:00
|
|
|
std::vector<I2NPMessage *> m_TunnelDataMsgs;
|
|
|
|
I2NPMessage * m_CurrentTunnelDataMsg;
|
|
|
|
size_t m_RemainingSize;
|
2013-11-11 03:19:49 +04:00
|
|
|
};
|
2013-11-13 16:56:16 +04:00
|
|
|
|
|
|
|
class TunnelGateway
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2013-11-29 16:52:09 +04:00
|
|
|
TunnelGateway (TunnelBase * tunnel):
|
|
|
|
m_Tunnel (tunnel), m_Buffer (tunnel->GetNextTunnelID ()), m_NumSentBytes (0) {};
|
2014-06-26 22:45:34 +04:00
|
|
|
void SendTunnelDataMsg (const TunnelMessageBlock& block);
|
|
|
|
void PutTunnelDataMsg (const TunnelMessageBlock& block);
|
|
|
|
void SendBuffer ();
|
2013-11-29 16:52:09 +04:00
|
|
|
size_t GetNumSentBytes () const { return m_NumSentBytes; };
|
2014-06-26 22:45:34 +04:00
|
|
|
|
2013-11-13 16:56:16 +04:00
|
|
|
private:
|
|
|
|
|
|
|
|
TunnelBase * m_Tunnel;
|
|
|
|
TunnelGatewayBuffer m_Buffer;
|
2013-11-29 16:52:09 +04:00
|
|
|
size_t m_NumSentBytes;
|
2013-11-13 16:56:16 +04:00
|
|
|
};
|
2013-11-11 03:19:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|