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-cpu.h"
29 #include "util-affinity.h"
30 #include "util-runmodes.h"
31 
32 static uint16_t DagConfigGetThreadCount(void *conf)
33 {
34  return 1;
35 }
36 
37 static void *ParseDagConfig(const char *iface)
38 {
39  return (void *)iface;
40 }
41 
42 const char *RunModeErfDagGetDefaultMode(void)
43 {
44  return "autofp";
45 }
46 
48 {
50  "Multi threaded DAG mode. Packets from "
51  "each flow are assigned to a single detect "
52  "thread, unlike \"dag_auto\" where packets "
53  "from the same flow can be processed by any "
54  "detect thread",
56 
58  RUNMODE_DAG, "single", "Singled threaded DAG mode", RunModeIdsErfDagSingle, NULL);
59 
61  "Workers DAG mode, each thread does all "
62  " tasks from acquisition to logging",
64 }
65 
67 {
68  int ret;
69 
70  SCEnter();
71 
73 
74  ret = RunModeSetLiveCaptureSingle(ParseDagConfig,
75  DagConfigGetThreadCount,
76  "ReceiveErfDag",
77  "DecodeErfDag",
79  NULL);
80  if (ret != 0) {
81  FatalError("DAG single runmode failed to start");
82  }
83 
84  SCLogInfo("RunModeIdsDagSingle initialised");
85 
86  SCReturnInt(0);
87 }
88 
90 {
91  int ret;
92 
93  SCEnter();
94 
96 
97  ret = RunModeSetLiveCaptureAutoFp(ParseDagConfig, DagConfigGetThreadCount, "ReceiveErfDag",
98  "DecodeErfDag", thread_name_autofp, NULL);
99  if (ret != 0) {
100  FatalError("DAG autofp runmode failed to start");
101  }
102 
103  SCLogInfo("RunModeIdsDagAutoFp initialised");
104 
105  SCReturnInt(0);
106 }
107 
109 {
110  int ret;
111 
112  SCEnter();
113 
114  TimeModeSetLive();
115 
116  ret = RunModeSetLiveCaptureWorkers(ParseDagConfig, DagConfigGetThreadCount, "ReceiveErfDag",
117  "DecodeErfDag", thread_name_workers, NULL);
118  if (ret != 0) {
119  FatalError("DAG workers runmode failed to start");
120  }
121 
122  SCLogInfo("RunModeIdsErfDagWorkers initialised");
123 
124  SCReturnInt(0);
125 }
thread_name_workers
const char * thread_name_workers
Definition: runmodes.c:67
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:329
util-runmodes.h
RunModeIdsErfDagSingle
int RunModeIdsErfDagSingle(void)
Definition: runmode-erf-dag.c:66
thread_name_autofp
const char * thread_name_autofp
Definition: runmodes.c:65
thread_name_single
const char * thread_name_single
Definition: runmodes.c:66
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:108
util-debug.h
util-cpu.h
SCEnter
#define SCEnter(...)
Definition: util-debug.h:284
RUNMODE_DAG
@ RUNMODE_DAG
Definition: runmodes.h:35
util-affinity.h
RunModeErfDagGetDefaultMode
const char * RunModeErfDagGetDefaultMode(void)
Definition: runmode-erf-dag.c:42
runmode-erf-dag.h
conf.h
RunModeRegisterNewRunMode
void RunModeRegisterNewRunMode(enum SCRunModes runmode, const char *name, const char *description, int(*RunModeFunc)(void), int(*RunModeIsIPSEnabled)(void))
Registers a new runmode.
Definition: runmodes.c:481
RunModeErfDagRegister
void RunModeErfDagRegister(void)
Definition: runmode-erf-dag.c:47
runmodes.h
SCLogInfo
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
Definition: util-debug.h:232
TimeModeSetLive
void TimeModeSetLive(void)
Definition: util-time.c:99
suricata-common.h
RunModeIdsErfDagAutoFp
int RunModeIdsErfDagAutoFp(void)
Definition: runmode-erf-dag.c:89
FatalError
#define FatalError(...)
Definition: util-debug.h:517
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:353
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:288
output.h