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) {
105 gettimeofday(&
tv, NULL);
106 TIMEVAL_TO_TIMESPEC(&
tv, &curtime);
108 for (i = 0; i < g_bypassed_func_max_index; i++) {
110 if (bypassedfunclist[i].Func == NULL)
112 tcount = bypassedfunclist[i].Func(th_v, &bypassstats, &curtime, bypassedfunclist[i].data);
124 for (i = 0; i < FLOW_BYPASS_DELAY * 100; i++) {
136 static TmEcode BypassedFlowManagerThreadInit(
ThreadVars *t,
const void *initdata,
void **data)
138 BypassedFlowManagerThreadData *ftd =
SCCalloc(1,
sizeof(BypassedFlowManagerThreadData));
162 if (g_bypassed_func_max_index < BYPASSFUNCMAX) {
163 bypassedfunclist[g_bypassed_func_max_index].Func = CheckFunc;
164 bypassedfunclist[g_bypassed_func_max_index].FuncInit = CheckFuncInit;
165 bypassedfunclist[g_bypassed_func_max_index].data = data;
166 g_bypassed_func_max_index++;
179 if (g_bypassed_update_max_index < BYPASSFUNCMAX) {
180 updatefunclist[g_bypassed_update_max_index].Func = UpdateFunc;
181 updatefunclist[g_bypassed_update_max_index].data = data;
182 g_bypassed_update_max_index++;
193 #ifdef CAPTURE_OFFLOAD_MANAGER
197 "BypassedFlowManager", 0);
198 BUG_ON(tv_flowmgr == NULL);
200 if (tv_flowmgr == NULL) {
201 printf(
"ERROR: TmThreadsCreate failed\n");
205 printf(
"ERROR: TmThreadSpawn failed\n");
213 #ifdef CAPTURE_OFFLOAD_MANAGER
214 for (
int i = 0; i < g_bypassed_update_max_index; i++) {
215 if (updatefunclist[i].Func(f, p, updatefunclist[i].data)) {
224 #ifdef CAPTURE_OFFLOAD_MANAGER