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_ {
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) {
101 gettimeofday(&
tv, NULL);
102 TIMEVAL_TO_TIMESPEC(&
tv, &curtime);
104 for (i = 0; i < g_bypassed_func_max_index; i++) {
106 if (bypassedfunclist[i].Func == NULL)
108 tcount = bypassedfunclist[i].Func(th_v, &bypassstats, &curtime, bypassedfunclist[i].data);
111 &th_v->
stats, ftd->flow_bypassed_cnt_clo, (uint64_t)bypassstats.
count);
114 &th_v->
stats, ftd->flow_bypassed_pkts, (uint64_t)bypassstats.
packets);
122 for (i = 0; i < FLOW_BYPASS_DELAY * 100; i++) {
134 static TmEcode BypassedFlowManagerThreadInit(
ThreadVars *t,
const void *initdata,
void **data)
136 BypassedFlowManagerThreadData *ftd =
SCCalloc(1,
sizeof(BypassedFlowManagerThreadData));
160 if (g_bypassed_func_max_index < BYPASSFUNCMAX) {
161 bypassedfunclist[g_bypassed_func_max_index].Func = CheckFunc;
162 bypassedfunclist[g_bypassed_func_max_index].FuncInit = CheckFuncInit;
163 bypassedfunclist[g_bypassed_func_max_index].data = data;
164 g_bypassed_func_max_index++;
177 if (g_bypassed_update_max_index < BYPASSFUNCMAX) {
178 updatefunclist[g_bypassed_update_max_index].Func = UpdateFunc;
179 updatefunclist[g_bypassed_update_max_index].data = data;
180 g_bypassed_update_max_index++;
191 #ifdef CAPTURE_OFFLOAD_MANAGER
195 "BypassedFlowManager", 0);
196 BUG_ON(tv_flowmgr == NULL);
198 if (tv_flowmgr == NULL) {
199 printf(
"ERROR: TmThreadsCreate failed\n");
203 printf(
"ERROR: TmThreadSpawn failed\n");
211 #ifdef CAPTURE_OFFLOAD_MANAGER
212 for (
int i = 0; i < g_bypassed_update_max_index; i++) {
213 if (updatefunclist[i].Func(f, p, updatefunclist[i].data)) {
222 #ifdef CAPTURE_OFFLOAD_MANAGER