suricata
datasets-md5.c
Go to the documentation of this file.
1
/* Copyright (C) 2017-2024 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
/**
19
* \file
20
*
21
* \author Victor Julien <victor@inliniac.net>
22
*/
23
24
#include "
suricata-common.h
"
25
#include "
conf.h
"
26
#include "
datasets.h
"
27
#include "
datasets-context-json.h
"
28
#include "
datasets-md5.h
"
29
#include "
util-hash-lookup3.h
"
30
31
#include "
util-thash.h
"
32
#include "
util-print.h
"
33
34
int
Md5StrSet
(
void
*
dst
,
void
*
src
)
35
{
36
Md5Type
*src_s =
src
;
37
Md5Type
*dst_s =
dst
;
38
memcpy(dst_s->
md5
, src_s->
md5
,
sizeof
(dst_s->
md5
));
39
dst_s->
rep
= src_s->
rep
;
40
return
0;
41
}
42
43
int
Md5StrJsonSet
(
void
*
dst
,
void
*
src
)
44
{
45
if
(
Md5StrSet
(
dst
,
src
) < 0)
46
return
-1;
47
48
Md5Type
*src_s =
src
;
49
Md5Type
*dst_s =
dst
;
50
51
if
(
DatajsonCopyJson
(&dst_s->
json
, &src_s->
json
) < 0)
52
return
-1;
53
54
return
0;
55
}
56
57
bool
Md5StrCompare
(
void
*a,
void
*b)
58
{
59
const
Md5Type
*as = a;
60
const
Md5Type
*bs = b;
61
62
return
(memcmp(as->
md5
, bs->
md5
,
sizeof
(as->
md5
)) == 0);
63
}
64
65
uint32_t
Md5StrHash
(uint32_t hash_seed,
void
*s)
66
{
67
const
Md5Type
*
str
= s;
68
return
hashword
((uint32_t *)
str
->md5,
sizeof
(
str
->md5) / 4, hash_seed);
69
}
70
71
// data stays in hash
72
void
Md5StrFree
(
void
*s)
73
{
74
}
75
76
void
Md5StrJsonFree
(
void
*s)
77
{
78
const
Md5Type
*as = s;
79
if
(as->
json
.
value
) {
80
SCFree
(as->
json
.
value
);
81
}
82
}
83
84
uint32_t
Md5StrJsonGetLength
(
void
*s)
85
{
86
const
Md5Type
*as = s;
87
return
as->
json
.
len
;
88
}
DataJsonType::len
uint16_t len
Definition:
datasets-context-json.h:34
datasets-md5.h
hashword
uint32_t hashword(const uint32_t *k, size_t length, uint32_t initval)
Definition:
util-hash-lookup3.c:172
Md5Type
Definition:
datasets-md5.h:30
Md5Type::rep
DataRepType rep
Definition:
datasets-md5.h:33
Md5Type::md5
uint8_t md5[16]
Definition:
datasets-md5.h:31
Md5StrCompare
bool Md5StrCompare(void *a, void *b)
Definition:
datasets-md5.c:57
datasets.h
util-print.h
Md5StrHash
uint32_t Md5StrHash(uint32_t hash_seed, void *s)
Definition:
datasets-md5.c:65
Md5Type::json
DataJsonType json
Definition:
datasets-md5.h:34
conf.h
suricata-common.h
datasets-context-json.h
Md5StrSet
int Md5StrSet(void *dst, void *src)
Definition:
datasets-md5.c:34
util-hash-lookup3.h
DatajsonCopyJson
int DatajsonCopyJson(DataJsonType *dst, DataJsonType *src)
Definition:
datasets-context-json.c:54
str
#define str(s)
Definition:
suricata-common.h:308
SCFree
#define SCFree(p)
Definition:
util-mem.h:61
src
uint16_t src
Definition:
app-layer-dnp3.h:5
DataJsonType::value
char * value
Definition:
datasets-context-json.h:33
dst
uint16_t dst
Definition:
app-layer-dnp3.h:4
util-thash.h
Md5StrJsonFree
void Md5StrJsonFree(void *s)
Definition:
datasets-md5.c:76
Md5StrJsonGetLength
uint32_t Md5StrJsonGetLength(void *s)
Definition:
datasets-md5.c:84
Md5StrFree
void Md5StrFree(void *s)
Definition:
datasets-md5.c:72
Md5StrJsonSet
int Md5StrJsonSet(void *dst, void *src)
Definition:
datasets-md5.c:43
src
datasets-md5.c
Generated on Sat Jun 21 2025 23:30:27 for suricata by
1.8.18