Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
Arp.h
1// Author: Kang Lin <kl222@126.com>
2
3#ifndef __ARP_H_KL_2024_11_10__
4#define __ARP_H_KL_2024_11_10__
5
6#pragma once
7
8#include <QObject>
9#include <QTime>
10#include <QTimer>
11#include <QMap>
12
13#ifdef HAVE_PCAPPLUSPLUS
14 #include <PcapLiveDevice.h>
15#endif
16
17#include "WakeOnLanQt.h"
18#include "ParameterWakeOnLan.h"
19
20class CArp : public QObject
21{
22 Q_OBJECT
23public:
24 explicit CArp(QObject *parent = nullptr);
25 virtual ~CArp();
26
27 int WakeOnLan(QSharedPointer<CParameterWakeOnLan> para);
28
29#ifdef HAVE_PCAPPLUSPLUS
30 class ArpRequest
31 {
32 public:
33 ArpRequest(QSharedPointer<CParameterWakeOnLan> p) {
34 para = p;
35 if(!para) return;
36 nRepeat = p->GetRepeat();
37 nTimeout = p->GetTimeOut();
38 tmRepeat = QTime::currentTime();
39 bWakeOnLan = false;
40 tmStart = QTime::currentTime();
41 }
42 QSharedPointer<CParameterWakeOnLan> para;
43 QTime tmRepeat;
44 int nRepeat;
45 int nTimeout;
46 bool bWakeOnLan;
47 QTime tmStart;
48 };
49 QMutex m_Mutex;
50 QMap<std::string, QSharedPointer<ArpRequest> > m_Para;
51private:
52 void ListInterfaces();
53 int StopCapture();
54 int SendArpPackage(pcpp::PcapLiveDevice* device,
55 std::string szSourceIp, std::string szTargetIp);
56#endif
57
58public:
59 int GetMac(QSharedPointer<CParameterWakeOnLan> para
60#ifdef HAVE_PCAPPLUSPLUS
61 ,QSharedPointer<ArpRequest> ar = QSharedPointer<ArpRequest>()
62#endif
63 );
64
65private Q_SLOTS:
66 void slotProcess();
67
68private:
69 CWakeOnLanQt m_Wol;
70
71 QTimer m_Timer;
72};
73
74#endif // __ARP_H_KL_2024_11_10__
Definition Arp.h:21