suricata
runmode-erf-dag.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2010 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 #include "suricata-common.h"
19 #include "tm-threads.h"
20 #include "conf.h"
21 #include "runmodes.h"
22 #include "runmode-erf-dag.h"
23 #include "output.h"
24 
25 #include "detect-engine.h"
26 
27 #include "util-debug.h"
28 #include "util-time.h"
29 #include "util-cpu.h"
30 #include "util-affinity.h"
31 #include "util-runmodes.h"
32 
33 static int DagConfigGetThreadCount(void *conf)
34 {
35  return 1;
36 }
37 
38 static void *ParseDagConfig(const char *iface)
39 {
40  return (void *)iface;
41 }
42 
43 const char *RunModeErfDagGetDefaultMode(void)
44 {
45  return "autofp";
46 }
47 
49 {
51  "Multi threaded DAG mode. Packets from "
52  "each flow are assigned to a single detect "
53  "thread, unlike \"dag_auto\" where packets "
54  "from the same flow can be processed by any "
55  "detect thread",
57 
59  RUNMODE_DAG, "single", "Singled threaded DAG mode", RunModeIdsErfDagSingle, NULL);
60 
62  "Workers DAG mode, each thread does all "
63  " tasks from acquisition to logging",
65 
66  return;
67 }
68 
70 {
71  int ret;
72 
73  SCEnter();
74 
76 
77  ret = RunModeSetLiveCaptureSingle(ParseDagConfig,
78  DagConfigGetThreadCount,
79  "ReceiveErfDag",
80  "DecodeErfDag",
82  NULL);
83  if (ret != 0) {
84  FatalError("DAG single runmode failed to start");
85  }
86 
87  SCLogInfo("RunModeIdsDagSingle initialised");
88 
89  SCReturnInt(0);
90 }
91 
93 {
94  int ret;
95 
96  SCEnter();
97 
99 
100  ret = RunModeSetLiveCaptureAutoFp(ParseDagConfig, DagConfigGetThreadCount, "ReceiveErfDag",
101  "DecodeErfDag", thread_name_autofp, NULL);
102  if (ret != 0) {
103  FatalError("DAG autofp runmode failed to start");
104  }
105 
106  SCLogInfo("RunModeIdsDagAutoFp initialised");
107 
108  SCReturnInt(0);
109 }
110 
112 {
113  int ret;
114 
115  SCEnter();
116 
117  TimeModeSetLive();
118 
119  ret = RunModeSetLiveCaptureWorkers(ParseDagConfig, DagConfigGetThreadCount, "ReceiveErfDag",
120  "DecodeErfDag", thread_name_workers, NULL);
121  if (ret != 0) {
122  FatalError("DAG workers runmode failed to start");
123  }
124 
125  SCLogInfo("RunModeIdsErfDagWorkers initialised");
126 
127  SCReturnInt(0);
128 }
thread_name_workers
const char * thread_name_workers
Definition: runmodes.c:82
tm-threads.h
detect-engine.h
RunModeSetLiveCaptureWorkers
int RunModeSetLiveCaptureWorkers(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, const char *recv_mod_name, const char *decode_mod_name, const char *thread_name, const char *live_dev)
Definition: util-runmodes.c:321
util-runmodes.h
RunModeIdsErfDagSingle
int RunModeIdsErfDagSingle(void)
Definition: runmode-erf-dag.c:69
thread_name_autofp
const char * thread_name_autofp
Definition: runmodes.c:80
thread_name_single
const char * thread_name_single
Definition: runmodes.c:81
RUNMODE_DAG
@ RUNMODE_DAG
Definition: runmodes.h:36
RunModeSetLiveCaptureAutoFp
int RunModeSetLiveCaptureAutoFp(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, const char *recv_mod_name, const char *decode_mod_name, const char *thread_name, const char *live_dev)
Definition: util-runmodes.c:85
RunModeIdsErfDagWorkers
int RunModeIdsErfDagWorkers(void)
Definition: runmode-erf-dag.c:111
util-debug.h
util-cpu.h
RunModeRegisterNewRunMode
void RunModeRegisterNewRunMode(enum RunModes runmode, const char *name, const char *description, int(*RunModeFunc)(void), int(*RunModeIsIPSEnabled)(void))
Registers a new runmode.
Definition: runmodes.c:502
SCEnter
#define SCEnter(...)
Definition: util-debug.h:271
util-affinity.h
util-time.h
RunModeErfDagGetDefaultMode
const char * RunModeErfDagGetDefaultMode(void)
Definition: runmode-erf-dag.c:43
runmode-erf-dag.h
conf.h
RunModeErfDagRegister
void RunModeErfDagRegister(void)
Definition: runmode-erf-dag.c:48
runmodes.h
SCLogInfo
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
Definition: util-debug.h:224
TimeModeSetLive
void TimeModeSetLive(void)
Definition: util-time.c:99
suricata-common.h
RunModeIdsErfDagAutoFp
int RunModeIdsErfDagAutoFp(void)
Definition: runmode-erf-dag.c:92
FatalError
#define FatalError(...)
Definition: util-debug.h:502
RunModeSetLiveCaptureSingle
int RunModeSetLiveCaptureSingle(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, const char *recv_mod_name, const char *decode_mod_name, const char *thread_name, const char *live_dev)
Definition: util-runmodes.c:350
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:275
output.h