Pull Cleanup: Minor changes and cleanup after merging the STP protocol builder contribution - removal of compilation errors, unncessary code, trailing whitespace

This commit is contained in:
Srivats P 2015-12-17 21:15:47 +05:30
parent c3c1ca84da
commit 9cd92c47ab
9 changed files with 61 additions and 82 deletions

View File

@ -38,23 +38,11 @@ extern ProtocolWidgetFactory *OstProtocolWidgetFactory;
QSettings *appSettings;
QMainWindow *mainWindow;
#if defined(Q_OS_WIN32)
QString kGzipPathDefaultValue;
QString kDiffPathDefaultValue;
QString kAwkPathDefaultValue;
#endif
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
int exitCode;
#if defined(Q_OS_WIN32)
kGzipPathDefaultValue = app.applicationDirPath() + "/gzip.exe";
kDiffPathDefaultValue = app.applicationDirPath() + "/diff.exe";
kAwkPathDefaultValue = app.applicationDirPath() + "/gawk.exe";
#endif
app.setApplicationName("Ostinato");
app.setOrganizationName("Ostinato");
app.setProperty("version", version);

View File

@ -74,11 +74,11 @@ PdmlReader::PdmlReader(OstProto::StreamConfigList *streams)
factory_.insert("sdp", PdmlTextProtocol::createInstance);
factory_.insert("sip", PdmlTextProtocol::createInstance);
factory_.insert("smtp", PdmlTextProtocol::createInstance);
factory_.insert("stp", PdmlStpProtocol::createInstance);
factory_.insert("tcp", PdmlTcpProtocol::createInstance);
factory_.insert("udp", PdmlUdpProtocol::createInstance);
factory_.insert("udplite", PdmlUdpProtocol::createInstance);
factory_.insert("vlan", PdmlVlanProtocol::createInstance);
factory_.insert("stp", PdmlStpProtocol::createInstance);
}
PdmlReader::~PdmlReader()

View File

