mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-07 07:44:13 +00:00
send ack per fragment. temporary disble check for duplicated through IV
This commit is contained in:
parent
05a96fd398
commit
2f601ce02f
4
SSU.cpp
4
SSU.cpp
@ -84,10 +84,10 @@ namespace ssu
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ScheduleTermination ();
|
ScheduleTermination ();
|
||||||
// check for duplicate
|
/* // check for duplicate
|
||||||
const uint8_t * iv = ((SSUHeader *)buf)->iv;
|
const uint8_t * iv = ((SSUHeader *)buf)->iv;
|
||||||
if (m_ReceivedIVs.count (iv)) return; // duplicate detected
|
if (m_ReceivedIVs.count (iv)) return; // duplicate detected
|
||||||
m_ReceivedIVs.insert (iv);
|
m_ReceivedIVs.insert (iv);*/
|
||||||
|
|
||||||
if (m_IsSessionKey && Validate (buf, len, m_MacKey)) // try session key first
|
if (m_IsSessionKey && Validate (buf, len, m_MacKey)) // try session key first
|
||||||
DecryptSessionKey (buf, len);
|
DecryptSessionKey (buf, len);
|
||||||
|
35
SSUData.cpp
35
SSUData.cpp
@ -1,3 +1,4 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "SSU.h"
|
#include "SSU.h"
|
||||||
#include "SSUData.h"
|
#include "SSUData.h"
|
||||||
@ -172,7 +173,9 @@ namespace ssu
|
|||||||
LogPrint ("SSU unexpected message ", (int)msg->GetHeader ()->typeID);
|
LogPrint ("SSU unexpected message ", (int)msg->GetHeader ()->typeID);
|
||||||
DeleteI2NPMessage (msg);
|
DeleteI2NPMessage (msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
SendFragmentAck (msgID, fragmentNum);
|
||||||
buf += fragmentSize;
|
buf += fragmentSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,6 +255,36 @@ namespace ssu
|
|||||||
m_Session.FillHeaderAndEncrypt (PAYLOAD_TYPE_DATA, buf, 48);
|
m_Session.FillHeaderAndEncrypt (PAYLOAD_TYPE_DATA, buf, 48);
|
||||||
m_Session.Send (buf, 48);
|
m_Session.Send (buf, 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SSUData::SendFragmentAck (uint32_t msgID, int fragmentNum)
|
||||||
|
{
|
||||||
|
if (fragmentNum > 64)
|
||||||
|
{
|
||||||
|
LogPrint ("Fragment number ", fragmentNum, " exceeds 64");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uint8_t buf[64 + 18];
|
||||||
|
uint8_t * payload = buf + sizeof (SSUHeader);
|
||||||
|
*payload = DATA_FLAG_ACK_BITFIELDS_INCLUDED; // flag
|
||||||
|
payload++;
|
||||||
|
*payload = 1; // number of ACK bitfields
|
||||||
|
payload++;
|
||||||
|
// one ack
|
||||||
|
*(uint32_t *)(payload) = htobe32 (msgID); // msgID
|
||||||
|
payload += 4;
|
||||||
|
div_t d = div (fragmentNum, 7);
|
||||||
|
memset (payload, 0x80, d.quot); // 0x80 means non-last
|
||||||
|
payload += d.quot;
|
||||||
|
*payload = 0x40 >> d.rem; // set corresponding bit
|
||||||
|
payload++;
|
||||||
|
*payload = 0; // number of fragments
|
||||||
|
|
||||||
|
size_t len = d.quot < 4 ? 48 : 64; // 48 = 37 + 7 + 4 (3+1)
|
||||||
|
// encrypt message with session key
|
||||||
|
m_Session.FillHeaderAndEncrypt (PAYLOAD_TYPE_DATA, buf, len);
|
||||||
|
m_Session.Send (buf, len);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,8 @@ namespace ssu
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
void SendMsgAck (uint32_t msgID);
|
void SendMsgAck (uint32_t msgID);
|
||||||
void ProcessSentMessageAck (uint32_t msgID);
|
void SendFragmentAck (uint32_t msgID, int fragmentNum);
|
||||||
|
void ProcessSentMessageAck (uint32_t msgID);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user