File indexing completed on 2024-04-21 04:00:15

0001 /*
0002     SPDX-FileCopyrightText: 2019 Jan Grulich <jgrulich@redhat.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef NETWORKMANAGERQT_WIREGUARD_DEVICE_H
0008 #define NETWORKMANAGERQT_WIREGUARD_DEVICE_H
0009 
0010 #include "device.h"
0011 #include <networkmanagerqt/networkmanagerqt_export.h>
0012 
0013 namespace NetworkManager
0014 {
0015 class WireGuardDevicePrivate;
0016 
0017 /**
0018  * A WireGuard device interface
0019  */
0020 class NETWORKMANAGERQT_EXPORT WireGuardDevice : public Device
0021 {
0022     Q_OBJECT
0023     Q_PROPERTY(QByteArray publicKey READ publicKey NOTIFY publicKeyChanged)
0024     Q_PROPERTY(uint listenPort READ listenPort NOTIFY listenPortChanged)
0025     Q_PROPERTY(uint fwMark READ fwMark NOTIFY fwMarkChanged)
0026 
0027 public:
0028     typedef QSharedPointer<WireGuardDevice> Ptr;
0029     typedef QList<Ptr> List;
0030     explicit WireGuardDevice(const QString &path, QObject *parent = nullptr);
0031     ~WireGuardDevice() override;
0032 
0033     Type type() const override;
0034 
0035     /**
0036      * 32-byte public WireGuard key.
0037      */
0038     QByteArray publicKey() const;
0039     /**
0040      * Local UDP listening port.
0041      */
0042     uint listenPort() const;
0043     /**
0044      * Optional 32-bit mark used to set routing policy for outgoing encrypted packets. See: ip-rule(8)
0045      */
0046     uint fwMark() const;
0047 
0048 Q_SIGNALS:
0049     /**
0050      * Emitted when the public key of this device has changed
0051      */
0052     void publicKeyChanged(const QByteArray &publicKey);
0053     /**
0054      * Emitted when the listen port of this device has changed
0055      */
0056     void listenPortChanged(uint listenPort);
0057     /**
0058      * Emitted when the fwmark of this device have changed
0059      */
0060     void fwMarkChanged(uint fwMark);
0061 
0062 private:
0063     Q_DECLARE_PRIVATE(WireGuardDevice)
0064 };
0065 
0066 }
0067 
0068 #endif