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 * A tun device interface
20 */
21class NETWORKMANAGERQT_EXPORT TunDevice : public Device
22{
23 Q_OBJECT
24 Q_PROPERTY(qlonglong owner READ owner NOTIFY ownerChanged)
25 Q_PROPERTY(qlonglong group READ group NOTIFY groupChanged)
26 Q_PROPERTY(QString mode READ mode NOTIFY modeChanged)
27 Q_PROPERTY(bool multiQueue READ multiQueue NOTIFY multiQueueChanged)
28 Q_PROPERTY(bool noPi READ noPi NOTIFY noPiChanged)
29 Q_PROPERTY(bool vnetHdr READ vnetHdr NOTIFY vnetHdrChanged)
30 Q_PROPERTY(QString hwAddress READ hwAddress NOTIFY hwAddressChanged)
31
32public:
33 typedef QSharedPointer<TunDevice> Ptr;
34 typedef QList<Ptr> List;
35 explicit TunDevice(const QString &path, QObject *parent = nullptr);
36 ~TunDevice() override;
37
38 Type type() const override;
39
40 /**
41 * The uid of the tunnel owner, or -1 if it has no owner.
42 */
43 qlonglong owner() const;
44 /**
45 * The gid of the tunnel group, or -1 if it has no owner.
46 */
47 qlonglong group() const;
48 /**
49 * The tunnel mode, either "tun" or "tap".
50 */
51 QString mode() const;
52 /**
53 * The tunnel's "TUN_TAP_MQ" flag; true if callers can connect to the tap device multiple times, for multiple send/receive queues.
54 */
55 bool multiQueue() const;
56 /**
57 * The tunnel's "TUN_NO_PI" flag; true if no protocol info is prepended to the tunnel packets.
58 */
59 bool noPi() const;
60 /**
61 * The tunnel's "TUN_VNET_HDR" flag; true if the tunnel packets include a virtio network header.
62 */
63 bool vnetHdr() const;
64 /**
65 * Hardware address of the device.
66 */
67 QString hwAddress() const;
68
69Q_SIGNALS:
70 /**
71 * Emitted when the uid of the tunnel owner has changed
72 */
73 void ownerChanged(qlonglong owner);
74 /**
75 * Emitted when the gid of the tunnel group has changed
76 */
77 void groupChanged(qlonglong group);
78 /**
79 * Emitted when the tunnel mode has changed
80 */
81 void modeChanged(const QString &mode);
82 /**
83 * Emitted when the tunnel's "TUN_TAP_MQ" flag has changed
84 */
85 void multiQueueChanged(bool multiQueue);
86 /**
87 * Emitted when the tunnel's "TUN_NO_PI" flag has changed
88 */
89 void noPiChanged(bool noPi);
90 /**
91 * Emitted when the tunnel's "TUN_VNET_HDR" flag has changed
92 */
93 void vnetHdrChanged(bool vnetHdr);
94 /**
95 * Emitted when the hardware address of the device has changed
96 */
97 void hwAddressChanged(const QString &hwAddress);
98
99private:
100 Q_DECLARE_PRIVATE(TunDevice)
101};
102
103}
104
105#endif
106

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