suricata
|
#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 "datasets-context-json.h"
#include "util-conf.h"
#include "util-mem.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"
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) |
int | DatasetAppendSet (Dataset *set) |
void | DatasetLock (void) |
void | DatasetUnlock (void) |
Dataset * | DatasetAlloc (const char *name) |
Dataset * | DatasetSearchByName (const char *name) |
int | DatasetParseIpv6String (Dataset *set, const char *line, struct in6_addr *in6) |
Dataset * | DatasetFind (const char *name, enum DatasetTypes type) |
look for set by name without creating it More... | |
int | DatasetGetOrCreate (const char *name, enum DatasetTypes type, const char *save, const char *load, uint64_t *memcap, uint32_t *hashsize, Dataset **ret_set) |
Dataset * | DatasetGet (const char *name, enum DatasetTypes type, const char *save, const char *load, uint64_t memcap, uint32_t hashsize) |
void | DatasetReload (void) |
void | DatasetPostReloadCleanup (void) |
void | DatasetGetDefaultMemcap (uint64_t *memcap, uint32_t *hashsize) |
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 |
Definition in file datasets.c.
#define DATASETS_HASHSIZE_DEFAULT 4096 |
Definition at line 598 of file datasets.c.
typedef int(* DatasetOpFunc) (Dataset *set, const uint8_t *data, const uint32_t data_len) |
Definition at line 1379 of file datasets.c.
enum DatasetGetPathType |
Enumerator | |
---|---|
TYPE_STATE | |
TYPE_LOAD |
Definition at line 282 of file datasets.c.
int DatasetAdd | ( | Dataset * | set, |
const uint8_t * | data, | ||
const uint32_t | data_len | ||
) |
Definition at line 1339 of file datasets.c.
References DATASET_TYPE_STRING, and Dataset::type.
int DatasetAddSerialized | ( | Dataset * | set, |
const char * | string | ||
) |
add serialized data to set
int | 1 added |
int | 0 already in hash |
int | -1 API error (not added) |
int | -2 DATA error |
Definition at line 1446 of file datasets.c.
int DatasetAddwRep | ( | Dataset * | set, |
const uint8_t * | data, | ||
const uint32_t | data_len, | ||
DataRepType * | rep | ||
) |
Definition at line 1359 of file datasets.c.
References DATASET_TYPE_STRING, and Dataset::type.
Dataset* DatasetAlloc | ( | const char * | name | ) |
Definition at line 112 of file datasets.c.
References Dataset::id, and SCCalloc.
int DatasetAppendSet | ( | Dataset * | set | ) |
Definition at line 79 of file datasets.c.
References Dataset::hash, Dataset::load, Dataset::name, Dataset::next, Dataset::save, SC_ATOMIC_GET, SCLogDebug, SCLogError, and Dataset::type.
Dataset* DatasetFind | ( | const char * | name, |
enum DatasetTypes | type | ||
) |
look for set by name without creating it
Definition at line 320 of file datasets.c.
References DatasetLock(), DatasetSearchByName(), DatasetUnlock(), name, Dataset::type, and type.
Dataset* DatasetGet | ( | const char * | name, |
enum DatasetTypes | type, | ||
const char * | save, | ||
const char * | load, | ||
uint64_t | memcap, | ||
uint32_t | hashsize | ||
) |
Definition at line 451 of file datasets.c.
References DATASET_TYPE_MD5, DatasetGetOrCreate(), DatasetLock(), DatasetUnlock(), Dataset::hash, hashsize, Md5StrCompare(), Md5StrFree(), Md5StrHash(), Md5StrSet(), name, SCLogDebug, SCLogError, THashInit(), and type.
void DatasetGetDefaultMemcap | ( | uint64_t * | memcap, |
uint32_t * | hashsize | ||
) |
Definition at line 599 of file datasets.c.
References DATASETS_HASHSIZE_DEFAULT, hashsize, ParseSizeStringU32(), ParseSizeStringU64(), SCConfGet(), SCLogWarning, and str.
Referenced by DatasetGetOrCreate(), and DatasetsInit().
int DatasetGetOrCreate | ( | const char * | name, |
enum DatasetTypes | type, | ||
const char * | save, | ||
const char * | load, | ||
uint64_t * | memcap, | ||
uint32_t * | hashsize, | ||
Dataset ** | ret_set | ||
) |
Calling function is responsible for locking via DatasetLock()
Definition at line 369 of file datasets.c.
References DATASET_NAME_MAX_LEN, DATASET_TYPE_NOTSET, DatasetGetDefaultMemcap(), DatasetSearchByName(), DatasetUnlock(), hashsize, Dataset::load, Dataset::name, name, Dataset::save, SCLogError, Dataset::type, and type.
Referenced by DatajsonGet(), and DatasetGet().
enum DatasetTypes DatasetGetTypeFromString | ( | const char * | s | ) |
Definition at line 62 of file datasets.c.
void DatasetLock | ( | void | ) |
Definition at line 102 of file datasets.c.
References SCMutexLock, and sets_lock.
Referenced by DatajsonGet(), DatasetFind(), DatasetGet(), DatasetPostReloadCleanup(), DatasetReload(), DatasetsDestroy(), and DatasetsSave().
int DatasetLookup | ( | Dataset * | set, |
const uint8_t * | data, | ||
const uint32_t | data_len | ||
) |
see if data is part of the set
set | dataset |
data | data to look up |
data_len | length in bytes of data |
-1 | error |
0 | not found |
1 | found |
Definition at line 1104 of file datasets.c.
References DATASET_TYPE_STRING, and Dataset::type.
int DatasetLookupSerialized | ( | Dataset * | set, |
const char * | string | ||
) |
add serialized data to set
int | 1 added |
int | 0 already in hash |
int | -1 API error (not added) |
int | -2 DATA error |
Definition at line 1458 of file datasets.c.
DataRepResultType DatasetLookupwRep | ( | Dataset * | set, |
const uint8_t * | data, | ||
const uint32_t | data_len, | ||
const DataRepType * | rep | ||
) |
Definition at line 1124 of file datasets.c.
References DATASET_TYPE_STRING, DataRepResultType::found, and Dataset::type.
Referenced by DetectDatarepBufferMatch().
int DatasetParseIpv6String | ( | Dataset * | set, |
const char * | line, | ||
struct in6_addr * | in6 | ||
) |
Definition at line 156 of file datasets.c.
References FatalErrorOnInit, Dataset::load, and Dataset::name.
void DatasetPostReloadCleanup | ( | void | ) |
Definition at line 569 of file datasets.c.
References DatasetLock(), and SCLogDebug.
void DatasetReload | ( | void | ) |
Definition at line 543 of file datasets.c.
References DatasetLock().
int DatasetRemove | ( | Dataset * | set, |
const uint8_t * | data, | ||
const uint32_t | data_len | ||
) |
Definition at line 1542 of file datasets.c.
References DATASET_TYPE_STRING, and Dataset::type.
int DatasetRemoveSerialized | ( | Dataset * | set, |
const char * | string | ||
) |
remove serialized data from set
int | 1 removed |
int | 0 found but busy (not removed) |
int | -1 API error (not removed) |
int | -2 DATA error |
Definition at line 1536 of file datasets.c.
void DatasetsDestroy | ( | void | ) |
Definition at line 774 of file datasets.c.
References DatasetLock(), and SCLogDebug.
Referenced by GlobalsDestroy().
Dataset* DatasetSearchByName | ( | const char * | name | ) |
Definition at line 121 of file datasets.c.
Referenced by DatasetFind(), and DatasetGetOrCreate().
int DatasetsInit | ( | void | ) |
Definition at line 622 of file datasets.c.
References dataset_max_one_hashsize, dataset_max_total_hashsize, DATASET_NAME_MAX_LEN, DatasetGetDefaultMemcap(), FatalError, FatalErrorOnInit, hashsize, SCConfNode_::name, next, ParseSizeStringU32(), SCConfGet(), SCConfGetNode(), SCConfNodeLookupChild(), SCLogDebug, str, and TAILQ_FOREACH.
Referenced by PreRunPostPrivsDropInit().
void DatasetsSave | ( | void | ) |
Definition at line 852 of file datasets.c.
References DatasetLock(), and SCLogDebug.
Referenced by GlobalsDestroy().
void DatasetUnlock | ( | void | ) |
Definition at line 107 of file datasets.c.
References SCMutexUnlock, and sets_lock.
Referenced by DatajsonGet(), DatasetFind(), DatasetGet(), and DatasetGetOrCreate().
uint32_t dataset_max_one_hashsize = 65536 |
Definition at line 50 of file datasets.c.
Referenced by DatasetsInit().
uint32_t dataset_max_total_hashsize = 16777216 |
Definition at line 51 of file datasets.c.
Referenced by DatasetsInit().
uint32_t dataset_used_hashsize = 0 |
Definition at line 52 of file datasets.c.
bool g_system |
Definition at line 191 of file suricata.c.
SCMutex sets_lock = SCMUTEX_INITIALIZER |
Definition at line 46 of file datasets.c.
Referenced by DatasetLock(), and DatasetUnlock().