31 #ifdef CAPTURE_OFFLOAD_MANAGER
33 #define FLOW_BYPASS_DELAY 10
35 #ifndef TIMEVAL_TO_TIMESPEC
36 #define TIMEVAL_TO_TIMESPEC(tv, ts) { \
37 (ts)->tv_sec = (tv)->tv_sec; \
38 (ts)->tv_nsec = (tv)->tv_usec * 1000; \
42 typedef struct BypassedFlowManagerThreadData_ {
43 uint16_t flow_bypassed_cnt_clo;
44 uint16_t flow_bypassed_pkts;
45 uint16_t flow_bypassed_bytes;
46 } BypassedFlowManagerThreadData;
48 #define BYPASSFUNCMAX 4
50 typedef struct BypassedCheckFuncItem_ {
54 } BypassedCheckFuncItem;
56 int g_bypassed_func_max_index = 0;
57 BypassedCheckFuncItem bypassedfunclist[BYPASSFUNCMAX];
59 typedef struct BypassedUpdateFuncItem_ {
62 } BypassedUpdateFuncItem;
64 int g_bypassed_update_max_index = 0;
65 BypassedUpdateFuncItem updatefunclist[BYPASSFUNCMAX];
71 BypassedFlowManagerThreadData *ftd = thread_data;
72 struct timespec curtime = {0, 0};
75 gettimeofday(&
tv, NULL);
76 TIMEVAL_TO_TIMESPEC(&
tv, &curtime);
78 for (i = 0; i < g_bypassed_func_max_index; i++) {
79 if (bypassedfunclist[i].FuncInit) {
80 bypassedfunclist[i].FuncInit(th_v, &curtime, bypassedfunclist[i].data);
86 for (i = 0; i < g_bypassed_func_max_index; i++) {
87 if (bypassedfunclist[i].FuncInit) {
97 gettimeofday(&
tv, NULL);
98 TIMEVAL_TO_TIMESPEC(&
tv, &curtime);
100 for (i = 0; i < g_bypassed_func_max_index; i++) {
102 if (bypassedfunclist[i].Func == NULL)
104 tcount = bypassedfunclist[i].Func(th_v, &bypassstats, &curtime, bypassedfunclist[i].data);
116 for (i = 0; i < FLOW_BYPASS_DELAY * 100; i++) {
128 static TmEcode BypassedFlowManagerThreadInit(
ThreadVars *t,
const void *initdata,
void **data)
130 BypassedFlowManagerThreadData *ftd =
SCCalloc(1,
sizeof(BypassedFlowManagerThreadData));
154 if (g_bypassed_func_max_index < BYPASSFUNCMAX) {
155 bypassedfunclist[g_bypassed_func_max_index].Func = CheckFunc;
156 bypassedfunclist[g_bypassed_func_max_index].FuncInit = CheckFuncInit;
157 bypassedfunclist[g_bypassed_func_max_index].data = data;
158 g_bypassed_func_max_index++;
171 if (g_bypassed_update_max_index < BYPASSFUNCMAX) {
172 updatefunclist[g_bypassed_update_max_index].Func = UpdateFunc;
173 updatefunclist[g_bypassed_update_max_index].data = data;
174 g_bypassed_update_max_index++;
185 #ifdef CAPTURE_OFFLOAD_MANAGER
189 "BypassedFlowManager", 0);
190 BUG_ON(tv_flowmgr == NULL);
192 if (tv_flowmgr == NULL) {
193 printf(
"ERROR: TmThreadsCreate failed\n");
197 printf(
"ERROR: TmThreadSpawn failed\n");
205 #ifdef CAPTURE_OFFLOAD_MANAGER
206 for (
int i = 0; i < g_bypassed_update_max_index; i++) {
207 if (updatefunclist[i].Func(f, p, updatefunclist[i].data)) {
216 #ifdef CAPTURE_OFFLOAD_MANAGER