File indexing completed on 2025-03-23 12:49:53
0001 /* 0002 SPDX-FileCopyrightText: 2013 Lukáš Tinkl <ltinkl@redhat.com> 0003 SPDX-FileCopyrightText: 2014 Jan Grulich <jgrulich@redhat.com> 0004 0005 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 0008 #ifndef NETWORKMANAGERQT_TUN_DEVICE_H 0009 #define NETWORKMANAGERQT_TUN_DEVICE_H 0010 0011 #include "device.h" 0012 #include <networkmanagerqt/networkmanagerqt_export.h> 0013 0014 namespace NetworkManager 0015 { 0016 class TunDevicePrivate; 0017 0018 /** 0019 * A tun device interface 0020 */ 0021 class NETWORKMANAGERQT_EXPORT TunDevice : public Device 0022 { 0023 Q_OBJECT 0024 Q_PROPERTY(qlonglong owner READ owner NOTIFY ownerChanged) 0025 Q_PROPERTY(qlonglong group READ group NOTIFY groupChanged) 0026 Q_PROPERTY(QString mode READ mode NOTIFY modeChanged) 0027 Q_PROPERTY(bool multiQueue READ multiQueue NOTIFY multiQueueChanged) 0028 Q_PROPERTY(bool noPi READ noPi NOTIFY noPiChanged) 0029 Q_PROPERTY(bool vnetHdr READ vnetHdr NOTIFY vnetHdrChanged) 0030 Q_PROPERTY(QString hwAddress READ hwAddress NOTIFY hwAddressChanged) 0031 0032 public: 0033 typedef QSharedPointer<TunDevice> Ptr; 0034 typedef QList<Ptr> List; 0035 explicit TunDevice(const QString &path, QObject *parent = nullptr); 0036 ~TunDevice() override; 0037 0038 Type type() const override; 0039 0040 /** 0041 * The uid of the tunnel owner, or -1 if it has no owner. 0042 */ 0043 qlonglong owner() const; 0044 /** 0045 * The gid of the tunnel group, or -1 if it has no owner. 0046 */ 0047 qlonglong group() const; 0048 /** 0049 * The tunnel mode, either "tun" or "tap". 0050 */ 0051 QString mode() const; 0052 /** 0053 * The tunnel's "TUN_TAP_MQ" flag; true if callers can connect to the tap device multiple times, for multiple send/receive queues. 0054 */ 0055 bool multiQueue() const; 0056 /** 0057 * The tunnel's "TUN_NO_PI" flag; true if no protocol info is prepended to the tunnel packets. 0058 */ 0059 bool noPi() const; 0060 /** 0061 * The tunnel's "TUN_VNET_HDR" flag; true if the tunnel packets include a virtio network header. 0062 */ 0063 bool vnetHdr() const; 0064 /** 0065 * Hardware address of the device. 0066 */ 0067 QString hwAddress() const; 0068 0069 Q_SIGNALS: 0070 /** 0071 * Emitted when the uid of the tunnel owner has changed 0072 */ 0073 void ownerChanged(qlonglong owner); 0074 /** 0075 * Emitted when the gid of the tunnel group has changed 0076 */ 0077 void groupChanged(qlonglong group); 0078 /** 0079 * Emitted when the tunnel mode has changed 0080 */ 0081 void modeChanged(const QString &mode); 0082 /** 0083 * Emitted when the tunnel's "TUN_TAP_MQ" flag has changed 0084 */ 0085 void multiQueueChanged(bool multiQueue); 0086 /** 0087 * Emitted when the tunnel's "TUN_NO_PI" flag has changed 0088 */ 0089 void noPiChanged(bool noPi); 0090 /** 0091 * Emitted when the tunnel's "TUN_VNET_HDR" flag has changed 0092 */ 0093 void vnetHdrChanged(bool vnetHdr); 0094 /** 0095 * Emitted when the hardware address of the device has changed 0096 */ 0097 void hwAddressChanged(const QString &hwAddress); 0098 0099 private: 0100 Q_DECLARE_PRIVATE(TunDevice) 0101 }; 0102 0103 } 0104 0105 #endif