suricata
suricata.h File Reference
#include "suricata-common.h"
#include "packet-queue.h"
#include "runmodes.h"
#include <ctype.h>
Include dependency graph for suricata.h:

Go to the source code of this file.

Data Structures

struct  SCInstance_
 

Macros

#define PROG_NAME   "Suricata"
 
#define PROG_VER   PACKAGE_VERSION
 
#define DEFAULT_CONF_FILE   CONFIG_DIR "/suricata.yaml"
 
#define DEFAULT_PID_DIR   LOCAL_STATE_DIR "/run/"
 
#define DEFAULT_PID_BASENAME   "suricata.pid"
 
#define DEFAULT_PID_FILENAME   DEFAULT_PID_DIR DEFAULT_PID_BASENAME
 
#define DOC_URL   "https://suricata.readthedocs.io/en/"
 
#define DOC_VERSION   "latest"
 
#define SURICATA_STOP   (1 << 0)
 
#define SURICATA_DONE   (1 << 2)
 
#define IS_SURI_HOST_MODE_SNIFFER_ONLY(host_mode)   ((host_mode) == SURI_HOST_IS_SNIFFER_ONLY)
 
#define IS_SURI_HOST_MODE_ROUTER(host_mode)   ((host_mode) == SURI_HOST_IS_ROUTER)
 
#define u8_tolower(c)   tolower((uint8_t)(c))
 
#define u8_toupper(c)   toupper((uint8_t)(c))
 

Typedefs

typedef struct SCInstance_ SCInstance
 

Enumerations

enum  { SURICATA_INIT = 0, SURICATA_RUNTIME, SURICATA_DEINIT }
 
enum  EngineMode { ENGINE_MODE_IDS, ENGINE_MODE_IPS }
 
enum  { SURI_HOST_IS_SNIFFER_ONLY, SURI_HOST_IS_ROUTER }
 

Functions

void EngineModeSetIPS (void)
 
void EngineModeSetIDS (void)
 
int EngineModeIsIPS (void)
 
int EngineModeIsIDS (void)
 
void GlobalsInitPreConfig (void)
 
void EngineStop (void)
 make sure threads can stop the engine by calling this function. Purpose: pcap file mode needs to be able to tell the engine the file eof is reached. More...
 
void EngineDone (void)
 Used to indicate that the current task is done. More...
 
int RunmodeIsUnittests (void)
 
int RunmodeGetCurrent (void)
 
int IsRuleReloadSet (int quiet)
 
int SuriHasSigFile (void)
 
int SuricataMain (int argc, char **argv)
 
int InitGlobal (void)
 Global initialization common to all runmodes. More...
 
int PostConfLoadedSetup (SCInstance *suri)
 
void PreRunInit (const int runmode)
 
void PreRunPostPrivsDropInit (const int runmode)
 
void PostRunDeinit (const int runmode, struct timeval *start_time)
 
void RegisterAllModules (void)
 
const char * GetProgramVersion (void)
 get string with program version More...
 

Variables

volatile uint8_t suricata_ctl_flags
 
int g_disable_randomness
 
uint16_t g_vlan_mask
 
int run_mode
 

Detailed Description

Author
Victor Julien victo.nosp@m.r@in.nosp@m.linia.nosp@m.c.ne.nosp@m.t

Definition in file suricata.h.

Macro Definition Documentation

◆ DEFAULT_CONF_FILE

#define DEFAULT_CONF_FILE   CONFIG_DIR "/suricata.yaml"

Definition at line 80 of file suricata.h.

◆ DEFAULT_PID_BASENAME

#define DEFAULT_PID_BASENAME   "suricata.pid"

Definition at line 83 of file suricata.h.

◆ DEFAULT_PID_DIR

#define DEFAULT_PID_DIR   LOCAL_STATE_DIR "/run/"

Definition at line 82 of file suricata.h.

◆ DEFAULT_PID_FILENAME

#define DEFAULT_PID_FILENAME   DEFAULT_PID_DIR DEFAULT_PID_BASENAME

Definition at line 84 of file suricata.h.

◆ DOC_URL

#define DOC_URL   "https://suricata.readthedocs.io/en/"

Definition at line 86 of file suricata.h.

◆ DOC_VERSION

#define DOC_VERSION   "latest"

Definition at line 91 of file suricata.h.

◆ IS_SURI_HOST_MODE_ROUTER

#define IS_SURI_HOST_MODE_ROUTER (   host_mode)    ((host_mode) == SURI_HOST_IS_ROUTER)

Definition at line 124 of file suricata.h.

◆ IS_SURI_HOST_MODE_SNIFFER_ONLY

#define IS_SURI_HOST_MODE_SNIFFER_ONLY (   host_mode)    ((host_mode) == SURI_HOST_IS_SNIFFER_ONLY)

Definition at line 123 of file suricata.h.

◆ PROG_NAME

#define PROG_NAME   "Suricata"

Definition at line 71 of file suricata.h.

◆ PROG_VER

#define PROG_VER   PACKAGE_VERSION

Definition at line 72 of file suricata.h.

◆ SURICATA_DONE

#define SURICATA_DONE   (1 << 2)

packets capture ended

Definition at line 97 of file suricata.h.

◆ SURICATA_STOP

#define SURICATA_STOP   (1 << 0)

gracefully stop the engine: process all outstanding packets first

Definition at line 95 of file suricata.h.

◆ u8_tolower

#define u8_tolower (   c)    tolower((uint8_t)(c))

Definition at line 177 of file suricata.h.

◆ u8_toupper

#define u8_toupper (   c)    toupper((uint8_t)(c))

Definition at line 178 of file suricata.h.

Typedef Documentation

