Index: autotests/settings/CMakeLists.txt =================================================================== --- autotests/settings/CMakeLists.txt +++ autotests/settings/CMakeLists.txt @@ -15,6 +15,7 @@ connectionsettingtest gsmsettingtest infinibandsettingtest + iptunnelsettingtest ipv4settingtest ipv6settingtest olpcmeshsettingtest Index: autotests/settings/iptunnelsettingtest.h =================================================================== --- /dev/null +++ autotests/settings/iptunnelsettingtest.h @@ -0,0 +1,36 @@ +/* + Copyright Pranav Gade + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . +*/ + +#ifndef NETWORKMANAGERQT_IP_TUNNEL_SETTING_TEST_H +#define NETWORKMANAGERQT_IP_TUNNEL_SETTING_TEST_H + +#include + +class IpTunnelSettingTest : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void testSetting_data(); + void testSetting(); +}; + +#endif // NETWORKMANAGERQT_IP_TUNNEL_SETTING_TEST_H + Index: autotests/settings/iptunnelsettingtest.cpp =================================================================== --- /dev/null +++ autotests/settings/iptunnelsettingtest.cpp @@ -0,0 +1,106 @@ +/* + Copyright 2018 Pranav Gade + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . +*/ + +#include "iptunnelsettingtest.h" + +#include "settings/iptunnelsetting.h" + +#include + +#include + +void IpTunnelSettingTest::testSetting_data() +{ + QTest::addColumn("mode"); + QTest::addColumn("pathMtuDiscovery"); + QTest::addColumn("encapsulationLimit"); + QTest::addColumn("flags"); + QTest::addColumn("flowLabel"); + QTest::addColumn("mtu"); + QTest::addColumn("tos"); + QTest::addColumn("ttl"); + QTest::addColumn("inputKey"); + QTest::addColumn("local"); + QTest::addColumn("parent"); + QTest::addColumn("outputKey"); + QTest::addColumn("remote"); + + QTest::newRow("setting1") + << (quint32)2 // mode + << false // pathMtuDiscovery + << (quint32)1 // encapsulationLimit + << (quint32)0x02 // flags + << (quint32)1 // flowLabel + << (quint32)1 // mtu + << (quint32)1 // tos + << (quint32)1 // ttl + << QString("key") // inputKey + << QString("abc") // local + << QString("par") // parent + << QString("out") // outputKey + << QString("rem"); // remote +} + +void IpTunnelSettingTest::testSetting() +{ + QFETCH(quint32, mode); + QFETCH(bool, pathMtuDiscovery); + QFETCH(quint32, encapsulationLimit); + QFETCH(quint32, flags); + QFETCH(quint32, flowLabel); + QFETCH(quint32, mtu); + QFETCH(quint32, tos); + QFETCH(quint32, ttl); + QFETCH(QString, inputKey); + QFETCH(QString, local); + QFETCH(QString, parent); + QFETCH(QString, outputKey); + QFETCH(QString, remote); + + QVariantMap map; + + map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_MODE), mode); + map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY), pathMtuDiscovery); + map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT), encapsulationLimit); + map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_FLAGS), flags); + map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_FLOW_LABEL), flowLabel); + map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_MTU), mtu); + map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_TOS), tos); + map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_TTL), ttl); + map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_INPUT_KEY), inputKey); + map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_LOCAL), local); + map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_PARENT), parent); + map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_OUTPUT_KEY), outputKey); + map.insert(QLatin1String(NM_SETTING_IP_TUNNEL_REMOTE), remote); + + NetworkManager::IpTunnelSetting setting; + setting.fromMap(map); + + QVariantMap map1 = setting.toMap(); + + // Will fail if set some default values, because they are skipped in toMap() method + QVariantMap::const_iterator it = map.constBegin(); + while (it != map.constEnd()) { + QCOMPARE(it.value(), map1.value(it.key())); + ++it; + } +} + +QTEST_MAIN(IpTunnelSettingTest) \ No newline at end of file Index: src/CMakeLists.txt =================================================================== --- src/CMakeLists.txt +++ src/CMakeLists.txt @@ -59,6 +59,7 @@ settings/cdmasetting.cpp settings/connectionsettings.cpp settings/gsmsetting.cpp + settings/iptunnelsetting.cpp settings/ipv4setting.cpp settings/ipv6setting.cpp settings/infinibandsetting.cpp @@ -209,6 +210,7 @@ GsmSetting GenericSetting InfinibandSetting + IpTunnelSetting Ipv4Setting Ipv6Setting OlpcMeshSetting Index: src/settings/connectionsettings.h =================================================================== --- src/settings/connectionsettings.h +++ src/settings/connectionsettings.h @@ -65,7 +65,8 @@ Wireless, Team, Generic, - Tun + Tun, + IpTunnel }; enum AutoconnectSlaves { Index: src/settings/connectionsettings.cpp =================================================================== --- src/settings/connectionsettings.cpp +++ src/settings/connectionsettings.cpp @@ -35,6 +35,7 @@ #include "gsmsetting.h" #include "cdmasetting.h" #include "infinibandsetting.h" +#include "iptunnelsetting.h" #include "ipv4setting.h" #include "ipv6setting.h" #include "pppsetting.h" @@ -192,6 +193,11 @@ addSetting(Setting::Ptr(new Ipv4Setting())); addSetting(Setting::Ptr(new Ipv6Setting())); break; + case ConnectionSettings::IpTunnel: + addSetting(Setting::Ptr(new Ipv4Setting())); + addSetting(Setting::Ptr(new Ipv6Setting())); + addSetting(Setting::Ptr(new IpTunnelSetting())); + break; case ConnectionSettings::Unknown: default: break; @@ -308,6 +314,10 @@ addSetting(connectionSettings->setting(Setting::Ipv4)); addSetting(connectionSettings->setting(Setting::Ipv6)); break; + case ConnectionSettings::IpTunnel: + addSetting(connectionSettings->setting(Setting::Ipv4)); + addSetting(connectionSettings->setting(Setting::Ipv6)); + addSetting(connectionSettings->setting(Setting::IpTunnel)); case ConnectionSettings::Unknown: default: break; @@ -352,6 +362,8 @@ type = Generic; } else if (typeString == QLatin1String(NM_SETTING_TUN_SETTING_NAME)) { type = Tun; + } else if (typeString == QLatin1String(NM_SETTING_IP_TUNNEL_SETTING_NAME)) { + type = IpTunnel; } return type; @@ -413,6 +425,9 @@ case Tun: typeString = QLatin1String(NM_SETTING_TUN_SETTING_NAME); break; + case IpTunnel: + typeString = QLatin1String(NM_SETTING_IP_TUNNEL_SETTING_NAME); + break; default: break; }; @@ -1065,6 +1080,9 @@ case Setting::Tun: dbg.nospace() << *(settingPtr.staticCast().data()); break; + case Setting::IpTunnel: + dbg.nospace() << *(settingPtr.staticCast().data()); + break; default: dbg.nospace() << *settingPtr.data(); } Index: src/settings/iptunnelsetting.h =================================================================== --- /dev/null +++ src/settings/iptunnelsetting.h @@ -0,0 +1,120 @@ +/* + Copyright 2018 Pranav Gade + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . +*/ + +#ifndef NETWORKMANAGERQT_IPTUNNEL_SETTING_H +#define NETWORKMANAGERQT_IPTUNNEL_SETTING_H + +#include +#include "setting.h" + +#include + +#if !NM_CHECK_VERSION(1, 12, 0) +#define NM_SETTING_IP_TUNNEL_FLAGS "flags" +#endif + +namespace NetworkManager +{ + +class IpTunnelSettingPrivate; + +/** + * Represents generic setting + */ +class NETWORKMANAGERQT_EXPORT IpTunnelSetting : public Setting +{ +public: + typedef QSharedPointer Ptr; + typedef QList List; + enum Mode { Unknown, Ipip, Gre, Sit, Isatap, Vti, Ip6ip6, Ipip6, Ip6gre, Vti6 }; + enum Flag { + None = NM_IP_TUNNEL_FLAG_NONE, + IgnEncapLimit = NM_IP_TUNNEL_FLAG_IP6_IGN_ENCAP_LIMIT, + UseOrigTclass = NM_IP_TUNNEL_FLAG_IP6_USE_ORIG_TCLASS, + UseOrigFlowlabel = NM_IP_TUNNEL_FLAG_IP6_USE_ORIG_FLOWLABEL, + Mip6Dev = NM_IP_TUNNEL_FLAG_IP6_MIP6_DEV, + RcvDscpCopy = NM_IP_TUNNEL_FLAG_IP6_RCV_DSCP_COPY, + UseOrigFwmark = NM_IP_TUNNEL_FLAG_IP6_USE_ORIG_FWMARK + }; + Q_DECLARE_FLAGS(Flags, Flag) + + IpTunnelSetting(); + explicit IpTunnelSetting(const Ptr &other); + ~IpTunnelSetting() override; + + QString name() const override; + + void setMode(Mode mode); + Mode mode() const; + + void setPathMtuDiscovery(bool discovery); + bool pathMtuDiscovery() const; + + void setEncapsulationLimit(quint32 limit); + quint32 encapsulationLimit() const; + + void setFlags(Flags flags); + Flags flags() const; + + void setFlowLabel(quint32 label); + quint32 flowLabel() const; + + void setMtu(quint32 mtu); + quint32 mtu() const; + + void setTos(quint32 tos); + quint32 tos() const; + + void setTtl(quint32 ttl); + quint32 ttl() const; + + void setInputKey(const QString &key); + QString inputKey() const; + + void setLocal(const QString &local); + QString local() const; + + void setParent(const QString &parent); + QString parent() const; + + void setOutputKey(const QString &key); + QString outputKey() const; + + void setRemote(const QString &remote); + QString remote() const; + + void fromMap(const QVariantMap &setting) override; + + QVariantMap toMap() const override; + +protected: + IpTunnelSettingPrivate *d_ptr; + +private: + Q_DECLARE_PRIVATE(IpTunnelSetting) +}; +Q_DECLARE_OPERATORS_FOR_FLAGS(IpTunnelSetting::Flags) + +NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const IpTunnelSetting &setting); + +} + +#endif // NETWORKMANAGERQT_IP_TUNNEL_SETTING_H + Index: src/settings/iptunnelsetting.cpp =================================================================== --- /dev/null +++ src/settings/iptunnelsetting.cpp @@ -0,0 +1,387 @@ +/* + Copyright Pranav Gade + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . +*/ + +#include "iptunnelsetting.h" +#include "iptunnelsetting_p.h" + +#include + +NetworkManager::IpTunnelSettingPrivate::IpTunnelSettingPrivate() + : name(NM_SETTING_IP_TUNNEL_SETTING_NAME) + , mode(IpTunnelSetting::Unknown) + , pathMtuDiscovery(true) + , encapsulationLimit(0) + , flags(IpTunnelSetting::None) + , flowLabel(0) + , tos(0) + , ttl(0) +{ } + +NetworkManager::IpTunnelSetting::IpTunnelSetting() + : Setting(Setting::IpTunnel) + , d_ptr(new IpTunnelSettingPrivate()) +{ } + +NetworkManager::IpTunnelSetting::IpTunnelSetting(const Ptr &other) + : Setting(other) + , d_ptr(new IpTunnelSettingPrivate()) +{ + setMode(other->mode()); + setPathMtuDiscovery(other->pathMtuDiscovery()); + setEncapsulationLimit(other->encapsulationLimit()); + setFlags(other->flags()); + setFlowLabel(other->flowLabel()); + setMtu(other->mtu()); + setTos(other->tos()); + setTtl(other->ttl()); + setInputKey(other->inputKey()); + setLocal(other->local()); + setOutputKey(other->outputKey()); + setParent(other->parent()); + setRemote(other->remote()); +} + +NetworkManager::IpTunnelSetting::~IpTunnelSetting() +{ + delete d_ptr; +} + +QString NetworkManager::IpTunnelSetting::name() const +{ + Q_D(const IpTunnelSetting); + + return d->name; +} + +void NetworkManager::IpTunnelSetting::setMode(NetworkManager::IpTunnelSetting::Mode mode) +{ + Q_D(IpTunnelSetting); + + d->mode = mode; +} + +NetworkManager::IpTunnelSetting::Mode NetworkManager::IpTunnelSetting::mode() const +{ + Q_D(const IpTunnelSetting); + + return d->mode; +} + +void NetworkManager::IpTunnelSetting::setPathMtuDiscovery(bool discovery) +{ + Q_D(IpTunnelSetting); + + d->pathMtuDiscovery = discovery; +} + +bool NetworkManager::IpTunnelSetting::pathMtuDiscovery() const +{ + Q_D(const IpTunnelSetting); + + return d->pathMtuDiscovery; +} + +void NetworkManager::IpTunnelSetting::setEncapsulationLimit(quint32 limit) +{ + Q_D(IpTunnelSetting); + + d->encapsulationLimit = limit; +} + +quint32 NetworkManager::IpTunnelSetting::encapsulationLimit() const +{ + Q_D(const IpTunnelSetting); + + return d->encapsulationLimit; +} + +void NetworkManager::IpTunnelSetting::setFlags(NetworkManager::IpTunnelSetting::Flags flags) +{ + Q_D(IpTunnelSetting); + + d->flags = flags; +} + +NetworkManager::IpTunnelSetting::Flags NetworkManager::IpTunnelSetting::flags() const +{ + Q_D(const IpTunnelSetting); + + return d->flags; +} + +void NetworkManager::IpTunnelSetting::setFlowLabel(quint32 label) +{ + Q_D(IpTunnelSetting); + + d->flowLabel = label; +} + +quint32 NetworkManager::IpTunnelSetting::flowLabel() const +{ + Q_D(const IpTunnelSetting); + + return d->flowLabel; +} + +void NetworkManager::IpTunnelSetting::setMtu(quint32 mtu) +{ + Q_D(IpTunnelSetting); + + d->mtu = mtu; +} + +quint32 NetworkManager::IpTunnelSetting::mtu() const +{ + Q_D(const IpTunnelSetting); + + return d->mtu; +} + +void NetworkManager::IpTunnelSetting::setTos(quint32 tos) +{ + Q_D(IpTunnelSetting); + + d->tos = tos; +} + +quint32 NetworkManager::IpTunnelSetting::tos() const +{ + Q_D(const IpTunnelSetting); + + return d->tos; +} + +void NetworkManager::IpTunnelSetting::setTtl(quint32 ttl) +{ + Q_D(IpTunnelSetting); + + d->ttl = ttl; +} + +quint32 NetworkManager::IpTunnelSetting::ttl() const +{ + Q_D(const IpTunnelSetting); + + return d->ttl; +} + +void NetworkManager::IpTunnelSetting::setInputKey(const QString &key) +{ + Q_D(IpTunnelSetting); + + d->inputKey = key; +} + +QString NetworkManager::IpTunnelSetting::inputKey() const +{ + Q_D(const IpTunnelSetting); + + return d->inputKey; +} + +void NetworkManager::IpTunnelSetting::setLocal(const QString &local) +{ + Q_D(IpTunnelSetting); + + d->local = local; +} + +QString NetworkManager::IpTunnelSetting::local() const +{ + Q_D(const IpTunnelSetting); + + return d->local; +} + +void NetworkManager::IpTunnelSetting::setParent(const QString &parent) +{ + Q_D(IpTunnelSetting); + + d->parent = parent; +} + +QString NetworkManager::IpTunnelSetting::parent() const +{ + Q_D(const IpTunnelSetting); + + return d->parent; +} + +void NetworkManager::IpTunnelSetting::setOutputKey(const QString &key) +{ + Q_D(IpTunnelSetting); + + d->outputKey = key; +} + +QString NetworkManager::IpTunnelSetting::outputKey() const +{ + Q_D(const IpTunnelSetting); + + return d->outputKey; +} + +void NetworkManager::IpTunnelSetting::setRemote(const QString &remote) +{ + Q_D(IpTunnelSetting); + + d->remote = remote; +} + +QString NetworkManager::IpTunnelSetting::remote() const +{ + Q_D(const IpTunnelSetting); + + return d->remote; +} + +void NetworkManager::IpTunnelSetting::fromMap(const QVariantMap &setting) +{ + if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_MODE))) { + setMode((Mode)setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_MODE)).toUInt()); + } + + if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY))) { + setPathMtuDiscovery(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY)).toBool()); + } + + if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT))) { + setEncapsulationLimit(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT)).toUInt()); + } + + if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_FLAGS))) { + setFlags((Flag)setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_FLAGS)).toUInt()); + } + + if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_FLOW_LABEL))) { + setFlowLabel(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_FLOW_LABEL)).toUInt()); + } + + if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_MTU))) { + setMtu(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_MTU)).toUInt()); + } + + if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_TOS))) { + setTos(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_TOS)).toUInt()); + } + + if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_TTL))) { + setTtl(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_TTL)).toUInt()); + } + + if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_INPUT_KEY))) { + setInputKey(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_INPUT_KEY)).toString()); + } + + if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_LOCAL))) { + setLocal(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_LOCAL)).toString()); + } + + if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_PARENT))) { + setParent(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_PARENT)).toString()); + } + + if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_OUTPUT_KEY))) { + setOutputKey(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_OUTPUT_KEY)).toString()); + } + + if (setting.contains(QLatin1String(NM_SETTING_IP_TUNNEL_REMOTE))) { + setRemote(setting.value(QLatin1String(NM_SETTING_IP_TUNNEL_REMOTE)).toString()); + } +} + +QVariantMap NetworkManager::IpTunnelSetting::toMap() const +{ + QVariantMap setting; + + setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY), pathMtuDiscovery()); + + if ((int)mode() > 0) { + setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_MODE), (int)mode()); + } + + if (encapsulationLimit() > 0) { + setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT), encapsulationLimit()); + } + + if (flags() > 0) { + setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_FLAGS), (int)flags()); + } + + if (flowLabel() > 0) { + setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_FLOW_LABEL), flowLabel()); + } + + if (mtu() > 0) { + setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_MTU), mtu()); + } + + if (tos() > 0) { + setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_TOS), tos()); + } + + if (ttl() > 0) { + setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_TTL), ttl()); + } + + if (!inputKey().isEmpty()) { + setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_INPUT_KEY), inputKey()); + } + + if (!local().isEmpty()) { + setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_LOCAL), local()); + } + + if (!parent().isEmpty()) { + setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_PARENT), parent()); + } + + if (!outputKey().isEmpty()) { + setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_OUTPUT_KEY), outputKey()); + } + + if (!remote().isEmpty()) { + setting.insert(QLatin1String(NM_SETTING_IP_TUNNEL_REMOTE), remote()); + } + + return setting; +} + +QDebug NetworkManager::operator <<(QDebug dbg, const NetworkManager::IpTunnelSetting &setting) +{ + dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n'; + dbg.nospace() << "initialized: " << !setting.isNull() << '\n'; + + dbg.nospace() << NM_SETTING_IP_TUNNEL_MODE << ": " << setting.mode() << '\n'; + dbg.nospace() << NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY << ": " << setting.pathMtuDiscovery() << '\n'; + dbg.nospace() << NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT << ": " << setting.encapsulationLimit() << '\n'; + dbg.nospace() << NM_SETTING_IP_TUNNEL_FLAGS << ": " << setting.flags() << '\n'; + dbg.nospace() << NM_SETTING_IP_TUNNEL_FLOW_LABEL << ": " << setting.flowLabel() << '\n'; + dbg.nospace() << NM_SETTING_IP_TUNNEL_MTU << ": " << setting.mtu() << '\n'; + dbg.nospace() << NM_SETTING_IP_TUNNEL_TOS << ": " << setting.tos() << '\n'; + dbg.nospace() << NM_SETTING_IP_TUNNEL_TTL << ": " << setting.ttl() << '\n'; + dbg.nospace() << NM_SETTING_IP_TUNNEL_INPUT_KEY << ": " << setting.inputKey() << '\n'; + dbg.nospace() << NM_SETTING_IP_TUNNEL_LOCAL << ": " << setting.local() << '\n'; + dbg.nospace() << NM_SETTING_IP_TUNNEL_PARENT << ": " << setting.parent() << '\n'; + dbg.nospace() << NM_SETTING_IP_TUNNEL_OUTPUT_KEY << ": " << setting.outputKey() << '\n'; + dbg.nospace() << NM_SETTING_IP_TUNNEL_REMOTE << ": " << setting.remote() << '\n'; + + return dbg.maybeSpace(); +} Index: src/settings/iptunnelsetting_p.h =================================================================== --- /dev/null +++ src/settings/iptunnelsetting_p.h @@ -0,0 +1,54 @@ +/* + Copyright 2018 Pranav Gade + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . +*/ + +#ifndef NETWORKMANAGERQT_IP_TUNNEL_SETTING_P_H +#define NETWORKMANAGERQT_IP_TUNNEL_SETTING_P_H + +#include + +namespace NetworkManager +{ + +class IpTunnelSettingPrivate +{ +public: + IpTunnelSettingPrivate(); + + QString name; + + NetworkManager::IpTunnelSetting::Mode mode; + bool pathMtuDiscovery; + quint32 encapsulationLimit; + NetworkManager::IpTunnelSetting::Flags flags; + quint32 flowLabel; + quint32 mtu; + quint32 tos; + quint32 ttl; + QString inputKey; + QString local; + QString outputKey; + QString parent; + QString remote; +}; + +} + +#endif // NETWORKMANAGERQT_IP_TUNNEL_SETTING_P_H + Index: src/settings/setting.h =================================================================== --- src/settings/setting.h +++ src/settings/setting.h @@ -72,7 +72,8 @@ Team, Generic, Tun, - Vxlan + Vxlan, + IpTunnel }; enum SecretFlagType { Index: src/settings/setting.cpp =================================================================== --- src/settings/setting.cpp +++ src/settings/setting.cpp @@ -118,6 +118,9 @@ case Vxlan: typeString = QLatin1String(NM_SETTING_VXLAN_SETTING_NAME); break; + case IpTunnel: + typeString = QLatin1String(NM_SETTING_IP_TUNNEL_SETTING_NAME); + break; case NetworkManager::Setting::Generic: typeString = QLatin1String(NM_SETTING_GENERIC_SETTING_NAME); break; @@ -172,6 +175,8 @@ type = Team; } else if (typeString == QLatin1String(NM_SETTING_VXLAN_SETTING_NAME)) { type = Vxlan; + } else if (typeString == QLatin1String(NM_SETTING_IP_TUNNEL_SETTING_NAME)) { + type = IpTunnel; } else if (typeString == QLatin1String(NM_SETTING_GENERIC_SETTING_NAME)) { type = Generic; }