suricata
detect-engine.h File Reference
#include "detect.h"
#include "suricata.h"
Include dependency graph for detect-engine.h:

Go to the source code of this file.

Macros

#define DetectEngineGetMaxSigId(de_ctx)   ((de_ctx)->signum)
 

Functions

void InspectionBufferInit (InspectionBuffer *buffer, uint32_t initial_size)
 
void InspectionBufferSetup (DetectEngineThreadCtx *det_ctx, const int list_id, InspectionBuffer *buffer, const uint8_t *data, const uint32_t data_len)
 setup the buffer with our initial data More...
 
void InspectionBufferFree (InspectionBuffer *buffer)
 
void * InspectionBufferCheckAndExpand (InspectionBuffer *buffer, uint32_t min_size)
 make sure that the buffer has at least 'min_size' bytes Expand the buffer if necessary More...
 
void InspectionBufferTruncate (InspectionBuffer *buffer, uint32_t buf_len)
 
void InspectionBufferCopy (InspectionBuffer *buffer, uint8_t *buf, uint32_t buf_len)
 
void InspectionBufferApplyTransforms (InspectionBuffer *buffer, const DetectEngineTransforms *transforms)
 
void InspectionBufferClean (DetectEngineThreadCtx *det_ctx)
 
InspectionBufferInspectionBufferGet (DetectEngineThreadCtx *det_ctx, const int list_id)
 
void InspectionBufferSetupMultiEmpty (InspectionBuffer *buffer)
 setup the buffer empty More...
 
void InspectionBufferSetupMulti (InspectionBuffer *buffer, const DetectEngineTransforms *transforms, const uint8_t *data, const uint32_t data_len)
 setup the buffer with our initial data More...
 
InspectionBufferInspectionBufferMultipleForListGet (DetectEngineThreadCtx *det_ctx, const int list_id, uint32_t local_id)
 for a InspectionBufferMultipleForList get a InspectionBuffer More...
 
int DetectBufferTypeRegister (const char *name)
 
int DetectBufferTypeGetByName (const char *name)
 
void DetectBufferTypeSupportsMpm (const char *name)
 
void DetectBufferTypeSupportsPacket (const char *name)
 
void DetectBufferTypeSupportsFrames (const char *name)
 
void DetectBufferTypeSupportsTransformations (const char *name)
 
void DetectBufferTypeSupportsMultiInstance (const char *name)
 
int DetectBufferTypeMaxId (void)
 
void DetectBufferTypeCloseRegistration (void)
 
void DetectBufferTypeSetDescriptionByName (const char *name, const char *desc)
 
const char * DetectBufferTypeGetDescriptionByName (const char *name)
 
void DetectBufferTypeRegisterSetupCallback (const char *name, void(*Callback)(const DetectEngineCtx *, Signature *))
 
void DetectBufferTypeRegisterValidateCallback (const char *name, bool(*ValidateCallback)(const Signature *, const char **sigerror))
 
int DetectEngineBufferTypeRegisterWithFrameEngines (DetectEngineCtx *de_ctx, const char *name, const int direction, const AppProto alproto, const uint8_t frame_type)
 
int DetectEngineBufferTypeRegister (DetectEngineCtx *de_ctx, const char *name)
 
const char * DetectEngineBufferTypeGetNameById (const DetectEngineCtx *de_ctx, const int id)
 
const DetectBufferTypeDetectEngineBufferTypeGetById (const DetectEngineCtx *de_ctx, const int id)
 
bool DetectEngineBufferTypeSupportsMpmGetById (const DetectEngineCtx *de_ctx, const int id)
 
bool DetectEngineBufferTypeSupportsPacketGetById (const DetectEngineCtx *de_ctx, const int id)
 
bool DetectEngineBufferTypeSupportsMultiInstanceGetById (const DetectEngineCtx *de_ctx, const int id)
 
bool DetectEngineBufferTypeSupportsFramesGetById (const DetectEngineCtx *de_ctx, const int id)
 
const char * DetectEngineBufferTypeGetDescriptionById (const DetectEngineCtx *de_ctx, const int id)
 
int DetectEngineBufferTypeGetByIdTransforms (DetectEngineCtx *de_ctx, const int id, TransformData *transforms, int transform_cnt)
 
void DetectEngineBufferRunSetupCallback (const DetectEngineCtx *de_ctx, const int id, Signature *s)
 
bool DetectEngineBufferRunValidateCallback (const DetectEngineCtx *de_ctx, const int id, const Signature *s, const char **sigerror)
 
bool DetectEngineBufferTypeValidateTransform (DetectEngineCtx *de_ctx, int sm_list, const uint8_t *content, uint16_t content_len, const char **namestr)
 Check content byte array compatibility with transforms. More...
 
void DetectEngineBufferTypeSupportsFrames (DetectEngineCtx *de_ctx, const char *name)
 
void DetectEngineBufferTypeSupportsPacket (DetectEngineCtx *de_ctx, const char *name)
 
void DetectEngineBufferTypeSupportsMpm (DetectEngineCtx *de_ctx, const char *name)
 
void DetectEngineBufferTypeSupportsTransformations (DetectEngineCtx *de_ctx, const char *name)
 
DetectEngineCtxDetectEngineCtxInitWithPrefix (const char *prefix, uint32_t tenant_id)
 
DetectEngineCtxDetectEngineCtxInit (void)
 
DetectEngineCtxDetectEngineCtxInitStubForDD (void)
 
