Browse Source

handle multiple fragments in one packet

pull/36/head
orignal 11 years ago
parent
commit
fd80a13495
  1. 31
      SSU.cpp

31
SSU.cpp

@ -368,24 +368,23 @@ namespace ssu
uint8_t flag = *buf; uint8_t flag = *buf;
buf++; buf++;
LogPrint ("Process SSU data flags=", (int)flag); LogPrint ("Process SSU data flags=", (int)flag);
if (flag)
{
//TODO: process options
return;
}
uint8_t numFragments = *buf; // number of fragments uint8_t numFragments = *buf; // number of fragments
buf++; buf++;
uint32_t msgID = be32toh (*(uint32_t *)buf); // message ID for (int i = 0; i < numFragments; i++)
buf += 4; {
uint8_t frag[4]; uint32_t msgID = be32toh (*(uint32_t *)buf); // message ID
frag[0] = 0; buf += 4;
memcpy (frag + 1, buf, 3); uint8_t frag[4];
buf += 3; frag[0] = 0;
uint32_t fragmentInfo = be32toh (*(uint32_t *)frag); // fragment info memcpy (frag + 1, buf, 3);
uint16_t fragmentSize = be16toh (fragmentInfo & 0x1FFF); // bits 0 - 13 buf += 3;
bool isLast = fragmentInfo & 0x010000; // bit 16 uint32_t fragmentInfo = be32toh (*(uint32_t *)frag); // fragment info
uint8_t fragmentNum = fragmentInfo >> 17; // bits 23 - 17 uint16_t fragmentSize = fragmentInfo & 0x1FFF; // bits 0 - 13
LogPrint ("SSU data fragment ", (int)fragmentNum, " of ", (int)numFragments, " of message ", msgID, " size=", (int)fragmentSize, isLast ? " last" : " non-last"); 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");
buf += fragmentSize;
}
} }
SSUServer::SSUServer (boost::asio::io_service& service, int port): SSUServer::SSUServer (boost::asio::io_service& service, int port):

Loading…
Cancel
Save