flow-util.h File Reference
#include "detect-engine-state.h"
#include "tmqh-flow.h"
Include dependency graph for flow-util.h:

Go to the source code of this file.


#define COPY_TIMESTAMP(src, dst)   ((dst)->tv_sec = (src)->tv_sec, (dst)->tv_usec = (src)->tv_usec)
#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)   ((((uint64_t)SC_ATOMIC_GET(flow_memuse) + (uint64_t)(size)) <= SC_ATOMIC_GET(flow_config.memcap)))
 check if a memory alloc would fit in the memcap More...


FlowFlowAlloc (void)
 allocate a flow More...
FlowFlowAllocDirect (void)
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 (Flow *, const Packet *)
uint8_t FlowGetReverseProtoMapping (uint8_t rproto)

Detailed Description

Victor Julien

Definition in file flow-util.h.

Macro Definition Documentation

#define COPY_TIMESTAMP (   src,
)    ((dst)->tv_sec = (src)->tv_sec, (dst)->tv_usec = (src)->tv_usec)

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

Referenced by FlowHandlePacketUpdate(), FlowInit(), and UTHBuildPacketReal().

#define FLOW_CHECK_MEMCAP (   size)    ((((uint64_t)SC_ATOMIC_GET(flow_memuse) + (uint64_t)(size)) <= SC_ATOMIC_GET(flow_config.memcap)))

check if a memory alloc would fit in the memcap

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

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

Referenced by FlowAlloc(), FlowInitConfig(), FlowSetupPacket(), FlowUpdateState(), and TmModuleFlowRecyclerRegister().

#define FLOW_RECYCLE (   f)

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

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

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

Referenced by FlowClearMemory().

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

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

Function Documentation

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 51 of file flow-util.c.

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

Referenced by FlowGetFromFlowKey(), FlowInitConfig(), FlowSetupPacket(), FlowStorageRegister(), FlowUpdateSpareFlows(), and TagTimeoutCheck().

Here is the call graph for this function:

Here is the caller graph for this function:

Flow* FlowAllocDirect ( void  )
void FlowFree ( Flow f)

cleanup & free the memory of a flow

fflow to clear & destroy

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

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

Referenced by AppLayerParserStreamTruncated(), FlowShutdown(), FlowStorageRegister(), FlowUpdateSpareFlows(), and UTHFreeFlow().

Here is the call graph for this function:

Here is the caller graph for this function:

uint8_t FlowGetProtoMapping ( uint8_t  proto)

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

protoprotocol which is needed to be mapped

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


Referenced by AppLayerGetTxIterator(), AppLayerParserDestroyProtocolParserLocalStorage(), AppLayerParserGetEventInfo(), AppLayerParserGetEventInfoById(), AppLayerParserGetEventsByTx(), AppLayerParserGetFiles(), AppLayerParserGetFirstDataDir(), AppLayerParserGetProtocolParserLocalStorage(), AppLayerParserGetStateProgress(), AppLayerParserGetTx(), AppLayerParserGetTxDetectFlags(), AppLayerParserGetTxDetectState(), AppLayerParserParse(), AppLayerParserProtocolGetLoggerBits(), AppLayerParserProtocolHasLogger(), AppLayerParserProtocolIsTxEventAware(), AppLayerParserProtoIsRegistered(), AppLayerParserRegisterDetectFlagsFuncs(), AppLayerParserRegisterDetectStateFuncs(), AppLayerParserRegisterGetEventInfo(), AppLayerParserRegisterGetEventInfoById(), AppLayerParserRegisterGetEventsFunc(), AppLayerParserRegisterGetFilesFunc(), AppLayerParserRegisterGetStateProgressFunc(), AppLayerParserRegisterGetTx(), AppLayerParserRegisterGetTxCnt(), AppLayerParserRegisterGetTxIterator(), AppLayerParserRegisterLocalStorageFunc(), AppLayerParserRegisterLogger(), AppLayerParserRegisterLoggerBits(), AppLayerParserRegisterLoggerFuncs(), AppLayerParserRegisterOptionFlags(), AppLayerParserRegisterParser(), AppLayerParserRegisterParserAcceptableDataDirection(), AppLayerParserRegisterProtocolUnittests(), AppLayerParserRegisterSetStreamDepthFlag(), AppLayerParserRegisterStateFuncs(), AppLayerParserRegisterTruncateFunc(), AppLayerParserRegisterTxFreeFunc(), AppLayerParserRestoreParserTable(), AppLayerParserSetStreamDepth(), AppLayerParserSetStreamDepthFlag(), AppLayerParserSetTxDetectFlags(), AppLayerParserSetTxLogged(), AppLayerParserStateCleanup(), AppLayerParserStreamTruncated(), AppLayerParserSupportsFiles(), AppLayerParserSupportsTxDetectState(), AppLayerProtoDetectUnittestCtxRestore(), AppLayerRegisterThreadCounters(), AppLayerSetupCounters(), DetectDnsQueryRegister(), FlowGetFromFlowKey(), FlowInit(), FlowSetProtoFreeFunc(), FlowShutdown(), FlowUpdateState(), RegisterDCERPCUDPParsers(), and TagTimeoutCheck().

uint8_t FlowGetReverseProtoMapping ( uint8_t  rproto)

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

References FLOW_PROTO_ICMP, FLOW_PROTO_SCTP, FLOW_PROTO_TCP, FLOW_PROTO_UDP, Flow_::icmp_d, Flow_::icmp_s, ICMPv4GetCounterpart(), and ICMPv6GetCounterpart().

Referenced by AppLayerParserThreadCtxAlloc(), and AppLayerParserThreadCtxFree().

Here is the call graph for this function:

Here is the caller graph for this function: