ostinato/common/dot3.cpp
Srivats P. 4c2df3c5a7 Protocols
---------
	- all protocols on allocation of a configWidget, also populate it before returning from configWidget()
	- VLAN TPID override is now correctly saved and restored from/to its widget (vlan.cpp)
	- Payload protocol returns a minimum frame value of 1 byte size (Hack to avoid crash in stream config dialog when sum of all protocol frame sizes is greater than the frame length
	- small layout changes in mac widget (mac.ui)
	- src/dst ip mask changed from 255.255.255.255 to 255.255.255.0 (ip4.proto)
	- src mac changed from u32 to u64 (mac.proto)
	- "Combo Protocol" protocol container introduced to define newer protocols as a combination of existing protocols e.g. dot2 = dot3 + llc - THIS IS NOT YET COMPLETE (comboprotocol.h)


Client/StreamConfigDialog
-------------------------
	- Advanced Protocol Selection implemented
	- Simple Protocol Selection rewritten to work alongside Advanced
	- Payload Widget is treated like any other protocol - hence it is not placedinto the dialog specially
	- Any protocol selection change (in Simple/Advanced mode) immediately triggers change in the Stream's protocolList
	- Protocol Widgets now are arranged in a toolBox on a top level tab of the dialog instead of a nested tabWidget
	- Vlan selection (Simple Mode) uses Radio buttons instead of checkboxes
	- Double Tagged (SVlan + CVlan) now works via Simple Mode
2009-09-23 14:53:26 +00:00

145 lines
2.5 KiB
C++

#include <qendian.h>
#include <QHostAddress>
#include "dot3.h"
#include "streambase.h"
#define SZ_FCS 4
Dot3ConfigForm::Dot3ConfigForm(QWidget *parent)
: QWidget(parent)
{
setupUi(this);
}
Dot3Protocol::Dot3Protocol(StreamBase *stream)
: AbstractProtocol(stream)
{
configForm = NULL;
}
Dot3Protocol::~Dot3Protocol()
{
delete configForm;
}
AbstractProtocol* Dot3Protocol::createInstance(StreamBase *stream)
{
return new Dot3Protocol(stream);
}
quint32 Dot3Protocol::protocolNumber() const
{
return OstProto::Protocol::kDot3FieldNumber;
}
void Dot3Protocol::protoDataCopyInto(OstProto::Protocol &protocol) const
{
protocol.MutableExtension(OstProto::dot3)->CopyFrom(data);
protocol.mutable_protocol_id()->set_id(protocolNumber());
}
void Dot3Protocol::protoDataCopyFrom(const OstProto::Protocol &protocol)
{
if (protocol.protocol_id().id() == protocolNumber() &&
protocol.HasExtension(OstProto::dot3))
data.MergeFrom(protocol.GetExtension(OstProto::dot3));
}
QString Dot3Protocol::name() const
{
return QString("802.3");
}
QString Dot3Protocol::shortName() const
{
return QString("802.3");
}
int Dot3Protocol::fieldCount() const
{
return dot3_fieldCount;
}
QVariant Dot3Protocol::fieldData(int index, FieldAttrib attrib,
int streamIndex) const
{
switch (index)
{
case dot3_length:
switch(attrib)
{
case FieldName:
return QString("Length");
case FieldValue:
{
quint16 len;
len = mpStream->frameLen() - SZ_FCS;
return len;
}
case FieldTextValue:
{
quint16 len;
len = mpStream->frameLen() - SZ_FCS;
return QString("%1").arg(len);
}
case FieldFrameValue:
{
quint16 len;
QByteArray fv;
len = mpStream->frameLen() - SZ_FCS;
fv.resize(2);
qToBigEndian(len, (uchar*) fv.data());
return fv;
}
default:
break;
}
break;
default:
break;
}
return AbstractProtocol::fieldData(index, attrib, streamIndex);
}
bool Dot3Protocol::setFieldData(int index, const QVariant &value,
FieldAttrib attrib)
{
// FIXME
return false;
}
QWidget* Dot3Protocol::configWidget()
{
if (configForm == NULL)
{
configForm = new Dot3ConfigForm;
loadConfigWidget();
}
return configForm;
}
void Dot3Protocol::loadConfigWidget()
{
configWidget();
configForm->leLength->setText(
fieldData(dot3_length, FieldValue).toString());
}
void Dot3Protocol::storeConfigWidget()
{
bool isOk;
configWidget();
data.set_length(configForm->leLength->text().toULong(&isOk));
}