2013-11-10 23:19:49 +00:00
|
|
|
#ifndef TUNNEL_GATEWAY_H__
|
|
|
|
#define TUNNEL_GATEWAY_H__
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <vector>
|
2015-06-17 16:08:06 +00:00
|
|
|
#include <memory>
|
2013-11-10 23:19:49 +00:00
|
|
|
#include "I2NPProtocol.h"
|
|
|
|
#include "TunnelBase.h"
|
|
|
|
|
|
|
|
namespace i2p
|
|
|
|
{
|
|
|
|
namespace tunnel
|
|
|
|
{
|
|
|
|
class TunnelGatewayBuffer
|
|
|
|
{
|
|
|
|
public:
|
2017-02-04 01:57:04 +00:00
|
|
|
TunnelGatewayBuffer ();
|
2015-02-05 02:24:48 +00:00
|
|
|
~TunnelGatewayBuffer ();
|
2014-02-20 02:24:55 +00:00
|
|
|
void PutI2NPMsg (const TunnelMessageBlock& block);
|
2017-02-04 01:57:04 +00:00
|
|
|
const std::vector<std::shared_ptr<const I2NPMessage> >& GetTunnelDataMsgs () const { return m_TunnelDataMsgs; };
|
2014-06-26 18:45:34 +00:00
|
|
|
void ClearTunnelDataMsgs ();
|
|
|
|
void CompleteCurrentTunnelDataMessage ();
|
2013-11-10 23:19:49 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2014-01-06 02:25:48 +00:00
|
|
|
void CreateCurrentTunnelDataMessage ();
|
2013-11-10 23:19:49 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2017-02-04 01:57:04 +00:00
|
|
|
std::vector<std::shared_ptr<const I2NPMessage> > m_TunnelDataMsgs;
|
2015-06-17 16:08:06 +00:00
|
|
|
std::shared_ptr<I2NPMessage> m_CurrentTunnelDataMsg;
|
2014-01-06 02:25:48 +00:00
|
|
|
size_t m_RemainingSize;
|
2015-06-26 20:06:59 +00:00
|
|
|
uint8_t m_NonZeroRandomBuffer[TUNNEL_DATA_MAX_PAYLOAD_SIZE];
|
2013-11-10 23:19:49 +00:00
|
|
|
};
|
2013-11-13 12:56:16 +00:00
|
|
|
|
|
|
|
class TunnelGateway
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2015-06-26 20:06:59 +00:00
|
|
|
TunnelGateway (TunnelBase * tunnel):
|
2017-02-04 01:57:04 +00:00
|
|
|
m_Tunnel (tunnel), m_NumSentBytes (0) {};
|
2014-06-26 18:45:34 +00:00
|
|
|
void SendTunnelDataMsg (const TunnelMessageBlock& block);
|
|
|
|
void PutTunnelDataMsg (const TunnelMessageBlock& block);
|
|
|
|
void SendBuffer ();
|
2013-11-29 12:52:09 +00:00
|
|
|
size_t GetNumSentBytes () const { return m_NumSentBytes; };
|
2014-06-26 18:45:34 +00:00
|
|
|
|
2013-11-13 12:56:16 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
TunnelBase * m_Tunnel;
|
|
|
|
TunnelGatewayBuffer m_Buffer;
|
2013-11-29 12:52:09 +00:00
|
|
|
size_t m_NumSentBytes;
|
2013-11-13 12:56:16 +00:00
|
|
|
};
|
2013-11-10 23:19:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|