Browse Source

use shared_ptr for DeliverStatus

pull/225/head
orignal 10 years ago
parent
commit
206f094dd4
  1. 2
      Garlic.cpp
  2. 4
      I2NPProtocol.cpp
  3. 2
      I2NPProtocol.h
  4. 7
      NetDb.cpp
  5. 2
      SSUSession.cpp
  6. 2
      TunnelPool.cpp

2
Garlic.cpp

@ -307,7 +307,7 @@ namespace garlic @@ -307,7 +307,7 @@ namespace garlic
htobe32buf (buf + size, inboundTunnel->GetNextTunnelID ()); // tunnelID
size += 4;
// create msg
auto msg = ToSharedI2NPMessage (CreateDeliveryStatusMsg (msgID));
auto msg = CreateDeliveryStatusMsg (msgID);
if (m_Owner)
{
//encrypt

4
I2NPProtocol.cpp

@ -90,7 +90,7 @@ namespace i2p @@ -90,7 +90,7 @@ namespace i2p
return msg;
}
I2NPMessage * CreateDeliveryStatusMsg (uint32_t msgID)
std::shared_ptr<I2NPMessage> CreateDeliveryStatusMsg (uint32_t msgID)
{
I2NPMessage * m = NewI2NPShortMessage ();
uint8_t * buf = m->GetPayload ();
@ -106,7 +106,7 @@ namespace i2p @@ -106,7 +106,7 @@ namespace i2p
}
m->len += DELIVERY_STATUS_SIZE;
FillI2NPMessageHeader (m, eI2NPDeliveryStatus);
return m;
return ToSharedI2NPMessage (m);
}
I2NPMessage * CreateRouterInfoDatabaseLookupMsg (const uint8_t * key, const uint8_t * from,

2
I2NPProtocol.h

@ -203,7 +203,7 @@ namespace tunnel @@ -203,7 +203,7 @@ namespace tunnel
I2NPMessage * CreateI2NPMessage (I2NPMessageType msgType, const uint8_t * buf, int len, uint32_t replyMsgID = 0);
I2NPMessage * CreateI2NPMessage (const uint8_t * buf, int len, std::shared_ptr<i2p::tunnel::InboundTunnel> from = nullptr);
I2NPMessage * CreateDeliveryStatusMsg (uint32_t msgID);
std::shared_ptr<I2NPMessage> CreateDeliveryStatusMsg (uint32_t msgID);
I2NPMessage * CreateRouterInfoDatabaseLookupMsg (const uint8_t * key, const uint8_t * from,
uint32_t replyTunnelID, bool exploratory = false, std::set<i2p::data::IdentHash> * excludedPeers = nullptr);
I2NPMessage * CreateLeaseSetDatabaseLookupMsg (const i2p::data::IdentHash& dest,

7
NetDb.cpp

@ -471,18 +471,15 @@ namespace data @@ -471,18 +471,15 @@ namespace data
uint32_t tunnelID = bufbe32toh (buf + offset);
offset += 4;
if (!tunnelID) // send response directly
transports.SendMessage (buf + offset, ToSharedI2NPMessage (deliveryStatus));
transports.SendMessage (buf + offset, deliveryStatus);
else
{
auto pool = i2p::tunnel::tunnels.GetExploratoryPool ();
auto outbound = pool ? pool->GetNextOutboundTunnel () : nullptr;
if (outbound)
outbound->SendTunnelDataMsg (buf + offset, tunnelID, ToSharedI2NPMessage (deliveryStatus));
outbound->SendTunnelDataMsg (buf + offset, tunnelID, deliveryStatus);
else
{
LogPrint (eLogError, "No outbound tunnels for DatabaseStore reply found");
DeleteI2NPMessage (deliveryStatus);
}
}
offset += 32;

2
SSUSession.cpp

@ -262,7 +262,7 @@ namespace transport @@ -262,7 +262,7 @@ namespace transport
if (paddingSize > 0) paddingSize = 16 - paddingSize;
payload += paddingSize;
// TODO: verify signature (need data from session request), payload points to signature
m_Data.Send (ToSharedI2NPMessage(CreateDeliveryStatusMsg (0)));
m_Data.Send (CreateDeliveryStatusMsg (0));
Established ();
}

2
TunnelPool.cpp

@ -254,7 +254,7 @@ namespace tunnel @@ -254,7 +254,7 @@ namespace tunnel
uint32_t msgID = rnd.GenerateWord32 ();
m_Tests[msgID] = std::make_pair (*it1, *it2);
(*it1)->SendTunnelDataMsg ((*it2)->GetNextIdentHash (), (*it2)->GetNextTunnelID (),
ToSharedI2NPMessage (CreateDeliveryStatusMsg (msgID)));
CreateDeliveryStatusMsg (msgID));
it1++; it2++;
}
}

Loading…
Cancel
Save