From: Victor Julien Date: Thu, 26 Jan 2023 14:39:45 +0000 (+0100) Subject: stream: add util to get absolute right edge of data X-Git-Tag: suricata-7.0.0-rc1~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ff2543343b732563acca1f3c4600b2782d13e32;p=thirdparty%2Fsuricata.git stream: add util to get absolute right edge of data --- diff --git a/src/stream-tcp-reassemble.c b/src/stream-tcp-reassemble.c index e647aaa6ec..662045d8ad 100644 --- a/src/stream-tcp-reassemble.c +++ b/src/stream-tcp-reassemble.c @@ -411,6 +411,16 @@ uint64_t StreamTcpGetAcked(const TcpStream *stream) return GetAbsLastAck(stream); } +// may contain gaps +uint64_t StreamDataRightEdge(const TcpStream *stream, const bool eof) +{ + uint64_t right_edge = STREAM_BASE_OFFSET(stream) + stream->segs_right_edge - stream->base_seq; + if (!eof && StreamTcpInlineMode() == FALSE) { + right_edge = MIN(GetAbsLastAck(stream), right_edge); + } + return right_edge; +} + uint64_t StreamTcpGetUsable(const TcpStream *stream, const bool eof) { uint64_t right_edge = StreamingBufferGetConsecutiveDataRightEdge(&stream->sb); diff --git a/src/stream-tcp.h b/src/stream-tcp.h index 3a4b0e9e57..ad26779f6d 100644 --- a/src/stream-tcp.h +++ b/src/stream-tcp.h @@ -212,6 +212,7 @@ void StreamTcpUpdateAppLayerProgress(TcpSession *ssn, char direction, uint64_t StreamTcpGetAcked(const TcpStream *stream); uint64_t StreamTcpGetUsable(const TcpStream *stream, const bool eof); +uint64_t StreamDataRightEdge(const TcpStream *stream, const bool eof); void StreamTcpThreadCacheEnable(void); void StreamTcpThreadCacheCleanup(void);