-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPacket.h
53 lines (48 loc) · 1.13 KB
/
Packet.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
#pragma once
#include "Global.h"
#include "StreamPool.h"
#include "ProtoHeader.h"
typedef struct FrameMsg
{
u_short num; // start from 1
QDateTime time;
QString src_addr;
QString des_addr;
int src_port;
int des_port;
QString protocol;
u_int length; // byte
QString info;
u_int stream_index;
}FrameMsg;
typedef struct ProtoMsg
{
QString name;
QString desc;
int value; // default value is -1
u_int offset; // bit
u_int length; // bit
QVector<ProtoMsg*> children;
}MsgItem;
class Packet
{
public:
u_char* pkt_data;
FrameMsg frame;
QVector<ProtoMsg*> protos;
StreamPool* streams;
Packet();
Packet(const struct pcap_pkthdr* header, const u_char* pkt_data, const u_short& num, StreamPool* ss);
~Packet();
void clearProtos(ProtoMsg*);
private:
void (Packet::* decodeUpper)(const u_char*);
void decodeEthernet(const u_char* payload);
void decodeIPv4(const u_char* payload);
void decodeIPv6(const u_char* payload);
void decodeARP(const u_char* payload);
void decodeTCP(const u_char* payload);
void decodeUDP(const u_char* payload);
void decodeICMP(const u_char* payload);
void decodeTLS_Record(const u_char* payload);
};