suricata
main.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.h"
19
20int main(int argc, char **argv)
21{
22 SuricataPreInit(argv[0]);
23
24 /* Parse command line options. This is optional, you could
25 * directly configure Suricata through the Conf API. */
26 SCParseCommandLine(argc, argv);
27
28 /* Validate/finalize the runmode. */
30 exit(EXIT_FAILURE);
31 }
32
33 /* Handle internal runmodes. Typically you wouldn't do this as a
34 * library user, however this example is showing how to replicate
35 * the Suricata application with the library. */
36 switch (SCStartInternalRunMode(argc, argv)) {
37 case TM_ECODE_DONE:
38 exit(EXIT_SUCCESS);
39 case TM_ECODE_FAILED:
40 exit(EXIT_FAILURE);
41 }
42
43 /* Load configuration file, could be done earlier but must be done
44 * before SuricataInit, but even then its still optional as you
45 * may be programmatically configuration Suricata. */
47 exit(EXIT_FAILURE);
48 }
49
50 /* Enable default signal handlers just like Suricata. */
52
55
56 /* Suricata is now running, but we enter a loop to keep it running
57 * until it shouldn't be running anymore. */
59
60 /* Shutdown engine. */
63
64 return EXIT_SUCCESS;
65}
int main(int argc, char **argv)
Definition main.c:157
void SuricataInit(void)
Definition suricata.c:3012
void SCEnableDefaultSignalHandlers(void)
Enable default signal handlers.
Definition suricata.c:289
void SuricataShutdown(void)
Definition suricata.c:3100
TmEcode SCLoadYamlConfig(void)
Definition suricata.c:1012
int SCFinalizeRunMode(void)
Definition suricata.c:2451
int SCStartInternalRunMode(int argc, char **argv)
Definition suricata.c:2389
void GlobalsDestroy(void)
Definition suricata.c:390
TmEcode SCParseCommandLine(int argc, char **argv)
Definition suricata.c:1369
void SuricataMainLoop(void)
Definition suricata.c:2922
void SuricataPreInit(const char *progname)
Definition suricata.c:3003
void SuricataPostInit(void)
Definition suricata.c:3111
@ TM_ECODE_FAILED
@ TM_ECODE_OK
@ TM_ECODE_DONE