mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2024-11-16 00:12:43 +00:00
immediate ack request flag
This commit is contained in:
parent
1a32c55ca3
commit
1a9c658836
@ -367,10 +367,11 @@ namespace transport
|
|||||||
};
|
};
|
||||||
if (packet->payloadSize > ackBlockSize)
|
if (packet->payloadSize > ackBlockSize)
|
||||||
{
|
{
|
||||||
|
// last
|
||||||
ackBlockSent = true;
|
ackBlockSent = true;
|
||||||
if (packet->payloadSize + 16 < m_MaxPayloadSize)
|
if (packet->payloadSize + 16 < m_MaxPayloadSize)
|
||||||
packet->payloadSize += CreatePaddingBlock (packet->payload + packet->payloadSize, m_MaxPayloadSize - packet->payloadSize);
|
packet->payloadSize += CreatePaddingBlock (packet->payload + packet->payloadSize, m_MaxPayloadSize - packet->payloadSize);
|
||||||
uint32_t packetNum = SendData (packet->payload, packet->payloadSize);
|
uint32_t packetNum = SendData (packet->payload, packet->payloadSize, SSU2_FLAG_IMMEDIATE_ACK_REQUESTED);
|
||||||
packet->sendTime = ts;
|
packet->sendTime = ts;
|
||||||
m_SentPackets.emplace (packetNum, packet);
|
m_SentPackets.emplace (packetNum, packet);
|
||||||
}
|
}
|
||||||
@ -419,9 +420,14 @@ namespace transport
|
|||||||
packet = m_Server.GetSentPacketsPool ().AcquireShared ();
|
packet = m_Server.GetSentPacketsPool ().AcquireShared ();
|
||||||
packet->payloadSize = CreateFollowOnFragmentBlock (packet->payload, m_MaxPayloadSize - offset, msg, fragmentNum, msgID);
|
packet->payloadSize = CreateFollowOnFragmentBlock (packet->payload, m_MaxPayloadSize - offset, msg, fragmentNum, msgID);
|
||||||
extraSize -= offset;
|
extraSize -= offset;
|
||||||
|
uint8_t flags = 0;
|
||||||
if (msg->offset >= msg->len && packet->payloadSize + 16 < m_MaxPayloadSize) // last fragment
|
if (msg->offset >= msg->len && packet->payloadSize + 16 < m_MaxPayloadSize) // last fragment
|
||||||
|
{
|
||||||
packet->payloadSize += CreatePaddingBlock (packet->payload + packet->payloadSize, m_MaxPayloadSize - packet->payloadSize);
|
packet->payloadSize += CreatePaddingBlock (packet->payload + packet->payloadSize, m_MaxPayloadSize - packet->payloadSize);
|
||||||
uint32_t followonPacketNum = SendData (packet->payload, packet->payloadSize);
|
if (fragmentNum > 2) // 3 or more fragments
|
||||||
|
flags |= SSU2_FLAG_IMMEDIATE_ACK_REQUESTED;
|
||||||
|
}
|
||||||
|
uint32_t followonPacketNum = SendData (packet->payload, packet->payloadSize, flags);
|
||||||
packet->sendTime = ts;
|
packet->sendTime = ts;
|
||||||
m_SentPackets.emplace (followonPacketNum, packet);
|
m_SentPackets.emplace (followonPacketNum, packet);
|
||||||
}
|
}
|
||||||
@ -1267,7 +1273,7 @@ namespace transport
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SSU2Session::SendData (const uint8_t * buf, size_t len)
|
uint32_t SSU2Session::SendData (const uint8_t * buf, size_t len, uint8_t flags)
|
||||||
{
|
{
|
||||||
if (len < 8)
|
if (len < 8)
|
||||||
{
|
{
|
||||||
@ -1279,6 +1285,7 @@ namespace transport
|
|||||||
header.h.packetNum = htobe32 (m_SendPacketNum);
|
header.h.packetNum = htobe32 (m_SendPacketNum);
|
||||||
header.h.type = eSSU2Data;
|
header.h.type = eSSU2Data;
|
||||||
memset (header.h.flags, 0, 3);
|
memset (header.h.flags, 0, 3);
|
||||||
|
if (flags) header.h.flags[0] = flags;
|
||||||
uint8_t nonce[12];
|
uint8_t nonce[12];
|
||||||
CreateNonce (m_SendPacketNum, nonce);
|
CreateNonce (m_SendPacketNum, nonce);
|
||||||
uint8_t payload[SSU2_MAX_PACKET_SIZE];
|
uint8_t payload[SSU2_MAX_PACKET_SIZE];
|
||||||
|
@ -48,6 +48,9 @@ namespace transport
|
|||||||
const int SSU2_MAX_NUM_ACK_RANGES = 32; // to send
|
const int SSU2_MAX_NUM_ACK_RANGES = 32; // to send
|
||||||
const uint8_t SSU2_MAX_NUM_FRAGMENTS = 64;
|
const uint8_t SSU2_MAX_NUM_FRAGMENTS = 64;
|
||||||
|
|
||||||
|
// flags
|
||||||
|
const uint8_t SSU2_FLAG_IMMEDIATE_ACK_REQUESTED = 0x01;
|
||||||
|
|
||||||
enum SSU2MessageType
|
enum SSU2MessageType
|
||||||
{
|
{
|
||||||
eSSU2SessionRequest = 0,
|
eSSU2SessionRequest = 0,
|
||||||
@ -275,7 +278,7 @@ namespace transport
|
|||||||
void KDFDataPhase (uint8_t * keydata_ab, uint8_t * keydata_ba);
|
void KDFDataPhase (uint8_t * keydata_ab, uint8_t * keydata_ba);
|
||||||
void SendTokenRequest ();
|
void SendTokenRequest ();
|
||||||
void SendRetry ();
|
void SendRetry ();
|
||||||
uint32_t SendData (const uint8_t * buf, size_t len); // returns packet num
|
uint32_t SendData (const uint8_t * buf, size_t len, uint8_t flags = 0); // returns packet num
|
||||||
void SendQuickAck ();
|
void SendQuickAck ();
|
||||||
void SendTermination ();
|
void SendTermination ();
|
||||||
void SendHolePunch (uint32_t nonce, const boost::asio::ip::udp::endpoint& ep, const uint8_t * introKey, uint64_t token);
|
void SendHolePunch (uint32_t nonce, const boost::asio::ip::udp::endpoint& ep, const uint8_t * introKey, uint64_t token);
|
||||||
|
Loading…
Reference in New Issue
Block a user