2020-05-22 16:18:41 +03:00
|
|
|
/*
|
2024-11-28 21:56:26 -05:00
|
|
|
* Copyright (c) 2013-2024, The PurpleI2P Project
|
2020-05-22 16:18:41 +03:00
|
|
|
*
|
|
|
|
* This file is part of Purple i2pd project and licensed under BSD3
|
|
|
|
*
|
|
|
|
* See full license text in LICENSE file at top of project tree
|
|
|
|
*/
|
|
|
|
|
2013-11-10 18:19:49 -05:00
|
|
|
#ifndef TUNNEL_GATEWAY_H__
|
|
|
|
#define TUNNEL_GATEWAY_H__
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <vector>
|
2015-06-17 12:08:06 -04:00
|
|
|
#include <memory>
|
2013-11-10 18:19:49 -05:00
|
|
|
#include "I2NPProtocol.h"
|
|
|
|
#include "TunnelBase.h"
|
|
|
|
|
|
|
|
namespace i2p
|
|
|
|
{
|
|
|
|
namespace tunnel
|
|
|
|
{
|
|
|
|
class TunnelGatewayBuffer
|
|
|
|
{
|
|
|
|
public:
|
2017-02-03 20:57:04 -05:00
|
|
|
TunnelGatewayBuffer ();
|
2015-02-04 21:24:48 -05:00
|
|
|
~TunnelGatewayBuffer ();
|
2018-01-06 11:48:51 +08:00
|
|
|
void PutI2NPMsg (const TunnelMessageBlock& block);
|
2017-02-03 20:57:04 -05:00
|
|
|
const std::vector<std::shared_ptr<const 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 ();
|
2018-01-06 11:48:51 +08:00
|
|
|
|
2013-11-10 18:19:49 -05:00
|
|
|
private:
|
|
|
|
|
2017-02-03 20:57:04 -05:00
|
|
|
std::vector<std::shared_ptr<const I2NPMessage> > m_TunnelDataMsgs;
|
2015-06-17 12:08:06 -04:00
|
|
|
std::shared_ptr<I2NPMessage> m_CurrentTunnelDataMsg;
|
2014-01-05 21:25:48 -05:00
|
|
|
size_t m_RemainingSize;
|
2021-11-20 18:31:18 -05:00
|
|
|
uint8_t * m_NonZeroRandomBuffer;
|
2018-01-06 11:48:51 +08:00
|
|
|
};
|
2013-11-13 07:56:16 -05:00
|
|
|
|
|
|
|
class TunnelGateway
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2024-11-29 11:31:13 -05:00
|
|
|
TunnelGateway (TunnelBase& tunnel):
|
2017-02-03 20:57:04 -05:00
|
|
|
m_Tunnel (tunnel), m_NumSentBytes (0) {};
|
2018-01-06 11:48:51 +08:00
|
|
|
void SendTunnelDataMsg (const TunnelMessageBlock& block);
|
2014-06-26 14:45:34 -04:00
|
|
|
void PutTunnelDataMsg (const TunnelMessageBlock& block);
|
2018-01-06 11:48:51 +08:00
|
|
|
void SendBuffer ();
|
2013-11-29 07:52:09 -05:00
|
|
|
size_t GetNumSentBytes () const { return m_NumSentBytes; };
|
2024-12-16 19:49:14 -05:00
|
|
|
const std::unique_ptr<TunnelTransportSender>& GetSender () const { return m_Sender; };
|
2018-01-06 11:48:51 +08:00
|
|
|
|
2013-11-13 07:56:16 -05:00
|
|
|
private:
|
|
|
|
|
2024-11-29 11:31:13 -05:00
|
|
|
TunnelBase& m_Tunnel;
|
2013-11-13 07:56:16 -05:00
|
|
|
TunnelGatewayBuffer m_Buffer;
|
2013-11-29 07:52:09 -05:00
|
|
|
size_t m_NumSentBytes;
|
2024-12-15 18:03:31 -05:00
|
|
|
std::unique_ptr<TunnelTransportSender> m_Sender;
|
2018-01-06 11:48:51 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2013-11-10 18:19:49 -05:00
|
|
|
|
|
|
|
#endif
|