suricata
runmode.c
Go to the documentation of this file.
1/* Copyright (C) 2024 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 "runmodes.h"
20#include "tm-threads.h"
21#include "util-affinity.h"
22
23#include "runmode.h"
24
26{
27 return "autofp";
28}
29
30static int RunModeSingle(void)
31{
32 SCLogNotice("...");
33
34 char thread_name[TM_THREAD_NAME_MAX];
35 snprintf(thread_name, sizeof(thread_name), "%s#01", thread_name_single);
37 thread_name, "packetpool", "packetpool", "packetpool", "packetpool", "pktacqloop");
38 if (tv == NULL) {
39 SCLogError("TmThreadCreatePacketHandler failed");
40 return -1;
41 }
42
43 TmModule *tm_module = TmModuleGetByName("ReceiveCiCapture");
44 if (tm_module == NULL) {
45 FatalError("TmModuleGetByName failed for ReceiveCiCapture");
46 }
47 TmSlotSetFuncAppend(tv, tm_module, NULL);
48
49 tm_module = TmModuleGetByName("DecodeCiCapture");
50 if (tm_module == NULL) {
51 FatalError("TmModuleGetByName DecodeCiCapture failed");
52 }
53 TmSlotSetFuncAppend(tv, tm_module, NULL);
54
55 tm_module = TmModuleGetByName("FlowWorker");
56 if (tm_module == NULL) {
57 FatalError("TmModuleGetByName for FlowWorker failed");
58 }
59 TmSlotSetFuncAppend(tv, tm_module, NULL);
60
62
64 FatalError("TmThreadSpawn failed");
65 }
66
67 return 0;
68}
69
71{
72 RunModeRegisterNewRunMode(slot, "single", "Single threaded", RunModeSingle, NULL);
73}
ThreadVars * tv
const char * CiCaptureIdsGetDefaultRunMode(void)
Definition runmode.c:25
void CiCaptureIdsRegister(int slot)
Definition runmode.c:70
const char * thread_name_single
Definition runmodes.c:67
void RunModeRegisterNewRunMode(enum SCRunModes runmode, const char *name, const char *description, int(*RunModeFunc)(void), int(*RunModeIsIPSEnabled)(void))
Registers a new runmode.
Definition runmodes.c:486
Per thread variable structure.
Definition threadvars.h:58
TmModule * TmModuleGetByName(const char *name)
get a tm module ptr by name
Definition tm-modules.c:46
@ TM_ECODE_OK
void TmSlotSetFuncAppend(ThreadVars *tv, TmModule *tm, const void *data)
Appends a new entry to the slots.
Definition tm-threads.c:658
ThreadVars * TmThreadCreatePacketHandler(const char *name, const char *inq_name, const char *inqh_name, const char *outq_name, const char *outqh_name, const char *slots)
Creates and returns a TV instance for a Packet Processing Thread. This function doesn't support custo...
TmEcode TmThreadSetCPU(ThreadVars *tv, uint8_t type)
Definition tm-threads.c:831
TmEcode TmThreadSpawn(ThreadVars *tv)
Spawns a thread associated with the ThreadVars instance tv.
#define TM_THREAD_NAME_MAX
Definition tm-threads.h:49
@ WORKER_CPU_SET
#define FatalError(...)
Definition util-debug.h:510
#define SCLogNotice(...)
Macro used to log NOTICE messages.
Definition util-debug.h:243
#define SCLogError(...)
Macro used to log ERROR messages.
Definition util-debug.h:267