DtkDevice
DTK library for device.
dnetdevice.h
1// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4#ifndef DNETDEVICE_H
5#define DNETDEVICE_H
6
7#include "dtkdevice_global.h"
8
9#include <QObject>
10
11DDEVICE_BEGIN_NAMESPACE
12
13class DNetDevicePrivate;
14class LIBDTKDEVICESHARED_EXPORT DNetDevice : public QObject
15{
16public:
17 struct DInetAddr4 {
18 int family {0};
19 QByteArray addr;
20 QByteArray mask;
21 QByteArray bcast;
22 };
23
24 struct DInetAddr6 {
25 int family {0};
26 QByteArray addr;
27 int prefixlen {0};
28 int scope {0};
29 };
30
31 struct DNetifInfo {
32 quint64 rxPackets {0}; // total packets received
33 quint64 rxBytes {0}; // total bytes received
34 quint64 rxErrors {0}; // bad packets received
35 quint64 rxDropped {0}; // no space in linux buffers
36 quint64 rxFifo {0}; // FIFO overruns
37 quint64 rxFrame {0}; // frame alignment error
38 quint64 txPackets {0}; // total packets transmitted
39 quint64 txBytes {0}; // total bytes transmitted
40 quint64 txErrors {0}; // packet transmit problems
41 quint64 txDropped {0}; // no space available in linux
42 quint64 txFifo {0}; // FIFO overruns
43 quint64 txCarrier {0}; // loss of link pulse
44 };
45
46 explicit DNetDevice(QObject *parent = nullptr);
48
49 int count();
50 QString name(int index);
51 QString vendor(int index);
52 QString model(int index);
53 QString type(int index);
54 QString macAddress(int index);
55 QString driver(int index);
56 QString speed(int index);
57
58 QString status(int index);
62 QString portStatus(int index, int port);
63 QList<int> applicationPorts(int pid);
64
65private:
66 QScopedPointer<DNetDevicePrivate> d_ptr;
67 Q_DECLARE_PRIVATE(DNetDevice)
68};
69
70DDEVICE_END_NAMESPACE
71
72#endif // DNETDEVICE_H
网卡设备信息.
Definition: dnetdevice.h:15
QString type(int index)
获取指定网卡的类型.
QString macAddress(int index)
获取指定网卡的MAC地址.
DInetAddr6 inetAddr6(int index)
获取指定网卡的IP6信息.
QList< int > applicationPorts(int pid)
获取指定应用的端口信息.
DInetAddr4 inetAddr4(int index)
获取指定网卡的IP4信息.
QString driver(int index)
获取指定网卡的驱动.
QString model(int index)
获取指定网卡的型号.
QString status(int index)
获取指定网卡的连接状态.
QString vendor(int index)
获取指定网卡的厂商.
DNetifInfo netifInfo(int index)
获取指定网卡的网络信息.
QString speed(int index)
获取指定网卡的速度.
QString portStatus(int index, int port)
获取指定网卡的端口状态.
int count()
获取所有网卡个数.
IPv4信息
Definition: dnetdevice.h:17
QByteArray bcast
Definition: dnetdevice.h:21
QByteArray addr
Definition: dnetdevice.h:19
QByteArray mask
Definition: dnetdevice.h:20
IPv6信息
Definition: dnetdevice.h:24
QByteArray addr
Definition: dnetdevice.h:26
网络状态信息
Definition: dnetdevice.h:31