mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-08 22:13:48 +01:00
handle recieved I2NP message
This commit is contained in:
parent
fd80a13495
commit
d04f9e723c
2 changed files with 27 additions and 1 deletions
27
SSU.cpp
27
SSU.cpp
|
@ -382,7 +382,32 @@ namespace ssu
|
|||
uint16_t fragmentSize = fragmentInfo & 0x1FFF; // bits 0 - 13
|
||||
bool isLast = fragmentInfo & 0x010000; // bit 16
|
||||
uint8_t fragmentNum = fragmentInfo >> 17; // bits 23 - 17
|
||||
LogPrint ("SSU data fragment ", (int)fragmentNum, " of message ", msgID, " size=", (int)fragmentSize, isLast ? " last" : " non-last");
|
||||
LogPrint ("SSU data fragment ", (int)fragmentNum, " of message ", msgID, " size=", (int)fragmentSize, isLast ? " last" : " non-last");
|
||||
I2NPMessage * msg = nullptr;
|
||||
if (fragmentNum > 0) // follow-up fragment
|
||||
{
|
||||
auto it = m_IncomleteMessages.find (msgID);
|
||||
if (it != m_IncomleteMessages.end ())
|
||||
msg = it->second;
|
||||
else
|
||||
// TODO:
|
||||
LogPrint ("Unexpected follow-on fragment ", fragmentNum, " of message ", msgID);
|
||||
}
|
||||
else // first fragment
|
||||
msg = NewI2NPMessage ();
|
||||
if (msg)
|
||||
{
|
||||
memcpy (msg->buf + msg->len, buf, fragmentSize);
|
||||
msg->len += fragmentSize;
|
||||
if (!fragmentNum && !isLast)
|
||||
m_IncomleteMessages[msgID] = msg;
|
||||
if (isLast)
|
||||
{
|
||||
if (fragmentNum > 0)
|
||||
m_IncomleteMessages.erase (msgID);
|
||||
i2p::HandleI2NPMessage (msg, false);
|
||||
}
|
||||
}
|
||||
buf += fragmentSize;
|
||||
}
|
||||
}
|
||||
|
|
1
SSU.h
1
SSU.h
|
@ -88,6 +88,7 @@ namespace ssu
|
|||
CryptoPP::CBC_Mode<CryptoPP::AES>::Encryption m_Encryption;
|
||||
CryptoPP::CBC_Mode<CryptoPP::AES>::Decryption m_Decryption;
|
||||
uint8_t m_SessionKey[32], m_MacKey[32];
|
||||
std::map<uint32_t, I2NPMessage *> m_IncomleteMessages;
|
||||
};
|
||||
|
||||
class SSUServer
|
||||
|
|
Loading…
Add table
Reference in a new issue