]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
stream: add util to get absolute right edge of data
authorVictor Julien <vjulien@oisf.net>
Thu, 26 Jan 2023 14:39:45 +0000 (15:39 +0100)
committerVictor Julien <vjulien@oisf.net>
Sat, 28 Jan 2023 11:46:41 +0000 (12:46 +0100)
src/stream-tcp-reassemble.c
src/stream-tcp.h

index e647aaa6ecda6664e1a85de9d402f6b3817ea87a..662045d8ad032452d867dfa4a26b76c531f37430 100644 (file)
@@ -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);
index 3a4b0e9e57fc4927e7ebeb4c59d14a3e14d3ca2e..ad26779f6dbf76d22f76c8aa2ee543557b99ae78 100644 (file)
@@ -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);