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  "Singled threaded DAG mode",
61 
63  "Workers DAG mode, each thread does all "
64  " tasks from acquisition to logging",
66 
67  return;
68 }
69 
71 {
72  int ret;
73 
74  SCEnter();
75 
77 
79 
80  ret = RunModeSetLiveCaptureSingle(ParseDagConfig,
81  DagConfigGetThreadCount,
82  "ReceiveErfDag",
83  "DecodeErfDag",
85  NULL);
86  if (ret != 0) {
87  SCLogError(SC_ERR_RUNMODE, "DAG single runmode failed to start");
88  exit(EXIT_FAILURE);
89  }
90 
91  SCLogInfo("RunModeIdsDagSingle initialised");
92 
93  SCReturnInt(0);
94 }
95 
97 {
98  int ret;
99 
100  SCEnter();
101 
103 
104  TimeModeSetLive();
105 
106  ret = RunModeSetLiveCaptureAutoFp(ParseDagConfig,
107  DagConfigGetThreadCount,
108  "ReceiveErfDag",
109  "DecodeErfDag",
111  NULL);
112  if (ret != 0) {
113  SCLogError(SC_ERR_RUNMODE, "DAG autofp runmode failed to start");
114  exit(EXIT_FAILURE);
115  }
116 
117  SCLogInfo("RunModeIdsDagAutoFp initialised");
118 
119  SCReturnInt(0);
120 }
121 
123 {
124  int ret;
125 
126  SCEnter();
127 
129 
130  TimeModeSetLive();
131 
132  ret = RunModeSetLiveCaptureWorkers(ParseDagConfig,
133  DagConfigGetThreadCount,
134  "ReceiveErfDag",
135  "DecodeErfDag",
137  NULL);
138  if (ret != 0) {
139  SCLogError(SC_ERR_RUNMODE, "DAG workers runmode failed to start");
140  exit(EXIT_FAILURE);
141  }
142 
143  SCLogInfo("RunModeIdsErfDagWorkers initialised");
144 
145  SCReturnInt(0);
146 }
int RunModeIdsErfDagAutoFp(void)
void RunModeInitialize(void)
Definition: runmodes.c:900
int RunModeIdsErfDagSingle(void)
const char * thread_name_single
Definition: runmodes.c:62
void TimeModeSetLive(void)
Definition: util-time.c:90
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
void RunModeRegisterNewRunMode(enum RunModes runmode, const char *name, const char *description, int(*RunModeFunc)(void))
Registers a new runmode.
Definition: runmodes.c:419
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