]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
stream/bool: Use bool for StreamTcpInlineMode
authorJeff Lucovsky <jlucovsky@oisf.net>
Thu, 27 Jul 2023 14:09:02 +0000 (10:09 -0400)
committerVictor Julien <victor@inliniac.net>
Fri, 17 Nov 2023 21:24:13 +0000 (22:24 +0100)
src/stream-tcp-list.c
src/stream-tcp-reassemble.c
src/stream-tcp.c
src/stream-tcp.h

index 164825440f0c4335aecbf31255b583e063d176a0..2b8a4d079cef9f95763db506dc1ba13fa1adf1bb 100644 (file)
@@ -779,7 +779,7 @@ static inline uint64_t GetLeftEdge(Flow *f, TcpSession *ssn, TcpStream *stream)
     if (use_raw) {
         uint64_t raw_progress = STREAM_RAW_PROGRESS(stream);
 
-        if (StreamTcpInlineMode() == TRUE) {
+        if (StreamTcpInlineMode()) {
             uint32_t chunk_size = (stream == &ssn->client) ?
                 stream_config.reassembly_toserver_chunk_size :
                 stream_config.reassembly_toclient_chunk_size;
@@ -834,14 +834,14 @@ static inline uint64_t GetLeftEdge(Flow *f, TcpSession *ssn, TcpStream *stream)
         last_ack_abs += (stream->last_ack - stream->base_seq);
     }
     /* in IDS mode we shouldn't see the base_seq pass last_ack */
-    DEBUG_VALIDATE_BUG_ON(last_ack_abs < left_edge && StreamTcpInlineMode() == FALSE && !f->ffr &&
+    DEBUG_VALIDATE_BUG_ON(last_ack_abs < left_edge && !StreamTcpInlineMode() && !f->ffr &&
                           ssn->state < TCP_CLOSED);
     left_edge = MIN(left_edge, last_ack_abs);
 
     /* if we're told to look for overlaps with different data we should
      * consider data that is ack'd as well. Injected packets may have
      * been ack'd or injected packet may be too late. */
-    if (StreamTcpInlineMode() == FALSE && check_overlap_different_data) {
+    if (!StreamTcpInlineMode() && check_overlap_different_data) {
         const uint32_t window = stream->window ? stream->window : 4096;
         if (window < left_edge)
             left_edge -= window;
index 737b222d53e22c25a524bce619a2ff47d9acfe33..06992da791a51a97a67e1ebe8341801cad954a20 100644 (file)
@@ -421,7 +421,7 @@ uint64_t StreamTcpGetAcked(const TcpStream *stream)
 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) {
+    if (!eof && !StreamTcpInlineMode()) {
         right_edge = MIN(GetAbsLastAck(stream), right_edge);
     }
     return right_edge;
@@ -430,7 +430,7 @@ uint64_t StreamDataRightEdge(const TcpStream *stream, const bool eof)
 uint64_t StreamTcpGetUsable(const TcpStream *stream, const bool eof)
 {
     uint64_t right_edge = StreamingBufferGetConsecutiveDataRightEdge(&stream->sb);
-    if (!eof && StreamTcpInlineMode() == FALSE) {
+    if (!eof && !StreamTcpInlineMode()) {
         right_edge = MIN(GetAbsLastAck(stream), right_edge);
     }
     return right_edge;
@@ -496,7 +496,7 @@ static int StreamTcpReassemblyConfig(bool quiet)
     if (overlap_diff_data) {
         StreamTcpReassembleConfigEnableOverlapCheck();
     }
-    if (StreamTcpInlineMode() == TRUE) {
+    if (StreamTcpInlineMode()) {
         StreamTcpReassembleConfigEnableOverlapCheck();
     }
 
@@ -1189,7 +1189,7 @@ static inline uint32_t AdjustToAcked(const Packet *p,
     uint32_t adjusted = data_len;
 
     /* get window of data that is acked */
-    if (StreamTcpInlineMode() == FALSE) {
+    if (!StreamTcpInlineMode()) {
         SCLogDebug("ssn->state %s", StreamTcpStateAsString(ssn->state));
         if (data_len == 0 || ((ssn->state < TCP_CLOSED ||
                                       (ssn->state == TCP_CLOSED &&
@@ -1481,7 +1481,7 @@ bool StreamReassembleRawHasDataReady(TcpSession *ssn, Packet *p)
                          STREAMTCP_STREAM_FLAG_DISABLE_RAW))
         return false;
 
-    if (StreamTcpInlineMode() == FALSE) {
+    if (!StreamTcpInlineMode()) {
         const uint64_t segs_re_abs =
                 STREAM_BASE_OFFSET(stream) + stream->segs_right_edge - stream->base_seq;
         if (STREAM_RAW_PROGRESS(stream) == segs_re_abs) {
@@ -1860,7 +1860,7 @@ int StreamReassembleRaw(TcpSession *ssn, const Packet *p,
                         uint64_t *progress_out, bool respect_inspect_depth)
 {
     /* handle inline separately as the logic is very different */
-    if (StreamTcpInlineMode() == TRUE) {
+    if (StreamTcpInlineMode()) {
         return StreamReassembleRawInline(ssn, p, Callback, cb_data, progress_out);
     }
 
index d76a0593a0d29a2db7539543fa276958bb3653b7..d41110aac5c7bb67b1b96cce86ce7165038cb6e1 100644 (file)
@@ -6851,9 +6851,9 @@ int StreamTcpBypassEnabled(void)
  *  \retval 0 no
  *  \retval 1 yes
  */
-int StreamTcpInlineMode(void)
+bool StreamTcpInlineMode(void)
 {
-    return (stream_config.flags & STREAMTCP_INIT_FLAG_INLINE) ? 1 : 0;
+    return (stream_config.flags & STREAMTCP_INIT_FLAG_INLINE);
 }
 
 
index 324671245995045cdbd192fa15ca6d0d431b0432..ff8a0998cb4e7172fff76e7f7f20d73db00efa04 100644 (file)
@@ -191,7 +191,7 @@ void StreamTcpSessionCleanup(TcpSession *ssn);
 void StreamTcpStreamCleanup(TcpStream *stream);
 /* check if bypass is enabled */
 int StreamTcpBypassEnabled(void);
-int StreamTcpInlineMode(void);
+bool StreamTcpInlineMode(void);
 
 int TcpSessionPacketSsnReuse(const Packet *p, const Flow *f, const void *tcp_ssn);