qt/ledset/pcapwin.h

43 lines
764 B
C
Raw Normal View History

2022-08-25 18:43:03 +08:00
#ifndef PCAPWIN_H
#define PCAPWIN_H
#include "basewin.h"
#define HAVE_REMOTE
2022-12-16 16:16:12 +08:00
#include <winsock2.h>
#include "pcap.h"
#include <QThread>
#define LINE_LEN 16
2022-08-25 18:43:03 +08:00
class PcapThread : public QThread {
Q_OBJECT
public:
explicit PcapThread(pcap *pcap);
~PcapThread() {
2022-12-16 16:16:12 +08:00
pcap_close(pcap);
2022-08-25 18:43:03 +08:00
}
pcap *pcap;
std::atomic<char> status{0};
protected:
void run();
signals:
void onMsg(const QString &);
void onError(char *);
};
class PcapWin : public BaseWin {
Q_OBJECT
public:
2022-12-16 16:16:12 +08:00
static PcapWin *newIns(QByteArray &, QWidget *);
2022-08-25 18:43:03 +08:00
explicit PcapWin(pcap *, pcap *, QWidget *parent = nullptr);
~PcapWin() {
2022-12-16 16:16:12 +08:00
pcap_close(pcap);
2022-08-25 18:43:03 +08:00
thd->status = 2;
}
PcapThread *thd{0};
pcap *pcap;
};
#endif // PCAPWIN_H