PegCount segs_released;
PegCount segs_used;
PegCount rebuilt_packets;
- PegCount rebuilt_data;
+ PegCount rebuilt_buffers;
PegCount overlaps;
PegCount gaps;
PegCount internalEvents;
"segs released",
"segs used",
"rebuilt packets",
- "rebuilt data",
+ "rebuilt buffers",
"overlaps",
"gaps",
"internal events",
unsigned flushbuf_size = flushbuf_end - flushbuf;
unsigned bytes_to_copy = getSegmentFlushSize(st, ss, toSeq, flushbuf_size);
unsigned bytes_copied = 0;
+ assert(bytes_to_copy);
STREAM5_DEBUG_WRAP(DebugMessage(DEBUG_STREAM_STATE,
"Flushing %u bytes from %X\n", bytes_to_copy, ss->seq));
- if ( SEQ_EQ(ss->seq + bytes_to_copy, toSeq) )
+ if (
+ !ss->next || (bytes_to_copy < ss->size) ||
+ SEQ_EQ(ss->seq + bytes_to_copy, toSeq)
+ )
flags |= PKT_PDU_TAIL;
const StreamBuffer* sb = st->splitter->reassemble(
if ( sb )
{
- unsigned len = s5_pkt->max_dsize;
- assert(sb->length <= len);
-
- if ( sb->length < len )
- len = sb->length;
-
s5_pkt->data = sb->data;
- s5_pkt->dsize = len;
+ s5_pkt->dsize = sb->length;
+ // FIXIT-M flushbuf should be eliminated from this function
+ // since we are actually using the stream splitter buffer
+ flushbuf = (uint8_t*)s5_pkt->data;
+
+ // ensure we stop here
bytes_to_copy = bytes_copied;
}
- else if ( !bytes_copied )
- {
- // FIXIT-P change stream splitter default reassemble
- // to copy into external buffer to eliminate this special case
- memcpy(flushbuf, ss->payload, bytes_to_copy);
- }
- else
- assert(bytes_to_copy == bytes_copied);
+ assert(bytes_to_copy == bytes_copied);
flushbuf += bytes_to_copy;
bytes_flushed += bytes_to_copy;
}
STREAM5_DEBUG_WRAP(bytes_queued -= bytes_flushed;);
-
STREAM5_DEBUG_WRAP(DebugMessage(DEBUG_STREAM_STATE,
"flushed %d bytes / %d segs on stream, "
"%d still queued\n",
const uint8_t* s5_pkt_end = s5_pkt->data + s5_pkt->max_dsize;
flushed_bytes = FlushStream(p, st, stop_seq, (uint8_t *)s5_pkt->data, s5_pkt_end);
- if (flushed_bytes == 0)
- {
- /* No more data... bail */
- break;
- }
- if ( !s5_pkt->dsize )
- tcpStats.rebuilt_data++;
+ if ( !flushed_bytes )
+ break; /* No more data... bail */
+
+ else if ( !s5_pkt->dsize )
+ tcpStats.rebuilt_buffers++;
+
else
{
((TCPHdr *)s5_pkt->ptrs.tcph)->th_seq = htonl(st->seglist_next->seq);
s5_pkt->packet_flags |= (PKT_REBUILT_STREAM|PKT_STREAM_EST);
- s5_pkt->dsize = (uint16_t)flushed_bytes;
if ((p->packet_flags & PKT_PDU_TAIL))
s5_pkt->packet_flags |= PKT_PDU_TAIL;