DetectEngineCtxDetectEngineCtxInitStubForMT (void)
 
void DetectEngineCtxFree (DetectEngineCtx *)
 Free a DetectEngineCtx:: More...
 
int DetectRegisterThreadCtxGlobalFuncs (const char *name, void *(*InitFunc)(void *), void *data, void(*FreeFunc)(void *))
 Register Thread keyword context Funcs (Global) More...
 
void * DetectThreadCtxGetGlobalKeywordThreadCtx (DetectEngineThreadCtx *det_ctx, int id)
 Retrieve thread local keyword ctx by id. More...
 
TmEcode DetectEngineThreadCtxInit (ThreadVars *, void *, void **)
 initialize thread specific detection engine context More...
 
TmEcode DetectEngineThreadCtxDeinit (ThreadVars *, void *)
 
void DetectEngineResetMaxSigId (DetectEngineCtx *)
 
void DetectEngineRegisterTests (void)
 
const char * DetectSigmatchListEnumToString (enum DetectSigmatchListEnum type)
 
uint32_t DetectEngineGetVersion (void)
 
void DetectEngineBumpVersion (void)
 
int DetectEngineAddToMaster (DetectEngineCtx *de_ctx)
 
DetectEngineCtxDetectEngineGetCurrent (void)
 
DetectEngineCtxDetectEngineGetByTenantId (uint32_t tenant_id)
 
void DetectEnginePruneFreeList (void)
 
int DetectEngineMoveToFreeList (DetectEngineCtx *de_ctx)
 
void DetectEngineClearMaster (void)
 
DetectEngineCtxDetectEngineReference (DetectEngineCtx *)
 
void DetectEngineDeReference (DetectEngineCtx **de_ctx)
 
int DetectEngineReload (const SCInstance *suri)
 Reload the detection engine. More...
 
int DetectEngineEnabled (void)
 Check if detection is enabled. More...
 
int DetectEngineMTApply (void)
 
int DetectEngineMultiTenantEnabled (void)
 
int DetectEngineMultiTenantSetup (const bool unix_socket)
 setup multi-detect / multi-tenancy More...
 
int DetectEngineReloadStart (void)
 
int DetectEngineReloadIsStart (void)
 
void DetectEngineReloadSetIdle (void)
 
int DetectEngineReloadIsIdle (void)
 
int DetectEngineLoadTenantBlocking (uint32_t tenant_id, const char *yaml)
 Load a tenant and wait for loading to complete. More...
 
int DetectEngineReloadTenantBlocking (uint32_t tenant_id, const char *yaml, int reload_cnt)
 Reload a tenant and wait for loading to complete. More...
 
int DetectEngineReloadTenantsBlocking (const int reload_cnt)
 Reload all tenants and wait for loading to complete. More...
 
int DetectEngineTenantRegisterLivedev (uint32_t tenant_id, int device_id)
 
int DetectEngineTenantRegisterVlanId (uint32_t tenant_id, uint16_t vlan_id)
 
int DetectEngineTenantUnregisterVlanId (uint32_t tenant_id, uint16_t vlan_id)
 
int DetectEngineTenantRegisterPcapFile (uint32_t tenant_id)
 
int DetectEngineTenantUnregisterPcapFile (uint32_t tenant_id)
 
uint8_t DetectEngineInspectGenericList (DetectEngineCtx *, DetectEngineThreadCtx *, const struct DetectEngineAppInspectionEngine_ *, const Signature *, Flow *, uint8_t, void *, void *, uint64_t)
 Do the content inspection & validation for a signature. More...
 
