NetworkManagerQt

vxlansetting.cpp
1/*
2 SPDX-FileCopyrightText: 2018 Billy Laws <blaws05@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "vxlansetting.h"
8#include "vxlansetting_p.h"
9
10#include <QDebug>
11
12NetworkManager::VxlanSettingPrivate::VxlanSettingPrivate()
13 : name(NM_SETTING_VXLAN_SETTING_NAME)
14 , ageing(32)
15 , destinationPort(8472)
16 , id(0)
17 , l2Miss(false)
18 , l3Miss(false)
19 , learning(true)
20 , limit(0)
21 , proxy(false)
22 , rsc(false)
23 , sourcePortMax(0)
24 , sourcePortMin(0)
25 , tos(0)
26 , ttl(0)
27{
28}
29
30NetworkManager::VxlanSetting::VxlanSetting()
31 : Setting(Setting::Vxlan)
32 , d_ptr(new VxlanSettingPrivate())
33{
34}
35
36NetworkManager::VxlanSetting::VxlanSetting(const NetworkManager::VxlanSetting::Ptr &other)
37 : Setting(other)
38 , d_ptr(new VxlanSettingPrivate())
39{
40 setAgeing(other->ageing());
41 setDestinationPort(other->destinationPort());
42 setId(other->id());
43 setL2Miss(other->l2Miss());
44 setL3Miss(other->l3Miss());
45 setLearning(other->learning());
46 setLimit(other->limit());
47 setLocal(other->local());
48 setParent(other->parent());
49 setProxy(other->proxy());
50 setRemote(other->remote());
51 setRsc(other->rsc());
52 setSourcePortMax(other->sourcePortMax());
53 setSourcePortMin(other->sourcePortMin());
54 setTos(other->tos());
55 setTtl(other->ttl());
56}
57
58NetworkManager::VxlanSetting::~VxlanSetting()
59{
60 delete d_ptr;
61}
62
64{
65 Q_D(const VxlanSetting);
66
67 return d->name;
68}
69
70void NetworkManager::VxlanSetting::setAgeing(quint32 ageing)
71{
73
74 d->ageing = ageing;
75}
76
77quint32 NetworkManager::VxlanSetting::ageing() const
78{
79 Q_D(const VxlanSetting);
80
81 return d->ageing;
82}
83
84void NetworkManager::VxlanSetting::setDestinationPort(quint32 port)
85{
86 Q_D(VxlanSetting);
87
88 d->destinationPort = port;
89}
90
91quint32 NetworkManager::VxlanSetting::destinationPort() const
92{
93 Q_D(const VxlanSetting);
94
95 return d->destinationPort;
96}
97
98void NetworkManager::VxlanSetting::setId(quint32 id)
99{
100 Q_D(VxlanSetting);
101
102 d->id = id;
103}
104
105quint32 NetworkManager::VxlanSetting::id() const
106{
107 Q_D(const VxlanSetting);
108
109 return d->id;
110}
111
112void NetworkManager::VxlanSetting::setL2Miss(bool enable)
113{
114 Q_D(VxlanSetting);
115
116 d->l2Miss = enable;
117}
118
119bool NetworkManager::VxlanSetting::l2Miss() const
120{
121 Q_D(const VxlanSetting);
122
123 return d->l2Miss;
124}
125
126void NetworkManager::VxlanSetting::setL3Miss(bool enable)
127{
128 Q_D(VxlanSetting);
129
130 d->l3Miss = enable;
131}
132
133bool NetworkManager::VxlanSetting::l3Miss() const
134{
135 Q_D(const VxlanSetting);
136
137 return d->l3Miss;
138}
139
140void NetworkManager::VxlanSetting::setLearning(bool enable)
141{
142 Q_D(VxlanSetting);
143
144 d->learning = enable;
145}
146
147bool NetworkManager::VxlanSetting::learning() const
148{
149 Q_D(const VxlanSetting);
150
151 return d->learning;
152}
153
154void NetworkManager::VxlanSetting::setLimit(quint32 limit)
155{
156 Q_D(VxlanSetting);
157
158 d->limit = limit;
159}
160
161quint32 NetworkManager::VxlanSetting::limit() const
162{
163 Q_D(const VxlanSetting);
164
165 return d->limit;
166}
167
168void NetworkManager::VxlanSetting::setLocal(QString local)
169{
170 Q_D(VxlanSetting);
171
172 d->local = local;
173}
174
175QString NetworkManager::VxlanSetting::local() const
176{
177 Q_D(const VxlanSetting);
178
179 return d->local;
180}
181
182void NetworkManager::VxlanSetting::setParent(QString parent)
183{
184 Q_D(VxlanSetting);
185
186 d->parent = parent;
187}
188
189QString NetworkManager::VxlanSetting::parent() const
190{
191 Q_D(const VxlanSetting);
192
193 return d->parent;
194}
195
196void NetworkManager::VxlanSetting::setProxy(bool enable)
197{
198 Q_D(VxlanSetting);
199
200 d->proxy = enable;
201}
202
203bool NetworkManager::VxlanSetting::proxy() const
204{
205 Q_D(const VxlanSetting);
206
207 return d->proxy;
208}
209
210void NetworkManager::VxlanSetting::setRemote(QString remote)
211{
212 Q_D(VxlanSetting);
213
214 d->remote = remote;
215}
216
217QString NetworkManager::VxlanSetting::remote() const
218{
219 Q_D(const VxlanSetting);
220
221 return d->remote;
222}
223
224void NetworkManager::VxlanSetting::setRsc(bool enable)
225{
226 Q_D(VxlanSetting);
227
228 d->rsc = enable;
229}
230
231bool NetworkManager::VxlanSetting::rsc() const
232{
233 Q_D(const VxlanSetting);
234
235 return d->rsc;
236}
237
238void NetworkManager::VxlanSetting::setSourcePortMax(quint32 maxPort)
239{
240 Q_D(VxlanSetting);
241
242 d->sourcePortMax = maxPort;
243}
244
245quint32 NetworkManager::VxlanSetting::sourcePortMax() const
246{
247 Q_D(const VxlanSetting);
248
249 return d->sourcePortMax;
250}
251
252void NetworkManager::VxlanSetting::setSourcePortMin(quint32 minPort)
253{
254 Q_D(VxlanSetting);
255
256 d->sourcePortMin = minPort;
257}
258
259quint32 NetworkManager::VxlanSetting::sourcePortMin() const
260{
261 Q_D(const VxlanSetting);
262
263 return d->sourcePortMin;
264}
265
266void NetworkManager::VxlanSetting::setTos(quint32 tos)
267{
268 Q_D(VxlanSetting);
269
270 d->tos = tos;
271}
272
273quint32 NetworkManager::VxlanSetting::tos() const
274{
275 Q_D(const VxlanSetting);
276
277 return d->tos;
278}
279
280void NetworkManager::VxlanSetting::setTtl(quint32 ttl)
281{
282 Q_D(VxlanSetting);
283
284 d->ttl = ttl;
285}
286
287quint32 NetworkManager::VxlanSetting::ttl() const
288{
289 Q_D(const VxlanSetting);
290
291 return d->ttl;
292}
293void NetworkManager::VxlanSetting::fromMap(const QVariantMap &setting)
294{
295 if (setting.contains(QLatin1String(NM_SETTING_VXLAN_AGEING))) {
296 setAgeing(setting.value(QLatin1String(NM_SETTING_VXLAN_AGEING)).toUInt());
297 }
298
299 if (setting.contains(QLatin1String(NM_SETTING_VXLAN_DESTINATION_PORT))) {
300 setDestinationPort(setting.value(QLatin1String(NM_SETTING_VXLAN_DESTINATION_PORT)).toUInt());
301 }
302
303 if (setting.contains(QLatin1String(NM_SETTING_VXLAN_ID))) {
304 setId(setting.value(QLatin1String(NM_SETTING_VXLAN_ID)).toUInt());
305 }
306
307 if (setting.contains(QLatin1String(NM_SETTING_VXLAN_L2_MISS))) {
308 setL2Miss(setting.value(QLatin1String(NM_SETTING_VXLAN_L2_MISS)).toBool());
309 }
310
311 if (setting.contains(QLatin1String(NM_SETTING_VXLAN_L3_MISS))) {
312 setL3Miss(setting.value(QLatin1String(NM_SETTING_VXLAN_L3_MISS)).toBool());
313 }
314
315 if (setting.contains(QLatin1String(NM_SETTING_VXLAN_LEARNING))) {
316 setLearning(setting.value(QLatin1String(NM_SETTING_VXLAN_LEARNING)).toBool());
317 }
318
319 if (setting.contains(QLatin1String(NM_SETTING_VXLAN_LIMIT))) {
320 setLimit(setting.value(QLatin1String(NM_SETTING_VXLAN_LIMIT)).toUInt());
321 }
322
323 if (setting.contains(QLatin1String(NM_SETTING_VXLAN_LOCAL))) {
324 setLocal(setting.value(QLatin1String(NM_SETTING_VXLAN_LOCAL)).toString());
325 }
326
327 if (setting.contains(QLatin1String(NM_SETTING_VXLAN_PARENT))) {
328 setParent(setting.value(QLatin1String(NM_SETTING_VXLAN_PARENT)).toString());
329 }
330
331 if (setting.contains(QLatin1String(NM_SETTING_VXLAN_PROXY))) {
332 setProxy(setting.value(QLatin1String(NM_SETTING_VXLAN_PROXY)).toBool());
333 }
334
335 if (setting.contains(QLatin1String(NM_SETTING_VXLAN_REMOTE))) {
336 setRemote(setting.value(QLatin1String(NM_SETTING_VXLAN_REMOTE)).toString());
337 }
338
339 if (setting.contains(QLatin1String(NM_SETTING_VXLAN_RSC))) {
340 setRsc(setting.value(QLatin1String(NM_SETTING_VXLAN_RSC)).toBool());
341 }
342
343 if (setting.contains(QLatin1String(NM_SETTING_VXLAN_SOURCE_PORT_MAX))) {
344 setSourcePortMax(setting.value(QLatin1String(NM_SETTING_VXLAN_SOURCE_PORT_MAX)).toUInt());
345 }
346
347 if (setting.contains(QLatin1String(NM_SETTING_VXLAN_SOURCE_PORT_MIN))) {
348 setSourcePortMin(setting.value(QLatin1String(NM_SETTING_VXLAN_SOURCE_PORT_MIN)).toUInt());
349 }
350
351 if (setting.contains(QLatin1String(NM_SETTING_VXLAN_TOS))) {
352 setTos(setting.value(QLatin1String(NM_SETTING_VXLAN_TOS)).toUInt());
353 }
354
355 if (setting.contains(QLatin1String(NM_SETTING_VXLAN_TTL))) {
356 setTtl(setting.value(QLatin1String(NM_SETTING_VXLAN_TTL)).toUInt());
357 }
358}
359
361{
362 QVariantMap setting;
363
364 if (ageing() != 32) {
365 setting.insert(QLatin1String(NM_SETTING_VXLAN_AGEING), ageing());
366 }
367
368 if (destinationPort() != 8472) {
369 setting.insert(QLatin1String(NM_SETTING_VXLAN_DESTINATION_PORT), destinationPort());
370 }
371
372 if (id()) {
373 setting.insert(QLatin1String(NM_SETTING_VXLAN_ID), id());
374 }
375
376 if (l2Miss()) {
377 setting.insert(QLatin1String(NM_SETTING_VXLAN_L2_MISS), l2Miss());
378 }
379
380 if (l3Miss()) {
381 setting.insert(QLatin1String(NM_SETTING_VXLAN_L3_MISS), l3Miss());
382 }
383
384 if (!learning()) {
385 setting.insert(QLatin1String(NM_SETTING_VXLAN_LEARNING), learning());
386 }
387
388 if (limit()) {
389 setting.insert(QLatin1String(NM_SETTING_VXLAN_LIMIT), limit());
390 }
391
392 if (!local().isEmpty()) {
393 setting.insert(QLatin1String(NM_SETTING_VXLAN_LOCAL), local());
394 }
395
396 if (!parent().isEmpty()) {
397 setting.insert(QLatin1String(NM_SETTING_VXLAN_PARENT), parent());
398 }
399
400 if (proxy()) {
401 setting.insert(QLatin1String(NM_SETTING_VXLAN_PROXY), proxy());
402 }
403
404 if (!remote().isEmpty()) {
405 setting.insert(QLatin1String(NM_SETTING_VXLAN_REMOTE), remote());
406 }
407
408 if (rsc()) {
409 setting.insert(QLatin1String(NM_SETTING_VXLAN_RSC), rsc());
410 }
411
412 if (sourcePortMax()) {
413 setting.insert(QLatin1String(NM_SETTING_VXLAN_SOURCE_PORT_MAX), sourcePortMax());
414 }
415
416 if (sourcePortMin()) {
417 setting.insert(QLatin1String(NM_SETTING_VXLAN_SOURCE_PORT_MIN), sourcePortMin());
418 }
419
420 if (tos()) {
421 setting.insert(QLatin1String(NM_SETTING_VXLAN_TOS), tos());
422 }
423
424 if (ttl()) {
425 setting.insert(QLatin1String(NM_SETTING_VXLAN_TTL), ttl());
426 }
427
428 return setting;
429}
430
431QDebug NetworkManager::operator<<(QDebug dbg, const NetworkManager::VxlanSetting &setting)
432{
433 dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n';
434 dbg.nospace() << "initialized: " << !setting.isNull() << '\n';
435
436 dbg.nospace() << NM_SETTING_VXLAN_AGEING << ": " << setting.ageing() << '\n';
437 dbg.nospace() << NM_SETTING_VXLAN_DESTINATION_PORT << ": " << setting.destinationPort() << '\n';
438 dbg.nospace() << NM_SETTING_VXLAN_ID << ": " << setting.id() << '\n';
439 dbg.nospace() << NM_SETTING_VXLAN_L2_MISS << ": " << setting.l2Miss() << '\n';
440 dbg.nospace() << NM_SETTING_VXLAN_L3_MISS << ": " << setting.l3Miss() << '\n';
441 dbg.nospace() << NM_SETTING_VXLAN_LEARNING << ": " << setting.learning() << '\n';
442 dbg.nospace() << NM_SETTING_VXLAN_LIMIT << ": " << setting.limit() << '\n';
443 dbg.nospace() << NM_SETTING_VXLAN_LOCAL << ": " << setting.local() << '\n';
444 dbg.nospace() << NM_SETTING_VXLAN_PARENT << ": " << setting.parent() << '\n';
445 dbg.nospace() << NM_SETTING_VXLAN_PROXY << ": " << setting.proxy() << '\n';
446 dbg.nospace() << NM_SETTING_VXLAN_REMOTE << ": " << setting.remote() << '\n';
447 dbg.nospace() << NM_SETTING_VXLAN_RSC << ": " << setting.rsc() << '\n';
448 dbg.nospace() << NM_SETTING_VXLAN_SOURCE_PORT_MAX << ": " << setting.sourcePortMax() << '\n';
449 dbg.nospace() << NM_SETTING_VXLAN_SOURCE_PORT_MIN << ": " << setting.sourcePortMin() << '\n';
450 dbg.nospace() << NM_SETTING_VXLAN_TOS << ": " << setting.tos() << '\n';
451 dbg.nospace() << NM_SETTING_VXLAN_TTL << ": " << setting.ttl() << '\n';
452
453 return dbg.maybeSpace();
454}
Represents vxlan setting.
void fromMap(const QVariantMap &setting) override
Must be reimplemented, default implementation does nothing.
QVariantMap toMap() const override
Must be reimplemented, default implementationd does nothing.
QString name() const override
Must be reimplemented, default implementationd does nothing.
QDebug & maybeSpace()
QDebug & nospace()
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.