From 5ca86b87f5476737fbad14df9daa7ad84fff5986 Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 17 Jun 2015 12:08:06 -0400 Subject: [PATCH] create shared I2NP tunnel message in OBGW --- TunnelGateway.cpp | 8 +++----- TunnelGateway.h | 7 ++++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/TunnelGateway.cpp b/TunnelGateway.cpp index fbef1208..33935259 100644 --- a/TunnelGateway.cpp +++ b/TunnelGateway.cpp @@ -12,8 +12,6 @@ namespace tunnel { TunnelGatewayBuffer::~TunnelGatewayBuffer () { - for (auto it: m_TunnelDataMsgs) - DeleteI2NPMessage (it); } void TunnelGatewayBuffer::PutI2NPMsg (const TunnelMessageBlock& block) @@ -138,7 +136,7 @@ namespace tunnel void TunnelGatewayBuffer::CreateCurrentTunnelDataMessage () { - m_CurrentTunnelDataMsg = NewI2NPShortMessage (); + m_CurrentTunnelDataMsg = ToSharedI2NPMessage (NewI2NPShortMessage ()); m_CurrentTunnelDataMsg->Align (12); // we reserve space for padding m_CurrentTunnelDataMsg->offset += TUNNEL_DATA_MSG_SIZE + I2NP_HEADER_SIZE; @@ -192,8 +190,8 @@ namespace tunnel auto tunnelMsgs = m_Buffer.GetTunnelDataMsgs (); for (auto tunnelMsg : tunnelMsgs) { - m_Tunnel->EncryptTunnelMsg (tunnelMsg); - FillI2NPMessageHeader (tunnelMsg, eI2NPTunnelData); + m_Tunnel->EncryptTunnelMsg (tunnelMsg.get ()); // TODO: + FillI2NPMessageHeader (tunnelMsg.get (), eI2NPTunnelData); // TODO: m_NumSentBytes += TUNNEL_DATA_MSG_SIZE; } i2p::transport::transports.SendMessages (m_Tunnel->GetNextIdentHash (), tunnelMsgs); diff --git a/TunnelGateway.h b/TunnelGateway.h index b81c01d3..cfad17b5 100644 --- a/TunnelGateway.h +++ b/TunnelGateway.h @@ -3,6 +3,7 @@ #include #include +#include #include "I2NPProtocol.h" #include "TunnelBase.h" @@ -17,7 +18,7 @@ namespace tunnel m_CurrentTunnelDataMsg (nullptr), m_RemainingSize (0) {}; ~TunnelGatewayBuffer (); void PutI2NPMsg (const TunnelMessageBlock& block); - const std::vector& GetTunnelDataMsgs () const { return m_TunnelDataMsgs; }; + const std::vector >& GetTunnelDataMsgs () const { return m_TunnelDataMsgs; }; void ClearTunnelDataMsgs (); void CompleteCurrentTunnelDataMessage (); @@ -28,8 +29,8 @@ namespace tunnel private: uint32_t m_TunnelID; - std::vector m_TunnelDataMsgs; - I2NPMessage * m_CurrentTunnelDataMsg; + std::vector > m_TunnelDataMsgs; + std::shared_ptr m_CurrentTunnelDataMsg; size_t m_RemainingSize; };