7#include "bridgesetting.h"
8#include "bridgesetting_p.h"
10#define NM_SETTING_BRIDGE_INTERFACE_NAME "interface-name"
14NetworkManager::BridgeSettingPrivate::BridgeSettingPrivate()
15 : name(NM_SETTING_BRIDGE_SETTING_NAME)
16 , multicastSnooping(true)
26NetworkManager::BridgeSetting::BridgeSetting()
27 : Setting(Setting::Bridge)
28 , d_ptr(new BridgeSettingPrivate())
32NetworkManager::BridgeSetting::BridgeSetting(
const Ptr &other)
34 , d_ptr(new BridgeSettingPrivate())
36 setInterfaceName(other->interfaceName());
38 setPriority(other->priority());
39 setForwardDelay(other->forwardDelay());
40 setHelloTime(other->helloTime());
41 setMaxAge(other->maxAge());
42 setAgingTime(other->agingTime());
43 setMulticastSnooping(other->multicastSnooping());
44 setMacAddress(other->macAddress());
47NetworkManager::BridgeSetting::~BridgeSetting()
59void NetworkManager::BridgeSetting::setInterfaceName(
const QString &name)
63 d->interfaceName = name;
66QString NetworkManager::BridgeSetting::interfaceName()
const
68 Q_D(
const BridgeSetting);
70 return d->interfaceName;
73void NetworkManager::BridgeSetting::setStp(
bool enabled)
80bool NetworkManager::BridgeSetting::stp()
const
82 Q_D(
const BridgeSetting);
87void NetworkManager::BridgeSetting::setPriority(quint32 priority)
91 d->priority = priority;
94quint32 NetworkManager::BridgeSetting::priority()
const
96 Q_D(
const BridgeSetting);
101void NetworkManager::BridgeSetting::setForwardDelay(quint32 delay)
105 d->forwardDelay = delay;
108quint32 NetworkManager::BridgeSetting::forwardDelay()
const
110 Q_D(
const BridgeSetting);
112 return d->forwardDelay;
115void NetworkManager::BridgeSetting::setHelloTime(quint32 time)
122quint32 NetworkManager::BridgeSetting::helloTime()
const
124 Q_D(
const BridgeSetting);
129void NetworkManager::BridgeSetting::setMaxAge(quint32 age)
136quint32 NetworkManager::BridgeSetting::maxAge()
const
138 Q_D(
const BridgeSetting);
143void NetworkManager::BridgeSetting::setAgingTime(quint32 time)
150quint32 NetworkManager::BridgeSetting::agingTime()
const
152 Q_D(
const BridgeSetting);
157void NetworkManager::BridgeSetting::setMulticastSnooping(
bool snooping)
161 d->multicastSnooping = snooping;
164bool NetworkManager::BridgeSetting::multicastSnooping()
const
166 Q_D(
const BridgeSetting);
168 return d->multicastSnooping;
171void NetworkManager::BridgeSetting::setMacAddress(
const QByteArray &address)
178QByteArray NetworkManager::BridgeSetting::macAddress()
const
180 Q_D(
const BridgeSetting);
182 return d->macAddress;
187 if (setting.contains(
QLatin1String(NM_SETTING_BRIDGE_INTERFACE_NAME))) {
188 setInterfaceName(setting.value(
QLatin1String(NM_SETTING_BRIDGE_INTERFACE_NAME)).toString());
190 if (setting.contains(
QLatin1String(NM_SETTING_BRIDGE_STP))) {
191 setStp(setting.value(
QLatin1String(NM_SETTING_BRIDGE_STP)).toBool());
194 if (setting.contains(
QLatin1String(NM_SETTING_BRIDGE_PRIORITY))) {
195 setPriority(setting.value(
QLatin1String(NM_SETTING_BRIDGE_PRIORITY)).toUInt());
198 if (setting.contains(
QLatin1String(NM_SETTING_BRIDGE_FORWARD_DELAY))) {
199 setForwardDelay(setting.value(
QLatin1String(NM_SETTING_BRIDGE_FORWARD_DELAY)).toUInt());
202 if (setting.contains(
QLatin1String(NM_SETTING_BRIDGE_HELLO_TIME))) {
203 setHelloTime(setting.value(
QLatin1String(NM_SETTING_BRIDGE_HELLO_TIME)).toUInt());
206 if (setting.contains(
QLatin1String(NM_SETTING_BRIDGE_MAX_AGE))) {
207 setMaxAge(setting.value(
QLatin1String(NM_SETTING_BRIDGE_MAX_AGE)).toUInt());
210 if (setting.contains(
QLatin1String(NM_SETTING_BRIDGE_AGEING_TIME))) {
211 setAgingTime(setting.value(
QLatin1String(NM_SETTING_BRIDGE_AGEING_TIME)).toUInt());
214 if (setting.contains(
QLatin1String(NM_SETTING_BRIDGE_MULTICAST_SNOOPING))) {
215 setMulticastSnooping(setting.value(
QLatin1String(NM_SETTING_BRIDGE_MULTICAST_SNOOPING)).toBool());
218 if (setting.contains(
QLatin1String(NM_SETTING_BRIDGE_MAC_ADDRESS))) {
219 setMacAddress(setting.value(
QLatin1String(NM_SETTING_BRIDGE_MAC_ADDRESS)).toByteArray());
227 if (!interfaceName().isEmpty()) {
228 setting.insert(
QLatin1String(NM_SETTING_BRIDGE_INTERFACE_NAME), interfaceName());
234 if (priority() != 128) {
235 setting.insert(
QLatin1String(NM_SETTING_BRIDGE_PRIORITY), priority());
238 if (forwardDelay() != 15) {
239 setting.insert(
QLatin1String(NM_SETTING_BRIDGE_FORWARD_DELAY), forwardDelay());
242 if (helloTime() != 2) {
243 setting.insert(
QLatin1String(NM_SETTING_BRIDGE_HELLO_TIME), helloTime());
246 if (maxAge() != 20) {
247 setting.insert(
QLatin1String(NM_SETTING_BRIDGE_MAX_AGE), maxAge());
250 if (agingTime() != 300) {
251 setting.insert(
QLatin1String(NM_SETTING_BRIDGE_AGEING_TIME), agingTime());
254 if (!multicastSnooping()) {
255 setting.insert(
QLatin1String(NM_SETTING_BRIDGE_MULTICAST_SNOOPING), multicastSnooping());
258 if (!macAddress().isEmpty()) {
259 setting.insert(
QLatin1String(NM_SETTING_BRIDGE_MAC_ADDRESS), macAddress());
267 dbg.
nospace() <<
"type: " << setting.typeAsString(setting.type()) <<
'\n';
268 dbg.
nospace() <<
"initialized: " << !setting.isNull() <<
'\n';
270 dbg.
nospace() << NM_SETTING_BRIDGE_INTERFACE_NAME <<
": " << setting.interfaceName() <<
'\n';
271 dbg.
nospace() << NM_SETTING_BRIDGE_STP <<
": " << setting.stp() <<
'\n';
272 dbg.
nospace() << NM_SETTING_BRIDGE_PRIORITY <<
": " << setting.priority() <<
'\n';
273 dbg.
nospace() << NM_SETTING_BRIDGE_FORWARD_DELAY <<
": " << setting.forwardDelay() <<
'\n';
274 dbg.
nospace() << NM_SETTING_BRIDGE_HELLO_TIME <<
": " << setting.helloTime() <<
'\n';
275 dbg.
nospace() << NM_SETTING_BRIDGE_MAX_AGE <<
": " << setting.maxAge() <<
'\n';
276 dbg.
nospace() << NM_SETTING_BRIDGE_AGEING_TIME <<
": " << setting.agingTime() <<
'\n';
277 dbg.
nospace() << NM_SETTING_BRIDGE_MULTICAST_SNOOPING <<
": " << setting.multicastSnooping() <<
'\n';
278 dbg.
nospace() << NM_SETTING_BRIDGE_MAC_ADDRESS <<
": " << setting.macAddress() <<
'\n';
Represents bridge setting.
QVariantMap toMap() const override
Must be reimplemented, default implementationd does nothing.
QString name() const override
Must be reimplemented, default implementationd does nothing.
void fromMap(const QVariantMap &setting) override
Must be reimplemented, default implementation does nothing.
PostalAddress address(const QVariant &location)