WAND Trace processing  4.0.5
hash_toeplitz.h
1 /*
2  *
3  * Copyright (c) 2007-2016 The University of Waikato, Hamilton, New Zealand.
4  * All rights reserved.
5  *
6  * This file is part of libtrace.
7  *
8  * This code has been developed by the University of Waikato WAND
9  * research group. For further information please see http://www.wand.net.nz/
10  *
11  * libtrace is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License as published by
13  * the Free Software Foundation; either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * libtrace is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23  *
24  *
25  */
26 
30 #include "config.h"
31 #include <stdint.h>
32 #include <stddef.h>
33 #include <libtrace.h>
34 
35 #ifndef HASH_TOEPLITZ_H
36 #define HASH_TOEPLITZ_H
37 
41 typedef struct toeplitz_conf {
42  unsigned int hash_ipv4 : 1;
43  unsigned int hash_tcp_ipv4 : 1;
44  unsigned int hash_ipv6 : 1;
45  unsigned int hash_tcp_ipv6 : 1;
46  unsigned int hash_ipv6_ex : 1;
47  unsigned int hash_tcp_ipv6_ex : 1;
48  /* These UDP ones are Intel extensions */
49  unsigned int x_hash_udp_ipv4 : 1;
50  unsigned int x_hash_udp_ipv6 : 1;
51  unsigned int x_hash_udp_ipv6_ex : 1;
52  uint8_t key[40];
53  uint32_t key_cache[320];
55 
56 DLLEXPORT void toeplitz_hash_expand_key(toeplitz_conf_t *conf);
57 DLLEXPORT uint32_t toeplitz_hash(const toeplitz_conf_t *tc, const uint8_t *data, size_t offset, size_t n, uint32_t result);
58 DLLEXPORT uint32_t toeplitz_first_hash(const toeplitz_conf_t *tc, const uint8_t *data, size_t n);
59 DLLEXPORT void toeplitz_init_config(toeplitz_conf_t *conf, bool bidirectional);
60 DLLEXPORT uint64_t toeplitz_hash_packet(const libtrace_packet_t * pkt, const toeplitz_conf_t *cnf);
61 DLLEXPORT void toeplitz_ncreate_bikey(uint8_t *key, size_t num);
62 DLLEXPORT void toeplitz_create_bikey(uint8_t *key);
63 DLLEXPORT void toeplitz_ncreate_unikey(uint8_t *key, size_t num);
64 DLLEXPORT void toeplitz_create_unikey(uint8_t *key);
65 
66 
67 /* IPv4 Only (Input[8] = @12-15, @16-19) src dst */
68 
69 // Using char any way in the hope this structure will auto allign
70 #pragma pack(push) /* push current alignment to stack */
71 #pragma pack(1) /* set alignment to 1 byte boundary */
72 typedef struct ipv4_toeplitz_only {
73  uint8_t src[4];
74  uint8_t dest[4];
76 #pragma pack(pop) /* restore original alignment from stack */
77 
78 #endif
Definition: hash_toeplitz.h:72
Trace file processing library header.
toeplitz hashing - see microsoft rss code
Definition: hash_toeplitz.h:41
The libtrace packet structure.
Definition: libtrace.h:543