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
|
|
|
|
{
|
|
|
|
struct TunnelMessageBlockExt: public TunnelMessageBlock
|
|
|
|
{
|
|
|
|
size_t deliveryInstructionsLen, totalLen;
|
2013-11-23 01:41:28 +00:00
|
|
|
bool isFragmented;
|
2013-11-10 23:19:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-11-23 01:41:28 +00:00
|
|
|
TunnelGatewayBuffer (): m_Remaining (0) {};
|
|
|
|
|
2013-11-10 23:19:49 +00:00
|
|
|
void PutI2NPMsg (const uint8_t * gwHash, uint32_t gwTunnel, I2NPMessage * msg);
|
|
|
|
std::vector<I2NPMessage *> GetTunnelDataMsgs (uint32_t tunnelID);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
size_t CreateFirstFragment (TunnelMessageBlockExt * block, uint8_t * buf, size_t len);
|
|
|
|
size_t CreateFollowOnFragment (TunnelMessageBlockExt * block, uint8_t * buf, size_t len);
|
2013-11-23 01:41:28 +00:00
|
|
|
I2NPMessage * CreateNextTunnelMessage (uint32_t tunnelID, int& ind);
|
2013-11-10 23:19:49 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
std::vector<TunnelMessageBlockExt *> m_I2NPMsgs;
|
|
|
|
// for fragmented messages
|
2013-11-23 01:41:28 +00:00
|
|
|
size_t m_NextOffset, m_NextSeqn, m_Remaining;
|
2013-11-10 23:19:49 +00:00
|
|
|
uint32_t m_NextMsgID;
|
|
|
|
};
|
2013-11-13 12:56:16 +00:00
|
|
|
|
|
|
|
class TunnelGateway
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
TunnelGateway (TunnelBase * tunnel): m_Tunnel (tunnel) {};
|
|
|
|
void SendTunnelDataMsg (const uint8_t * gwHash, uint32_t gwTunnel, i2p::I2NPMessage * msg);
|
2013-11-23 01:41:28 +00:00
|
|
|
void PutTunnelDataMsg (const uint8_t * gwHash, uint32_t gwTunnel, i2p::I2NPMessage * msg);
|
|
|
|
void SendBuffer ();
|
2013-11-13 12:56:16 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
TunnelBase * m_Tunnel;
|
|
|
|
TunnelGatewayBuffer m_Buffer;
|
|
|
|
};
|
2013-11-10 23:19:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|