Browse Source

delete deprecated SendPacket

pull/93/head
orignal 10 years ago
parent
commit
2e1a8552bf
  1. 60
      Streaming.cpp
  2. 1
      Streaming.h

60
Streaming.cpp

@ -289,7 +289,8 @@ namespace stream
void Stream::SendQuickAck () void Stream::SendQuickAck ()
{ {
uint8_t packet[MAX_PACKET_SIZE]; Packet p;
uint8_t * packet = p.GetBuffer ();
size_t size = 0; size_t size = 0;
*(uint32_t *)(packet + size) = htobe32 (m_SendStreamID); *(uint32_t *)(packet + size) = htobe32 (m_SendStreamID);
size += 4; // sendStreamID size += 4; // sendStreamID
@ -306,8 +307,9 @@ namespace stream
size += 2; // flags size += 2; // flags
*(uint16_t *)(packet + size) = 0; // no options *(uint16_t *)(packet + size) = 0; // no options
size += 2; // options size size += 2; // options size
p.len = size;
if (SendPacket (packet, size)) std::vector<Packet *> { &p };
LogPrint ("Quick Ack sent"); LogPrint ("Quick Ack sent");
} }
@ -368,66 +370,14 @@ namespace stream
{ {
if (packet) if (packet)
{ {
bool ret = SendPacket (packet->GetBuffer (), packet->GetLength ()); SendPackets (std::vector<Packet *> { packet });
if (ret)
{
bool isEmpty = m_SentPackets.empty (); bool isEmpty = m_SentPackets.empty ();
m_SentPackets.insert (packet); m_SentPackets.insert (packet);
if (isEmpty) if (isEmpty)
ScheduleResend (); ScheduleResend ();
}
else
delete packet;
return ret;
}
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; return true;
} }
else else
{
LogPrint ("All leases are expired");
DeleteI2NPMessage (msg);
}
}
else
{
LogPrint ("No outbound tunnels in the pool");
DeleteI2NPMessage (msg);
}
return false; return false;
} }

1
Streaming.h

@ -103,7 +103,6 @@ namespace stream
void SendQuickAck (); void SendQuickAck ();
bool SendPacket (Packet * packet); bool SendPacket (Packet * packet);
bool SendPacket (const uint8_t * buf, size_t len); // TODO: remove
void SendPackets (const std::vector<Packet *>& packets); void SendPackets (const std::vector<Packet *>& packets);
void SavePacket (Packet * packet); void SavePacket (Packet * packet);

Loading…
Cancel
Save