From 2e1a8552bf09f7b16dffdab0083fbb9f48215cdb Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 12 Aug 2014 16:52:04 -0400 Subject: [PATCH] delete deprecated SendPacket --- Streaming.cpp | 74 +++++++++------------------------------------------ Streaming.h | 1 - 2 files changed, 12 insertions(+), 63 deletions(-) diff --git a/Streaming.cpp b/Streaming.cpp index d9730622..bbc6bd30 100644 --- a/Streaming.cpp +++ b/Streaming.cpp @@ -289,7 +289,8 @@ namespace stream void Stream::SendQuickAck () { - uint8_t packet[MAX_PACKET_SIZE]; + Packet p; + uint8_t * packet = p.GetBuffer (); size_t size = 0; *(uint32_t *)(packet + size) = htobe32 (m_SendStreamID); size += 4; // sendStreamID @@ -306,9 +307,10 @@ namespace stream size += 2; // flags *(uint16_t *)(packet + size) = 0; // no options size += 2; // options size - - if (SendPacket (packet, size)) - LogPrint ("Quick Ack sent"); + p.len = size; + + std::vector { &p }; + LogPrint ("Quick Ack sent"); } void Stream::Close () @@ -368,69 +370,17 @@ namespace stream { if (packet) { - bool ret = SendPacket (packet->GetBuffer (), packet->GetLength ()); - if (ret) - { - bool isEmpty = m_SentPackets.empty (); - m_SentPackets.insert (packet); - if (isEmpty) - ScheduleResend (); - } - else - delete packet; - return ret; + SendPackets (std::vector { packet }); + bool isEmpty = m_SentPackets.empty (); + m_SentPackets.insert (packet); + if (isEmpty) + ScheduleResend (); + return true; } else return false; } - bool Stream::SendPacket (const uint8_t * buf, size_t len) - { - if (!m_RemoteLeaseSet) - { - UpdateCurrentRemoteLease (); - if (!m_RemoteLeaseSet) - { - LogPrint ("Can't send packet. Missing remote LeaseSet"); - return false; - } - } - - I2NPMessage * leaseSet = nullptr; - - if (m_LeaseSetUpdated) - { - leaseSet = m_LocalDestination->GetLeaseSetMsg (); - m_LeaseSetUpdated = false; - } - - I2NPMessage * msg = i2p::garlic::routing.WrapMessage (*m_RemoteLeaseSet, - CreateDataMessage (this, buf, len), leaseSet); - auto outboundTunnel = m_LocalDestination->GetTunnelPool ()->GetNextOutboundTunnel (); - if (outboundTunnel) - { - auto ts = i2p::util::GetMillisecondsSinceEpoch (); - if (ts >= m_CurrentRemoteLease.endDate) - UpdateCurrentRemoteLease (); - if (ts < m_CurrentRemoteLease.endDate) - { - outboundTunnel->SendTunnelDataMsg (m_CurrentRemoteLease.tunnelGateway, m_CurrentRemoteLease.tunnelID, msg); - return true; - } - else - { - LogPrint ("All leases are expired"); - DeleteI2NPMessage (msg); - } - } - else - { - LogPrint ("No outbound tunnels in the pool"); - DeleteI2NPMessage (msg); - } - return false; - } - void Stream::SendPackets (const std::vector& packets) { if (!m_RemoteLeaseSet) diff --git a/Streaming.h b/Streaming.h index ea6443c8..5fa346a4 100644 --- a/Streaming.h +++ b/Streaming.h @@ -103,7 +103,6 @@ namespace stream void SendQuickAck (); bool SendPacket (Packet * packet); - bool SendPacket (const uint8_t * buf, size_t len); // TODO: remove void SendPackets (const std::vector& packets); void SavePacket (Packet * packet);