uint8_t DetectEngineInspectBufferGeneric (DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const DetectEngineAppInspectionEngine *engine, const Signature *s, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 Do the content inspection & validation for a signature. More...
 
uint8_t DetectEngineInspectMultiBufferGeneric (DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const DetectEngineAppInspectionEngine *engine, const Signature *s, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 
int DetectEngineInspectPktBufferGeneric (DetectEngineThreadCtx *det_ctx, const DetectEnginePktInspectionEngine *engine, const Signature *s, Packet *p, uint8_t *alert_flags)
 Do the content inspection & validation for a signature. More...
 
void DetectAppLayerInspectEngineRegister (const char *name, AppProto alproto, uint32_t dir, int progress, InspectEngineFuncPtr Callback2, InspectionBufferGetDataPtr GetData)
 Registers an app inspection engine. More...
 
void DetectAppLayerMultiRegister (const char *name, AppProto alproto, uint32_t dir, int progress, InspectionMultiBufferGetDataPtr GetData, int priority, int tx_min_progress)
 
void DetectPktInspectEngineRegister (const char *name, InspectionBufferGetPktDataPtr GetPktData, InspectionBufferPktInspectFunc Callback)
 register inspect engine at start up time More...
 
void DetectEngineFrameInspectEngineRegister (DetectEngineCtx *de_ctx, const char *name, int dir, InspectionBufferFrameInspectFunc Callback, AppProto alproto, uint8_t type)
 register inspect engine at start up time More...
 
int DetectEngineAppInspectionEngine2Signature (DetectEngineCtx *de_ctx, Signature *s)
 
void DetectEngineAppInspectionEngineSignatureFree (DetectEngineCtx *, Signature *s)
 free app inspect engines for a signature More...
 
bool DetectEnginePktInspectionRun (ThreadVars *tv, DetectEngineThreadCtx *det_ctx, const Signature *s, Flow *f, Packet *p, uint8_t *alert_flags)
 
int DetectEnginePktInspectionSetup (Signature *s)
 
void DetectEngineSetParseMetadata (void)
 
void DetectEngineUnsetParseMetadata (void)
 
int DetectEngineMustParseMetadata (void)
 
bool DetectBufferIsPresent (const Signature *s, const uint32_t buf_id)
 
int WARN_UNUSED DetectBufferSetActiveList (DetectEngineCtx *de_ctx, Signature *s, const int list)
 
int DetectBufferGetActiveList (DetectEngineCtx *de_ctx, Signature *s)
 
SigMatchDetectBufferGetFirstSigMatch (const Signature *s, const uint32_t buf_id)
 
SigMatchDetectBufferGetLastSigMatch (const Signature *s, const uint32_t buf_id)
 
DetectEngineThreadCtxDetectEngineThreadCtxInitForReload (ThreadVars *tv, DetectEngineCtx *new_de_ctx, int mt)
 
void DetectRunStoreStateTx (const SigGroupHead *sgh, Flow *f, void *tx, uint64_t tx_id, const Signature *s, uint32_t inspect_flags, uint8_t flow_flags, const uint16_t file_no_match)
 
void DetectEngineStateResetTxs (Flow *f)
 Reset de state for active tx' To be used on detect engine reload. More...
 
void DeStateRegisterTests (void)
 

Detailed Description

Macro Definition Documentation

◆ DetectEngineGetMaxSigId

#define DetectEngineGetMaxSigId (   de_ctx)    ((de_ctx)->signum)

Definition at line 106 of file detect-engine.h.

Function Documentation

◆ DetectAppLayerInspectEngineRegister()

void DetectAppLayerInspectEngineRegister ( const char *  name,
AppProto  alproto,
uint32_t  dir,
int  progress,
InspectEngineFuncPtr  Callback2,
InspectionBufferGetDataPtr  GetData 
)

Registers an app inspection engine.

Parameters
nameName of the detection list
alprotoApp layer protocol for which we will register the engine.
directionThe direction for the engine: SIG_FLAG_TOSERVER or SIG_FLAG_TOCLIENT
progressMinimal progress value for inspect engine to run
CallbackThe engine callback.

Definition at line 240 of file detect-engine.c.

Referenced by DetectFileRegisterFileProtocols(), and DetectHelperBufferRegister().

Here is the caller graph for this function:

◆ DetectAppLayerMultiRegister()

void DetectAppLayerMultiRegister ( const char *  name,
AppProto  alproto,
uint32_t  dir,
int  progress,
InspectionMultiBufferGetDataPtr  GetData,
int  priority,
int  tx_min_progress 
)

Definition at line 2205 of file detect-engine.c.

◆ DetectBufferGetActiveList()

◆ DetectBufferGetFirstSigMatch()

SigMatch* DetectBufferGetFirstSigMatch ( const Signature s,
const uint32_t  buf_id 
)

◆ DetectBufferGetLastSigMatch()

SigMatch* DetectBufferGetLastSigMatch ( const Signature s,
const uint32_t  buf_id 
)

◆ DetectBufferIsPresent()

bool DetectBufferIsPresent ( const Signature s,
const uint32_t  buf_id 
)

◆ DetectBufferSetActiveList()

int WARN_UNUSED DetectBufferSetActiveList ( DetectEngineCtx de_ctx,
Signature s,
const int  list 
)

Definition at line 1357 of file detect-engine.c.

◆ DetectBufferTypeCloseRegistration()

void DetectBufferTypeCloseRegistration ( void  )

Definition at line 1818 of file detect-engine.c.

References BUG_ON.

◆ DetectBufferTypeGetByName()

int DetectBufferTypeGetByName ( const char *  name)

Definition at line 1094 of file detect-engine.c.

Referenced by DetectEngineAppInspectionEngine2Signature(), DetectFrameMpmRegister(), and DetectPktInspectEngineRegister().

Here is the caller graph for this function:

◆ DetectBufferTypeGetDescriptionByName()

const char* DetectBufferTypeGetDescriptionByName ( const char *  name)

Definition at line 1211 of file detect-engine.c.

◆ DetectBufferTypeMaxId()

int DetectBufferTypeMaxId ( void  )

Definition at line 922 of file detect-engine.c.

◆ DetectBufferTypeRegister()

int DetectBufferTypeRegister ( const char *  name)

Definition at line 1030 of file detect-engine.c.

References BUG_ON.

Referenced by DetectHelperBufferRegister(), and DetectPktInspectEngineRegister().

Here is the caller graph for this function:

◆ DetectBufferTypeRegisterSetupCallback()

void DetectBufferTypeRegisterSetupCallback ( const char *  name,
void(*)(const DetectEngineCtx *, Signature *)  Callback 
)

Definition at line 1288 of file detect-engine.c.

References BUG_ON.

◆ DetectBufferTypeRegisterValidateCallback()

void DetectBufferTypeRegisterValidateCallback ( const char *  name,
bool(*)(const Signature *, const char **sigerror)  ValidateCallback 
)

Definition at line 1306 of file detect-engine.c.

References BUG_ON.

◆ DetectBufferTypeSetDescriptionByName()

void DetectBufferTypeSetDescriptionByName ( const char *  name,
const char *  desc 
)

Definition at line 1191 of file detect-engine.c.

References BUG_ON.

◆ DetectBufferTypeSupportsFrames()

void DetectBufferTypeSupportsFrames ( const char *  name)

Definition at line 1054 of file detect-engine.c.

References BUG_ON.

Referenced by DetectFrameMpmRegister().

Here is the caller graph for this function:

◆ DetectBufferTypeSupportsMpm()

void DetectBufferTypeSupportsMpm ( const char *  name)

Definition at line 1074 of file detect-engine.c.

References BUG_ON.

Referenced by DetectFrameMpmRegister().

Here is the caller graph for this function:

◆ DetectBufferTypeSupportsMultiInstance()

void DetectBufferTypeSupportsMultiInstance ( const char *  name)

Definition at line 1044 of file detect-engine.c.

References BUG_ON.

◆ DetectBufferTypeSupportsPacket()

void DetectBufferTypeSupportsPacket ( const char *  name)

Definition at line 1064 of file detect-engine.c.

References BUG_ON.

◆ DetectBufferTypeSupportsTransformations()

void DetectBufferTypeSupportsTransformations ( const char *  name)

Definition at line 1084 of file detect-engine.c.

References BUG_ON.

Referenced by DetectFrameMpmRegister().

Here is the caller graph for this function:

◆ DetectEngineAddToMaster()

int DetectEngineAddToMaster ( DetectEngineCtx de_ctx)

Definition at line 4643 of file detect-engine.c.

References de_ctx, and SCLogDebug.

◆ DetectEngineAppInspectionEngine2Signature()

◆ DetectEngineAppInspectionEngineSignatureFree()

void DetectEngineAppInspectionEngineSignatureFree ( DetectEngineCtx de_ctx,
Signature s 
)

free app inspect engines for a signature

For lists that are registered multiple times, like http_header and http_cookie, making the engines owner of the lists is complicated. Multiple engines in a sig may be pointing to the same list. To address this the 'free' code needs to be extra careful about not double freeing, so it takes an approach to first fill an array of the to-free pointers before freeing them.

Definition at line 816 of file detect-engine.c.

References Signature_::app_inspect, BUG_ON, SigMatchData_::ctx, de_ctx, Signature_::frame_inspect, SigTableElmt_::Free, SigMatchData_::is_last, next, DetectEngineAppInspectionEngine_::next, DetectEnginePktInspectionEngine::next, DetectEngineFrameInspectionEngine::next, Signature_::pkt_inspect, SCFree, sigmatch_table, DetectEngineAppInspectionEngine_::smd, DetectEnginePktInspectionEngine::smd, DetectEngineFrameInspectionEngine::smd, and SigMatchData_::type.

◆ DetectEngineBufferRunSetupCallback()

void DetectEngineBufferRunSetupCallback ( const DetectEngineCtx de_ctx,
const int  id,
Signature s 
)

Definition at line 1298 of file detect-engine.c.

References de_ctx, DetectEngineBufferTypeGetById(), and DetectBufferType_::SetupCallback.

Here is the call graph for this function:

◆ DetectEngineBufferRunValidateCallback()

bool DetectEngineBufferRunValidateCallback ( const DetectEngineCtx de_ctx,
const int  id,
const Signature s,
const char **  sigerror 
)

Definition at line 1316 of file detect-engine.c.

References de_ctx, DetectEngineBufferTypeGetById(), and DetectBufferType_::ValidateCallback.

Here is the call graph for this function:

◆ DetectEngineBufferTypeGetById()

◆ DetectEngineBufferTypeGetByIdTransforms()

◆ DetectEngineBufferTypeGetDescriptionById()

const char* DetectEngineBufferTypeGetDescriptionById ( const DetectEngineCtx de_ctx,
const int  id 
)

Definition at line 1202 of file detect-engine.c.

References de_ctx, DetectBufferType_::description, and DetectEngineBufferTypeGetById().

Referenced by EngineAnalysisFP().

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

◆ DetectEngineBufferTypeGetNameById()

const char* DetectEngineBufferTypeGetNameById ( const DetectEngineCtx de_ctx,
const int  id 
)

Definition at line 1124 of file detect-engine.c.

References de_ctx, DetectEngineBufferTypeGetById(), and DetectBufferType_::name.

Referenced by DumpPatterns(), EngineAnalysisFP(), and EngineAnalysisRules2().

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

◆ DetectEngineBufferTypeRegister()

int DetectEngineBufferTypeRegister ( DetectEngineCtx de_ctx,
const char *  name 
)

Definition at line 1181 of file detect-engine.c.

Referenced by DetectEngineFrameInspectEngineRegister(), and DetectEngineFrameMpmRegister().

Here is the caller graph for this function:

◆ DetectEngineBufferTypeRegisterWithFrameEngines()

int DetectEngineBufferTypeRegisterWithFrameEngines ( DetectEngineCtx de_ctx,
const char *  name,
const int  direction,
const AppProto  alproto,
const uint8_t  frame_type 
)

Definition at line 1147 of file detect-engine.c.

◆ DetectEngineBufferTypeSupportsFrames()

void DetectEngineBufferTypeSupportsFrames ( DetectEngineCtx de_ctx,
const char *  name 
)

Definition at line 1220 of file detect-engine.c.

Referenced by DetectEngineFrameMpmRegister().

Here is the caller graph for this function:

◆ DetectEngineBufferTypeSupportsFramesGetById()

bool DetectEngineBufferTypeSupportsFramesGetById ( const DetectEngineCtx de_ctx,
const int  id 
)

Definition at line 1279 of file detect-engine.c.

References de_ctx, DetectEngineBufferTypeGetById(), DetectBufferType_::frame, and SCLogDebug.

Here is the call graph for this function:

◆ DetectEngineBufferTypeSupportsMpm()

void DetectEngineBufferTypeSupportsMpm ( DetectEngineCtx de_ctx,
const char *  name 
)

Definition at line 1236 of file detect-engine.c.

Referenced by DetectEngineFrameMpmRegister().

Here is the caller graph for this function:

◆ DetectEngineBufferTypeSupportsMpmGetById()

bool DetectEngineBufferTypeSupportsMpmGetById ( const DetectEngineCtx de_ctx,
const int  id 
)

Definition at line 1270 of file detect-engine.c.

References de_ctx, DetectEngineBufferTypeGetById(), DetectBufferType_::mpm, and SCLogDebug.

Referenced by DetectGetLastSMFromMpmLists(), and FastPatternSupportEnabledForSigMatchList().

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

◆ DetectEngineBufferTypeSupportsMultiInstanceGetById()

bool DetectEngineBufferTypeSupportsMultiInstanceGetById ( const DetectEngineCtx de_ctx,
const int  id 
)

Definition at line 1252 of file detect-engine.c.

References BOOL2STR, de_ctx, DetectEngineBufferTypeGetById(), DetectBufferType_::multi_instance, and SCLogDebug.

Referenced by DetectBufferGetActiveList().

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

◆ DetectEngineBufferTypeSupportsPacket()

void DetectEngineBufferTypeSupportsPacket ( DetectEngineCtx de_ctx,
const char *  name 
)

Definition at line 1228 of file detect-engine.c.

◆ DetectEngineBufferTypeSupportsPacketGetById()

bool DetectEngineBufferTypeSupportsPacketGetById ( const DetectEngineCtx de_ctx,
const int  id 
)

Definition at line 1261 of file detect-engine.c.

References de_ctx, DetectEngineBufferTypeGetById(), DetectBufferType_::packet, and SCLogDebug.

Here is the call graph for this function:

◆ DetectEngineBufferTypeSupportsTransformations()

void DetectEngineBufferTypeSupportsTransformations ( DetectEngineCtx de_ctx,
const char *  name 
)

Definition at line 1244 of file detect-engine.c.

Referenced by DetectEngineFrameMpmRegister().

Here is the caller graph for this function:

◆ DetectEngineBufferTypeValidateTransform()

bool DetectEngineBufferTypeValidateTransform ( DetectEngineCtx de_ctx,
int  sm_list,
const uint8_t *  content,
uint16_t  content_len,
const char **  namestr 
)

Check content byte array compatibility with transforms.

The "content" array is presented to the transforms so that each transform may validate that it's compatible with the transform.

When a transform indicates the byte array is incompatible, none of the subsequent transforms, if any, are invoked. This means the first validation failure terminates the loop.

Parameters
de_ctxDetection engine context.
sm_listThe SM list id.
contentThe byte array being validated
namestrreturns the name of the transform that is incompatible with content.
Return values
true(false) If any of the transforms indicate the byte array is (is not) compatible.

Definition at line 1687 of file detect-engine.c.

References BUG_ON, DetectEngineTransforms::cnt, de_ctx, DetectEngineBufferTypeGetById(), SigTableElmt_::name, TransformData_::options, sigmatch_table, TransformData_::transform, DetectEngineTransforms::transforms, DetectBufferType_::transforms, and SigTableElmt_::TransformValidate.

Referenced by DetectContentSetup().

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

◆ DetectEngineBumpVersion()

void DetectEngineBumpVersion ( void  )

Definition at line 3819 of file detect-engine.c.

◆ DetectEngineClearMaster()

void DetectEngineClearMaster ( void  )

Definition at line 4743 of file detect-engine.c.

Referenced by GlobalsDestroy().

Here is the caller graph for this function:

◆ DetectEngineCtxFree()

◆ DetectEngineCtxInit()

DetectEngineCtx* DetectEngineCtxInit ( void  )

Definition at line 2584 of file detect-engine.c.

Referenced by DetectEngineCtxInitWithPrefix().

Here is the caller graph for this function:

◆ DetectEngineCtxInitStubForDD()

DetectEngineCtx* DetectEngineCtxInitStubForDD ( void  )

Definition at line 2579 of file detect-engine.c.

◆ DetectEngineCtxInitStubForMT()

DetectEngineCtx* DetectEngineCtxInitStubForMT ( void  )

Definition at line 2574 of file detect-engine.c.

◆ DetectEngineCtxInitWithPrefix()

DetectEngineCtx* DetectEngineCtxInitWithPrefix ( const char *  prefix,
uint32_t  tenant_id 
)

Definition at line 2589 of file detect-engine.c.

References DetectEngineCtxInit().

Here is the call graph for this function:

◆ DetectEngineDeReference()

void DetectEngineDeReference ( DetectEngineCtx **  de_ctx)

Definition at line 4619 of file detect-engine.c.

References BUG_ON, and de_ctx.

Referenced by GlobalsDestroy().

Here is the caller graph for this function:

◆ DetectEngineEnabled()

int DetectEngineEnabled ( void  )

Check if detection is enabled.

Return values
booltrue or false

Definition at line 3795 of file detect-engine.c.

◆ DetectEngineFrameInspectEngineRegister()

◆ DetectEngineGetByTenantId()

DetectEngineCtx* DetectEngineGetByTenantId ( uint32_t  tenant_id)

Definition at line 4593 of file detect-engine.c.

◆ DetectEngineGetCurrent()

DetectEngineCtx* DetectEngineGetCurrent ( void  )

Definition at line 3828 of file detect-engine.c.

Referenced by DetectEngineThreadCtxInit(), and GlobalsDestroy().

Here is the caller graph for this function:

◆ DetectEngineGetVersion()

uint32_t DetectEngineGetVersion ( void  )

Definition at line 3809 of file detect-engine.c.

References version.

◆ DetectEngineInspectBufferGeneric()

uint8_t DetectEngineInspectBufferGeneric ( DetectEngineCtx de_ctx,
DetectEngineThreadCtx det_ctx,
const DetectEngineAppInspectionEngine engine,
const Signature s,
Flow f,
uint8_t  flags,
void *  alstate,
void *  txv,
uint64_t  tx_id 
)

◆ DetectEngineInspectGenericList()

uint8_t DetectEngineInspectGenericList ( DetectEngineCtx de_ctx,
DetectEngineThreadCtx det_ctx,
const struct DetectEngineAppInspectionEngine_ engine,
const Signature s,
Flow f,
uint8_t  flags,
void *  alstate,
void *  txv,
uint64_t  tx_id 
)

Do the content inspection & validation for a signature.

Parameters
de_ctxDetection engine context
det_ctxDetection engine thread context
sSignature to inspect
smSigMatch to inspect
fFlow
flagsapp layer flags
stateApp layer state
Return values
0no match
1match

Definition at line 2112 of file detect-engine.c.

References SigMatchData_::ctx, DETECT_ENGINE_INSPECT_SIG_CANT_MATCH, DETECT_ENGINE_INSPECT_SIG_MATCH, DETECT_ENGINE_INSPECT_SIG_NO_MATCH, flags, SigMatchData_::is_last, KEYWORD_PROFILING_END, KEYWORD_PROFILING_START, SCLogDebug, sigmatch_table, DetectEngineAppInspectionEngine_::smd, and SigMatchData_::type.

Referenced by DetectHelperBufferRegister().

Here is the caller graph for this function:

◆ DetectEngineInspectMultiBufferGeneric()

◆ DetectEngineInspectPktBufferGeneric()

int DetectEngineInspectPktBufferGeneric ( DetectEngineThreadCtx det_ctx,
const DetectEnginePktInspectionEngine engine,
const Signature s,
Packet p,
uint8_t *  _alert_flags 
)

◆ DetectEngineLoadTenantBlocking()

int DetectEngineLoadTenantBlocking ( uint32_t  tenant_id,
const char *  yaml 
)

Load a tenant and wait for loading to complete.

Definition at line 4117 of file detect-engine.c.

◆ DetectEngineMoveToFreeList()

int DetectEngineMoveToFreeList ( DetectEngineCtx de_ctx)

Definition at line 4703 of file detect-engine.c.

Referenced by GlobalsDestroy().

Here is the caller graph for this function:

◆ DetectEngineMTApply()

int DetectEngineMTApply ( void  )

Definition at line 4890 of file detect-engine.c.

◆ DetectEngineMultiTenantEnabled()

int DetectEngineMultiTenantEnabled ( void  )

TODO locking? Not needed if this is a one time setting at startup

Definition at line 3860 of file detect-engine.c.

◆ DetectEngineMultiTenantSetup()

int DetectEngineMultiTenantSetup ( const bool  unix_socket)

setup multi-detect / multi-tenancy

See if MT is enabled. If so, setup the selector, tenants and mappings. Tenants and mappings are optional, and can also dynamically be added and removed from the unix socket.

Definition at line 4280 of file detect-engine.c.

References TENANT_SELECTOR_UNKNOWN.

◆ DetectEngineMustParseMetadata()

int DetectEngineMustParseMetadata ( void  )

Definition at line 4957 of file detect-engine.c.

Referenced by DetectMetadataHashInit().

Here is the caller graph for this function:

◆ DetectEnginePktInspectionRun()

bool DetectEnginePktInspectionRun ( ThreadVars tv,
DetectEngineThreadCtx det_ctx,
const Signature s,
Flow f,
Packet p,
uint8_t *  alert_flags 
)

◆ DetectEnginePktInspectionSetup()

int DetectEnginePktInspectionSetup ( Signature s)

◆ DetectEnginePruneFreeList()

void DetectEnginePruneFreeList ( void  )

Definition at line 4713 of file detect-engine.c.

◆ DetectEngineReference()

DetectEngineCtx* DetectEngineReference ( DetectEngineCtx )

Definition at line 3851 of file detect-engine.c.

References de_ctx, and DetectEngineCtx_::ref_cnt.

Referenced by DetectEngineThreadCtxInitForReload().

Here is the caller graph for this function:

◆ DetectEngineRegisterTests()

void DetectEngineRegisterTests ( void  )

Definition at line 5199 of file detect-engine.c.

References UtRegisterTest().

Here is the call graph for this function:

◆ DetectEngineReload()

int DetectEngineReload ( const SCInstance suri)

Reload the detection engine.

Parameters
filenameYAML file to load for the detect config
Return values
-1error
0ok

Definition at line 4770 of file detect-engine.c.

References SCInstance_::conf_filename, and SCLogNotice.

Referenced by SuricataMainLoop().

Here is the caller graph for this function:

◆ DetectEngineReloadIsIdle()

int DetectEngineReloadIsIdle ( void  )

Definition at line 2088 of file detect-engine.c.

References SCMutexLock.

◆ DetectEngineReloadIsStart()

int DetectEngineReloadIsStart ( void  )

Definition at line 2068 of file detect-engine.c.

References SCMutexLock.

Referenced by SuricataMainLoop().

Here is the caller graph for this function:

◆ DetectEngineReloadSetIdle()

void DetectEngineReloadSetIdle ( void  )

Definition at line 2080 of file detect-engine.c.

References SCMutexLock.

Referenced by SuricataMainLoop().

Here is the caller graph for this function:

◆ DetectEngineReloadStart()

int DetectEngineReloadStart ( void  )

Definition at line 2054 of file detect-engine.c.

References SCMutexLock.

Referenced by SuricataMainLoop().

Here is the caller graph for this function:

◆ DetectEngineReloadTenantBlocking()

int DetectEngineReloadTenantBlocking ( uint32_t  tenant_id,
const char *  yaml,
int  reload_cnt 
)

Reload a tenant and wait for loading to complete.

Definition at line 4131 of file detect-engine.c.

◆ DetectEngineReloadTenantsBlocking()

int DetectEngineReloadTenantsBlocking ( const int  reload_cnt)

Reload all tenants and wait for loading to complete.

Definition at line 4145 of file detect-engine.c.

◆ DetectEngineResetMaxSigId()

void DetectEngineResetMaxSigId ( DetectEngineCtx )

Definition at line 3043 of file detect-engine.c.

References de_ctx, and DetectEngineCtx_::signum.

Referenced by SigCleanSignatures().

Here is the caller graph for this function:

◆ DetectEngineSetParseMetadata()

void DetectEngineSetParseMetadata ( void  )

Definition at line 4947 of file detect-engine.c.

◆ DetectEngineTenantRegisterLivedev()

int DetectEngineTenantRegisterLivedev ( uint32_t  tenant_id,
int  device_id 
)

Definition at line 4560 of file detect-engine.c.

◆ DetectEngineTenantRegisterPcapFile()

int DetectEngineTenantRegisterPcapFile ( uint32_t  tenant_id)

Definition at line 4576 of file detect-engine.c.

References SCLogInfo, and TENANT_SELECTOR_DIRECT.

◆ DetectEngineTenantRegisterVlanId()

int DetectEngineTenantRegisterVlanId ( uint32_t  tenant_id,
uint16_t  vlan_id 
)

Definition at line 4566 of file detect-engine.c.

◆ DetectEngineTenantUnregisterPcapFile()

int DetectEngineTenantUnregisterPcapFile ( uint32_t  tenant_id)

Definition at line 4582 of file detect-engine.c.

References SCLogInfo, and TENANT_SELECTOR_DIRECT.

◆ DetectEngineTenantUnregisterVlanId()

int DetectEngineTenantUnregisterVlanId ( uint32_t  tenant_id,
uint16_t  vlan_id 
)

Definition at line 4571 of file detect-engine.c.

◆ DetectEngineThreadCtxDeinit()

TmEcode DetectEngineThreadCtxDeinit ( ThreadVars ,
void *   
)

Definition at line 3592 of file detect-engine.c.

References HashTableFree(), DetectEngineThreadCtx_::mt_det_ctxs_hash, SCLogWarning, and TM_ECODE_OK.

Referenced by DetectEngineThreadCtxInit(), UTHMatchPackets(), UTHMatchPacketsWithResults(), UTHPacketMatchSig(), and UTHPacketMatchSigMpm().

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

◆ DetectEngineThreadCtxInit()

TmEcode DetectEngineThreadCtxInit ( ThreadVars tv,
void *  initdata,
void **  data 
)

initialize thread specific detection engine context

Note
there is a special case when using delayed detect. In this case the function is called twice per thread. The first time the rules are not yet loaded. de_ctx->delayed_detect_initialized will be 0. The 2nd time they will be loaded. de_ctx->delayed_detect_initialized will be 1. This is needed to do the per thread counter registration before the packet runtime starts. In delayed detect mode, the first call will return a NULL ptr through the data ptr.
Parameters
tvThreadVars for this thread
initdatapointer to de_ctx
data[out]pointer to store our thread detection ctx
Return values
TM_ECODE_OKif all went well
TM_ECODE_FAILEDon serious errors

alert counter setup

Definition at line 3365 of file detect-engine.c.

References DetectEngineThreadCtx_::de_ctx, DETECT_ENGINE_TYPE_NORMAL, DETECT_ENGINE_TYPE_TENANT, DetectEngineGetCurrent(), DetectEngineThreadCtxDeinit(), RunmodeIsUnittests(), SCCalloc, TM_ECODE_FAILED, tv, DetectEngineThreadCtx_::tv, DetectEngineCtx_::type, and unlikely.

Referenced by UTHMatchPackets(), UTHMatchPacketsWithResults(), UTHPacketMatchSig(), and UTHPacketMatchSigMpm().

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

◆ DetectEngineThreadCtxInitForReload()

DetectEngineThreadCtx* DetectEngineThreadCtxInitForReload ( ThreadVars tv,
DetectEngineCtx new_de_ctx,
int  mt 
)

◆ DetectEngineUnsetParseMetadata()

void DetectEngineUnsetParseMetadata ( void  )

Definition at line 4952 of file detect-engine.c.

◆ DetectPktInspectEngineRegister()

void DetectPktInspectEngineRegister ( const char *  name,
InspectionBufferGetPktDataPtr  GetPktData,
InspectionBufferPktInspectFunc  Callback 
)

◆ DetectRegisterThreadCtxGlobalFuncs()

int DetectRegisterThreadCtxGlobalFuncs ( const char *  name,
void *(*)(void *)  InitFunc,
void *  data,
void(*)(void *)  FreeFunc 
)

Register Thread keyword context Funcs (Global)

IDs stay static over reloads and between tenants

Parameters
namekeyword name for error printing
InitFuncfunction ptr
FreeFuncfunction ptr
Return values
idfor retrieval of ctx at runtime
-1on error

Definition at line 3739 of file detect-engine.c.

References BUG_ON.

◆ DetectSigmatchListEnumToString()

◆ DetectThreadCtxGetGlobalKeywordThreadCtx()

void* DetectThreadCtxGetGlobalKeywordThreadCtx ( DetectEngineThreadCtx det_ctx,
int  id 
)

Retrieve thread local keyword ctx by id.

Parameters
det_ctxdetection engine thread ctx to retrieve the ctx from
idid of the ctx returned by DetectRegisterThreadCtxInitFunc at keyword init.
Return values
ctxor NULL on error

Definition at line 3783 of file detect-engine.c.

References DetectEngineThreadCtx_::global_keyword_ctxs_array, and DetectEngineThreadCtx_::global_keyword_ctxs_size.

Referenced by HttpHeaderGetBufferSpace().

Here is the caller graph for this function:

◆ InspectionBufferApplyTransforms()

void InspectionBufferApplyTransforms ( InspectionBuffer buffer,
const DetectEngineTransforms transforms 
)

◆ InspectionBufferCheckAndExpand()

void* InspectionBufferCheckAndExpand ( InspectionBuffer buffer,
uint32_t  min_size 
)

make sure that the buffer has at least 'min_size' bytes Expand the buffer if necessary

Definition at line 1627 of file detect-engine.c.

References InspectionBuffer::buf, likely, SCRealloc, and InspectionBuffer::size.

Referenced by FileSwfDecompression(), and InspectionBufferCopy().

Here is the caller graph for this function:

◆ InspectionBufferClean()

◆ InspectionBufferCopy()

void InspectionBufferCopy ( InspectionBuffer buffer,
uint8_t *  buf,
uint32_t  buf_len 
)

◆ InspectionBufferFree()

void InspectionBufferFree ( InspectionBuffer buffer)

Definition at line 1615 of file detect-engine.c.

References InspectionBuffer::buf, and SCFree.

◆ InspectionBufferGet()

InspectionBuffer* InspectionBufferGet ( DetectEngineThreadCtx det_ctx,
const int  list_id 
)

Definition at line 1501 of file detect-engine.c.

References DetectEngineThreadCtx_::buffers, and DetectEngineThreadCtx_::inspect.

Referenced by DetectHelperGetData(), and InspectionBufferSetup().

Here is the caller graph for this function:

◆ InspectionBufferInit()

void InspectionBufferInit ( InspectionBuffer buffer,
uint32_t  initial_size 
)

Definition at line 1558 of file detect-engine.c.

References InspectionBuffer::buf, SCCalloc, and InspectionBuffer::size.

◆ InspectionBufferMultipleForListGet()

InspectionBuffer* InspectionBufferMultipleForListGet ( DetectEngineThreadCtx det_ctx,
const int  list_id,
const uint32_t  local_id 
)

for a InspectionBufferMultipleForList get a InspectionBuffer

Parameters
fbthe multiple buffer array
local_idthe index to get a buffer
bufferthe inspect buffer or NULL in case of error

Definition at line 1521 of file detect-engine.c.

References DETECT_EVENT_TOO_MANY_BUFFERS, DetectEngineSetEvent(), and unlikely.

Referenced by DetectHelperGetMultiData().

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

◆ InspectionBufferSetup()

void InspectionBufferSetup ( DetectEngineThreadCtx det_ctx,
const int  list_id,
InspectionBuffer buffer,
const uint8_t *  data,
const uint32_t  data_len 
)

◆ InspectionBufferSetupMulti()

void InspectionBufferSetupMulti ( InspectionBuffer buffer,
const DetectEngineTransforms transforms,
const uint8_t *  data,
const uint32_t  data_len 
)

setup the buffer with our initial data

Definition at line 1581 of file detect-engine.c.

References DEBUG_VALIDATE_BUG_ON, InspectionBuffer::initialized, InspectionBuffer::inspect, InspectionBuffer::inspect_len, InspectionBufferApplyTransforms(), InspectionBuffer::len, InspectionBuffer::orig, and InspectionBuffer::orig_len.

Referenced by DetectHelperGetMultiData().

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

◆ InspectionBufferSetupMultiEmpty()

void InspectionBufferSetupMultiEmpty ( InspectionBuffer buffer)

setup the buffer empty

Definition at line 1568 of file detect-engine.c.

References DEBUG_VALIDATE_BUG_ON, InspectionBuffer::initialized, InspectionBuffer::inspect, InspectionBuffer::inspect_len, and InspectionBuffer::len.

Referenced by DetectHelperGetMultiData().

Here is the caller graph for this function:

◆ InspectionBufferTruncate()

void InspectionBufferTruncate ( InspectionBuffer buffer,
uint32_t  buf_len 
)