]>
Commit | Line | Data |
---|---|---|
317376f5 VJ |
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); | |
e9fe5ada SB |
27 | void DatasetReload(void); |
28 | void DatasetPostReloadCleanup(void); | |
317376f5 VJ |
29 | |
30 | enum DatasetTypes { | |
31 | #define DATASET_TYPE_NOTSET 0 | |
32 | DATASET_TYPE_STRING = 1, | |
33 | DATASET_TYPE_MD5, | |
34 | DATASET_TYPE_SHA256, | |
35 | }; | |
36 | ||
e264a0ce | 37 | #define DATASET_NAME_MAX_LEN 63 |
317376f5 | 38 | typedef struct Dataset { |
e264a0ce | 39 | char name[DATASET_NAME_MAX_LEN + 1]; |
317376f5 VJ |
40 | enum DatasetTypes type; |
41 | uint32_t id; | |
e9fe5ada SB |
42 | bool from_yaml; /* Mark whether the set was retrieved from YAML */ |
43 | bool hidden; /* Mark the old sets hidden in case of reload */ | |
317376f5 VJ |
44 | THashTableContext *hash; |
45 | ||
46 | char load[PATH_MAX]; | |
47 | char save[PATH_MAX]; | |
48 | ||
49 | struct Dataset *next; | |
50 | } Dataset; | |
51 | ||
1d6a358d VJ |
52 | enum DatasetTypes DatasetGetTypeFromString(const char *s); |
53 | Dataset *DatasetFind(const char *name, enum DatasetTypes type); | |
5ac94fc4 SB |
54 | Dataset *DatasetGet(const char *name, enum DatasetTypes type, const char *save, const char *load, |
55 | uint64_t memcap, uint32_t hashsize); | |
317376f5 VJ |
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); | |
af06883f | 60 | |
1d6a358d | 61 | int DatasetAddSerialized(Dataset *set, const char *string); |
af06883f | 62 | int DatasetRemoveSerialized(Dataset *set, const char *string); |
317376f5 VJ |
63 | |
64 | #endif /* __DATASETS_H__ */ |