summaryrefslogtreecommitdiffstats
path: root/src/runmode-erf-dag.c
blob: 503d1a15562ab0b8e92a6faf3e13d54f06ac9e76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* Copyright (C) 2007-2010 Open Information Security Foundation
 *
 * You can copy, redistribute or modify this Program under the terms of
 * the GNU General Public License version 2 as published by the Free
 * Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * version 2 along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */

#include "suricata-common.h"
#include "tm-threads.h"
#include "conf.h"
#include "runmodes.h"
#include "runmode-erf-dag.h"
#include "output.h"

#include "detect-engine.h"

#include "util-debug.h"
#include "util-time.h"
#include "util-cpu.h"
#include "util-affinity.h"
#include "util-runmodes.h"

static int DagConfigGetThreadCount(void *conf)
{
    return 1;
}

static void *ParseDagConfig(const char *iface)
{
    return (void *)iface;
}

const char *RunModeErfDagGetDefaultMode(void)
{
    return "autofp";
}

void RunModeErfDagRegister(void)
{
    RunModeRegisterNewRunMode(RUNMODE_DAG, "autofp",
            "Multi threaded DAG mode.  Packets from "
            "each flow are assigned to a single detect "
            "thread, unlike \"dag_auto\" where packets "
            "from the same flow can be processed by any "
            "detect thread",
            RunModeIdsErfDagAutoFp, NULL);

    RunModeRegisterNewRunMode(
            RUNMODE_DAG, "single", "Singled threaded DAG mode", RunModeIdsErfDagSingle, NULL);

    RunModeRegisterNewRunMode(RUNMODE_DAG, "workers",
            "Workers DAG mode, each thread does all "
            " tasks from acquisition to logging",
            RunModeIdsErfDagWorkers, NULL);

    return;
}

int RunModeIdsErfDagSingle(void)
{
    int ret;

    SCEnter();

    TimeModeSetLive();

    ret = RunModeSetLiveCaptureSingle(ParseDagConfig,
        DagConfigGetThreadCount,
        "ReceiveErfDag",
        "DecodeErfDag",
        thread_name_single,
        NULL);
    if (ret != 0) {
        FatalError("DAG single runmode failed to start");
    }

    SCLogInfo("RunModeIdsDagSingle initialised");

    SCReturnInt(0);
}

int RunModeIdsErfDagAutoFp(void)
{
    int ret;

    SCEnter();

    TimeModeSetLive();

    ret = RunModeSetLiveCaptureAutoFp(ParseDagConfig, DagConfigGetThreadCount, "ReceiveErfDag",
            "DecodeErfDag", thread_name_autofp, NULL);
    if (ret != 0) {
        FatalError("DAG autofp runmode failed to start");
    }

    SCLogInfo("RunModeIdsDagAutoFp initialised");

    SCReturnInt(0);
}

int RunModeIdsErfDagWorkers(void)
{
    int ret;

    SCEnter();

    TimeModeSetLive();

    ret = RunModeSetLiveCaptureWorkers(ParseDagConfig, DagConfigGetThreadCount, "ReceiveErfDag",
            "DecodeErfDag", thread_name_workers, NULL);
    if (ret != 0) {
        FatalError("DAG workers runmode failed to start");
    }

    SCLogInfo("RunModeIdsErfDagWorkers initialised");

    SCReturnInt(0);
}