* \param f flow
* \param ts timestamp
*
- * \retval 0 not timed out
- * \retval 1 timed out
+ * \retval false not timed out
+ * \retval true timed out
*/
-static int FlowManagerFlowTimeout(Flow *f, SCTime_t ts, uint32_t *next_ts, const bool emerg)
+static bool FlowManagerFlowTimeout(Flow *f, SCTime_t ts, uint32_t *next_ts, const bool emerg)
{
uint32_t flow_times_out_at = f->timeout_at;
if (emerg) {
/* do the timeout check */
if ((uint64_t)flow_times_out_at >= SCTIME_SECS(ts)) {
- return 0;
+ return false;
}
- return 1;
+ return true;
}
/** \internal
* \param ts timestamp
* \param counters Flow timeout counters
*
- * \retval 0 not timeout
- * \retval 1 timeout (or not capture bypassed)
+ * \retval false not timeout
+ * \retval true timeout (or not capture bypassed)
*/
-static inline int FlowBypassedTimeout(Flow *f, SCTime_t ts, FlowTimeoutCounters *counters)
+static inline bool FlowBypassedTimeout(Flow *f, SCTime_t ts, FlowTimeoutCounters *counters)
{
#ifdef CAPTURE_OFFLOAD
if (f->flow_state != FLOW_STATE_CAPTURE_BYPASSED) {
- return 1;
+ return true;
}
FlowBypassInfo *fc = FlowGetStorageById(f, GetFlowBypassInfoID());
}
counters->bypassed_pkts += pkts_tosrc + pkts_todst;
counters->bypassed_bytes += bytes_tosrc + bytes_todst;
- return 0;
- } else {
- SCLogDebug("No new packet, dead flow %"PRId64"", FlowGetId(f));
- if (f->livedev) {
- if (FLOW_IS_IPV4(f)) {
- LiveDevSubBypassStats(f->livedev, 1, AF_INET);
- } else if (FLOW_IS_IPV6(f)) {
- LiveDevSubBypassStats(f->livedev, 1, AF_INET6);
- }
+ return false;
+ }
+ SCLogDebug("No new packet, dead flow %" PRId64 "", FlowGetId(f));
+ if (f->livedev) {
+ if (FLOW_IS_IPV4(f)) {
+ LiveDevSubBypassStats(f->livedev, 1, AF_INET);
+ } else if (FLOW_IS_IPV6(f)) {
+ LiveDevSubBypassStats(f->livedev, 1, AF_INET6);
}
- counters->bypassed_count++;
- return 1;
}
+ counters->bypassed_count++;
}
#endif /* CAPTURE_OFFLOAD */
- return 1;
+ return true;
}
typedef struct FlowManagerTimeoutThread {
if (f->proto == IPPROTO_TCP &&
!(f->flags & (FLOW_TIMEOUT_REASSEMBLY_DONE | FLOW_ACTION_DROP)) &&
- !FlowIsBypassed(f) && FlowForceReassemblyNeedReassembly(f) == 1) {
+ !FlowIsBypassed(f) && FlowForceReassemblyNeedReassembly(f)) {
/* Send the flow to its thread */
FlowForceReassemblyForFlow(f);
FLOWLOCK_UNLOCK(f);
* be modified when we have both the flow and hash row lock */
/* timeout logic goes here */
- if (FlowManagerFlowTimeout(f, ts, next_ts, emergency) == 0) {
-
+ if (FlowManagerFlowTimeout(f, ts, next_ts, emergency) == false) {
counters->flows_notimeout++;
prev_f = f;
-/* Copyright (C) 2007-2017 Open Information Security Foundation
+/* Copyright (C) 2007-2024 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
*
* \param f *LOCKED* flow
*
- * \retval 0 no
- * \retval 1 yes
+ * \retval false no
+ * \retval true yes
*/
-int FlowForceReassemblyNeedReassembly(Flow *f)
+bool FlowForceReassemblyNeedReassembly(Flow *f)
{
if (f == NULL || f->protoctx == NULL) {
- SCReturnInt(0);
+ return false;
}
TcpSession *ssn = (TcpSession *)f->protoctx;
/* nothing to do */
if (client == STREAM_HAS_UNPROCESSED_SEGMENTS_NONE &&
server == STREAM_HAS_UNPROCESSED_SEGMENTS_NONE) {
- SCReturnInt(0);
+ return false;
}
f->ffr_ts = client;
f->ffr_tc = server;
- SCReturnInt(1);
+ return true;
}
/**
/* in case of additional work, we pull the flow out of the
* hash and xfer ownership to the injected packet(s) */
- if (FlowForceReassemblyNeedReassembly(f) == 1) {
+ if (FlowForceReassemblyNeedReassembly(f)) {
RemoveFromHash(f, prev_f);
f->flow_end_flags |= FLOW_END_FLAG_SHUTDOWN;
FlowForceReassemblyForFlow(f);
-/* Copyright (C) 2007-2012 Open Information Security Foundation
+/* Copyright (C) 2007-2024 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "stream-tcp-private.h"
void FlowForceReassemblyForFlow(Flow *f);
-int FlowForceReassemblyNeedReassembly(Flow *f);
+bool FlowForceReassemblyNeedReassembly(Flow *f);
void FlowForceReassembly(void);
Packet *FlowForceReassemblyPseudoPacketGet(int direction, Flow *f, const TcpSession *ssn);
-/* Copyright (C) 2016-2020 Open Information Security Foundation
+/* Copyright (C) 2016-2024 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
if (f->proto == IPPROTO_TCP) {
if (!(f->flags & (FLOW_TIMEOUT_REASSEMBLY_DONE | FLOW_ACTION_DROP)) &&
- !FlowIsBypassed(f) && FlowForceReassemblyNeedReassembly(f) == 1 &&
- f->ffr != 0) {
+ !FlowIsBypassed(f) && FlowForceReassemblyNeedReassembly(f) && f->ffr != 0) {
/* read detect thread in case we're doing a reload */
void *detect_thread = SC_ATOMIC_GET(fw->detect_thread);
int cnt = FlowFinish(tv, f, fw, detect_thread);