-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatatypes.hpp
More file actions
64 lines (50 loc) · 1.17 KB
/
datatypes.hpp
File metadata and controls
64 lines (50 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef DATATYPE_H
#define DATATYPE_H
#include "hash.h"
#include "string.h"
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define LGN 13
typedef struct key_t_s {
unsigned char key[13];
} key_tp;
typedef uint32_t val_tp;
/**
* Object for hash
*/
typedef struct {
/// overloaded operation
long operator() (const key_tp &k) const { return MurmurHash64A(k.key, 13, 388650253); }
} key_tp_hash;
/**
* Object for equality
*/
typedef struct {
/// overloaded operation
bool operator() (const key_tp &x, const key_tp &y) const {
return memcmp(x.key, y.key, 13)==0;
}
} key_tp_eq;
typedef std::unordered_set<key_tp, key_tp_hash, key_tp_eq> myset;
typedef std::unordered_map<key_tp, val_tp, key_tp_hash, key_tp_eq> mymap;
typedef std::vector<std::pair<key_tp, val_tp> > myvector;
/**
* IP flow key
* */
typedef struct __attribute__ ((__packed__)) flow_key {
uint32_t src_ip;
uint32_t dst_ip;
uint16_t src_port;
uint16_t dst_port;
uint8_t protocol;
} flow_key_t;
/**
*input data
* */
typedef struct __attribute__ ((__packed__)) Tuple {
flow_key_t key;
uint16_t size;
} tuple_t;
#endif