mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 08:00:38 +03:00
created additional ranges if acnt > 255
This commit is contained in:
parent
206c068d8e
commit
ffab29890b
@ -2008,7 +2008,7 @@ namespace transport
|
|||||||
buf[0] = eSSU2BlkAck;
|
buf[0] = eSSU2BlkAck;
|
||||||
uint32_t ackThrough = m_OutOfSequencePackets.empty () ? m_ReceivePacketNum : *m_OutOfSequencePackets.rbegin ();
|
uint32_t ackThrough = m_OutOfSequencePackets.empty () ? m_ReceivePacketNum : *m_OutOfSequencePackets.rbegin ();
|
||||||
htobe32buf (buf + 3, ackThrough); // Ack Through
|
htobe32buf (buf + 3, ackThrough); // Ack Through
|
||||||
uint8_t acnt = 0;
|
uint16_t acnt = 0;
|
||||||
int numRanges = 0;
|
int numRanges = 0;
|
||||||
if (ackThrough)
|
if (ackThrough)
|
||||||
{
|
{
|
||||||
@ -2024,6 +2024,27 @@ namespace transport
|
|||||||
}
|
}
|
||||||
// ranges
|
// ranges
|
||||||
uint32_t lastNum = ackThrough - acnt;
|
uint32_t lastNum = ackThrough - acnt;
|
||||||
|
if (acnt > 255)
|
||||||
|
{
|
||||||
|
auto d = std::div (acnt - 255, 255);
|
||||||
|
acnt = 255;
|
||||||
|
if (d.quot > SSU2_MAX_NUM_ACK_RANGES)
|
||||||
|
{
|
||||||
|
d.quot = SSU2_MAX_NUM_ACK_RANGES;
|
||||||
|
d.rem = 0;
|
||||||
|
}
|
||||||
|
// Acks only ragnes for acnt
|
||||||
|
for (int i = 0; i < d.quot; i++)
|
||||||
|
{
|
||||||
|
buf[8 + numRanges*2] = 0; buf[8 + numRanges*2 + 1] = 255; // NACKs 0, Acks 255
|
||||||
|
numRanges++;
|
||||||
|
}
|
||||||
|
if (d.rem > 0)
|
||||||
|
{
|
||||||
|
buf[8 + numRanges*2] = 0; buf[8 + numRanges*2 + 1] = d.rem;
|
||||||
|
numRanges++;
|
||||||
|
}
|
||||||
|
}
|
||||||
while (it != m_OutOfSequencePackets.rend () && numRanges < SSU2_MAX_NUM_ACK_RANGES)
|
while (it != m_OutOfSequencePackets.rend () && numRanges < SSU2_MAX_NUM_ACK_RANGES)
|
||||||
{
|
{
|
||||||
if (lastNum - (*it) > 255)
|
if (lastNum - (*it) > 255)
|
||||||
@ -2073,7 +2094,7 @@ namespace transport
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buf[7] = acnt; // acnt
|
buf[7] = (uint8_t)acnt; // acnt
|
||||||
htobe16buf (buf + 1, 5 + numRanges*2);
|
htobe16buf (buf + 1, 5 + numRanges*2);
|
||||||
return 8 + numRanges*2;
|
return 8 + numRanges*2;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user