suricata
flow-util.h File Reference
#include "flow.h"
#include "stream-tcp-private.h"
Include dependency graph for flow-util.h:

Go to the source code of this file.

Data Structures

struct  FlowEndCounters_
 

Macros

#define RESET_COUNTERS(f)
 
#define FLOW_INITIALIZE(f)
 
#define FLOW_RECYCLE(f)
 macro to recycle a flow before it goes into the spare queue for reuse. More...
 
#define FLOW_DESTROY(f)
 
#define FLOW_CHECK_MEMCAP(size)
 check if a memory alloc would fit in the memcap More...
 

Typedefs

typedef struct FlowEndCounters_ FlowEndCounters
 

Functions

FlowFlowAlloc (void)
 allocate a flow More...
 
void FlowFree (Flow *)
 cleanup & free the memory of a flow More...
 
uint8_t FlowGetProtoMapping (uint8_t)
 Function to map the protocol to the defined FLOW_PROTO_* enumeration. More...
 
void FlowInit (ThreadVars *, Flow *, const Packet *)
 
uint8_t FlowGetReverseProtoMapping (uint8_t rproto)
 
void FlowEndCountersRegister (ThreadVars *t, FlowEndCounters *fec)
 

Detailed Description

Author
Victor Julien victo.nosp@m.r@in.nosp@m.linia.nosp@m.c.ne.nosp@m.t

Definition in file flow-util.h.

Macro Definition Documentation

◆ FLOW_CHECK_MEMCAP

#define FLOW_CHECK_MEMCAP (   size)
Value:
((((uint64_t)SC_ATOMIC_GET(flow_memuse) + (uint64_t)(size)) <= \

check if a memory alloc would fit in the memcap

Parameters
sizememory allocation size to check
Return values
1it fits
0no fit

Definition at line 137 of file flow-util.h.

◆ FLOW_DESTROY

#define FLOW_DESTROY (   f)
Value:
do { \
FlowCleanupAppLayer((f)); \
GenericVarFree((f)->flowvar); \
} while (0)

Definition at line 122 of file flow-util.h.

◆ FLOW_INITIALIZE

#define FLOW_INITIALIZE (   f)

Definition at line 39 of file flow-util.h.

◆ FLOW_RECYCLE

#define FLOW_RECYCLE (   f)

macro to recycle a flow before it goes into the spare queue for reuse.

Note that the lnext, lprev, hnext fields are untouched, those are managed by the queueing code. Same goes for fb (FlowBucket ptr) field.

Definition at line 82 of file flow-util.h.

◆ RESET_COUNTERS

#define RESET_COUNTERS (   f)
Value:
do { \
(f)->todstpktcnt = 0; \
(f)->tosrcpktcnt = 0; \
(f)->todstbytecnt = 0; \
(f)->tosrcbytecnt = 0; \
} while (0)

Definition at line 31 of file flow-util.h.

Typedef Documentation

◆ FlowEndCounters

Function Documentation

◆ FlowAlloc()

Flow* FlowAlloc ( void  )

allocate a flow

We check against the memuse counter. If it passes that check we increment the counter first, then we try to alloc.

Return values
fthe flow or NULL on out of memory

Definition at line 55 of file flow-util.c.

References FLOW_CHECK_MEMCAP, FLOW_INITIALIZE, FlowStorageSize(), SC_ATOMIC_ADD, SC_ATOMIC_SUB, SCCalloc, and unlikely.

Referenced by LLVMFuzzerTestOneInput().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FlowEndCountersRegister()

◆ FlowFree()

void FlowFree ( Flow f)

cleanup & free the memory of a flow

Parameters
fflow to clear & destroy

Definition at line 83 of file flow-util.c.

References FLOW_DESTROY, FlowStorageSize(), SC_ATOMIC_SUB, and SCFree.

Referenced by FlowReset(), FlowShutdown(), LLVMFuzzerTestOneInput(), and UTHBuildPacketOfFlows().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FlowGetProtoMapping()

uint8_t FlowGetProtoMapping ( uint8_t  proto)

Function to map the protocol to the defined FLOW_PROTO_* enumeration.

Parameters
protoprotocol which is needed to be mapped

Definition at line 98 of file flow-util.c.

References FLOW_PROTO_DEFAULT, FLOW_PROTO_ICMP, FLOW_PROTO_TCP, FLOW_PROTO_UDP, and proto.

Referenced by AppLayerParserApplyTxConfig(), AppLayerParserGetEventInfo(), AppLayerParserGetEventInfoById(), AppLayerParserParse(), AppLayerParserProtocolGetLoggerBits(), AppLayerParserProtocolHasLogger(), AppLayerParserProtoIsRegistered(), FlowReset(), FlowSetProtoFreeFunc(), FlowShutdown(), and LLVMFuzzerTestOneInput().

Here is the caller graph for this function:

◆ FlowGetReverseProtoMapping()

uint8_t FlowGetReverseProtoMapping ( uint8_t  rproto)

Definition at line 112 of file flow-util.c.

References FLOW_PROTO_ICMP, FLOW_PROTO_TCP, and FLOW_PROTO_UDP.

Referenced by AppLayerParserThreadCtxAlloc(), and AppLayerParserThreadCtxFree().

Here is the caller graph for this function:

◆ FlowInit()

FLOWLOCK_DESTROY
#define FLOWLOCK_DESTROY(fb)
Definition: flow.h:268
flow_config
FlowConfig flow_config
Definition: flow.c:91
SC_ATOMIC_GET
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
Definition: util-atomic.h:375