◆ SCInstance

typedef struct SCInstance_ SCInstance

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SURICATA_INIT 
SURICATA_RUNTIME 
SURICATA_DEINIT 

Definition at line 100 of file suricata.h.

◆ anonymous enum

anonymous enum
Enumerator
SURI_HOST_IS_SNIFFER_ONLY 
SURI_HOST_IS_ROUTER 

Definition at line 118 of file suricata.h.

◆ EngineMode

enum EngineMode
Enumerator
ENGINE_MODE_IDS 
ENGINE_MODE_IPS 

Definition at line 107 of file suricata.h.

Function Documentation

◆ EngineDone()

void EngineDone ( void  )

Used to indicate that the current task is done.

This is mainly used by pcap-file to tell it has finished to treat a pcap files when running in unix-socket mode.

Definition at line 425 of file suricata.c.

References suricata_ctl_flags, and SURICATA_DONE.

◆ EngineModeIsIDS()

int EngineModeIsIDS ( void  )

Definition at line 249 of file suricata.c.

◆ EngineModeIsIPS()

int EngineModeIsIPS ( void  )

Definition at line 244 of file suricata.c.

Referenced by AlertFastLogger(), AlertJsonHeader(), FlowHandlePacketUpdate(), and StreamTcpInitConfig().

Here is the caller graph for this function:

◆ EngineModeSetIDS()

void EngineModeSetIDS ( void  )

Definition at line 259 of file suricata.c.

◆ EngineModeSetIPS()

void EngineModeSetIPS ( void  )

Definition at line 254 of file suricata.c.

◆ EngineStop()

void EngineStop ( void  )

make sure threads can stop the engine by calling this function. Purpose: pcap file mode needs to be able to tell the engine the file eof is reached.

Definition at line 414 of file suricata.c.

References suricata_ctl_flags, and SURICATA_STOP.

Referenced by ReceiveErfFileLoop().

Here is the caller graph for this function:

◆ GetProgramVersion()

const char* GetProgramVersion ( void  )

get string with program version

Get the program version as passed to us from AC_INIT

Add 'RELEASE' is no '-dev' in the version. Add the REVISION if passed to us.

Possible outputs: release: '5.0.1 RELEASE' dev with rev: '5.0.1-dev (64a789bbf 2019-10-18)' dev w/o rev: '5.0.1-dev'

Definition at line 1045 of file suricata.c.

References PROG_VER, and xstr.

◆ GlobalsInitPreConfig()

void GlobalsInitPreConfig ( void  )

Definition at line 327 of file suricata.c.

References SCThresholdConfGlobalInit(), SupportFastPatternForSigMatchTypes(), and TimeInit().

Referenced by LLVMFuzzerTestOneInput(), and RunUnittests().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitGlobal()

◆ IsRuleReloadSet()

int IsRuleReloadSet ( int  quiet)

◆ PostConfLoadedSetup()

int PostConfLoadedSetup ( SCInstance suri)

This function is meant to contain code that needs to be run once the configuration has been loaded.

Definition at line 2408 of file suricata.c.

References AppLayerSetup(), SCInstance_::checksum_validation, ConfGet(), ConfGetBool(), ConfGetValue(), ConfSet(), LiveDevRegisterExtension(), LiveSetOffloadDisable(), LiveSetOffloadWarn(), MpmTableSetup(), RegisterFlowBypassInfo(), SCInstance_::runmode_custom_mode, SCReturnInt, SpmTableSetup(), StorageInit(), StringParseUint16(), and TM_ECODE_FAILED.

Referenced by LLVMFuzzerTestOneInput().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PostRunDeinit()

void PostRunDeinit ( const int  runmode,
struct timeval *  start_time 
)

◆ PreRunInit()

◆ PreRunPostPrivsDropInit()

void PreRunPostPrivsDropInit ( const int  runmode)

Definition at line 2003 of file suricata.c.

References RUNMODE_UNIX_SOCKET, RunModeInitializeOutputs(), StatsSetupPostConfigPostOutput(), and StatsSetupPostConfigPreOutput().

Here is the call graph for this function:

◆ RegisterAllModules()

◆ RunmodeGetCurrent()

int RunmodeGetCurrent ( void  )

Definition at line 272 of file suricata.c.

References run_mode.

Referenced by ConfUnixSocketIsEnable(), RunModeGetMainMode(), and SigLoadSignatures().

Here is the caller graph for this function:

◆ RunmodeIsUnittests()

◆ SuricataMain()

int SuricataMain ( int  argc,
char **  argv 
)

Definition at line 2685 of file suricata.c.

Referenced by main().

Here is the caller graph for this function:

◆ SuriHasSigFile()

int SuriHasSigFile ( void  )

Definition at line 239 of file suricata.c.

References SCInstance_::sig_file, and suricata.

Variable Documentation

◆ g_disable_randomness

int g_disable_randomness

disable randomness to get reproducible results accross runs

Definition at line 227 of file suricata.c.

Referenced by RandomGet().

◆ g_vlan_mask

uint16_t g_vlan_mask

determine (without branching) if we include the vlan_ids when hashing or comparing flows

Definition at line 234 of file suricata.c.

Referenced by FlowKeyGetHash().

◆ run_mode

int run_mode

Run mode selected

Definition at line 201 of file suricata.c.

Referenced by RunmodeGetCurrent(), and RunmodeIsUnittests().

◆ suricata_ctl_flags

volatile uint8_t suricata_ctl_flags

suricata engine control flags

Definition at line 198 of file suricata.c.

Referenced by EngineDone(), EngineStop(), ReceiveErfDagLoop(), ReceiveErfFileLoop(), and ReceivePfringLoop().