7#include "ovsbridgesetting.h"
8#include "ovsbridgesetting_p.h"
12#if !NM_CHECK_VERSION(1, 10, 0)
13#define NM_SETTING_OVS_BRIDGE_SETTING_NAME "ovs-bridge"
14#define NM_SETTING_OVS_BRIDGE_FAIL_MODE "fail-mode"
15#define NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE "mcast-snooping-enable"
16#define NM_SETTING_OVS_BRIDGE_RSTP_ENABLE "rstp-enable"
17#define NM_SETTING_OVS_BRIDGE_STP_ENABLE "stp-enable"
20NetworkManager::OvsBridgeSettingPrivate::OvsBridgeSettingPrivate()
21 : name(NM_SETTING_OVS_BRIDGE_SETTING_NAME)
22 , mcastSnoopingEnable(false)
28NetworkManager::OvsBridgeSetting::OvsBridgeSetting()
29 : Setting(Setting::OvsBridge)
30 , d_ptr(new OvsBridgeSettingPrivate())
34NetworkManager::OvsBridgeSetting::OvsBridgeSetting(
const Ptr &other)
36 , d_ptr(new OvsBridgeSettingPrivate())
38 setFailMode(other->failMode());
39 setMcastSnoopingEnable(other->mcastSnoopingEnable());
40 setRstpEnable(other->rstpEnable());
41 setStpEnable(other->stpEnable());
44NetworkManager::OvsBridgeSetting::~OvsBridgeSetting()
56void NetworkManager::OvsBridgeSetting::setMcastSnoopingEnable(
bool mcastSnoopingEnable)
60 d->mcastSnoopingEnable = mcastSnoopingEnable;
63bool NetworkManager::OvsBridgeSetting::mcastSnoopingEnable()
const
65 Q_D(
const OvsBridgeSetting);
67 return d->mcastSnoopingEnable;
70void NetworkManager::OvsBridgeSetting::setRstpEnable(
bool rstpEnable)
72 Q_D(OvsBridgeSetting);
74 d->rstpEnable = rstpEnable;
77bool NetworkManager::OvsBridgeSetting::rstpEnable()
const
79 Q_D(
const OvsBridgeSetting);
84void NetworkManager::OvsBridgeSetting::setStpEnable(
bool stpEnable)
86 Q_D(OvsBridgeSetting);
88 d->stpEnable = stpEnable;
91bool NetworkManager::OvsBridgeSetting::stpEnable()
const
93 Q_D(
const OvsBridgeSetting);
98void NetworkManager::OvsBridgeSetting::setFailMode(
const QString &mode)
100 Q_D(OvsBridgeSetting);
105QString NetworkManager::OvsBridgeSetting::failMode()
const
107 Q_D(
const OvsBridgeSetting);
114 if (setting.contains(
QLatin1String(NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE))) {
115 setMcastSnoopingEnable(setting.value(
QLatin1String(NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE)).toBool());
118 if (setting.contains(
QLatin1String(NM_SETTING_OVS_BRIDGE_RSTP_ENABLE))) {
119 setRstpEnable(setting.value(
QLatin1String(NM_SETTING_OVS_BRIDGE_RSTP_ENABLE)).toBool());
122 if (setting.contains(
QLatin1String(NM_SETTING_OVS_BRIDGE_STP_ENABLE))) {
123 setStpEnable(setting.value(
QLatin1String(NM_SETTING_OVS_BRIDGE_STP_ENABLE)).toBool());
126 if (setting.contains(
QLatin1String(NM_SETTING_OVS_BRIDGE_FAIL_MODE))) {
127 setFailMode(setting.value(
QLatin1String(NM_SETTING_OVS_BRIDGE_FAIL_MODE)).toString());
135 setting.insert(
QLatin1String(NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE), mcastSnoopingEnable());
136 setting.insert(
QLatin1String(NM_SETTING_OVS_BRIDGE_RSTP_ENABLE), rstpEnable());
137 setting.insert(
QLatin1String(NM_SETTING_OVS_BRIDGE_STP_ENABLE), stpEnable());
139 if (!failMode().isEmpty()) {
140 setting.insert(
QLatin1String(NM_SETTING_OVS_BRIDGE_FAIL_MODE), failMode());
148 dbg.
nospace() <<
"type: " << setting.typeAsString(setting.type()) <<
'\n';
149 dbg.
nospace() <<
"initialized: " << !setting.isNull() <<
'\n';
151 dbg.
nospace() << NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE <<
": " << setting.mcastSnoopingEnable() <<
'\n';
152 dbg.
nospace() << NM_SETTING_OVS_BRIDGE_RSTP_ENABLE <<
": " << setting.rstpEnable() <<
'\n';
153 dbg.
nospace() << NM_SETTING_OVS_BRIDGE_STP_ENABLE <<
": " << setting.stpEnable() <<
'\n';
154 dbg.
nospace() << NM_SETTING_OVS_BRIDGE_FAIL_MODE <<
": " << setting.failMode() <<
'\n';
Represents ovs-bridge setting.
void fromMap(const QVariantMap &setting) override
Must be reimplemented, default implementation does nothing.
QString name() const override
Must be reimplemented, default implementationd does nothing.
QVariantMap toMap() const override
Must be reimplemented, default implementationd does nothing.