-/* Copyright (C) 2007-2011 Open Information Security Foundation
+/* Copyright (C) 2007-2021 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
return;
}
- uint32_t size_ts = ssn->client.last_ack - ssn->client.isn - 1;
- uint32_t size_tc = ssn->server.last_ack - ssn->server.isn - 1;
- SCLogDebug("size_ts %u, size_tc %u", size_ts, size_tc);
+ const uint32_t size_ts = StreamDataAvailableForProtoDetect(&ssn->client);
+ const uint32_t size_tc = StreamDataAvailableForProtoDetect(&ssn->server);
+ SCLogDebug("size_ts %" PRIu32 ", size_tc %" PRIu32, size_ts, size_tc);
#ifdef DEBUG_VALIDATION
if (!(ssn->client.flags & STREAMTCP_STREAM_FLAG_GAP))
SCReturnUInt(0);
}
+uint32_t StreamDataAvailableForProtoDetect(TcpStream *stream) {
+ if (RB_EMPTY(&stream->sb.sbb_tree)) {
+ if (stream->sb.stream_offset != 0)
+ return 0;
+
+ return stream->sb.buf_offset;
+ } else {
+ DEBUG_VALIDATE_BUG_ON(stream->sb.head == NULL);
+ DEBUG_VALIDATE_BUG_ON(stream->sb.sbb_size == 0);
+ return stream->sb.sbb_size;
+ }
+}
+
/**
* \brief Insert a packets TCP data into the stream reassembly engine.
*