mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 06:54:15 +00:00
eliminate misalignment for LeaseSet
This commit is contained in:
parent
4b47bfb5db
commit
9a7e21778e
22
LeaseSet.cpp
22
LeaseSet.cpp
@ -42,14 +42,14 @@ namespace data
|
|||||||
// leases
|
// leases
|
||||||
for (auto it: tunnels)
|
for (auto it: tunnels)
|
||||||
{
|
{
|
||||||
Lease lease;
|
memcpy (m_Buffer + m_BufferLen, it->GetNextIdentHash (), 32);
|
||||||
memcpy (lease.tunnelGateway, it->GetNextIdentHash (), 32);
|
m_BufferLen += 32; // gateway id
|
||||||
lease.tunnelID = htobe32 (it->GetNextTunnelID ());
|
htobe32buf (m_Buffer + m_BufferLen, it->GetNextTunnelID ());
|
||||||
|
m_BufferLen += 4; // tunnel id
|
||||||
uint64_t ts = it->GetCreationTime () + i2p::tunnel::TUNNEL_EXPIRATION_TIMEOUT - 60; // 1 minute before expiration
|
uint64_t ts = it->GetCreationTime () + i2p::tunnel::TUNNEL_EXPIRATION_TIMEOUT - 60; // 1 minute before expiration
|
||||||
ts *= 1000; // in milliseconds
|
ts *= 1000; // in milliseconds
|
||||||
lease.endDate = htobe64 (ts);
|
htobe64buf (m_Buffer + m_BufferLen, ts);
|
||||||
memcpy(m_Buffer + m_BufferLen, &lease, sizeof(Lease));
|
m_BufferLen += 8; // end date
|
||||||
m_BufferLen += sizeof (Lease);
|
|
||||||
}
|
}
|
||||||
// signature
|
// signature
|
||||||
localDestination->Sign (m_Buffer, m_BufferLen, m_Buffer + m_BufferLen);
|
localDestination->Sign (m_Buffer, m_BufferLen, m_Buffer + m_BufferLen);
|
||||||
@ -82,11 +82,13 @@ namespace data
|
|||||||
for (int i = 0; i < num; i++)
|
for (int i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
Lease lease;
|
Lease lease;
|
||||||
memcpy (&lease, leases, sizeof(Lease));
|
lease.tunnelGateway = leases;
|
||||||
lease.tunnelID = be32toh (lease.tunnelID);
|
leases += 32; // gateway
|
||||||
lease.endDate = be64toh (lease.endDate);
|
lease.tunnelID = bufbe32toh (leases);
|
||||||
|
leases += 4; // tunnel ID
|
||||||
|
lease.endDate = bufbe64toh (leases);
|
||||||
|
leases += 8; // end date
|
||||||
m_Leases.push_back (lease);
|
m_Leases.push_back (lease);
|
||||||
leases += sizeof (Lease);
|
|
||||||
|
|
||||||
// check if lease's gateway is in our netDb
|
// check if lease's gateway is in our netDb
|
||||||
if (!netdb.FindRouter (lease.tunnelGateway))
|
if (!netdb.FindRouter (lease.tunnelGateway))
|
||||||
|
@ -16,12 +16,9 @@ namespace tunnel
|
|||||||
|
|
||||||
namespace data
|
namespace data
|
||||||
{
|
{
|
||||||
|
|
||||||
#pragma pack(1)
|
|
||||||
|
|
||||||
struct Lease
|
struct Lease
|
||||||
{
|
{
|
||||||
uint8_t tunnelGateway[32];
|
IdentHash tunnelGateway;
|
||||||
uint32_t tunnelID;
|
uint32_t tunnelID;
|
||||||
uint64_t endDate;
|
uint64_t endDate;
|
||||||
|
|
||||||
@ -33,8 +30,6 @@ namespace data
|
|||||||
return tunnelID < other.tunnelID;
|
return tunnelID < other.tunnelID;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack()
|
|
||||||
|
|
||||||
const int MAX_LS_BUFFER_SIZE = 3072;
|
const int MAX_LS_BUFFER_SIZE = 3072;
|
||||||
class LeaseSet: public RoutingDestination
|
class LeaseSet: public RoutingDestination
|
||||||
|
Loading…
x
Reference in New Issue
Block a user