forked from linuxdeepin/dde-network-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipconfilctchecker.h
86 lines (67 loc) · 2.08 KB
/
ipconfilctchecker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#ifndef IPCONFILCTCHECKER_H
#define IPCONFILCTCHECKER_H
#include <QObject>
#include "netutils.h"
#include "networkconst.h"
class QThread;
namespace dde {
namespace network {
class NetworkDeviceBase;
class NetworkProcesser;
class DeviceIPChecker;
class NetworkDBusProxy;
class IPConfilctChecker : public QObject
{
Q_OBJECT
Q_SIGNALS:
void conflictStatusChanged(NetworkDeviceBase *, const bool);
public:
explicit IPConfilctChecker(NetworkProcesser *networkProcesser, const bool ipChecked, QObject *parent = nullptr);
~IPConfilctChecker();
void release();
private Q_SLOT:
void onDeviceAdded(QList<NetworkDeviceBase *> devices);
void onIPConfilct(const QString &ip, const QString &macAddress);
void onSenderIPInfo(const QStringList &ips);
private:
void handlerIpConflict(const QString &ip, const QString &macAddress, const QString &activeConnectionInfo);
QMap<QString, NetworkDeviceBase *> parseDeviceIp(const QString &activeConnectionInfo);
void clearUnExistDevice();
private:
NetworkDBusProxy *m_networkInter;
NetworkProcesser *m_networkProcesser;
QList<DeviceIPChecker *> m_deviceCheckers;
bool m_ipNeedCheck;
QThread *m_thread;
};
class DeviceIPChecker : public QObject
{
Q_OBJECT
Q_SIGNALS:
void conflictStatusChanged(NetworkDeviceBase *, const bool);
void ipConflictCheck(const QStringList &);
public:
explicit DeviceIPChecker(NetworkDeviceBase *device, NetworkDBusProxy *netInter, QObject *parent);
~DeviceIPChecker();
NetworkDeviceBase *device();
void setDeviceInfo(const QStringList &ipv4, const QString &macAddress);
void handlerIpConflict();
QStringList ipV4();
bool ipConflicted();
private:
NetworkDeviceBase *m_device;
NetworkDBusProxy *m_networkInter;
QStringList m_ipV4;
QString m_macAddress;
int m_conflictCount;
int m_clearCount;
int m_count;
bool m_ipConflicted;
QList<QStringList> m_changeIpv4s;
};
}
}
#endif // IPCONFILCTCHECKER_H