|
| #define | FLOW_QUIET true |
| |
| #define | TOSERVER 0 |
| |
| #define | TOCLIENT 1 |
| |
| #define | FLOW_TO_SRC_SEEN BIT_U32(0) |
| |
| #define | FLOW_TO_DST_SEEN BIT_U32(1) |
| |
| #define | FLOW_TC_APP_UPDATE_NEXT BIT_U32(2) |
| |
| #define | FLOW_IS_ELEPHANT BIT_U32(3) |
| |
| #define | FLOW_ACTION_ACCEPT BIT_U32(4) |
| |
| #define | FLOW_NOPAYLOAD_INSPECTION BIT_U32(6) |
| |
| #define | FLOW_ACTION_DROP BIT_U32(7) |
| |
| #define | FLOW_SGH_TOSERVER BIT_U32(8) |
| |
| #define | FLOW_SGH_TOCLIENT BIT_U32(9) |
| |
| #define | FLOW_TOSERVER_DROP_LOGGED BIT_U32(10) |
| |
| #define | FLOW_TOCLIENT_DROP_LOGGED BIT_U32(11) |
| |
| #define | FLOW_HAS_ALERTS BIT_U32(12) |
| |
| #define | FLOW_TS_PM_ALPROTO_DETECT_DONE BIT_U32(13) |
| |
| #define | FLOW_TS_PP_ALPROTO_DETECT_DONE BIT_U32(14) |
| |
| #define | FLOW_TS_PE_ALPROTO_DETECT_DONE BIT_U32(15) |
| |
| #define | FLOW_TC_PM_ALPROTO_DETECT_DONE BIT_U32(16) |
| |
| #define | FLOW_TC_PP_ALPROTO_DETECT_DONE BIT_U32(17) |
| |
| #define | FLOW_TC_PE_ALPROTO_DETECT_DONE BIT_U32(18) |
| |
| #define | FLOW_TIMEOUT_REASSEMBLY_DONE BIT_U32(19) |
| |
| #define | FLOW_IPV4 BIT_U32(20) |
| |
| #define | FLOW_IPV6 BIT_U32(21) |
| |
| #define | FLOW_PROTO_DETECT_TS_DONE BIT_U32(22) |
| |
| #define | FLOW_PROTO_DETECT_TC_DONE BIT_U32(23) |
| |
| #define | FLOW_CHANGE_PROTO BIT_U32(24) |
| |
| #define | FLOW_WRONG_THREAD BIT_U32(25) |
| |
| #define | FLOW_DIR_REVERSED BIT_U32(26) |
| |
| #define | FLOW_HAS_EXPECTATION BIT_U32(27) |
| |
| #define | FLOW_ACTION_PASS BIT_U32(28) |
| |
| #define | FLOW_TS_APP_UPDATED BIT_U32(29) |
| |
| #define | FLOW_TC_APP_UPDATED BIT_U32(30) |
| |
| #define | FLOW_TS_APP_UPDATE_NEXT BIT_U32(31) |
| |
| #define | FLOWFILE_INIT 0 |
| |
| #define | FLOWFILE_NO_MAGIC_TS BIT_U16(0) |
| |
| #define | FLOWFILE_NO_MAGIC_TC BIT_U16(1) |
| |
| #define | FLOWFILE_NO_STORE_TS BIT_U16(2) |
| |
| #define | FLOWFILE_NO_STORE_TC BIT_U16(3) |
| |
| #define | FLOWFILE_NO_MD5_TS BIT_U16(4) |
| |
| #define | FLOWFILE_NO_MD5_TC BIT_U16(5) |
| |
| #define | FLOWFILE_NO_SHA1_TS BIT_U16(6) |
| |
| #define | FLOWFILE_NO_SHA1_TC BIT_U16(7) |
| |
| #define | FLOWFILE_NO_SHA256_TS BIT_U16(8) |
| |
| #define | FLOWFILE_NO_SHA256_TC BIT_U16(9) |
| |
| #define | FLOWFILE_STORE_TS BIT_U16(12) |
| |
| #define | FLOWFILE_STORE_TC BIT_U16(13) |
| |
| #define | FLOWFILE_NONE_TS |
| |
| #define | FLOWFILE_NONE_TC |
| |
| #define | FLOWFILE_NONE (FLOWFILE_NONE_TS|FLOWFILE_NONE_TC) |
| |
| #define | FLOW_IS_IPV4(f) (((f)->flags & FLOW_IPV4) == FLOW_IPV4) |
| |
| #define | FLOW_IS_IPV6(f) (((f)->flags & FLOW_IPV6) == FLOW_IPV6) |
| |
| #define | FLOW_GET_SP(f) ((f)->flags & FLOW_DIR_REVERSED) ? (f)->dp : (f)->sp; |
| |
| #define | FLOW_GET_DP(f) ((f)->flags & FLOW_DIR_REVERSED) ? (f)->sp : (f)->dp; |
| |
| #define | FLOW_COPY_IPV4_ADDR_TO_PACKET(fa, pa) |
| |
| #define | FLOW_COPY_IPV6_ADDR_TO_PACKET(fa, pa) |
| |
| #define | FLOW_SET_IPV4_SRC_ADDR_FROM_PACKET(ip4h, a) |
| |
| #define | FLOW_SET_IPV4_DST_ADDR_FROM_PACKET(ip4h, a) |
| |
| #define | FLOW_SET_IPV6_SRC_ADDR_FROM_PACKET(ip6h, a) |
| |
| #define | FLOW_SET_IPV6_DST_ADDR_FROM_PACKET(ip6h, a) |
| |
| #define | FLOW_PKT_TOSERVER 0x01 |
| |
| #define | FLOW_PKT_TOCLIENT 0x02 |
| |
| #define | FLOW_PKT_ESTABLISHED 0x04 |
| |
| #define | FLOW_PKT_TOSERVER_FIRST 0x08 |
| |
| #define | FLOW_PKT_TOCLIENT_FIRST 0x10 |
| |
| #define | FLOW_PKT_LAST_PSEUDO 0x20 |
| |
| #define | FLOW_END_FLAG_EMERGENCY 0x01 |
| |
| #define | FLOW_END_FLAG_TIMEOUT 0x02 |
| |
| #define | FLOW_END_FLAG_FORCED 0x04 |
| |
| #define | FLOW_END_FLAG_SHUTDOWN 0x08 |
| |
| #define | FLOW_END_FLAG_TCPREUSE 0x10 |
| |
| #define | FLOWLOCK_MUTEX |
| |
| #define | FLOWLOCK_INIT(fb) SCMutexInit(&(fb)->m, NULL) |
| |
| #define | FLOWLOCK_DESTROY(fb) SCMutexDestroy(&(fb)->m) |
| |
| #define | FLOWLOCK_RDLOCK(fb) SCMutexLock(&(fb)->m) |
| |
| #define | FLOWLOCK_WRLOCK(fb) SCMutexLock(&(fb)->m) |
| |
| #define | FLOWLOCK_TRYRDLOCK(fb) SCMutexTrylock(&(fb)->m) |
| |
| #define | FLOWLOCK_TRYWRLOCK(fb) SCMutexTrylock(&(fb)->m) |
| |
| #define | FLOWLOCK_UNLOCK(fb) SCMutexUnlock(&(fb)->m) |
| |
| #define | FLOW_IS_PM_DONE(f, dir) (((dir) & STREAM_TOSERVER) ? ((f)->flags & FLOW_TS_PM_ALPROTO_DETECT_DONE) : ((f)->flags & FLOW_TC_PM_ALPROTO_DETECT_DONE)) |
| |
| #define | FLOW_IS_PP_DONE(f, dir) (((dir) & STREAM_TOSERVER) ? ((f)->flags & FLOW_TS_PP_ALPROTO_DETECT_DONE) : ((f)->flags & FLOW_TC_PP_ALPROTO_DETECT_DONE)) |
| |
| #define | FLOW_IS_PE_DONE(f, dir) (((dir) & STREAM_TOSERVER) ? ((f)->flags & FLOW_TS_PE_ALPROTO_DETECT_DONE) : ((f)->flags & FLOW_TC_PE_ALPROTO_DETECT_DONE)) |
| |
| #define | FLOW_SET_PM_DONE(f, dir) (((dir) & STREAM_TOSERVER) ? ((f)->flags |= FLOW_TS_PM_ALPROTO_DETECT_DONE) : ((f)->flags |= FLOW_TC_PM_ALPROTO_DETECT_DONE)) |
| |
| #define | FLOW_SET_PP_DONE(f, dir) (((dir) & STREAM_TOSERVER) ? ((f)->flags |= FLOW_TS_PP_ALPROTO_DETECT_DONE) : ((f)->flags |= FLOW_TC_PP_ALPROTO_DETECT_DONE)) |
| |
| #define | FLOW_SET_PE_DONE(f, dir) (((dir) & STREAM_TOSERVER) ? ((f)->flags |= FLOW_TS_PE_ALPROTO_DETECT_DONE) : ((f)->flags |= FLOW_TC_PE_ALPROTO_DETECT_DONE)) |
| |
| #define | FLOW_RESET_PM_DONE(f, dir) (((dir) & STREAM_TOSERVER) ? ((f)->flags &= ~FLOW_TS_PM_ALPROTO_DETECT_DONE) : ((f)->flags &= ~FLOW_TC_PM_ALPROTO_DETECT_DONE)) |
| |
| #define | FLOW_RESET_PP_DONE(f, dir) (((dir) & STREAM_TOSERVER) ? ((f)->flags &= ~FLOW_TS_PP_ALPROTO_DETECT_DONE) : ((f)->flags &= ~FLOW_TC_PP_ALPROTO_DETECT_DONE)) |
| |
| #define | FLOW_RESET_PE_DONE(f, dir) (((dir) & STREAM_TOSERVER) ? ((f)->flags &= ~FLOW_TS_PE_ALPROTO_DETECT_DONE) : ((f)->flags &= ~FLOW_TC_PE_ALPROTO_DETECT_DONE)) |
| |
| #define | addr_data32 address.address_un_data32 |
| |
| #define | addr_data16 address.address_un_data16 |
| |
| #define | addr_data8 address.address_un_data8 |
| |
| #define | FLOW_STATE_SIZE 4 |
| |
|
| void | FlowSetupPacket (Packet *p) |
| | prepare packet for a life with flow Set PKT_WANTS_FLOW flag to indicate workers should do a flow lookup and calc the hash value to be used in the lookup and autofp flow balancing. More...
|
| |
| void | FlowHandlePacket (ThreadVars *, FlowLookupStruct *, Packet *) |
| | Entry point for packet flow handling. More...
|
| |
| void | FlowInitConfig (bool) |
| | initialize the configuration More...
|
| |
| void | FlowReset (void) |
| |
| void | FlowShutdown (void) |
| | shutdown the flow engine More...
|
| |
| void | FlowSetHasAlertsFlag (Flow *) |
| | Set flag to indicate that flow has alerts. More...
|
| |
| int | FlowHasAlerts (const Flow *) |
| | Check if flow has alerts. More...
|
| |
| void | FlowSetChangeProtoFlag (Flow *) |
| | Set flag to indicate to change proto for the flow. More...
|
| |
| void | FlowUnsetChangeProtoFlag (Flow *) |
| | Unset flag to indicate to change proto for the flow. More...
|
| |
| int | FlowChangeProto (Flow *) |
| | Check if change proto flag is set for flow. More...
|
| |
| void | FlowSwap (Flow *) |
| | swap the flow's direction More...
|
| |
| void | FlowRegisterTests (void) |
| | Function to register the Flow Unitests. More...
|
| |
| int | FlowSetProtoFreeFunc (uint8_t, void(*Free)(void *)) |
| | Function to set the function to get protocol specific flow state. More...
|
| |
| int | FlowGetPacketDirection (const Flow *, const Packet *) |
| | determine the direction of the packet compared to the flow More...
|
| |
| void | FlowCleanupAppLayer (Flow *) |
| |
| void | FlowUpdateState (Flow *f, enum FlowState s) |
| |
| int | FlowSetMemcap (uint64_t size) |
| | Update memcap value. More...
|
| |
| uint64_t | FlowGetMemcap (void) |
| | Return memcap value. More...
|
| |
| uint64_t | FlowGetMemuse (void) |
| |
| enum ExceptionPolicy | FlowGetMemcapExceptionPolicy (void) |
| |
| FlowStorageId | GetFlowBypassInfoID (void) |
| |
| void | RegisterFlowBypassInfo (void) |
| |
| int | FlowClearMemory (Flow *, uint8_t) |
| | Function clear the flow memory before queueing it to spare flow queue. More...
|
| |
| uint8_t | FlowGetDisruptionFlags (const Flow *f, uint8_t flags) |
| | get 'disruption' flags: GAP/DEPTH/PASS More...
|
| |
| void | FlowHandlePacketUpdate (Flow *f, Packet *p, ThreadVars *tv, DecodeThreadVars *dtv) |
| | Update Packet and Flow. More...
|
| |
Flow data structure.
The flow is a global data structure that is created for new packets of a flow and then looked up for the following packets of a flow.
Locking
The flow is updated/used by multiple packets at the same time. This is why there is a flow-mutex. It's a mutex and not a spinlock because some operations on the flow can be quite expensive, thus spinning would be too expensive.
The flow "header" (addresses, ports, proto, recursion level) are static after the initialization and remain read-only throughout the entire live of a flow. This is why we can access those without protection of the lock.