1/*
2 SPDX-FileCopyrightText: 2017 Jan Grulich <jgrulich@redhat.com>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "device_p.h"
8#include "iptunneldevice_p.h"
9#include "manager.h"
10
11NetworkManager::IpTunnelDevicePrivate::IpTunnelDevicePrivate(const QString &path, IpTunnelDevice *q)
12 : DevicePrivate(path, q)
13#ifdef NMQT_STATIC
14 , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus())
15#else
16 , iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus())
17#endif
18{
19}
20
21NetworkManager::IpTunnelDevicePrivate::~IpTunnelDevicePrivate()
22{
23}
24
25NetworkManager::IpTunnelDevice::IpTunnelDevice(const QString &path, QObject *parent)
26 : Device(*new IpTunnelDevicePrivate(path, this), parent)
27{
28 Q_D(IpTunnelDevice);
29
30 QVariantMap initialProperties = NetworkManagerPrivate::retrieveInitialProperties(interfaceName: d->iface.staticInterfaceName(), path);
31 if (!initialProperties.isEmpty()) {
32 d->propertiesChanged(properties: initialProperties);
33 }
34
35}
36
37NetworkManager::IpTunnelDevice::~IpTunnelDevice()
38{
39}
40
41NetworkManager::Device::Type NetworkManager::IpTunnelDevice::type() const
42{
43 return NetworkManager::Device::IpTunnel;
44}
45
46uchar NetworkManager::IpTunnelDevice::encapsulationLimit() const
47{
48 Q_D(const IpTunnelDevice);
49 return d->encapsulationLimit;
50}
51
52uint NetworkManager::IpTunnelDevice::flowLabel() const
53{
54 Q_D(const IpTunnelDevice);
55 return d->flowLabel;
56}
57
58QString NetworkManager::IpTunnelDevice::inputKey() const
59{
60 Q_D(const IpTunnelDevice);
61 return d->inputKey;
62}
63
64QString NetworkManager::IpTunnelDevice::local() const
65{
66 Q_D(const IpTunnelDevice);
67 return d->local;
68}
69
70uint NetworkManager::IpTunnelDevice::mode() const
71{
72 Q_D(const IpTunnelDevice);
73 return d->mode;
74}
75
76QString NetworkManager::IpTunnelDevice::outputKey() const
77{
78 Q_D(const IpTunnelDevice);
79 return d->outputKey;
80}
81
82NetworkManager::Device::Ptr NetworkManager::IpTunnelDevice::parent() const
83{
84 Q_D(const IpTunnelDevice);
85 return NetworkManager::findNetworkInterface(uni: d->parent);
86}
87
88bool NetworkManager::IpTunnelDevice::pathMtuDiscovery() const
89{
90 Q_D(const IpTunnelDevice);
91 return d->pathMtuDiscovery;
92}
93
94QString NetworkManager::IpTunnelDevice::remote() const
95{
96 Q_D(const IpTunnelDevice);
97 return d->remote;
98}
99
100uchar NetworkManager::IpTunnelDevice::tos() const
101{
102 Q_D(const IpTunnelDevice);
103 return d->tos;
104}
105
106uchar NetworkManager::IpTunnelDevice::ttl() const
107{
108 Q_D(const IpTunnelDevice);
109 return d->ttl;
110}
111
112void NetworkManager::IpTunnelDevicePrivate::propertyChanged(const QString &property, const QVariant &value)
113{
114 Q_Q(IpTunnelDevice);
115
116 if (property == QLatin1String("EncapsulationLimit")) {
117 encapsulationLimit = static_cast<ushort>(value.toUInt());
118 Q_EMIT q->encapsulationLimitChanged(limit: encapsulationLimit);
119 } else if (property == QLatin1String("FlowLabel")) {
120 flowLabel = value.toUInt();
121 Q_EMIT q->flowLabelChanged(flowLabel);
122 } else if (property == QLatin1String("InputKey")) {
123 inputKey = value.toString();
124 Q_EMIT q->inputKeyChanged(inputKey);
125 } else if (property == QLatin1String("Local")) {
126 local = value.toString();
127 Q_EMIT q->localChanged(local);
128 } else if (property == QLatin1String("Mode")) {
129 mode = value.toUInt();
130 Q_EMIT q->modeChanged(mode);
131 } else if (property == QLatin1String("OutputKey")) {
132 outputKey = value.toString();
133 Q_EMIT q->outputKeyChanged(outputKey);
134 } else if (property == QLatin1String("Parent")) {
135 parent = value.toString();
136 Q_EMIT q->parentChanged(parent);
137 } else if (property == QLatin1String("PathMtuDiscovery")) {
138 pathMtuDiscovery = value.toBool();
139 Q_EMIT q->pathMtuDiscoveryChanged(pathMtuDiscovery);
140 } else if (property == QLatin1String("Remote")) {
141 remote = value.toString();
142 Q_EMIT q->remoteChanged(remote);
143 } else if (property == QLatin1String("Tos")) {
144 tos = static_cast<ushort>(value.toUInt());
145 Q_EMIT q->tosChanged(tos);
146 } else if (property == QLatin1String("Ttl")) {
147 ttl = static_cast<ushort>(value.toUInt());
148 Q_EMIT q->ttlChanged(ttl);
149 } else {
150 DevicePrivate::propertyChanged(property, value);
151 }
152}
153
154#include "moc_iptunneldevice.cpp"
155#include "moc_iptunneldevice_p.cpp"
156

source code of networkmanager-qt/src/iptunneldevice.cpp