i2pd/LeaseSet.cpp

34 lines
626 B
C++
Raw Normal View History

2013-11-25 03:10:27 +04:00
#include "Log.h"
#include "LeaseSet.h"
namespace i2p
{
namespace data
{
2013-12-20 07:05:45 +04:00
2013-11-25 03:10:27 +04:00
LeaseSet::LeaseSet (const uint8_t * buf, int len)
{
#pragma pack(1)
struct H
{
Identity destination;
2013-11-25 03:10:27 +04:00
uint8_t encryptionKey[256];
uint8_t signingKey[128];
uint8_t num;
};
#pragma pack ()
const H * header = (const H *)buf;
2013-12-20 07:05:45 +04:00
m_Identity = header->destination;
m_IdentHash = CalculateIdentHash (m_Identity);
2013-11-25 03:10:27 +04:00
memcpy (m_EncryptionKey, header->encryptionKey, 256);
LogPrint ("LeaseSet num=", (int)header->num);
for (int i = 0; i < header->num; i++)
{
m_Leases.push_back (*(Lease *)(buf + sizeof (H)));
}
}
}
}