Device Emulation (contd.): If vlan tag count is zero, clear vlan encap

This commit is contained in:
Srivats P 2016-03-08 18:27:10 +05:30
parent db8ad92738
commit 065698369f

View File

@ -286,7 +286,7 @@ void DeviceGroupDialog::loadDeviceGroup()
void DeviceGroupDialog::storeDeviceGroup() void DeviceGroupDialog::storeDeviceGroup()
{ {
OstProto::DeviceGroup *devGrp = port_->deviceGroupByIndex(index_); OstProto::DeviceGroup *devGrp = port_->deviceGroupByIndex(index_);
int tagCount = 0; int tagCount = vlanTagCount->value();
Q_ASSERT(devGrp); Q_ASSERT(devGrp);
@ -295,7 +295,6 @@ void DeviceGroupDialog::storeDeviceGroup()
OstEmul::VlanEmulation *vlan = devGrp->mutable_encap() OstEmul::VlanEmulation *vlan = devGrp->mutable_encap()
->MutableExtension(OstEmul::vlan); ->MutableExtension(OstEmul::vlan);
vlan->clear_stack(); vlan->clear_stack();
tagCount = vlanTagCount->value();
for (int i = 0; i < tagCount; i++) { for (int i = 0; i < tagCount; i++) {
OstEmul::VlanEmulation::Vlan *v = vlan->add_stack(); OstEmul::VlanEmulation::Vlan *v = vlan->add_stack();
v->set_vlan_tag( v->set_vlan_tag(
@ -307,6 +306,9 @@ void DeviceGroupDialog::storeDeviceGroup()
v->set_tpid(vlans->item(i, kVlanTpid)->text().toUInt(NULL, 16)); v->set_tpid(vlans->item(i, kVlanTpid)->text().toUInt(NULL, 16));
} }
if (!tagCount)
devGrp->clear_encap();
devGrp->set_device_count(devicePerVlanCount->value()); devGrp->set_device_count(devicePerVlanCount->value());
OstEmul::MacEmulation *mac = devGrp->MutableExtension(OstEmul::mac); OstEmul::MacEmulation *mac = devGrp->MutableExtension(OstEmul::mac);