]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
stream: TcpStreamCnf.midstream type changed to bool
authorIlya Bakhtin <ilya.bakhtin@gmail.com>
Thu, 18 Feb 2021 20:25:58 +0000 (21:25 +0100)
committerVictor Julien <victor@inliniac.net>
Mon, 22 Feb 2021 10:16:40 +0000 (11:16 +0100)
src/stream-tcp.c
src/stream-tcp.h
src/tests/stream-tcp.c

index 1fc325702f9f551c2f9a700518663620467425bb..b6d641988541272206b31f7189aa86425606a48d 100644 (file)
@@ -418,7 +418,9 @@ void StreamTcpInitConfig(char quiet)
         SCLogConfig("stream \"memcap\": %"PRIu64, SC_ATOMIC_GET(stream_config.memcap));
     }
 
-    ConfGetBool("stream.midstream", &stream_config.midstream);
+    int imidstream;
+    ConfGetBool("stream.midstream", &imidstream);
+    stream_config.midstream = imidstream != 0;
 
     if (!quiet) {
         SCLogConfig("stream \"midstream\" session pickups: %s", stream_config.midstream ? "enabled" : "disabled");
@@ -919,8 +921,7 @@ static int StreamTcpPacketStateNone(ThreadVars *tv, Packet *p,
 
     /* SYN/ACK */
     } else if ((p->tcph->th_flags & (TH_SYN|TH_ACK)) == (TH_SYN|TH_ACK)) {
-        if (stream_config.midstream == FALSE &&
-                stream_config.async_oneside == FALSE)
+        if (!stream_config.midstream && stream_config.async_oneside == FALSE)
             return 0;
 
         if (ssn == NULL) {
@@ -1079,7 +1080,7 @@ static int StreamTcpPacketStateNone(ThreadVars *tv, Packet *p,
                 ssn->client.last_ack);
 
     } else if (p->tcph->th_flags & TH_ACK) {
-        if (stream_config.midstream == FALSE)
+        if (!stream_config.midstream)
             return 0;
 
         if (ssn == NULL) {
@@ -5049,7 +5050,7 @@ static int TcpSessionPacketIsStreamStarter(const Packet *p)
         return 1;
     }
 
-    if (stream_config.midstream == TRUE || stream_config.async_oneside == TRUE) {
+    if (stream_config.midstream || stream_config.async_oneside == TRUE) {
         if (p->tcph->th_flags == (TH_SYN|TH_ACK)) {
             SCLogDebug("packet %"PRIu64" is a midstream stream starter: %02x", p->pcap_cnt, p->tcph->th_flags);
             return 1;
@@ -5170,7 +5171,7 @@ static int TcpSessionReuseDoneEnough(const Packet *p, const Flow *f, const TcpSe
         return TcpSessionReuseDoneEnoughSyn(p, f, ssn);
     }
 
-    if (stream_config.midstream == TRUE || stream_config.async_oneside == TRUE) {
+    if (stream_config.midstream || stream_config.async_oneside == TRUE) {
         if (p->tcph->th_flags == (TH_SYN|TH_ACK)) {
             return TcpSessionReuseDoneEnoughSynAck(p, f, ssn);
         }
index 653e8d3aa1d76a6fb2f35adee3aaca14ceded249..6ee62b5be9ff9276aea5ac58f01fdf381ee78b48 100644 (file)
@@ -55,7 +55,7 @@ typedef struct TcpStreamCnf_ {
 
     uint32_t prealloc_sessions; /**< ssns to prealloc per stream thread */
     uint32_t prealloc_segments; /**< segments to prealloc per stream thread */
-    int midstream;
+    bool midstream;
     int async_oneside;
     uint32_t reassembly_depth;  /**< Depth until when we reassemble the stream */
 
index 1d01a83d4488fde922023cb926f51508a3b85809..75a8018b8b1fab6ff7288a67fbfcd7d8e4b3360a 100644 (file)
@@ -214,7 +214,7 @@ static int StreamTcpTest03(void)
     if (StreamTcpPacket(&tv, p, &stt, &pq) == -1)
         goto end;
 
-    if (stream_config.midstream != TRUE) {
+    if (!stream_config.midstream) {
         ret = 1;
         goto end;
     }
@@ -281,7 +281,7 @@ static int StreamTcpTest04(void)
     if (StreamTcpPacket(&tv, p, &stt, &pq) == -1)
         goto end;
 
-    if (stream_config.midstream != TRUE) {
+    if (!stream_config.midstream) {
         ret = 1;
         goto end;
     }
@@ -379,7 +379,7 @@ static int StreamTcpTest05(void)
     if (StreamTcpPacket(&tv, p, &stt, &pq) == -1)
         goto end;
 
-    if (stream_config.midstream != TRUE) {
+    if (!stream_config.midstream) {
         ret = 1;
         goto end;
     }
@@ -1226,7 +1226,7 @@ static int StreamTcpTest14(void)
     if (StreamTcpPacket(&tv, p, &stt, &pq) == -1)
         goto end;
 
-    if (stream_config.midstream != TRUE) {
+    if (!stream_config.midstream) {
         ret = 1;
         goto end;
     }
@@ -1616,7 +1616,7 @@ static int StreamTcpTest15(void)
     if (StreamTcpPacket(&tv, p, &stt, &pq) == -1)
         goto end;
 
-    if (stream_config.midstream != TRUE) {
+    if (!stream_config.midstream) {
         ret = 1;
         goto end;
     }
@@ -1778,7 +1778,7 @@ static int StreamTcpTest16(void)
     if (StreamTcpPacket(&tv, p, &stt, &pq) == -1)
         goto end;
 
-    if (stream_config.midstream != TRUE) {
+    if (!stream_config.midstream) {
         ret = 1;
         goto end;
     }
@@ -1941,7 +1941,7 @@ static int StreamTcpTest17(void)
     if (StreamTcpPacket(&tv, p, &stt, &pq) == -1)
         goto end;
 
-    if (stream_config.midstream != TRUE) {
+    if (!stream_config.midstream) {
         ret = 1;
         goto end;
     }