-
Notifications
You must be signed in to change notification settings - Fork 108
/
hep.h
160 lines (145 loc) · 4.36 KB
/
hep.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#ifndef HEP_H
#define HEP_H
#include "cloud_router/cloud_router_base.h"
enum eHEP_ProtocolType {
_hep_prot_SIP = 0x01,
_hep_prot_XMPP = 0x02,
_hep_prot_SDP = 0x03,
_hep_prot_RTP = 0x04,
_hep_prot_RTCP_JSON = 0x05,
_hep_prot_MGCP = 0x06,
_hep_prot_MEGACO = 0x07,
_hep_prot_M2UA = 0x08,
_hep_prot_M3UA = 0x09,
_hep_prot_IAX = 0x0a,
_hep_prot_H3222 = 0x0b,
_hep_prot_H321 = 0x0c,
_hep_prot_M2PA = 0x0d,
_hep_prot_MOS_full_report_JSON = 0x22,
_hep_prot_MOS_short_report = 0x23,
_hep_prot_SIP_JSON = 0x32,
_hep_prot_DNS_JSON = 0x35,
_hep_prot_M3UA_ISUP_JSON = 0x36,
_hep_prot_RTSP = 0x37,
_hep_prot_DIAMETER = 0x38,
_hep_prot_GSM_MAP = 0x39,
_hep_prot_RTCP_PION = 0x3a,
_hep_prot_CDR = 0x3c
};
enum eHEP_VendorType {
_hep_vendor_FreeSWITCH = 1,
_hep_vendor_Kamailio = 2,
_hep_vendor_OpenSIPS = 3,
_hep_vendor_Asterisk = 4,
_hep_vendor_Homer = 5,
_hep_vendor_SipXecs = 6,
_hep_vendor_Yeti = 7,
_hep_vendor_Genesys = 8
};
enum eHEP_ChunkType {
_hep_chunk_ip_protocol_family = 0x01,
_hep_chunk_ip_protocol_id = 0x02,
_hep_chunk_ip_source_address_v4 = 0x03,
_hep_chunk_ip_destination_address_v4 = 0x04,
_hep_chunk_ip_source_address_v6 = 0x05,
_hep_chunk_ip_destination_address_v6 = 0x06,
_hep_chunk_protocol_source_port = 0x07,
_hep_chunk_protocol_destination_port = 0x08,
_hep_chunk_timestamp_seconds = 0x09,
_hep_chunk_timestamp_microseconds = 0x0a,
_hep_chunk_protocol_type = 0x0b,
_hep_chunk_capture_agent_id = 0x0c,
_hep_chunk_keep_alive_timer = 0x0d,
_hep_chunk_authenticate_key = 0x0e,
_hep_chunk_captured_packet_payload = 0x0f,
_hep_chunk_captured_packet_payload_compressed = 0x10,
_hep_chunk_internal_correlation_id = 0x11,
_hep_chunk_vlan_id = 0x12,
_hep_chunk_group_id = 0x13,
_hep_chunk_source_mac = 0x14,
_hep_chunk_destination_mac = 0x15,
_hep_chunk_ethernet_type = 0x16,
_hep_chunk_tcp_flag = 0x17,
_hep_chunk_ip_tos = 0x18,
_hep_chunk_mos_value = 0x20,
_hep_chunk_r_factor = 0x21,
_hep_chunk_geo_location = 0x22,
_hep_chunk_jitter = 0x23,
_hep_chunk_transaction_type = 0x24,
_hep_chunk_payload_json_keys = 0x25,
_hep_chunk_tags_values = 0x26,
_hep_chunk_tag_type = 0x27
};
struct sHEP_Data {
inline sHEP_Data() {
set_flags = 0;
}
string dump();
u_int64_t set_flags;
u_int8_t ip_protocol_family;
u_int8_t ip_protocol_id;
vmIP ip_source_address;
vmIP ip_destination_address;
vmPort protocol_source_port;
vmPort protocol_destination_port;
u_int32_t timestamp_seconds;
u_int32_t timestamp_microseconds;
u_int8_t protocol_type;
u_int32_t capture_agent_id;
u_int16_t keep_alive_timer;
SimpleBuffer authenticate_key;
SimpleBuffer captured_packet_payload;
//SimpleBuffer captured_compressed_payload;
SimpleBuffer internal_correlation_id;
u_int16_t vlan_id;
SimpleBuffer group_id;
u_int64_t source_mac;
u_int64_t destination_mac;
u_int16_t ethernet_type;
u_int8_t tcp_flag;
u_int8_t ip_tos;
u_int16_t mos_value;
u_int16_t r_factor;
SimpleBuffer geo_location;
u_int32_t jitter;
SimpleBuffer transaction_type;
SimpleBuffer payload_json_keys;
SimpleBuffer tags_values;
u_int16_t tag_type;
};
class cHEP_ProcessData {
public:
cHEP_ProcessData();
void processData(u_char *data, size_t dataLen);
protected:
bool isCompleteHep(u_char *data, size_t dataLen);
bool isBeginHep(u_char *data, size_t dataLen);
u_int16_t hepLength(u_char *data, size_t dataLen);
unsigned processHeps(u_char *data, size_t dataLen);
void processHep(u_char *data, size_t dataLen);
u_int16_t chunkVendor(u_char *data, size_t dataLen);
u_int16_t chunkType(u_char *data, size_t dataLen);
u_int16_t chunkLength(u_char *data, size_t dataLen);
void processChunks(u_char *data, size_t dataLen, sHEP_Data *hepData);
void processChunk(u_char *data, size_t dataLen, sHEP_Data *hepData);
public:
SimpleBuffer hep_buffer;
};
class cHEP_Server : public cServer, public cHEP_ProcessData {
public:
cHEP_Server(bool udp);
virtual ~cHEP_Server();
void createConnection(cSocket *socket);
void evData(u_char *data, size_t dataLen);
};
class cHEP_Connection : public cServerConnection, public cHEP_ProcessData {
public:
cHEP_Connection(cSocket *socket);
virtual ~cHEP_Connection();
void evData(u_char *data, size_t dataLen);
void connection_process();
};
void HEP_ServerStart(const char *host, int port, bool udp);
void HEP_ServerStop();
void HEP_client_emulation(const char *pcap, vmIP client_ip, vmIP server_ip, vmIP destination_ip, vmPort destination_port, bool udp);
#endif //HEP_H