i2pd/TunnelGateway.h

55 lines
1.3 KiB
C
Raw Normal View History

2013-11-10 23:19:49 +00: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 02:25:48 +00:00
TunnelGatewayBuffer (uint32_t tunnelID): m_TunnelID (tunnelID),
m_CurrentTunnelDataMsg (nullptr), m_RemainingSize (0) {};
2013-11-10 23:19:49 +00:00
void PutI2NPMsg (const uint8_t * gwHash, uint32_t gwTunnel, I2NPMessage * msg);
2013-11-29 12:52:09 +00:00
std::vector<I2NPMessage *> GetTunnelDataMsgs ();
2013-11-10 23:19:49 +00:00
private:
2014-01-06 02:25:48 +00:00
void CreateCurrentTunnelDataMessage ();
void CompleteCurrentTunnelDataMessage ();
2013-11-10 23:19:49 +00:00
private:
2013-11-29 12:52:09 +00:00
uint32_t m_TunnelID;
2014-01-06 02:25:48 +00:00
std::vector<I2NPMessage *> m_TunnelDataMsgs;
I2NPMessage * m_CurrentTunnelDataMsg;
size_t m_RemainingSize;
2013-11-10 23:19:49 +00:00
};
class TunnelGateway
{
public:
2013-11-29 12:52:09 +00:00
TunnelGateway (TunnelBase * tunnel):
m_Tunnel (tunnel), m_Buffer (tunnel->GetNextTunnelID ()), m_NumSentBytes (0) {};
void SendTunnelDataMsg (const uint8_t * gwHash, uint32_t gwTunnel, i2p::I2NPMessage * msg);
void PutTunnelDataMsg (const uint8_t * gwHash, uint32_t gwTunnel, i2p::I2NPMessage * msg);
void SendBuffer ();
2013-11-29 12:52:09 +00:00
size_t GetNumSentBytes () const { return m_NumSentBytes; };
private:
TunnelBase * m_Tunnel;
TunnelGatewayBuffer m_Buffer;
2013-11-29 12:52:09 +00:00
size_t m_NumSentBytes;
};
2013-11-10 23:19:49 +00:00
}
}
#endif