#ifndef GLOBALFUNC_H #define GLOBALFUNC_H #include #include "pcaprethread.h" 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; } enum enum_rcvCardType{ enum_xixun_sync = 0, enum_xixun_async = 1, enum_zrf = 2, enum_mxe }; 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}; }; //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}; }; extern HeadMap headMap; extern HeadMap_ZRF headMap_zrf; extern byte *sepas; extern pcap *pcapSend; class PcapReThread; extern PcapReThread *reThd; extern QString gFileHome; QByteArray getNetDev(QWidget *parent, QByteArray, bool); inline int sendMsg(const byte *msg, int size, int id, qint64 timeout, std::function callback, WaitingDlg *waitingDlg = 0) { return reThd->sendMsgNet(msg, size, id, timeout, callback, waitingDlg); } inline int sendMsg(QByteArray &msg, int id, qint64 timeout, std::function callback, WaitingDlg *waitingDlg = 0) { return sendMsg((byte*)msg.data(), msg.size(), id, timeout, callback, waitingDlg); } int sendMsgSync(QByteArray &msg, int id, qint64 timeout, WaitingDlg *waitingDlg = 0); #endif // GLOBALFUNC_H