From 8ff2543343b732563acca1f3c4600b2782d13e32 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 26 Jan 2023 15:39:45 +0100 Subject: [PATCH] stream: add util to get absolute right edge of data --- src/stream-tcp-reassemble.c | 10 ++++++++++ src/stream-tcp.h | 1 + 2 files changed, 11 insertions(+) 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); -- 2.47.2