THashDataUnlock(d);
}
static bool DatasetIsStatic(const char *save, const char *load);
+static void GetDefaultMemcap(uint64_t *memcap, uint32_t *hashsize);
enum DatasetTypes DatasetGetTypeFromString(const char *s)
{
Dataset *DatasetGet(const char *name, enum DatasetTypes type, const char *save, const char *load,
uint64_t memcap, uint32_t hashsize)
{
+ uint64_t default_memcap = 0;
+ uint32_t default_hashsize = 0;
if (strlen(name) > DATASET_NAME_MAX_LEN) {
return NULL;
}
char cnf_name[128];
snprintf(cnf_name, sizeof(cnf_name), "datasets.%s.hash", name);
+ GetDefaultMemcap(&default_memcap, &default_hashsize);
switch (type) {
case DATASET_TYPE_MD5:
set->hash = THashInit(cnf_name, sizeof(Md5Type), Md5StrSet, Md5StrFree, Md5StrHash,
SCMutexUnlock(&sets_lock);
}
+static void GetDefaultMemcap(uint64_t *memcap, uint32_t *hashsize)
+{
+ const char *str = NULL;
+ if (ConfGetValue("datasets.defaults.memcap", &str) == 1) {
+ if (ParseSizeStringU64(str, memcap) < 0) {
+ SCLogWarning(SC_ERR_INVALID_VALUE,
+ "memcap value cannot be deduced: %s,"
+ " resetting to default",
+ str);
+ *memcap = 0;
+ }
+ }
+ if (ConfGetValue("datasets.defaults.hashsize", &str) == 1) {
+ if (ParseSizeStringU32(str, hashsize) < 0) {
+ SCLogWarning(SC_ERR_INVALID_VALUE,
+ "hashsize value cannot be deduced: %s,"
+ " resetting to default",
+ str);
+ *hashsize = 0;
+ }
+ }
+}
+
int DatasetsInit(void)
{
SCLogDebug("datasets start");
int n = 0;
ConfNode *datasets = ConfGetNode("datasets");
+ uint64_t default_memcap = 0;
+ uint32_t default_hashsize = 0;
+ GetDefaultMemcap(&default_memcap, &default_hashsize);
if (datasets != NULL) {
int list_pos = 0;
ConfNode *iter = NULL;