1/*
2 SPDX-FileCopyrightText: 2013 Lukáš Tinkl <ltinkl@redhat.com>
3 SPDX-FileCopyrightText: 2014 Jan Grulich <jgrulich@redhat.com>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8#ifndef NETWORKMANAGERQT_TUN_DEVICE_H
9#define NETWORKMANAGERQT_TUN_DEVICE_H
10
11#include "device.h"
12#include <networkmanagerqt/networkmanagerqt_export.h>
13
14namespace NetworkManager
15{
16class TunDevicePrivate;
17
18/*!
19 * \class NetworkManager::TunDevice
20 * \inheaderfile NetworkManagerQt/TunDevice
21 * \inmodule NetworkManagerQt
22 *
23 * \brief A tun device interface.
24 */
25class NETWORKMANAGERQT_EXPORT TunDevice : public Device
26{
27 Q_OBJECT
28
29 /*!
30 * \property NetworkManager::TunDevice::owner
31 */
32 Q_PROPERTY(qlonglong owner READ owner NOTIFY ownerChanged)
33
34 /*!
35 * \property NetworkManager::TunDevice::group
36 */
37 Q_PROPERTY(qlonglong group READ group NOTIFY groupChanged)
38
39 /*!
40 * \property NetworkManager::TunDevice::mode
41 */
42 Q_PROPERTY(QString mode READ mode NOTIFY modeChanged)
43
44 /*!
45 * \property NetworkManager::TunDevice::multiQueue
46 */
47 Q_PROPERTY(bool multiQueue READ multiQueue NOTIFY multiQueueChanged)
48
49 /*!
50 * \property NetworkManager::TunDevice::noPi
51 */
52 Q_PROPERTY(bool noPi READ noPi NOTIFY noPiChanged)
53
54 /*!
55 * \property NetworkManager::TunDevice::vnetHdr
56 */
57 Q_PROPERTY(bool vnetHdr READ vnetHdr NOTIFY vnetHdrChanged)
58
59 /*!
60 * \property NetworkManager::TunDevice::hwAddress
61 */
62 Q_PROPERTY(QString hwAddress READ hwAddress NOTIFY hwAddressChanged)
63
64public:
65 /*!
66 * \typedef NetworkManager::TunDevice::Ptr
67 */
68 typedef QSharedPointer<TunDevice> Ptr;
69 /*!
70 * \typedef NetworkManager::TunDevice::List
71 */
72 typedef QList<Ptr> List;
73 /*!
74 */
75 explicit TunDevice(const QString &path, QObject *parent = nullptr);
76 ~TunDevice() override;
77
78 Type type() const override;
79
80 /*!
81 * The uid of the tunnel owner, or -1 if it has no owner.
82 */
83 qlonglong owner() const;
84 /*!
85 * The gid of the tunnel group, or -1 if it has no owner.
86 */
87 qlonglong group() const;
88 /*!
89 * The tunnel mode, either "tun" or "tap".
90 */
91 QString mode() const;
92 /*!
93 * The tunnel's "TUN_TAP_MQ" flag; true if callers can connect to the tap device multiple times, for multiple send/receive queues.
94 */
95 bool multiQueue() const;
96 /*!
97 * The tunnel's "TUN_NO_PI" flag; true if no protocol info is prepended to the tunnel packets.
98 */
99 bool noPi() const;
100 /*!
101 * The tunnel's "TUN_VNET_HDR" flag; true if the tunnel packets include a virtio network header.
102 */
103 bool vnetHdr() const;
104 /*!
105 * Hardware address of the device.
106 */
107 QString hwAddress() const;
108
109Q_SIGNALS:
110 /*!
111 * Emitted when the uid of the tunnel owner has changed
112 */
113 void ownerChanged(qlonglong owner);
114 /*!
115 * Emitted when the gid of the tunnel group has changed
116 */
117 void groupChanged(qlonglong group);
118 /*!
119 * Emitted when the tunnel mode has changed
120 */
121 void modeChanged(const QString &mode);
122 /*!
123 * Emitted when the tunnel's "TUN_TAP_MQ" flag has changed
124 */
125 void multiQueueChanged(bool multiQueue);
126 /*!
127 * Emitted when the tunnel's "TUN_NO_PI" flag has changed
128 */
129 void noPiChanged(bool noPi);
130 /*!
131 * Emitted when the tunnel's "TUN_VNET_HDR" flag has changed
132 */
133 void vnetHdrChanged(bool vnetHdr);
134 /*!
135 * Emitted when the hardware address of the device has changed
136 */
137 void hwAddressChanged(const QString &hwAddress);
138
139private:
140 Q_DECLARE_PRIVATE(TunDevice)
141};
142
143}
144
145#endif
146

source code of networkmanager-qt/src/tundevice.h