1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-15 13:49:56 +00:00
i2pd/TunnelGateway.h

58 lines
1.3 KiB
C
Raw Permalink Normal View History

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