38 lines
665 B
C
38 lines
665 B
C
|
#ifndef PCAPTHREAD_H
|
||
|
#define PCAPTHREAD_H
|
||
|
|
||
|
#include <QThread>
|
||
|
#include <winsock2.h>
|
||
|
#include "pcap.h"
|
||
|
#include <QVector>
|
||
|
|
||
|
#pragma comment(lib, "wpcap.lib")
|
||
|
#pragma comment(lib, "Ws2_32.lib")
|
||
|
|
||
|
#define LINE_LEN 16
|
||
|
#define MAX_ADDR_LEN 16
|
||
|
|
||
|
struct Packet {
|
||
|
QString time;
|
||
|
u_int len;
|
||
|
u_int caplen;
|
||
|
QString data;
|
||
|
};
|
||
|
|
||
|
class CapThread : public QThread {
|
||
|
Q_OBJECT
|
||
|
public:
|
||
|
explicit CapThread(pcap *pcap, QObject *parent = nullptr);
|
||
|
void setPacketList(QList<Packet> *p){p->clear();packet_list=p;}
|
||
|
pcap *pcap{0};
|
||
|
QList<Packet> *packet_list;
|
||
|
Packet packet;
|
||
|
protected:
|
||
|
void run();
|
||
|
|
||
|
signals:
|
||
|
void onMsg();
|
||
|
};
|
||
|
|
||
|
#endif // PCAPTHREAD_H
|