Browse Source

process extended data

pull/93/head
orignal 11 years ago
parent
commit
05d869254d
  1. 35
      SSUData.cpp
  2. 2
      SSUData.h

35
SSUData.cpp

@ -39,12 +39,8 @@ namespace ssu @@ -39,12 +39,8 @@ namespace ssu
}
}
void SSUData::ProcessMessage (uint8_t * buf, size_t len)
void SSUData::ProcessAcks (uint8_t *& buf, uint8_t flag)
{
//uint8_t * start = buf;
uint8_t flag = *buf;
buf++;
LogPrint ("Process SSU data flags=", (int)flag);
if (flag & DATA_FLAG_EXPLICIT_ACKS_INCLUDED)
{
// explicit ACKs
@ -83,7 +79,7 @@ namespace ssu @@ -83,7 +79,7 @@ namespace ssu
{
if (fragment < numSentFragments)
{
delete it->second[fragment];
delete[] it->second[fragment];
it->second[fragment] = nullptr;
}
}
@ -95,7 +91,11 @@ namespace ssu @@ -95,7 +91,11 @@ namespace ssu
}
while (isNonLast);
}
}
}
}
void SSUData::ProcessFragments (uint8_t * buf)
{
uint8_t numFragments = *buf; // number of fragments
buf++;
for (int i = 0; i < numFragments; i++)
@ -208,6 +208,27 @@ namespace ssu @@ -208,6 +208,27 @@ namespace ssu
}
}
void SSUData::ProcessMessage (uint8_t * buf, size_t len)
{
//uint8_t * start = buf;
uint8_t flag = *buf;
buf++;
LogPrint ("Process SSU data flags=", (int)flag);
// process acks if presented
if (flag & (DATA_FLAG_ACK_BITFIELDS_INCLUDED | DATA_FLAG_EXPLICIT_ACKS_INCLUDED))
ProcessAcks (buf, flag);
// extended data if presented
if (flag & DATA_FLAG_EXTENDED_DATA_INCLUDED)
{
uint8_t extendedDataSize = *buf;
buf++; // size
LogPrint ("SSU extended data of ", extendedDataSize, " bytes presented");
buf += extendedDataSize;
}
// process data
ProcessFragments (buf);
}
void SSUData::Send (i2p::I2NPMessage * msg)
{
uint32_t msgID = msg->ToSSU ();

2
SSUData.h

@ -65,6 +65,8 @@ namespace ssu @@ -65,6 +65,8 @@ namespace ssu
void SendMsgAck (uint32_t msgID);
void SendFragmentAck (uint32_t msgID, int fragmentNum);
void ProcessAcks (uint8_t *& buf, uint8_t flag);
void ProcessFragments (uint8_t * buf);
void ProcessSentMessageAck (uint32_t msgID);
private:

Loading…
Cancel
Save