suricata
datasets.c File Reference
#include "suricata-common.h"
#include "suricata.h"
#include "rust.h"
#include "conf.h"
#include "datasets.h"
#include "datasets-string.h"
#include "datasets-ipv4.h"
#include "datasets-ipv6.h"
#include "datasets-md5.h"
#include "datasets-sha256.h"
#include "datasets-reputation.h"
#include "util-conf.h"
#include "util-thash.h"
#include "util-print.h"
#include "util-byte.h"
#include "util-misc.h"
#include "util-path.h"
#include "util-debug.h"
#include "util-validate.h"
Include dependency graph for datasets.c:

Go to the source code of this file.

Macros

#define DATASETS_HASHSIZE_DEFAULT   4096
 

Typedefs

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

Enumerations

enum  DatasetGetPathType { TYPE_STATE, TYPE_LOAD }
 

Functions

int DatasetAddwRep (Dataset *set, const uint8_t *data, const uint32_t data_len, DataRepType *rep)
 
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, uint64_t memcap, uint32_t hashsize)
 
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 DatasetLookupSerialized (Dataset *set, const char *string)
 add serialized data to set More...
 
int DatasetRemoveSerialized (Dataset *set, const char *string)
 remove serialized data from set More...
 
int DatasetRemove (Dataset *set, const uint8_t *data, const uint32_t data_len)
 

Variables

SCMutex sets_lock = SCMUTEX_INITIALIZER
 
uint32_t dataset_max_one_hashsize = 65536
 
uint32_t dataset_max_total_hashsize = 16777216
 
uint32_t dataset_used_hashsize = 0
 
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.

Macro Definition Documentation

◆ DATASETS_HASHSIZE_DEFAULT

#define DATASETS_HASHSIZE_DEFAULT   4096

Definition at line 579 of file datasets.c.

Typedef Documentation

◆ DatasetOpFunc

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

Definition at line 1363 of file datasets.c.

Enumeration Type Documentation

◆ DatasetGetPathType

Enumerator
TYPE_STATE 
TYPE_LOAD 

Definition at line 277 of file datasets.c.

Function Documentation

◆ DatasetAdd()

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

Definition at line 1323 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 1426 of file datasets.c.

◆ DatasetAddwRep()

int DatasetAddwRep ( Dataset set,
const uint8_t *  data,
const uint32_t  data_len,
DataRepType *  rep 
)

Definition at line 1343 of file datasets.c.

References DATASET_TYPE_STRING, and Dataset::type.

◆ DatasetFind()

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

look for set by name without creating it

Definition at line 315 of file datasets.c.

References SCMutexLock, and sets_lock.

◆ DatasetGet()

Dataset* DatasetGet ( const char *  name,
enum DatasetTypes  type,
const char *  save,
const char *  load,
uint64_t  memcap,
uint32_t  hashsize 
)

Definition at line 357 of file datasets.c.

References DATASET_NAME_MAX_LEN, name, SCMutexLock, and sets_lock.

◆ DatasetGetTypeFromString()

enum DatasetTypes DatasetGetTypeFromString ( const char *  s)

Definition at line 60 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 1088 of file datasets.c.

References DATASET_TYPE_STRING, and Dataset::type.

Referenced by DetectDatasetBufferMatch().

Here is the caller graph for this function:

◆ DatasetLookupSerialized()

int DatasetLookupSerialized ( 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 1438 of file datasets.c.

◆ DatasetLookupwRep()

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

Definition at line 1108 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 550 of file datasets.c.

References SCLogDebug, SCMutexLock, and sets_lock.

◆ DatasetReload()

void DatasetReload ( void  )

Definition at line 524 of file datasets.c.

References SCMutexLock, and sets_lock.

◆ DatasetRemove()

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

Definition at line 1522 of file datasets.c.

References DATASET_TYPE_STRING, and Dataset::type.

Referenced by DetectDatasetBufferMatch().

Here is the caller graph for this function:

◆ 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 1516 of file datasets.c.

◆ DatasetsDestroy()

void DatasetsDestroy ( void  )

Definition at line 758 of file datasets.c.

References SCLogDebug.

Referenced by GlobalsDestroy().

Here is the caller graph for this function:

◆ DatasetsInit()

int DatasetsInit ( void  )

Definition at line 603 of file datasets.c.

References ConfGetNode(), and SCLogDebug.

Referenced by PreRunPostPrivsDropInit().

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

◆ DatasetsSave()

void DatasetsSave ( void  )

Definition at line 836 of file datasets.c.

References SCLogDebug.

Referenced by GlobalsDestroy().

Here is the caller graph for this function:

Variable Documentation

◆ dataset_max_one_hashsize

uint32_t dataset_max_one_hashsize = 65536

Definition at line 48 of file datasets.c.

◆ dataset_max_total_hashsize

uint32_t dataset_max_total_hashsize = 16777216

Definition at line 49 of file datasets.c.

◆ dataset_used_hashsize

uint32_t dataset_used_hashsize = 0

Definition at line 50 of file datasets.c.

◆ g_system

bool g_system

Definition at line 188 of file suricata.c.

◆ sets_lock

Definition at line 44 of file datasets.c.

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