suricata
datasets.c File Reference
#include "suricata-common.h"
#include "conf.h"
#include "datasets.h"
#include "datasets-string.h"
#include "datasets-md5.h"
#include "datasets-sha256.h"
#include "datasets-reputation.h"
#include "util-thash.h"
#include "util-print.h"
#include "util-crypt.h"
#include "util-base64.h"
#include "util-byte.h"
Include dependency graph for datasets.c:

Go to the source code of this file.

Enumerations

enum  DatasetGetPathType { TYPE_STATE, TYPE_LOAD }
 

Functions

enum DatasetTypes DatasetGetTypeFromString (const char *s)
 
DatasetDatasetFind (const char *name, enum DatasetTypes type)
 look for set by name without creating it More...
 
DatasetDatasetGet (const char *name, enum DatasetTypes type, const char *save, const char *load)
 
void DatasetReload (void)
 
void DatasetPostReloadCleanup (void)
 
int DatasetsInit (void)
 
void DatasetsDestroy (void)
 
void DatasetsSave (void)
 
int DatasetLookup (Dataset *set, const uint8_t *data, const uint32_t data_len)
 see if data is part of the set More...
 
DataRepResultType DatasetLookupwRep (Dataset *set, const uint8_t *data, const uint32_t data_len, const DataRepType *rep)
 
int DatasetAdd (Dataset *set, const uint8_t *data, const uint32_t data_len)
 
int DatasetAddSerialized (Dataset *set, const char *string)
 add serialized data to set More...
 
int DatasetRemoveSerialized (Dataset *set, const char *string)
 remove serialized data from set More...
 

Variables

SCMutex sets_lock = SCMUTEX_INITIALIZER
 
bool g_system
 

Detailed Description

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

Definition in file datasets.c.

Enumeration Type Documentation

◆ DatasetGetPathType

Enumerator
TYPE_STATE 
TYPE_LOAD 

Definition at line 367 of file datasets.c.

Function Documentation

◆ DatasetAdd()

int DatasetAdd ( Dataset set,
const uint8_t *  data,
const uint32_t  data_len 
)

Definition at line 1042 of file datasets.c.

References DATASET_TYPE_STRING, and Dataset::type.

Referenced by DetectDatasetBufferMatch().

Here is the caller graph for this function:

◆ DatasetAddSerialized()

int DatasetAddSerialized ( Dataset set,
const char *  string 
)

add serialized data to set

Return values
int1 added
int0 already in hash
int-1 API error (not added)
int-2 DATA error

Definition at line 1081 of file datasets.c.

References DATASET_TYPE_STRING, DecodeBase64(), len, and Dataset::type.

Here is the call graph for this function:

◆ DatasetFind()

Dataset* DatasetFind ( const char *  name,
enum DatasetTypes  type 
)

look for set by name without creating it

Definition at line 405 of file datasets.c.

References SCMutexLock, and sets_lock.

◆ DatasetGet()

Dataset* DatasetGet ( const char *  name,
enum DatasetTypes  type,
const char *  save,
const char *  load 
)

Definition at line 419 of file datasets.c.

References DATASET_NAME_MAX_LEN, SCMutexLock, and sets_lock.

◆ DatasetGetTypeFromString()

enum DatasetTypes DatasetGetTypeFromString ( const char *  s)

Definition at line 50 of file datasets.c.

◆ DatasetLookup()

int DatasetLookup ( Dataset set,
const uint8_t *  data,
const uint32_t  data_len 
)

see if data is part of the set

Parameters
setdataset
datadata to look up
data_lenlength in bytes of data
Return values
-1error
0not found
1found

Definition at line 893 of file datasets.c.

References DATASET_TYPE_STRING, and Dataset::type.

Referenced by DetectDatasetBufferMatch().

Here is the caller graph for this function:

◆ DatasetLookupwRep()

DataRepResultType DatasetLookupwRep ( Dataset set,
const uint8_t *  data,
const uint32_t  data_len,
const DataRepType rep 
)

Definition at line 909 of file datasets.c.

References DATASET_TYPE_STRING, DataRepResultType::found, and Dataset::type.

Referenced by DetectDatarepBufferMatch().

Here is the caller graph for this function:

◆ DatasetPostReloadCleanup()

void DatasetPostReloadCleanup ( void  )

Definition at line 570 of file datasets.c.

References SCLogDebug, SCMutexLock, and sets_lock.

◆ DatasetReload()

void DatasetReload ( void  )

Definition at line 548 of file datasets.c.

References SCMutexLock, and sets_lock.

◆ DatasetRemoveSerialized()

int DatasetRemoveSerialized ( Dataset set,
const char *  string 
)

remove serialized data from set

Return values
int1 removed
int0 found but busy (not removed)
int-1 API error (not removed)
int-2 DATA error

Definition at line 1163 of file datasets.c.

References DATASET_TYPE_STRING, DecodeBase64(), len, and Dataset::type.

Here is the call graph for this function:

◆ DatasetsDestroy()

void DatasetsDestroy ( void  )

Definition at line 676 of file datasets.c.

References SCLogDebug.

◆ DatasetsInit()

int DatasetsInit ( void  )

Definition at line 596 of file datasets.c.

References ConfGetNode(), ConfNodeLookupChild(), DATASET_NAME_MAX_LEN, FatalError, ConfNode_::name, next, SC_ERR_CONF_NAME_TOO_LONG, SCLogDebug, and TAILQ_FOREACH.

Referenced by PreRunInit().

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

◆ DatasetsSave()

void DatasetsSave ( void  )

Definition at line 731 of file datasets.c.

References SCLogDebug.

Variable Documentation

◆ g_system

bool g_system

Definition at line 223 of file suricata.c.

◆ sets_lock

Definition at line 37 of file datasets.c.

Referenced by DatasetFind(), DatasetGet(), DatasetPostReloadCleanup(), and DatasetReload().