Browse Source

handle recieved I2NP message

pull/36/head
orignal 11 years ago
parent
commit
d04f9e723c
  1. 25
      SSU.cpp
  2. 1
      SSU.h

25
SSU.cpp

@ -383,6 +383,31 @@ namespace ssu @@ -383,6 +383,31 @@ namespace ssu
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");
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

@ -88,6 +88,7 @@ namespace ssu @@ -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…
Cancel
Save