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; QSettings *appSettings;
QMainWindow *mainWindow; QMainWindow *mainWindow;
#if defined(Q_OS_WIN32)
QString kGzipPathDefaultValue;
QString kDiffPathDefaultValue;
QString kAwkPathDefaultValue;
#endif
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
QApplication app(argc, argv); QApplication app(argc, argv);
int exitCode; 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.setApplicationName("Ostinato");
app.setOrganizationName("Ostinato"); app.setOrganizationName("Ostinato");
app.setProperty("version", version); app.setProperty("version", version);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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