From: Ilya Bakhtin Date: Thu, 18 Feb 2021 20:25:58 +0000 (+0100) Subject: stream: TcpStreamCnf.midstream type changed to bool X-Git-Tag: suricata-7.0.0-beta1~1776 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3b64803e5e0fbd7700b9ca3b0a39be0d91a3130;p=thirdparty%2Fsuricata.git stream: TcpStreamCnf.midstream type changed to bool --- diff --git a/src/stream-tcp.c b/src/stream-tcp.c index 1fc325702f..b6d6419885 100644 --- a/src/stream-tcp.c +++ b/src/stream-tcp.c @@ -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); } diff --git a/src/stream-tcp.h b/src/stream-tcp.h index 653e8d3aa1..6ee62b5be9 100644 --- a/src/stream-tcp.h +++ b/src/stream-tcp.h @@ -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 */ diff --git a/src/tests/stream-tcp.c b/src/tests/stream-tcp.c index 1d01a83d44..75a8018b8b 100644 --- a/src/tests/stream-tcp.c +++ b/src/tests/stream-tcp.c @@ -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; }