source: lib/hash_toeplitz.h

cachetimestampsdevelopetsiliverc-4.0.3rc-4.0.4ringdecrementfixringperformance
Last change on this file was e4eaca5, checked in by Shane Alcock <salcock@…>, 4 years ago

Add DLLEXPORT to all hash_toeplitz API functions.

This allows the toeplitz hasher to be used outside of
libtrace -- e.g. a user can create their own hasher and pass
it into trace_set_hasher.

This is useful if a user wants to use the same hasher (and
therefore the same seed) across multiple traces -- libtrace
in-built hashers are re-seeded for each trace file so their
hashing is not consistent across multiple inputs.

  • Property mode set to 100644
File size: 2.7 KB
Line 
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
27/**
28 * toeplitz hashing - see microsoft rss code
29 */
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
38/**
39 * The default expected to be used.
40 */ 
41typedef 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];
54} toeplitz_conf_t;
55
56DLLEXPORT void toeplitz_hash_expand_key(toeplitz_conf_t *conf);
57DLLEXPORT uint32_t toeplitz_hash(const toeplitz_conf_t *tc, const uint8_t *data, size_t offset, size_t n, uint32_t result);
58DLLEXPORT uint32_t toeplitz_first_hash(const toeplitz_conf_t *tc, const uint8_t *data, size_t n);
59DLLEXPORT void toeplitz_init_config(toeplitz_conf_t *conf, bool bidirectional);
60DLLEXPORT uint64_t toeplitz_hash_packet(const libtrace_packet_t * pkt, const toeplitz_conf_t *cnf);
61DLLEXPORT void toeplitz_ncreate_bikey(uint8_t *key, size_t num);
62DLLEXPORT void toeplitz_create_bikey(uint8_t *key);
63DLLEXPORT void toeplitz_ncreate_unikey(uint8_t *key, size_t num);
64DLLEXPORT 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 */
72typedef struct ipv4_toeplitz_only {
73        uint8_t src[4];
74        uint8_t dest[4];
75} toeplitz_ipv4_only_t;
76#pragma pack(pop)   /* restore original alignment from stack */
77
78#endif
Note: See TracBrowser for help on using the repository browser.