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 const char *default_mode;
34 
35 static int DagConfigGetThreadCount(void *conf)
36 {
37  return 1;
38 }
39 
40 static void *ParseDagConfig(const char *iface)
41 {
42  return (void *)iface;
43 }
44 
45 const char *RunModeErfDagGetDefaultMode(void)
46 {
47  return default_mode;
48 }
49 
51 {
52  default_mode = "autofp";
53 
55  "Multi threaded DAG mode. Packets from "
56  "each flow are assigned to a single detect "
57  "thread, unlike \"dag_auto\" where packets "
58  "from the same flow can be processed by any "
59  "detect thread",
61 
63  "Singled threaded DAG mode",
65 
67  "Workers DAG mode, each thread does all "
68  " tasks from acquisition to logging",
70 
71  return;
72 }
73 
75 {
76  int ret;
77 
78  SCEnter();
79 
81 
83 
84  ret = RunModeSetLiveCaptureSingle(ParseDagConfig,
85  DagConfigGetThreadCount,
86  "ReceiveErfDag",
87  "DecodeErfDag",
89  NULL);
90  if (ret != 0) {
91  SCLogError(SC_ERR_RUNMODE, "DAG single runmode failed to start");
92  exit(EXIT_FAILURE);
93  }
94 
95  SCLogInfo("RunModeIdsDagSingle initialised");
96 
97  SCReturnInt(0);
98 }
99 
101 {
102  int ret;
103 
104  SCEnter();
105 
107 
108  TimeModeSetLive();
109 
110  ret = RunModeSetLiveCaptureAutoFp(ParseDagConfig,
111  DagConfigGetThreadCount,
112  "ReceiveErfDag",
113  "DecodeErfDag",
115  NULL);
116  if (ret != 0) {
117  SCLogError(SC_ERR_RUNMODE, "DAG autofp runmode failed to start");
118  exit(EXIT_FAILURE);
119  }
120 
121  SCLogInfo("RunModeIdsDagAutoFp initialised");
122 
123  SCReturnInt(0);
124 }
125 
127 {
128  int ret;
129 
130  SCEnter();
131 
133 
134  TimeModeSetLive();
135 
136  ret = RunModeSetLiveCaptureWorkers(ParseDagConfig,
137  DagConfigGetThreadCount,
138  "ReceiveErfDag",
139  "DecodeErfDag",
141  NULL);
142  if (ret != 0) {
143  SCLogError(SC_ERR_RUNMODE, "DAG workers runmode failed to start");
144  exit(EXIT_FAILURE);
145  }
146 
147  SCLogInfo("RunModeIdsErfDagWorkers initialised");
148 
149  SCReturnInt(0);
150 }
int RunModeIdsErfDagAutoFp(void)
void RunModeInitialize(void)
Definition: runmodes.c:912
void RunModeRegisterNewRunMode(int runmode, const char *name, const char *description, int(*RunModeFunc)(void))
Registers a new runmode.
Definition: runmodes.c:426
int RunModeIdsErfDagSingle(void)
const char * thread_name_single
Definition: runmodes.c:62
void TimeModeSetLive(void)
Definition: util-time.c:82
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:89
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:294
#define SCEnter(...)
Definition: util-debug.h:337
#define SCReturnInt(x)
Definition: util-debug.h:341
void RunModeErfDagRegister(void)
int RunModeSetLiveCaptureSingle(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, const char *recv_mod_name, const char *decode_mod_name, const char *thread_name, const char *live_dev)
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
Definition: util-debug.h:254
const char * RunModeErfDagGetDefaultMode(void)
const char * thread_name_autofp
Definition: runmodes.c:61
int RunModeIdsErfDagWorkers(void)
int RunModeSetLiveCaptureWorkers(ConfigIfaceParserFunc ConfigParser, ConfigIfaceThreadsCountFunc ModThreadsCount, const char *recv_mod_name, const char *decode_mod_name, const char *thread_name, const char *live_dev)
const char * thread_name_workers
Definition: runmodes.c:63