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) {
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);
120 for (i = 0; i < FLOW_BYPASS_DELAY * 100; i++) {
132 static TmEcode BypassedFlowManagerThreadInit(
ThreadVars *t,
const void *initdata,
void **data)
134 BypassedFlowManagerThreadData *ftd =
SCCalloc(1,
sizeof(BypassedFlowManagerThreadData));
158 if (g_bypassed_func_max_index < BYPASSFUNCMAX) {
159 bypassedfunclist[g_bypassed_func_max_index].Func = CheckFunc;
160 bypassedfunclist[g_bypassed_func_max_index].FuncInit = CheckFuncInit;
161 bypassedfunclist[g_bypassed_func_max_index].data = data;
162 g_bypassed_func_max_index++;
175 if (g_bypassed_update_max_index < BYPASSFUNCMAX) {
176 updatefunclist[g_bypassed_update_max_index].Func = UpdateFunc;
177 updatefunclist[g_bypassed_update_max_index].data = data;
178 g_bypassed_update_max_index++;
189 #ifdef CAPTURE_OFFLOAD_MANAGER
193 "BypassedFlowManager", 0);
194 BUG_ON(tv_flowmgr == NULL);
196 if (tv_flowmgr == NULL) {
197 printf(
"ERROR: TmThreadsCreate failed\n");
201 printf(
"ERROR: TmThreadSpawn failed\n");
209 #ifdef CAPTURE_OFFLOAD_MANAGER
210 for (
int i = 0; i < g_bypassed_update_max_index; i++) {
211 if (updatefunclist[i].Func(f, p, updatefunclist[i].data)) {
220 #ifdef CAPTURE_OFFLOAD_MANAGER