suricata
datasets-ipv6.c
Go to the documentation of this file.
1 /* Copyright (C) 2022 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 Eric Leblond <el@stamus-networks.com>
22  */
23 
24 #include "suricata-common.h"
25 #include "conf.h"
26 #include "datasets.h"
27 #include "datasets-ipv6.h"
28 #include "util-hash-lookup3.h"
29 #include "util-thash.h"
30 #include "util-print.h"
31 
32 int IPv6Set(void *dst, void *src)
33 {
34  IPv6Type *src_s = src;
35  IPv6Type *dst_s = dst;
36  memcpy(dst_s->ipv6, src_s->ipv6, sizeof(dst_s->ipv6));
37  dst_s->rep = src_s->rep;
38  return 0;
39 }
40 
41 bool IPv6Compare(void *a, void *b)
42 {
43  const IPv6Type *as = a;
44  const IPv6Type *bs = b;
45 
46  return (memcmp(as->ipv6, bs->ipv6, sizeof(as->ipv6)) == 0);
47 }
48 
49 uint32_t IPv6Hash(uint32_t hash_seed, void *s)
50 {
51  const IPv6Type *str = s;
52  return hashword((uint32_t *)str->ipv6, 4, hash_seed);
53 }
54 
55 // data stays in hash
56 void IPv6Free(void *s)
57 {
58 }
hashword
uint32_t hashword(const uint32_t *k, size_t length, uint32_t initval)
Definition: util-hash-lookup3.c:172
IPv6Compare
bool IPv6Compare(void *a, void *b)
Definition: datasets-ipv6.c:41
datasets.h
IPv6Set
int IPv6Set(void *dst, void *src)
Definition: datasets-ipv6.c:32
datasets-ipv6.h
IPv6Type::ipv6
uint8_t ipv6[16]
Definition: datasets-ipv6.h:30
IPv6Type::rep
DataRepType rep
Definition: datasets-ipv6.h:31
util-print.h
conf.h
IPv6Type
Definition: datasets-ipv6.h:29
suricata-common.h
util-hash-lookup3.h
IPv6Hash
uint32_t IPv6Hash(uint32_t hash_seed, void *s)
Definition: datasets-ipv6.c:49
str
#define str(s)
Definition: suricata-common.h:291
src
uint16_t src
Definition: app-layer-dnp3.h:5
IPv6Free
void IPv6Free(void *s)
Definition: datasets-ipv6.c:56
dst
uint16_t dst
Definition: app-layer-dnp3.h:4
util-thash.h