32 #ifdef CAPTURE_OFFLOAD_MANAGER
34 #define FLOW_BYPASS_DELAY 10
36 #ifndef TIMEVAL_TO_TIMESPEC
37 #define TIMEVAL_TO_TIMESPEC(tv, ts) { \
38 (ts)->tv_sec = (tv)->tv_sec; \
39 (ts)->tv_nsec = (tv)->tv_usec * 1000; \
43 typedef struct BypassedFlowManagerThreadData_ {
44 uint16_t flow_bypassed_cnt_clo;
45 uint16_t flow_bypassed_pkts;
46 uint16_t flow_bypassed_bytes;
47 } BypassedFlowManagerThreadData;
49 #define BYPASSFUNCMAX 4
51 typedef struct BypassedCheckFuncItem_ {
55 } BypassedCheckFuncItem;
57 int g_bypassed_func_max_index = 0;
58 BypassedCheckFuncItem bypassedfunclist[BYPASSFUNCMAX];
60 typedef struct BypassedUpdateFuncItem_ {
63 } BypassedUpdateFuncItem;
65 int g_bypassed_update_max_index = 0;
66 BypassedUpdateFuncItem updatefunclist[BYPASSFUNCMAX];
72 BypassedFlowManagerThreadData *ftd = thread_data;
73 struct timespec curtime = {0, 0};
76 gettimeofday(&
tv, NULL);
77 TIMEVAL_TO_TIMESPEC(&
tv, &curtime);
79 for (i = 0; i < g_bypassed_func_max_index; i++) {
80 if (bypassedfunclist[i].FuncInit) {
81 bypassedfunclist[i].FuncInit(th_v, &curtime, bypassedfunclist[i].data);
87 for (i = 0; i < g_bypassed_func_max_index; i++) {
88 if (bypassedfunclist[i].FuncInit) {
98 gettimeofday(&
tv, NULL);
99 TIMEVAL_TO_TIMESPEC(&
tv, &curtime);
101 for (i = 0; i < g_bypassed_func_max_index; i++) {
103 if (bypassedfunclist[i].Func == NULL)
105 tcount = bypassedfunclist[i].Func(th_v, &bypassstats, &curtime, bypassedfunclist[i].data);
117 for (i = 0; i < FLOW_BYPASS_DELAY * 100; i++) {
129 static TmEcode BypassedFlowManagerThreadInit(
ThreadVars *t,
const void *initdata,
void **data)
131 BypassedFlowManagerThreadData *ftd =
SCCalloc(1,
sizeof(BypassedFlowManagerThreadData));
155 if (g_bypassed_func_max_index < BYPASSFUNCMAX) {
156 bypassedfunclist[g_bypassed_func_max_index].Func = CheckFunc;
157 bypassedfunclist[g_bypassed_func_max_index].FuncInit = CheckFuncInit;
158 bypassedfunclist[g_bypassed_func_max_index].data = data;
159 g_bypassed_func_max_index++;
172 if (g_bypassed_update_max_index < BYPASSFUNCMAX) {
173 updatefunclist[g_bypassed_update_max_index].Func = UpdateFunc;
174 updatefunclist[g_bypassed_update_max_index].data = data;
175 g_bypassed_update_max_index++;
186 #ifdef CAPTURE_OFFLOAD_MANAGER
190 "BypassedFlowManager", 0);
191 BUG_ON(tv_flowmgr == NULL);
193 if (tv_flowmgr == NULL) {
194 printf(
"ERROR: TmThreadsCreate failed\n");
198 printf(
"ERROR: TmThreadSpawn failed\n");
206 #ifdef CAPTURE_OFFLOAD_MANAGER
207 for (
int i = 0; i < g_bypassed_update_max_index; i++) {
208 if (updatefunclist[i].Func(f, p, updatefunclist[i].data)) {
217 #ifdef CAPTURE_OFFLOAD_MANAGER