From 9e57a4ea2854d48d44c87c2e0f4a968cc558d184 Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 2 Feb 2017 20:45:33 -0500 Subject: [PATCH] use I2NP message of tunnel data length for TunnelData --- I2NPProtocol.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/I2NPProtocol.cpp b/I2NPProtocol.cpp index 96b30cb6..0a5031e7 100644 --- a/I2NPProtocol.cpp +++ b/I2NPProtocol.cpp @@ -27,6 +27,13 @@ namespace i2p return std::make_shared >(); } + std::shared_ptr NewI2NPTunnelMessage () + { + auto msg = new I2NPMessageBuffer(); // reserved for alignment and NTCP 16 + 6 + 12 + msg->Align (12); + return std::shared_ptr(msg); + } + std::shared_ptr NewI2NPMessage (size_t len) { return (len < I2NP_MAX_SHORT_MESSAGE_SIZE/2) ? NewI2NPShortMessage () : NewI2NPMessage (); @@ -464,7 +471,7 @@ namespace i2p std::shared_ptr CreateTunnelDataMsg (const uint8_t * buf) { - auto msg = NewI2NPShortMessage (); + auto msg = NewI2NPTunnelMessage (); msg->Concat (buf, i2p::tunnel::TUNNEL_DATA_MSG_SIZE); msg->FillI2NPMessageHeader (eI2NPTunnelData); return msg; @@ -472,7 +479,7 @@ namespace i2p std::shared_ptr CreateTunnelDataMsg (uint32_t tunnelID, const uint8_t * payload) { - auto msg = NewI2NPShortMessage (); + auto msg = NewI2NPTunnelMessage (); htobe32buf (msg->GetPayload (), tunnelID); msg->len += 4; // tunnelID msg->Concat (payload, i2p::tunnel::TUNNEL_DATA_MSG_SIZE - 4); @@ -482,7 +489,7 @@ namespace i2p std::shared_ptr CreateEmptyTunnelDataMsg () { - auto msg = NewI2NPShortMessage (); + auto msg = NewI2NPTunnelMessage (); msg->len += i2p::tunnel::TUNNEL_DATA_MSG_SIZE; return msg; }