-/* Copyright (C) 2007-2022 Open Information Security Foundation
+/* Copyright (C) 2007-2023 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
const bool use_app = !(ssn->flags & STREAMTCP_FLAG_APP_LAYER_DISABLED);
const bool use_raw = !(stream->flags & STREAMTCP_STREAM_FLAG_DISABLE_RAW);
const bool use_log = stream_config.streaming_log_api;
- SCLogDebug("use_app %d use_raw %d use_log %d", use_app, use_raw, use_log);
+ SCLogDebug("use_app %d use_raw %d use_log %d tcp win %u", use_app, use_raw, use_log,
+ stream->window);
if (use_raw) {
uint64_t raw_progress = STREAM_RAW_PROGRESS(stream);
}
const uint64_t left_edge = GetLeftEdge(f, ssn, stream);
+ SCLogDebug("buffer left_edge %" PRIu64, left_edge);
if (left_edge && left_edge > STREAM_BASE_OFFSET(stream)) {
uint32_t slide = left_edge - STREAM_BASE_OFFSET(stream);
SCLogDebug("buffer sliding %u to offset %"PRIu64, slide, left_edge);
void *StreamTcpReassembleRealloc(void *optr, size_t orig_size, size_t size)
{
if (size > orig_size) {
- if (StreamTcpReassembleCheckMemcap(size - orig_size) == 0)
+ if (StreamTcpReassembleCheckMemcap(size - orig_size) == 0) {
+ SCLogDebug("memcap hit at %" PRIu64, SC_ATOMIC_GET(stream_config.reassembly_memcap));
return NULL;
+ }
}
void *nptr = SCRealloc(optr, size);
- if (nptr == NULL)
+ if (nptr == NULL) {
+ SCLogDebug("realloc fail");
return NULL;
-
+ }
if (size > orig_size) {
StreamTcpReassembleIncrMemuse(size - orig_size);
} else {
/** \brief alloc a tcp segment pool entry */
static void *TcpSegmentPoolAlloc(void)
{
+ SCLogDebug("segment alloc");
if (StreamTcpReassembleCheckMemcap((uint32_t)sizeof(TcpSegment)) == 0) {
return NULL;
}
*data = mydata;
*data_len = mydata_len;
} else {
+ SCLogDebug("block mode");
StreamingBufferBlock *blk = GetBlock(&stream->sb, offset);
if (blk == NULL) {
*data = NULL;
/* block at expected offset */
if (blk->offset == offset) {
+ SCLogDebug("blk at offset");
StreamingBufferSBBGetData(&stream->sb, blk, data, data_len);
uint64_t app_progress = STREAM_APP_PROGRESS(*stream);
SCLogDebug("app progress %"PRIu64, app_progress);
- SCLogDebug("last_ack %u, base_seq %u", (*stream)->last_ack, (*stream)->base_seq);
-
+#ifdef DEBUG
+ uint64_t last_ack_abs = GetAbsLastAck(*stream);
+ SCLogDebug("last_ack %u (abs %" PRIu64 "), base_seq %u", (*stream)->last_ack, last_ack_abs,
+ (*stream)->base_seq);
+#endif
const uint8_t *mydata;
uint32_t mydata_len;
bool last_was_gap = false;
bool check_for_gap_ahead = ((*stream)->data_required > 0);
bool gap_ahead =
GetAppBuffer(*stream, &mydata, &mydata_len, app_progress, check_for_gap_ahead);
+ SCLogDebug("gap_ahead %s mydata_len %u", BOOL2STR(gap_ahead), mydata_len);
if (last_was_gap && mydata_len == 0) {
break;
}
continue;
} else if (flags & STREAM_DEPTH) {
+ SCLogDebug("DEPTH");
// we're just called once with this flag, so make sure we pass it on
if (mydata == NULL && mydata_len > 0) {
mydata_len = 0;
}
} else if (mydata == NULL || (mydata_len == 0 && ((flags & STREAM_EOF) == 0))) {
+ SCLogDebug("GAP?1");
/* Possibly a gap, but no new data. */
if ((p->flags & PKT_PSEUDO_STREAM_END) == 0 || ssn->state < TCP_CLOSED)
SCReturnInt(0);
*stream, &(*stream)->sb, mydata_len, app_progress);
if ((p->flags & PKT_PSEUDO_STREAM_END) == 0 || ssn->state < TCP_CLOSED) {
+ SCLogDebug("GAP?2");
if (mydata_len < (*stream)->data_required) {
+ SCLogDebug("GAP?3 gap_head %s", BOOL2STR(gap_ahead));
if (gap_ahead) {
SCLogDebug("GAP while expecting more data (expect %u, gap size %u)",
(*stream)->data_required, mydata_len);
}
(*stream)->data_required = 0;
+ SCLogDebug("parser");
/* update the app-layer */
(void)AppLayerHandleTCPData(tv, ra_ctx, p, p->flow, ssn, stream,
(uint8_t *)mydata, mydata_len, flags);