suricata
datasets.h
Go to the documentation of this file.
1 /* Copyright (C) 2017 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 #ifndef __DATASETS_H__
19 #define __DATASETS_H__
20 
21 #include "util-thash.h"
22 #include "datasets-reputation.h"
23 
24 int DatasetsInit(void);
25 void DatasetsDestroy(void);
26 void DatasetsSave(void);
27 void DatasetReload(void);
28 void DatasetPostReloadCleanup(void);
29 
31 #define DATASET_TYPE_NOTSET 0
35 };
36 
37 #define DATASET_NAME_MAX_LEN 63
38 typedef struct Dataset {
40  enum DatasetTypes type;
41  uint32_t id;
42  bool from_yaml; /* Mark whether the set was retrieved from YAML */
43  bool hidden; /* Mark the old sets hidden in case of reload */
45 
46  char load[PATH_MAX];
47  char save[PATH_MAX];
48 
49  struct Dataset *next;
51 
52 enum DatasetTypes DatasetGetTypeFromString(const char *s);
53 Dataset *DatasetFind(const char *name, enum DatasetTypes type);
54 Dataset *DatasetGet(const char *name, enum DatasetTypes type,
55  const char *save, const char *load);
56 int DatasetAdd(Dataset *set, const uint8_t *data, const uint32_t data_len);
57 int DatasetLookup(Dataset *set, const uint8_t *data, const uint32_t data_len);
58 DataRepResultType DatasetLookupwRep(Dataset *set, const uint8_t *data, const uint32_t data_len,
59  const DataRepType *rep);
60 
61 int DatasetAddSerialized(Dataset *set, const char *string);
62 int DatasetRemoveSerialized(Dataset *set, const char *string);
63 
64 #endif /* __DATASETS_H__ */
DatasetFind
Dataset * DatasetFind(const char *name, enum DatasetTypes type)
look for set by name without creating it
Definition: datasets.c:405
DatasetRemoveSerialized
int DatasetRemoveSerialized(Dataset *set, const char *string)
remove serialized data from set
Definition: datasets.c:1163
Dataset::name
char name[DATASET_NAME_MAX_LEN+1]
Definition: datasets.h:39
Dataset::id
uint32_t id
Definition: datasets.h:41
Dataset::save
char save[PATH_MAX]
Definition: datasets.h:47
Dataset::hash
THashTableContext * hash
Definition: datasets.h:44
DatasetAddSerialized
int DatasetAddSerialized(Dataset *set, const char *string)
add serialized data to set
Definition: datasets.c:1081
Dataset::type
enum DatasetTypes type
Definition: datasets.h:40
Dataset
struct Dataset Dataset
DatasetsSave
void DatasetsSave(void)
Definition: datasets.c:731
DATASET_TYPE_SHA256
@ DATASET_TYPE_SHA256
Definition: datasets.h:34
DatasetLookup
int DatasetLookup(Dataset *set, const uint8_t *data, const uint32_t data_len)
see if data is part of the set
Definition: datasets.c:893
datasets-reputation.h
DatasetReload
void DatasetReload(void)
Definition: datasets.c:548
DatasetLookupwRep
DataRepResultType DatasetLookupwRep(Dataset *set, const uint8_t *data, const uint32_t data_len, const DataRepType *rep)
Definition: datasets.c:909
DataRepResultType
Definition: datasets-reputation.h:31
type
uint8_t type
Definition: decode-icmpv4.h:0
DatasetPostReloadCleanup
void DatasetPostReloadCleanup(void)
Definition: datasets.c:570
THashTableContext_
Definition: util-thash.h:143
DatasetsInit
int DatasetsInit(void)
Definition: datasets.c:596
DatasetTypes
DatasetTypes
Definition: datasets.h:30
Dataset::next
struct Dataset * next
Definition: datasets.h:49
DatasetsDestroy
void DatasetsDestroy(void)
Definition: datasets.c:676
DATASET_NAME_MAX_LEN
#define DATASET_NAME_MAX_LEN
Definition: datasets.h:37
DatasetAdd
int DatasetAdd(Dataset *set, const uint8_t *data, const uint32_t data_len)
Definition: datasets.c:1042
Dataset::hidden
bool hidden
Definition: datasets.h:43
DATASET_TYPE_MD5
@ DATASET_TYPE_MD5
Definition: datasets.h:33
DATASET_TYPE_STRING
@ DATASET_TYPE_STRING
Definition: datasets.h:32
Dataset
Definition: datasets.h:38
Dataset::from_yaml
bool from_yaml
Definition: datasets.h:42
DatasetGetTypeFromString
enum DatasetTypes DatasetGetTypeFromString(const char *s)
Definition: datasets.c:52
util-thash.h
Dataset::load
char load[PATH_MAX]
Definition: datasets.h:46
DataRepType
Definition: datasets-reputation.h:27
DatasetGet
Dataset * DatasetGet(const char *name, enum DatasetTypes type, const char *save, const char *load)
Definition: datasets.c:419