Fix incorrect display of STP Mac addresses

Use MacEdit instead of QLineEdit to fix and simplify. MacEdit is what
the Mac protocol uses.

Fixes #340
This commit is contained in:
Srivats P 2021-04-24 20:30:30 +05:30
parent 5f10014c23
commit c2c52d1e6d
2 changed files with 13 additions and 30 deletions

View File

@ -156,23 +156,7 @@
<item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="1">
<widget class="QLineEdit" name="ui_root_id">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="inputMask">
<string>&gt;HH HH HH HH HH HH; </string>
</property>
<property name="text">
<string> </string>
</property>
<property name="cursorPosition">
<number>17</number>
</property>
</widget>
<widget class="MacEdit" name="ui_root_id"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_11">
@ -254,11 +238,7 @@
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QLineEdit" name="ui_bridge_id">
<property name="inputMask">
<string>&gt;HH HH HH HH HH HH; </string>
</property>
</widget>
<widget class="MacEdit" name="ui_bridge_id"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_15">
@ -499,6 +479,13 @@
<tabstop>ui_hello_time</tabstop>
<tabstop>ui_forward_delay</tabstop>
</tabstops>
<customwidgets>
<customwidget>
<class>MacEdit</class>
<extends>QLineEdit</extends>
<header>macedit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -136,8 +136,7 @@ void StpConfigForm::loadWidget(AbstractProtocol *proto)
AbstractProtocol::FieldValue
).toULongLong(&isOk);
ui_root_id->setText(
QString::number(rootId & 0x0000FFFFFFFFFFFFULL, BASE_HEX));
ui_root_id->setValue(rootId & 0x0000FFFFFFFFFFFFULL);
ui_root_id_priority->setText(QString::number(rootId >> 48));
ui_root_path_cost->setText(
@ -153,8 +152,7 @@ void StpConfigForm::loadWidget(AbstractProtocol *proto)
AbstractProtocol::FieldValue
).toULongLong(&isOk);
ui_bridge_id->setText(
QString::number(bridgeId & 0x0000FFFFFFFFFFFFULL, BASE_HEX));
ui_bridge_id->setValue(bridgeId & 0x0000FFFFFFFFFFFFULL);
ui_bridge_id_priority->setText(QString::number(bridgeId >> 48));
// port priority is a first byte of stp_port_id field
@ -214,8 +212,7 @@ void StpConfigForm::storeWidget(AbstractProtocol *proto)
// and the last 6 bytes are root MAC address (IEEE802.1D-2008)
quint64 rootIdPrio = ui_root_id_priority->text()
.toULongLong(&isOk) & TWO_BYTE_MAX;
quint64 rootId = hexStrToUInt64(
ui_root_id->text()) | rootIdPrio << 48;
quint64 rootId = ui_root_id->value() | (rootIdPrio << 48);
proto->setFieldData(StpProtocol::stp_root_id, rootId);
proto->setFieldData(
@ -226,8 +223,7 @@ void StpConfigForm::storeWidget(AbstractProtocol *proto)
// and the last 6 bytes are bridge MAC address (IEEE802.1D-2008)
quint64 bridgeIdPrio =
ui_bridge_id_priority->text().toULongLong(&isOk) & TWO_BYTE_MAX;
quint64 bridgeId =
hexStrToUInt64(ui_bridge_id->text()) | bridgeIdPrio << 48;
quint64 bridgeId = ui_bridge_id->value() | (bridgeIdPrio << 48);
proto->setFieldData(StpProtocol::stp_bridge_id, bridgeId);
// port priority is a first byte of stp_port_id field