4c2df3c5a7
--------- - 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
178 lines
3.0 KiB
C++
178 lines
3.0 KiB
C++
#include <qendian.h>
|
|
#include <QHostAddress>
|
|
|
|
#include "sample.h"
|
|
|
|
SampleConfigForm::SampleConfigForm(QWidget *parent)
|
|
: QWidget(parent)
|
|
{
|
|
setupUi(this);
|
|
}
|
|
|
|
SampleProtocol::SampleProtocol(StreamBase *stream);
|
|
: AbstractProtocol(stream)
|
|
{
|
|
configForm = NULL;
|
|
}
|
|
|
|
SampleProtocol::~SampleProtocol()
|
|
{
|
|
delete configForm;
|
|
}
|
|
|
|
AbstractProtocol* SampleProtocol::createInstance(StreamBase *stream)
|
|
{
|
|
return new SampleProtocol(frameProtoList, streamCore);
|
|
}
|
|
|
|
quint32 SampleProtocol::protocolNumber() const
|
|
{
|
|
return OstProto::Protocol::kSampleFieldNumber;
|
|
}
|
|
|
|
void SampleProtocol::protoDataCopyInto(OstProto::Protocol &protocol) const
|
|
{
|
|
protocol.MutableExtension(OstProto::sample)->CopyFrom(data);
|
|
protocol.mutable_protocol_id()->set_id(protocolNumber())
|
|
}
|
|
|
|
void SampleProtocol::protoDataCopyFrom(const OstProto::Protocol &protocol)
|
|
{
|
|
if (protocol.protocol_id()->id() == protocolNumber() &&
|
|
protocol.HasExtension(OstProto::sample))
|
|
data.MergeFrom(protocol.GetExtension(OstProto::sample));
|
|
}
|
|
|
|
QString SampleProtocol::name() const
|
|
{
|
|
return QString("Sample");
|
|
}
|
|
|
|
QString SampleProtocol::shortName() const
|
|
{
|
|
return QString("Sample");
|
|
}
|
|
|
|
int SampleProtocol::fieldCount() const
|
|
{
|
|
return sample_fieldCount;
|
|
}
|
|
|
|
AbstractProtocol::FieldFlags SampleProtocol::fieldFlags(int index) const
|
|
{
|
|
AbstractProtocol::FieldFlags flags;
|
|
|
|
flags = AbstractProtocol::fieldFlags(index);
|
|
|
|
switch (index)
|
|
{
|
|
case sample_normal:
|
|
break;
|
|
|
|
case sample_cksum:
|
|
flags |= FieldIsCksum;
|
|
break;
|
|
|
|
case sample_meta:
|
|
flags |= FieldIsMeta;
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return flags;
|
|
}
|
|
|
|
QVariant SampleProtocol::fieldData(int index, FieldAttrib attrib,
|
|
int streamIndex) const
|
|
{
|
|
switch (index)
|
|
{
|
|
case sample_FIXME:
|
|
{
|
|
switch(attrib)
|
|
{
|
|
case FieldName:
|
|
return QString("FIXME");
|
|
case FieldValue:
|
|
return data.FIXME();
|
|
case FieldTextValue:
|
|
return QString("%1").arg(data.FIXME());
|
|
case FieldFrameValue:
|
|
return QByteArray(1, (char)(data.FIXME() & 0xF0));
|
|
case FieldBitSize:
|
|
return 4;
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
|
|
}
|
|
case sample_FIXME:
|
|
{
|
|
switch(attrib)
|
|
{
|
|
case FieldName:
|
|
return QString("FIXME");
|
|
case FieldValue:
|
|
return FIXME;
|
|
case FieldTextValue:
|
|
return QString("%1").arg(FIXME);
|
|
case FieldFrameValue:
|
|
{
|
|
QByteArray fv;
|
|
fv.resize(0);
|
|
qToBigEndian(FIXME, (uchar*) fv.data());
|
|
return fv;
|
|
}
|
|
return QByteArray(1, (char)(FIXME() & 0xF0));
|
|
case FieldBitSize:
|
|
return 4;
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
// Meta fields
|
|
|
|
case sample_FIXME:
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return AbstractProtocol::fieldData(index, attrib, streamIndex);
|
|
}
|
|
|
|
bool SampleProtocol::setFieldData(int index, const QVariant &value,
|
|
FieldAttrib attrib)
|
|
{
|
|
// FIXME
|
|
return false;
|
|
}
|
|
|
|
|
|
QWidget* SampleProtocol::configWidget()
|
|
{
|
|
if (configForm == NULL)
|
|
{
|
|
configForm = new SampleConfigForm;
|
|
loadConfigWidget();
|
|
}
|
|
|
|
return configForm;
|
|
}
|
|
|
|
void SampleProtocol::loadConfigWidget()
|
|
{
|
|
configWidget();
|
|
}
|
|
|
|
void SampleProtocol::storeConfigWidget()
|
|
{
|
|
bool isOk;
|
|
|
|
configWidget();
|
|
}
|
|
|