Go to the documentation of this file.
24 #ifndef __FLOW_UTIL_H__
25 #define __FLOW_UTIL_H__
30 #define COPY_TIMESTAMP(src, dst) ((dst)->tv_sec = (src)->tv_sec, (dst)->tv_usec = (src)->tv_usec)
32 #define RESET_COUNTERS(f) \
34 (f)->todstpktcnt = 0; \
35 (f)->tosrcpktcnt = 0; \
36 (f)->todstbytecnt = 0; \
37 (f)->tosrcbytecnt = 0; \
40 #define FLOW_INITIALIZE(f) \
45 (f)->livedev = NULL; \
46 (f)->timeout_at = 0; \
47 (f)->timeout_policy = 0; \
50 (f)->flow_state = 0; \
53 (f)->probing_parser_toserver_alproto_masks = 0; \
54 (f)->probing_parser_toclient_alproto_masks = 0; \
56 (f)->file_flags = 0; \
57 (f)->protodetect_dp = 0; \
58 SCTIME_INIT((f)->lastts); \
60 (f)->protoctx = NULL; \
61 (f)->flow_end_flags = 0; \
63 (f)->alproto_ts = 0; \
64 (f)->alproto_tc = 0; \
65 (f)->alproto_orig = 0; \
66 (f)->alproto_expect = 0; \
67 (f)->de_ctx_version = 0; \
68 (f)->thread_id[0] = 0; \
69 (f)->thread_id[1] = 0; \
70 (f)->alparser = NULL; \
71 (f)->alstate = NULL; \
72 (f)->sgh_toserver = NULL; \
73 (f)->sgh_toclient = NULL; \
74 (f)->flowvar = NULL; \
75 RESET_COUNTERS((f)); \
83 #define FLOW_RECYCLE(f) \
85 FlowCleanupAppLayer((f)); \
89 (f)->livedev = NULL; \
93 (f)->timeout_at = 0; \
94 (f)->timeout_policy = 0; \
95 (f)->flow_state = 0; \
98 (f)->probing_parser_toserver_alproto_masks = 0; \
99 (f)->probing_parser_toclient_alproto_masks = 0; \
101 (f)->file_flags = 0; \
102 (f)->protodetect_dp = 0; \
103 SCTIME_INIT((f)->lastts); \
104 (f)->protoctx = NULL; \
105 (f)->flow_end_flags = 0; \
106 (f)->alparser = NULL; \
107 (f)->alstate = NULL; \
109 (f)->alproto_ts = 0; \
110 (f)->alproto_tc = 0; \
111 (f)->alproto_orig = 0; \
112 (f)->alproto_expect = 0; \
113 (f)->de_ctx_version = 0; \
114 (f)->thread_id[0] = 0; \
115 (f)->thread_id[1] = 0; \
116 (f)->sgh_toserver = NULL; \
117 (f)->sgh_toclient = NULL; \
118 GenericVarFree((f)->flowvar); \
119 (f)->flowvar = NULL; \
120 if (MacSetFlowStorageEnabled()) { \
121 MacSet *ms = FlowGetStorageById((f), MacSetGetFlowStorageID()); \
126 RESET_COUNTERS((f)); \
129 #define FLOW_DESTROY(f) \
131 FlowCleanupAppLayer((f)); \
133 FLOWLOCK_DESTROY((f)); \
134 GenericVarFree((f)->flowvar); \
144 #define FLOW_CHECK_MEMCAP(size) \
145 ((((uint64_t)SC_ATOMIC_GET(flow_memuse) + (uint64_t)(size)) <= \
146 SC_ATOMIC_GET(flow_config.memcap)))
void StatsIncr(ThreadVars *tv, uint16_t id)
Increments the local counter.
uint8_t FlowGetProtoMapping(uint8_t)
Function to map the protocol to the defined FLOW_PROTO_* enumeration.
uint16_t flow_tcp_liberal
uint16_t flow_state[FLOW_STATE_SIZE]
Flow * FlowAlloc(void)
allocate a flow
uint16_t flow_tcp_state[TCP_CLOSED+1]
struct FlowEndCounters_ FlowEndCounters
Flow * FlowAllocDirect(void)
Per thread variable structure.
void FlowFree(Flow *)
cleanup & free the memory of a flow
void FlowEndCountersRegister(ThreadVars *t, FlowEndCounters *fec)
void FlowInit(Flow *, const Packet *)
uint8_t FlowGetReverseProtoMapping(uint8_t rproto)