2023-03-20 11:30:19 +08:00
|
|
|
#ifndef PCAPRETHREAD_H
|
|
|
|
#define PCAPRETHREAD_H
|
|
|
|
|
2023-06-06 12:13:33 +08:00
|
|
|
#include "waitingdlg.h"
|
2023-03-20 11:30:19 +08:00
|
|
|
#include "pcap.h"
|
2023-06-06 12:13:33 +08:00
|
|
|
#include <QThread>
|
|
|
|
|
|
|
|
typedef std::function<void(int, const QByteArray)> FuncIntByte;
|
2023-06-13 18:00:19 +08:00
|
|
|
#define LineLen 16
|
2023-03-20 11:30:19 +08:00
|
|
|
|
2023-06-06 12:13:33 +08:00
|
|
|
struct PcapResp {
|
|
|
|
FuncIntByte callback;
|
2023-03-20 11:30:19 +08:00
|
|
|
int id;
|
2023-05-27 17:43:57 +08:00
|
|
|
qint64 timeout;
|
2023-06-06 12:13:33 +08:00
|
|
|
bool notCancelled{true};
|
2023-03-20 11:30:19 +08:00
|
|
|
};
|
|
|
|
class PcapReThread : public QThread {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit PcapReThread(pcap *pcap);
|
2023-06-06 12:13:33 +08:00
|
|
|
~PcapReThread();
|
|
|
|
|
|
|
|
int sendMsgNet(const byte *msg, int size, int id, qint64 timeout, FuncIntByte callback, WaitingDlg *waitingDlg = 0);
|
|
|
|
QList<PcapResp*> resps;
|
2023-03-20 11:30:19 +08:00
|
|
|
std::mutex mtx;
|
|
|
|
pcap *pcap;
|
2023-06-13 18:00:19 +08:00
|
|
|
std::atomic<char> status{0};
|
2023-07-28 14:48:41 +08:00
|
|
|
QByteArray intro{"\x55\x55"};
|
2023-06-13 18:00:19 +08:00
|
|
|
char fmt{0};
|
2023-03-20 11:30:19 +08:00
|
|
|
signals:
|
2023-06-13 18:00:19 +08:00
|
|
|
void onCallback(FuncIntByte callback, int code, const QByteArray data);
|
|
|
|
void onMsg(const QString &);
|
2023-03-20 11:30:19 +08:00
|
|
|
void onError(char *);
|
|
|
|
protected:
|
|
|
|
void run();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PCAPRETHREAD_H
|