2022-12-16 15:08:53 +08:00
|
|
|
#ifndef GLOBALFUNC_H
|
|
|
|
#define GLOBALFUNC_H
|
|
|
|
|
2023-05-27 17:43:57 +08:00
|
|
|
#include <QtEndian>
|
2023-03-20 12:11:58 +08:00
|
|
|
#include "pcaprethread.h"
|
|
|
|
|
2023-05-27 17:43:57 +08:00
|
|
|
struct Head {
|
|
|
|
byte pre[2]{0x55, 0x55};
|
|
|
|
byte ver{1};
|
|
|
|
byte srv{0};
|
|
|
|
quint16_be len{0};
|
|
|
|
byte tgtAddr[4]{0xff, 0xff, 0xff, 0xff};
|
|
|
|
byte srcAddr[4]{0, 0, 0, 0};
|
|
|
|
byte ptr[4]{0, 0, 0, 0};
|
|
|
|
byte ans[2]{0, 0};
|
|
|
|
quint32_be chk{0};
|
|
|
|
byte bodyh[4]{0, 0, 0, 0};
|
|
|
|
quint16_be bodylen{0};
|
|
|
|
};
|
|
|
|
struct Msg1024 : Head {
|
|
|
|
byte body[1024-sizeof(Head)]{0};
|
|
|
|
};
|
|
|
|
static byte fi = 0;
|
|
|
|
inline byte ie(byte size = 1) {
|
|
|
|
fi = size;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
inline byte ipp(byte size = 1) {
|
|
|
|
auto rtn = fi;
|
|
|
|
fi += size;
|
|
|
|
return rtn;
|
|
|
|
}
|
2023-08-24 16:55:38 +08:00
|
|
|
enum enum_rcvCardType{
|
|
|
|
enum_xixun_sync = 0,
|
|
|
|
enum_xixun_async = 1,
|
|
|
|
enum_zrf = 2,
|
|
|
|
enum_mxe
|
|
|
|
};
|
2023-05-27 17:43:57 +08:00
|
|
|
struct HeadMap {
|
|
|
|
byte pre{ipp(2)};
|
|
|
|
byte ver{fi++};
|
|
|
|
byte srv{fi++};
|
|
|
|
byte len{ipp(2)};
|
|
|
|
byte tgtAddr{ipp(4)};
|
|
|
|
byte srcAddr{ipp(4)};
|
|
|
|
byte ptr{ipp(4)};
|
|
|
|
byte ans{ipp(2)};
|
|
|
|
byte chk{ipp(4)};
|
|
|
|
byte body{ipp(4)};
|
|
|
|
byte bodylen{ipp(2)};
|
|
|
|
byte end{fi};
|
|
|
|
};
|
2023-08-24 16:55:38 +08:00
|
|
|
//added by alahover -s 20230822
|
|
|
|
struct HeadMap_ZRF {
|
|
|
|
byte pre{ie(2)};
|
|
|
|
byte tgtAddr{ipp(6)};
|
|
|
|
byte srcAddr{ipp(6)};
|
|
|
|
byte protcolFlag{ipp(2)};
|
|
|
|
byte pkgType{fi++};
|
|
|
|
byte reserve{fi++};
|
|
|
|
byte netPort{ipp(4)};
|
|
|
|
byte rcvIndex{ipp(2)};
|
|
|
|
byte end{fi};
|
|
|
|
};
|
2023-06-06 12:13:33 +08:00
|
|
|
|
2023-05-27 17:43:57 +08:00
|
|
|
extern HeadMap headMap;
|
2023-08-24 16:55:38 +08:00
|
|
|
extern HeadMap_ZRF headMap_zrf;
|
2023-06-13 18:00:19 +08:00
|
|
|
extern byte *sepas;
|
2023-06-06 12:13:33 +08:00
|
|
|
extern pcap *pcapSend;
|
|
|
|
class PcapReThread;
|
2023-03-20 12:11:58 +08:00
|
|
|
extern PcapReThread *reThd;
|
2023-07-28 14:48:41 +08:00
|
|
|
extern QString gFileHome;
|
2023-03-20 12:11:58 +08:00
|
|
|
|
2023-03-24 18:41:48 +08:00
|
|
|
QByteArray getNetDev(QWidget *parent, QByteArray, bool);
|
2022-12-16 15:08:53 +08:00
|
|
|
|
2023-06-06 12:13:33 +08:00
|
|
|
inline int sendMsg(const byte *msg, int size, int id, qint64 timeout, std::function<void(int code, const QByteArray)> callback, WaitingDlg *waitingDlg = 0) {
|
|
|
|
return reThd->sendMsgNet(msg, size, id, timeout, callback, waitingDlg);
|
2023-05-27 17:43:57 +08:00
|
|
|
}
|
2023-06-06 12:13:33 +08:00
|
|
|
inline int sendMsg(QByteArray &msg, int id, qint64 timeout, std::function<void(int code, const QByteArray)> callback, WaitingDlg *waitingDlg = 0) {
|
|
|
|
return sendMsg((byte*)msg.data(), msg.size(), id, timeout, callback, waitingDlg);
|
2023-05-27 17:43:57 +08:00
|
|
|
}
|
2023-06-07 19:11:03 +08:00
|
|
|
int sendMsgSync(QByteArray &msg, int id, qint64 timeout, WaitingDlg *waitingDlg = 0);
|
2022-12-16 15:08:53 +08:00
|
|
|
#endif // GLOBALFUNC_H
|