@ -140,7 +140,7 @@ message Protocol {
kDot2LlcFieldNumber = 206;
kDot2SnapFieldNumber = 207;
kVlanStackFieldNumber = 208;
kStpFieldNumber = 210;
kStpFieldNumber = 209;
kArpFieldNumber = 300;
kIp4FieldNumber = 301;

View File

@ -95,9 +95,9 @@ ProtocolWidgetFactory::ProtocolWidgetFactory()
OstProto::Protocol::kDot2SnapFieldNumber,
(void*) Dot2SnapConfigForm::createInstance);
OstProtocolWidgetFactory->registerProtocolConfigWidget(
OstProto::Protocol::kStpFieldNumber,
OstProto::Protocol::kStpFieldNumber,
(void*) StpConfigForm::createInstance);
// Layer 3 Protocols
OstProtocolWidgetFactory->registerProtocolConfigWidget(
OstProto::Protocol::kArpFieldNumber,

View File

@ -75,11 +75,6 @@ QString StpProtocol::shortName() const
return QString("STP");
}
AbstractProtocol::ProtocolIdType StpProtocol::protocolIdType() const
{
return ProtocolIdLlc;
}
quint32 StpProtocol::protocolId(ProtocolIdType type) const
{
switch(type)
@ -234,17 +229,17 @@ QVariant StpProtocol::fieldData(int index, FieldAttrib attrib,
case FieldName:
return QString("Root Identifier");
case FieldValue:
return (qulonglong) data_.root_id();
return (quint64) data_.root_id();
case FieldTextValue:
{
// Root ID contain two value:
// Root ID Priority(first 2 bytes)
// and Root ID MAC (last 6 bytes). (IEEE802.1D-2008)
quint16 priority = (
data_.root_id() & 0xFFFF000000000000) >> (BYTES_TO_BITS(6));
quint64 mac = data_.root_id() & 0x0000FFFFFFFFFFFF;
data_.root_id() & 0xFFFF000000000000ULL) >> (BYTES_TO_BITS(6));
quint64 mac = data_.root_id() & 0x0000FFFFFFFFFFFFULL;
return QString("Priority: %1 / MAC: %2")
.arg(QString::number(priority),
.arg(QString::number(priority),
uintToMacStr(mac));
}
case FieldFrameValue:
@ -292,15 +287,15 @@ QVariant StpProtocol::fieldData(int index, FieldAttrib attrib,
case FieldName:
return QString("Bridge Identifier");
case FieldValue:
return (qulonglong) data_.bridge_id();
return (quint64) data_.bridge_id();
case FieldTextValue:
{
// Bridge ID contain two value:
// Bridge ID Priority(first 2 bytes)
// and Bridge ID MAC (last 6 bytes). (IEEE802.1D-2008)
quint16 priority = (data_.bridge_id() & 0xFFFF000000000000
quint16 priority = (data_.bridge_id() & 0xFFFF000000000000ULL
) >> (BYTES_TO_BITS(6));
quint64 mac = data_.bridge_id() & 0x0000FFFFFFFFFFFF;
quint64 mac = data_.bridge_id() & 0x0000FFFFFFFFFFFFULL;
return QString("Priority: %1 / MAC: %2").arg(QString::number(priority),
uintToMacStr(mac));
}

View File

@ -27,34 +27,34 @@ This module is developed by PLVision <developers@plvision.eu>
/*
Stp Protocol Frame Format -
+------------------------------------+------------------+------------------+
| Protocol ID | Protocol VID | BPDU type |
| (16) | (8) | (8) |
+------------------+-----------------+------------------+------------------+
| Flags | Root Identifier ->|
| (8) | (64) ->|
+------------------+-------------------------------------------------------+
|-> Root Identifier ->|
|-> (64) ->|
+------------------+-------------------------------------------------------+
|-> Root Identifier| Root Path Cost ->|
|-> (8) | (32) ->|
+------------------+-------------------------------------------------------+
|-> Root Path Cost | Bridge Identifier ->|
|-> (32) | (64) ->|
+------------------+-------------------------------------------------------+
|-> Bridge Identifier ->|
|-> (64) ->|
+------------------+--------------------------------- --+------------------+
|-> Bridge Identif.| Port Identifier | Message Age ->|
|-> (64) | (16) | (16) ->|
+------------------+------------------------------------+------------------+
|-> Message Age | Max Age | Hello Time ->|
|-> (16) | (16) | (16) ->|
+------------------+------------------------------------+------------------+
|-> Hello Time | Forward delay |
|-> (16) | (16) |
+------------------+------------------------------------+
+------------------------------------+------------------+------------------+
| Protocol ID | Protocol VID | BPDU type |
| (16) | (8) | (8) |
+------------------+-----------------+------------------+------------------+
| Flags | Root Identifier ->|
| (8) | (64) ->|
+------------------+-------------------------------------------------------+
|-> Root Identifier ->|
|-> (64) ->|
+------------------+-------------------------------------------------------+
|-> Root Identifier| Root Path Cost ->|
|-> (8) | (32) ->|
+------------------+-------------------------------------------------------+
|-> Root Path Cost | Bridge Identifier ->|
|-> (32) | (64) ->|
+------------------+-------------------------------------------------------+
|-> Bridge Identifier ->|
|-> (64) ->|
+------------------+--------------------------------- --+------------------+
|-> Bridge Identif.| Port Identifier | Message Age ->|
|-> (64) | (16) | (16) ->|
+------------------+------------------------------------+------------------+
|-> Message Age | Max Age | Hello Time ->|
|-> (16) | (16) | (16) ->|
+------------------+------------------------------------+------------------+
|-> Hello Time | Forward delay |
|-> (16) | (16) |
+------------------+------------------------------------+
Figures in brackets represent field width in bits
*/
@ -89,7 +89,6 @@ public:
virtual void protoDataCopyInto(OstProto::Protocol &protocol) const;
virtual void protoDataCopyFrom(const OstProto::Protocol &protocol);
virtual ProtocolIdType protocolIdType() const;
virtual quint32 protocolId(ProtocolIdType type) const;
virtual QString name() const;

View File

@ -107,9 +107,6 @@
</item>
<item row="3" column="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QCheckBox" name="ui_flags_tc_check">
<property name="sizePolicy">

View File

@ -27,7 +27,7 @@ This module is developed by PLVision <developers@plvision.eu>
#define ONE_BYTE_MAX 255
#define TWO_BYTE_MAX 65535
#define FOUR_BYTE_MAX 4294967295
#define FOUR_BYTE_MAX 4294967295U
#define BIT_0 0
#define BIT_7 7
#define ONE_BIT(pos) ((unsigned int)(1 << (pos)))
@ -39,7 +39,7 @@ class UNumberValidator : public QValidator
private:
quint64 min_;
quint64 max_;
public:
UNumberValidator(quint64 min, quint64 max, QObject * parent = 0)
: QValidator(parent), min_(min), max_(max){}
@ -62,13 +62,13 @@ StpConfigForm::StpConfigForm(QWidget *parent)
QRegExp reMac("([0-9,a-f,A-F]{2,2}[:-]){5,5}[0-9,a-f,A-F]{2,2}");
setupUi(this);
QRegExpValidator *validateMACAddress =
QRegExpValidator *validateMACAddress =
new QRegExpValidator(reMac, this);
UNumberValidator *validateByte =
UNumberValidator *validateByte =
new UNumberValidator(0, ONE_BYTE_MAX, this);
UNumberValidator *validate2Byte =
UNumberValidator *validate2Byte =
new UNumberValidator(0, TWO_BYTE_MAX, this);
UNumberValidator *validate4Byte =
UNumberValidator *validate4Byte =
new UNumberValidator(0, FOUR_BYTE_MAX, this);
ui_protocol_id->setValidator(validate2Byte);
@ -129,24 +129,24 @@ void StpConfigForm::loadWidget(AbstractProtocol *proto)
ui_flags_tc_check->setChecked(flags & ONE_BIT(BIT_0));
ui_flags_tca_check->setChecked(flags & ONE_BIT(BIT_7));
// root priority value stored as the first two bytes of stp_root_id
// root priority value stored as the first two bytes of stp_root_id
// and the last 6 bytes are root MAC address (IEEE802.1D-2008)
quint64 rootId = proto->fieldData(
StpProtocol::stp_root_id,
AbstractProtocol::FieldValue
).toULongLong(&isOk);
ui_root_id->setText(
QString::number(rootId & 0x0000FFFFFFFFFFFF, BASE_HEX));
QString::number(rootId & 0x0000FFFFFFFFFFFFULL, BASE_HEX));
ui_root_id_priority->setText(QString::number(rootId >> 48));
ui_root_path_cost->setText(
proto->fieldData(
StpProtocol::stp_root_path_cost,
AbstractProtocol::FieldValue
).toString());
// bridge priority value stored as the first two bytes of stp_bridge_id
// bridge priority value stored as the first two bytes of stp_bridge_id
// and the last 6 bytes are bridge MAC address (IEEE802.1D-2008)
quint64 bridgeId = proto->fieldData(
StpProtocol::stp_bridge_id,
@ -154,7 +154,7 @@ void StpConfigForm::loadWidget(AbstractProtocol *proto)
).toULongLong(&isOk);
ui_bridge_id->setText(
QString::number(bridgeId & 0x0000FFFFFFFFFFFF, BASE_HEX));
QString::number(bridgeId & 0x0000FFFFFFFFFFFFULL, BASE_HEX));
ui_bridge_id_priority->setText(QString::number(bridgeId >> 48));
// port priority is a first byte of stp_port_id field
@ -163,7 +163,7 @@ void StpConfigForm::loadWidget(AbstractProtocol *proto)
StpProtocol::stp_port_id,
AbstractProtocol::FieldValue
).toUInt(&isOk);
ui_port_id_priority->setText(QString::number(portId >> 8));
ui_port_id_number->setText(QString::number(portId & ONE_BYTE_MAX));
@ -210,31 +210,31 @@ void StpConfigForm::storeWidget(AbstractProtocol *proto)
if (ui_flags_tca_check->isChecked()) flags = flags | ONE_BIT(BIT_7);
proto->setFieldData(StpProtocol::stp_flags, flags);
// root priority value stored as the first two bytes of stp_root_id
// root priority value stored as the first two bytes of stp_root_id
// 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;
proto->setFieldData(StpProtocol::stp_root_id, rootId);
proto->setFieldData(
StpProtocol::stp_root_path_cost,
ui_root_path_cost->text());
// bridge priority value stored as the first two bytes of stp_bridge_id
// bridge priority value stored as the first two bytes of stp_bridge_id
// 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 =
quint64 bridgeIdPrio =
ui_bridge_id_priority->text().toULongLong(&isOk) & TWO_BYTE_MAX;
quint64 bridgeId =
hexStrToUInt64(ui_bridge_id->text()) | bridgeIdPrio << 48;
proto->setFieldData(StpProtocol::stp_bridge_id, bridgeId);
// port priority is a first byte of stp_port_id field
// and port ID is a second byte (IEEE802.1D-2008)
ushort portIdPrio =
ushort portIdPrio =
ui_port_id_priority->text().toUInt(&isOk, BASE_DEC) & ONE_BYTE_MAX;
ushort portId =
ushort portId =
ui_port_id_number->text().toUInt(&isOk, BASE_DEC) & ONE_BYTE_MAX;
proto->setFieldData(StpProtocol::stp_port_id, portIdPrio << 8 | portId);
// timers

View File

@ -62,7 +62,7 @@ void PdmlStpProtocol::unknownFieldHandler(
{
bool isOk;
OstProto::Stp *stp = pbProto->MutableExtension(OstProto::stp);
if ((name == "") && (pos == ROOT_IDENTIFIER_POS))
{
stp->set_root_id(attributes.value("value").toString().