36 uint32_t begintsn = tsn, endtsn = 0;
38 EV_INFO <<
"Trying to reassemble message..." << endl;
41 while (queue->getChunk(begintsn) && !(queue->getChunk(begintsn))->bbit)
44 if (queue->getChunk(begintsn)) {
48 while (queue->getChunk(endtsn) && !(queue->getChunk(endtsn))->ebit)
51 if (queue->getChunk(endtsn)) {
52 EV_INFO <<
"All fragments found, now reassembling..." << endl;
54 SctpDataVariables *firstVar = queue->getChunk(begintsn), *processVar;
55 SctpSimpleMessage *firstSimple = check_and_cast<SctpSimpleMessage *>(firstVar->userData);
57 EV_INFO <<
"First fragment has " << firstVar->len / 8 <<
" bytes." << endl;
59 while (++begintsn <= endtsn) {
60 processVar = queue->getAndExtractChunk(begintsn);
61 SctpSimpleMessage *processSimple = check_and_cast<SctpSimpleMessage *>(processVar->userData);
63 EV_INFO <<
"Adding fragment with " << processVar->len / 8 <<
" bytes." << endl;
65 if ((firstSimple->getDataArraySize() > 0) && (processSimple->getDataArraySize() > 0)) {
66 firstSimple->setDataArraySize(firstSimple->getDataArraySize() + processSimple->getDataArraySize());
67 firstSimple->setDataLen(firstSimple->getDataLen() + processSimple->getDataLen());
68 firstSimple->setByteLength(firstSimple->getByteLength() + processSimple->getByteLength());
70 for (uint32_t i = 0; i < (processVar->len / 8); i++)
71 firstSimple->setData(i + (firstVar->len / 8), processSimple->getData(i));
74 firstVar->len += processVar->len;
76 delete processVar->userData;
82 EV_INFO <<
"Reassembly done. Length=" << firstVar->len <<
"\n";