This repository has been archived by the owner on Sep 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcapture.h
68 lines (57 loc) · 1.69 KB
/
capture.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
#ifndef CAPTURE_H
#define CAPTURE_H
#include <QWidget>
#include <sys/socket.h>
#include <net/ethernet.h>
#include <netinet/if_ether.h>
#include <cerrno>
#include <cstring>
#include <QMessageBox>
#include <QTimer>
#include <QListWidgetItem>
#include <QVariant>
#include <string>
#include "CNetworkSniffer.h"
namespace Ui {
class Capture;
}
class Capture : public QWidget
{
Q_OBJECT
public:
explicit Capture(QWidget *parent = 0);
~Capture();
bool connectToRawSocket();
const std::vector<CEthenetFrame *> &getCapturedFrames() const;
void addPacketToList(unsigned char *buffer, ssize_t total_len);
private slots:
void captureEverything();
void onListItemClicked(QListWidgetItem *item);
void on_stopCapture_clicked();
void on_filterPushButton_clicked();
private:
std::string generateListItemText(CEthenetFrame *, ssize_t);
std::string bufferToStringPrettyfier(const void *object, ssize_t max_len);
bool keepPacket(CEthenetFrame *frame);
void addToStats(CEthenetFrame *frame) ;
const unsigned int MAX_PACKET_LEN = 65536;
Ui::Capture *ui;
int sock_raw = -1;
unsigned char *buffer = new unsigned char[MAX_PACKET_LEN];
struct sockaddr saddr;
socklen_t sockaddr_size = sizeof(saddr);
std::vector<CEthenetFrame *> ethernetFrameVector;
C_NetworkSniffer sniffer;
QMessageBox messageBox;
QTimer *timer = new QTimer(this);
unsigned int ipv4Stats = 0;
unsigned int ipv6Stats = 0;
unsigned int DNSStats = 0;
unsigned int HTTPStats = 0;
unsigned int TCPStats = 0;
unsigned int UDPStats = 0;
unsigned int ICMPv4Stats = 0;
unsigned int unknownStats = 0;
unsigned int ARPStats = 0;
};
#endif // CAPTURE_H