-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathFiveTuple.h
59 lines (47 loc) · 1.23 KB
/
FiveTuple.h
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
#pragma once
#include "net.h"
namespace FeatureExtractor {
/**
* 5-tuple identificator for conversation
* <IP protocol, source IP, source port, destination IP, destination port>
*/
class FiveTuple
{
ip_field_protocol_t ip_proto;
uint32_t src_ip;
uint32_t dst_ip;
uint16_t src_port;
uint16_t dst_port;
public:
FiveTuple();
~FiveTuple();
ip_field_protocol_t get_ip_proto() const;
void set_ip_proto(ip_field_protocol_t ip_proto);
uint32_t get_src_ip() const;
void set_src_ip(uint32_t src_ip);
uint32_t get_dst_ip() const;
void set_dst_ip(uint32_t dst_ip);
uint16_t get_src_port() const;
void set_src_port(uint16_t src_port);
uint16_t get_dst_port() const;
void set_dst_port(uint16_t dst_port);
/**
* Returns true if source endpoint (IP:port) is the same as destination
*/
bool land() const;
/**
* Less than operator - can be used for map<> keyoperator
* Operator '<' is applied to field in this order:
* 1. IP protocol
* 2. Source IP
* 3. Destination IP
* 4. Source port
* 5. Destionatio port
*/
bool operator<(const FiveTuple& other) const;
/**
* Creates 5-tuple with swapped source and destionation (IPs, ports)
*/
FiveTuple get_reversed() const;
};
}