mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 08:00:38 +03:00
handle individaul bitfields ack
This commit is contained in:
parent
02296ef775
commit
275155998f
34
SSUData.cpp
34
SSUData.cpp
@ -61,11 +61,39 @@ namespace ssu
|
||||
buf++;
|
||||
for (int i = 0; i < numBitfields; i++)
|
||||
{
|
||||
uint32_t msgID = be32toh (*(uint32_t *)buf);
|
||||
buf += 4; // msgID
|
||||
// TODO: process individual Ack bitfields
|
||||
while (*buf & 0x80) // not last
|
||||
auto it = m_SentMessages.find (msgID);
|
||||
int numSentFragments = it->second.size ();
|
||||
// process individual Ack bitfields
|
||||
bool isNonLast = false;
|
||||
int fragment = 0;
|
||||
do
|
||||
{
|
||||
uint8_t bitfield = *buf;
|
||||
isNonLast = bitfield & 0x80;
|
||||
bitfield &= 0x7F; // clear MSB
|
||||
if (bitfield && it != m_SentMessages.end ())
|
||||
{
|
||||
// process bits
|
||||
uint8_t mask = 0x40;
|
||||
for (int j = 0; j < 7; j++)
|
||||
{
|
||||
if (bitfield & mask)
|
||||
{
|
||||
if (fragment < numSentFragments)
|
||||
{
|
||||
delete it->second[fragment];
|
||||
it->second[fragment] = nullptr;
|
||||
}
|
||||
}
|
||||
fragment++;
|
||||
mask >>= 1;
|
||||
}
|
||||
}
|
||||
buf++;
|
||||
buf++; // last byte
|
||||
}
|
||||
while (isNonLast);
|
||||
}
|
||||
}
|
||||
uint8_t numFragments = *buf; // number of fragments
|
||||
|
Loading…
Reference in New Issue
Block a user