NOX: SampleProtocol - separated protocol and widget as per new framework
This commit is contained in:
parent
7d3caad43c
commit
6193db495d
@ -86,7 +86,6 @@ StreamConfigDialog::StreamConfigDialog(Port &port, uint streamIndex,
|
|||||||
connect(rbL4Other, SIGNAL(toggled(bool)), rbPayloadOther, SLOT(setChecked(bool)));
|
connect(rbL4Other, SIGNAL(toggled(bool)), rbPayloadOther, SLOT(setChecked(bool)));
|
||||||
connect(rbL4Other, SIGNAL(toggled(bool)), gbPayloadProto, SLOT(setDisabled(bool)));
|
connect(rbL4Other, SIGNAL(toggled(bool)), gbPayloadProto, SLOT(setDisabled(bool)));
|
||||||
|
|
||||||
#if 0 // temp mask
|
|
||||||
// Setup valid subsequent protocols for L2 to L4 protocols
|
// Setup valid subsequent protocols for L2 to L4 protocols
|
||||||
for (int i = ProtoL2; i <= ProtoL4; i++)
|
for (int i = ProtoL2; i <= ProtoL4; i++)
|
||||||
{
|
{
|
||||||
@ -133,7 +132,6 @@ StreamConfigDialog::StreamConfigDialog(Port &port, uint streamIndex,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
mpAvailableProtocolsModel = new QStringListModel(
|
mpAvailableProtocolsModel = new QStringListModel(
|
||||||
OstProtocolManager->protocolDatabase(), this);
|
OstProtocolManager->protocolDatabase(), this);
|
||||||
|
@ -46,7 +46,6 @@ HEADERS = \
|
|||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
mac.h \
|
mac.h \
|
||||||
payload.h \
|
|
||||||
vlan.h \
|
vlan.h \
|
||||||
svlan.h \
|
svlan.h \
|
||||||
vlanstack.h \
|
vlanstack.h \
|
||||||
@ -71,11 +70,10 @@ HEADERS += \
|
|||||||
udp.h \
|
udp.h \
|
||||||
textproto.h \
|
textproto.h \
|
||||||
hexdump.h \
|
hexdump.h \
|
||||||
|
payload.h \
|
||||||
|
sample.h \
|
||||||
userscript.h
|
userscript.h
|
||||||
|
|
||||||
HEADERS1 += \
|
|
||||||
sample.h
|
|
||||||
|
|
||||||
SOURCES = \
|
SOURCES = \
|
||||||
abstractprotocol.cpp \
|
abstractprotocol.cpp \
|
||||||
crc32c.cpp \
|
crc32c.cpp \
|
||||||
@ -86,7 +84,6 @@ SOURCES = \
|
|||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
mac.cpp \
|
mac.cpp \
|
||||||
payload.cpp \
|
|
||||||
vlan.cpp \
|
vlan.cpp \
|
||||||
svlan.cpp \
|
svlan.cpp \
|
||||||
eth2.cpp \
|
eth2.cpp \
|
||||||
@ -104,11 +101,10 @@ SOURCES += \
|
|||||||
udp.cpp \
|
udp.cpp \
|
||||||
textproto.cpp \
|
textproto.cpp \
|
||||||
hexdump.cpp \
|
hexdump.cpp \
|
||||||
|
payload.cpp \
|
||||||
|
sample.cpp \
|
||||||
userscript.cpp
|
userscript.cpp
|
||||||
|
|
||||||
SOURCES1 += \
|
|
||||||
sample.cpp
|
|
||||||
|
|
||||||
QMAKE_DISTCLEAN += object_script.*
|
QMAKE_DISTCLEAN += object_script.*
|
||||||
|
|
||||||
include(../protobuf.pri)
|
include(../protobuf.pri)
|
||||||
|
@ -10,7 +10,6 @@ FORMS = \
|
|||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
mac.ui \
|
mac.ui \
|
||||||
payload.ui \
|
|
||||||
vlan.ui \
|
vlan.ui \
|
||||||
eth2.ui \
|
eth2.ui \
|
||||||
dot3.ui \
|
dot3.ui \
|
||||||
@ -25,15 +24,14 @@ FORMS += \
|
|||||||
udp.ui \
|
udp.ui \
|
||||||
textproto.ui \
|
textproto.ui \
|
||||||
hexdump.ui \
|
hexdump.ui \
|
||||||
|
payload.ui \
|
||||||
|
sample.ui \
|
||||||
userscript.ui
|
userscript.ui
|
||||||
|
|
||||||
FORMS1 += \
|
|
||||||
sample.ui
|
|
||||||
|
|
||||||
PROTOS = \
|
PROTOS = \
|
||||||
fileformat.proto
|
fileformat.proto
|
||||||
|
|
||||||
# TODO: Move fileformat related stuff into a different library
|
# TODO: Move fileformat related stuff into a different library - why?
|
||||||
HEADERS = \
|
HEADERS = \
|
||||||
ostprotolib.h \
|
ostprotolib.h \
|
||||||
abstractfileformat.h \
|
abstractfileformat.h \
|
||||||
@ -51,7 +49,6 @@ HEADERS += \
|
|||||||
comboprotocolconfig.h \
|
comboprotocolconfig.h \
|
||||||
protocolwidgetfactory.h \
|
protocolwidgetfactory.h \
|
||||||
macconfig.h \
|
macconfig.h \
|
||||||
payloadconfig.h \
|
|
||||||
vlanconfig.h \
|
vlanconfig.h \
|
||||||
svlanconfig.h \
|
svlanconfig.h \
|
||||||
vlanstackconfig.h \
|
vlanstackconfig.h \
|
||||||
@ -73,6 +70,8 @@ HEADERS += \
|
|||||||
udpconfig.h \
|
udpconfig.h \
|
||||||
textprotoconfig.h \
|
textprotoconfig.h \
|
||||||
hexdumpconfig.h \
|
hexdumpconfig.h \
|
||||||
|
payloadconfig.h \
|
||||||
|
sampleconfig.h \
|
||||||
userscriptconfig.h
|
userscriptconfig.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
@ -88,7 +87,6 @@ SOURCES += \
|
|||||||
SOURCES += \
|
SOURCES += \
|
||||||
protocolwidgetfactory.cpp \
|
protocolwidgetfactory.cpp \
|
||||||
macconfig.cpp \
|
macconfig.cpp \
|
||||||
payloadconfig.cpp \
|
|
||||||
vlanconfig.cpp \
|
vlanconfig.cpp \
|
||||||
eth2config.cpp \
|
eth2config.cpp \
|
||||||
dot3config.cpp \
|
dot3config.cpp \
|
||||||
@ -105,6 +103,8 @@ SOURCES += \
|
|||||||
udpconfig.cpp \
|
udpconfig.cpp \
|
||||||
textprotoconfig.cpp \
|
textprotoconfig.cpp \
|
||||||
hexdumpconfig.cpp \
|
hexdumpconfig.cpp \
|
||||||
|
payloadconfig.cpp \
|
||||||
|
sampleconfig.cpp \
|
||||||
userscriptconfig.cpp
|
userscriptconfig.cpp
|
||||||
|
|
||||||
QMAKE_DISTCLEAN += object_script.*
|
QMAKE_DISTCLEAN += object_script.*
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2010 Srivats P.
|
Copyright (C) 2010, 2014 Srivats P.
|
||||||
|
|
||||||
This file is part of "Ostinato"
|
This file is part of "Ostinato"
|
||||||
|
|
||||||
@ -21,20 +21,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "abstractprotocol.h"
|
#include "abstractprotocol.h"
|
||||||
|
|
||||||
#include "protocol.pb.h"
|
#include "protocol.pb.h"
|
||||||
#if 0
|
|
||||||
#include "sample.h"
|
|
||||||
#else
|
|
||||||
#include "mac.h"
|
#include "mac.h"
|
||||||
#include "payload.h"
|
|
||||||
#include "vlan.h"
|
#include "vlan.h"
|
||||||
#include "svlan.h"
|
#include "svlan.h"
|
||||||
#include "vlanstack.h"
|
#include "vlanstack.h"
|
||||||
|
|
||||||
|
// L2 Protos
|
||||||
#include "dot3.h"
|
#include "dot3.h"
|
||||||
#include "llc.h"
|
#include "llc.h"
|
||||||
#include "dot2llc.h"
|
#include "dot2llc.h"
|
||||||
#include "snap.h"
|
#include "snap.h"
|
||||||
#include "dot2snap.h"
|
#include "dot2snap.h"
|
||||||
#include "eth2.h"
|
#include "eth2.h"
|
||||||
|
|
||||||
// L3 Protos
|
// L3 Protos
|
||||||
#include "arp.h"
|
#include "arp.h"
|
||||||
#include "ip4.h"
|
#include "ip4.h"
|
||||||
@ -43,18 +43,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "ip4over6.h"
|
#include "ip4over6.h"
|
||||||
#include "ip6over4.h"
|
#include "ip6over4.h"
|
||||||
#include "ip6over6.h"
|
#include "ip6over6.h"
|
||||||
|
|
||||||
// L4 Protos
|
// L4 Protos
|
||||||
#include "icmp.h"
|
#include "icmp.h"
|
||||||
#include "igmp.h"
|
#include "igmp.h"
|
||||||
#include "mld.h"
|
#include "mld.h"
|
||||||
#include "tcp.h"
|
#include "tcp.h"
|
||||||
#include "udp.h"
|
#include "udp.h"
|
||||||
|
|
||||||
// L5 Protos
|
// L5 Protos
|
||||||
#include "textproto.h"
|
#include "textproto.h"
|
||||||
|
|
||||||
// Special Protos
|
// Special Protos
|
||||||
#include "hexdump.h"
|
#include "hexdump.h"
|
||||||
|
#include "payload.h"
|
||||||
|
#include "sample.h"
|
||||||
#include "userscript.h"
|
#include "userscript.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
ProtocolManager *OstProtocolManager;
|
ProtocolManager *OstProtocolManager;
|
||||||
|
|
||||||
@ -63,14 +67,8 @@ ProtocolManager::ProtocolManager()
|
|||||||
/*! \todo (LOW) calls to registerProtocol() should be done by the protocols
|
/*! \todo (LOW) calls to registerProtocol() should be done by the protocols
|
||||||
themselves (once this is done remove the #includes for all the protocols)
|
themselves (once this is done remove the #includes for all the protocols)
|
||||||
*/
|
*/
|
||||||
#if 0
|
|
||||||
registerProtocol(OstProto::Protocol::kSampleFieldNumber,
|
|
||||||
(void*) SampleProtocol::createInstance);
|
|
||||||
#else
|
|
||||||
registerProtocol(OstProto::Protocol::kMacFieldNumber,
|
registerProtocol(OstProto::Protocol::kMacFieldNumber,
|
||||||
(void*) MacProtocol::createInstance);
|
(void*) MacProtocol::createInstance);
|
||||||
registerProtocol(OstProto::Protocol::kPayloadFieldNumber,
|
|
||||||
(void*) PayloadProtocol::createInstance);
|
|
||||||
|
|
||||||
registerProtocol(OstProto::Protocol::kVlanFieldNumber,
|
registerProtocol(OstProto::Protocol::kVlanFieldNumber,
|
||||||
(void*) VlanProtocol::createInstance);
|
(void*) VlanProtocol::createInstance);
|
||||||
@ -128,10 +126,13 @@ ProtocolManager::ProtocolManager()
|
|||||||
// Special Protocols
|
// Special Protocols
|
||||||
registerProtocol(OstProto::Protocol::kHexDumpFieldNumber,
|
registerProtocol(OstProto::Protocol::kHexDumpFieldNumber,
|
||||||
(void*) HexDumpProtocol::createInstance);
|
(void*) HexDumpProtocol::createInstance);
|
||||||
|
registerProtocol(OstProto::Protocol::kPayloadFieldNumber,
|
||||||
|
(void*) PayloadProtocol::createInstance);
|
||||||
|
registerProtocol(OstProto::Protocol::kSampleFieldNumber,
|
||||||
|
(void*) SampleProtocol::createInstance);
|
||||||
registerProtocol(OstProto::Protocol::kUserScriptFieldNumber,
|
registerProtocol(OstProto::Protocol::kUserScriptFieldNumber,
|
||||||
(void*) UserScriptProtocol::createInstance);
|
(void*) UserScriptProtocol::createInstance);
|
||||||
|
|
||||||
#endif
|
|
||||||
populateNeighbourProtocols();
|
populateNeighbourProtocols();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,10 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "protocolwidgetfactory.h"
|
#include "protocolwidgetfactory.h"
|
||||||
|
|
||||||
#include "macconfig.h"
|
#include "macconfig.h"
|
||||||
#include "payloadconfig.h"
|
|
||||||
#include "vlanconfig.h"
|
#include "vlanconfig.h"
|
||||||
#include "svlanconfig.h"
|
#include "svlanconfig.h"
|
||||||
#include "vlanstackconfig.h"
|
#include "vlanstackconfig.h"
|
||||||
|
// L2 Protocol Widgets
|
||||||
#include "eth2config.h"
|
#include "eth2config.h"
|
||||||
#include "dot3config.h"
|
#include "dot3config.h"
|
||||||
#include "llcconfig.h"
|
#include "llcconfig.h"
|
||||||
@ -48,6 +48,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "textprotoconfig.h"
|
#include "textprotoconfig.h"
|
||||||
// Special Protocol Widgets
|
// Special Protocol Widgets
|
||||||
#include "hexdumpconfig.h"
|
#include "hexdumpconfig.h"
|
||||||
|
#include "payloadconfig.h"
|
||||||
|
#include "sampleconfig.h"
|
||||||
#include "userscriptconfig.h"
|
#include "userscriptconfig.h"
|
||||||
|
|
||||||
ProtocolWidgetFactory *OstProtocolWidgetFactory;
|
ProtocolWidgetFactory *OstProtocolWidgetFactory;
|
||||||
@ -62,9 +64,6 @@ ProtocolWidgetFactory::ProtocolWidgetFactory()
|
|||||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||||
OstProto::Protocol::kMacFieldNumber,
|
OstProto::Protocol::kMacFieldNumber,
|
||||||
(void*) MacConfigForm::createInstance);
|
(void*) MacConfigForm::createInstance);
|
||||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
|
||||||
OstProto::Protocol::kPayloadFieldNumber,
|
|
||||||
(void*) PayloadConfigForm::createInstance);
|
|
||||||
|
|
||||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||||
OstProto::Protocol::kVlanFieldNumber,
|
OstProto::Protocol::kVlanFieldNumber,
|
||||||
@ -145,6 +144,12 @@ ProtocolWidgetFactory::ProtocolWidgetFactory()
|
|||||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||||
OstProto::Protocol::kHexDumpFieldNumber,
|
OstProto::Protocol::kHexDumpFieldNumber,
|
||||||
(void*) HexDumpConfigForm::createInstance);
|
(void*) HexDumpConfigForm::createInstance);
|
||||||
|
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||||
|
OstProto::Protocol::kPayloadFieldNumber,
|
||||||
|
(void*) PayloadConfigForm::createInstance);
|
||||||
|
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||||
|
OstProto::Protocol::kSampleFieldNumber,
|
||||||
|
(void*) SampleConfigForm::createInstance);
|
||||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||||
OstProto::Protocol::kUserScriptFieldNumber,
|
OstProto::Protocol::kUserScriptFieldNumber,
|
||||||
(void*) UserScriptConfigForm::createInstance);
|
(void*) UserScriptConfigForm::createInstance);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2010 Srivats P.
|
Copyright (C) 2010, 2014 Srivats P.
|
||||||
|
|
||||||
This file is part of "Ostinato"
|
This file is part of "Ostinato"
|
||||||
|
|
||||||
@ -17,26 +17,15 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <qendian.h>
|
|
||||||
|
|
||||||
#include "sample.h"
|
#include "sample.h"
|
||||||
|
|
||||||
SampleConfigForm::SampleConfigForm(QWidget *parent)
|
|
||||||
: QWidget(parent)
|
|
||||||
{
|
|
||||||
setupUi(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
SampleProtocol::SampleProtocol(StreamBase *stream, AbstractProtocol *parent)
|
SampleProtocol::SampleProtocol(StreamBase *stream, AbstractProtocol *parent)
|
||||||
: AbstractProtocol(stream, parent)
|
: AbstractProtocol(stream, parent)
|
||||||
{
|
{
|
||||||
/* The configWidget is created lazily */
|
|
||||||
configForm = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SampleProtocol::~SampleProtocol()
|
SampleProtocol::~SampleProtocol()
|
||||||
{
|
{
|
||||||
delete configForm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractProtocol* SampleProtocol::createInstance(StreamBase *stream,
|
AbstractProtocol* SampleProtocol::createInstance(StreamBase *stream,
|
||||||
@ -97,7 +86,9 @@ quint32 SampleProtocol::protocolId(ProtocolIdType type) const
|
|||||||
{
|
{
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case ProtocolIdIp: return 1234;
|
case ProtocolIdLlc: return 0xFFFFFF;
|
||||||
|
case ProtocolIdEth: return 0xFFFF;
|
||||||
|
case ProtocolIdIp: return 0xFF;
|
||||||
default:break;
|
default:break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +111,7 @@ int SampleProtocol::fieldCount() const
|
|||||||
*/
|
*/
|
||||||
int SampleProtocol::frameFieldCount() const
|
int SampleProtocol::frameFieldCount() const
|
||||||
{
|
{
|
||||||
return 0;
|
return AbstractProtocol::frameFieldCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -384,14 +375,14 @@ bool SampleProtocol::setFieldData(int index, const QVariant &value,
|
|||||||
{
|
{
|
||||||
uint a = value.toUInt(&isOk);
|
uint a = value.toUInt(&isOk);
|
||||||
if (isOk)
|
if (isOk)
|
||||||
data.set_ab((data.ab() & 0xe000) | (a << 13));
|
data.set_ab((data.ab() & 0x1FFF) | ((a & 0x07) << 13));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case sample_b:
|
case sample_b:
|
||||||
{
|
{
|
||||||
uint b = value.toUInt(&isOk);
|
uint b = value.toUInt(&isOk);
|
||||||
if (isOk)
|
if (isOk)
|
||||||
data.set_ab((data.ab() & 0x1FFF) | b);
|
data.set_ab((data.ab() & 0xe000) | (b & 0x1FFF));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case sample_payloadLength:
|
case sample_payloadLength:
|
||||||
@ -484,63 +475,3 @@ int SampleProtocol::protocolFrameVariableCount() const
|
|||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* SampleProtocol::configWidget()
|
|
||||||
{
|
|
||||||
/* Lazy creation of the configWidget */
|
|
||||||
if (configForm == NULL)
|
|
||||||
{
|
|
||||||
configForm = new SampleConfigForm;
|
|
||||||
loadConfigWidget();
|
|
||||||
}
|
|
||||||
|
|
||||||
return configForm;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
TODO: Edit this function to load each field's data into the config Widget
|
|
||||||
|
|
||||||
See AbstractProtocol::loadConfigWidget() for more info
|
|
||||||
*/
|
|
||||||
void SampleProtocol::loadConfigWidget()
|
|
||||||
{
|
|
||||||
configWidget();
|
|
||||||
|
|
||||||
configForm->sampleA->setText(fieldData(sample_a, FieldValue).toString());
|
|
||||||
configForm->sampleB->setText(fieldData(sample_b, FieldValue).toString());
|
|
||||||
|
|
||||||
configForm->samplePayloadLength->setText(
|
|
||||||
fieldData(sample_payloadLength, FieldValue).toString());
|
|
||||||
|
|
||||||
configForm->isChecksumOverride->setChecked(
|
|
||||||
fieldData(sample_is_override_checksum, FieldValue).toBool());
|
|
||||||
configForm->sampleChecksum->setText(uintToHexStr(
|
|
||||||
fieldData(sample_checksum, FieldValue).toUInt(), 2));
|
|
||||||
|
|
||||||
configForm->sampleX->setText(fieldData(sample_x, FieldValue).toString());
|
|
||||||
configForm->sampleY->setText(fieldData(sample_y, FieldValue).toString());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
TODO: Edit this function to store each field's data from the config Widget
|
|
||||||
|
|
||||||
See AbstractProtocol::storeConfigWidget() for more info
|
|
||||||
*/
|
|
||||||
void SampleProtocol::storeConfigWidget()
|
|
||||||
{
|
|
||||||
bool isOk;
|
|
||||||
|
|
||||||
configWidget();
|
|
||||||
setFieldData(sample_a, configForm->sampleA->text());
|
|
||||||
setFieldData(sample_b, configForm->sampleB->text());
|
|
||||||
|
|
||||||
setFieldData(sample_payloadLength, configForm->samplePayloadLength->text());
|
|
||||||
setFieldData(sample_is_override_checksum,
|
|
||||||
configForm->isChecksumOverride->isChecked());
|
|
||||||
setFieldData(sample_checksum, configForm->sampleChecksum->text().toUInt(&isOk, BASE_HEX));
|
|
||||||
|
|
||||||
setFieldData(sample_x, configForm->sampleX->text());
|
|
||||||
setFieldData(sample_y, configForm->sampleY->text());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2010 Srivats P.
|
Copyright (C) 2010, 2014 Srivats P.
|
||||||
|
|
||||||
This file is part of "Ostinato"
|
This file is part of "Ostinato"
|
||||||
|
|
||||||
@ -20,10 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#ifndef _SAMPLE_H
|
#ifndef _SAMPLE_H
|
||||||
#define _SAMPLE_H
|
#define _SAMPLE_H
|
||||||
|
|
||||||
#include "sample.pb.h"
|
|
||||||
#include "ui_sample.h"
|
|
||||||
|
|
||||||
#include "abstractprotocol.h"
|
#include "abstractprotocol.h"
|
||||||
|
#include "sample.pb.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Sample Protocol Frame Format -
|
Sample Protocol Frame Format -
|
||||||
@ -34,19 +32,9 @@ Sample Protocol Frame Format -
|
|||||||
Figures in brackets represent field width in bits
|
Figures in brackets represent field width in bits
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SampleConfigForm : public QWidget, public Ui::Sample
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
SampleConfigForm(QWidget *parent = 0);
|
|
||||||
private slots:
|
|
||||||
};
|
|
||||||
|
|
||||||
class SampleProtocol : public AbstractProtocol
|
class SampleProtocol : public AbstractProtocol
|
||||||
{
|
{
|
||||||
private:
|
public:
|
||||||
OstProto::Sample data;
|
|
||||||
SampleConfigForm *configForm;
|
|
||||||
enum samplefield
|
enum samplefield
|
||||||
{
|
{
|
||||||
// Frame Fields
|
// Frame Fields
|
||||||
@ -63,7 +51,6 @@ private:
|
|||||||
sample_fieldCount
|
sample_fieldCount
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
SampleProtocol(StreamBase *stream, AbstractProtocol *parent = 0);
|
SampleProtocol(StreamBase *stream, AbstractProtocol *parent = 0);
|
||||||
virtual ~SampleProtocol();
|
virtual ~SampleProtocol();
|
||||||
|
|
||||||
@ -95,9 +82,8 @@ public:
|
|||||||
virtual bool isProtocolFrameSizeVariable() const;
|
virtual bool isProtocolFrameSizeVariable() const;
|
||||||
virtual int protocolFrameVariableCount() const;
|
virtual int protocolFrameVariableCount() const;
|
||||||
|
|
||||||
virtual QWidget* configWidget();
|
private:
|
||||||
virtual void loadConfigWidget();
|
OstProto::Sample data;
|
||||||
virtual void storeConfigWidget();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
117
common/sampleconfig.cpp
Normal file
117
common/sampleconfig.cpp
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2010, 2014 Srivats P.
|
||||||
|
|
||||||
|
This file is part of "Ostinato"
|
||||||
|
|
||||||
|
This is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "sampleconfig.h"
|
||||||
|
#include "sample.h"
|
||||||
|
|
||||||
|
SampleConfigForm::SampleConfigForm(QWidget *parent)
|
||||||
|
: AbstractProtocolConfigForm(parent)
|
||||||
|
{
|
||||||
|
setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
SampleConfigForm::~SampleConfigForm()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SampleConfigForm* SampleConfigForm::createInstance()
|
||||||
|
{
|
||||||
|
return new SampleConfigForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
TODO: Edit this function to load each field's data into the config Widget
|
||||||
|
|
||||||
|
See AbstractProtocolConfigForm::loadWidget() for more info
|
||||||
|
*/
|
||||||
|
void SampleConfigForm::loadWidget(AbstractProtocol *proto)
|
||||||
|
{
|
||||||
|
sampleA->setText(
|
||||||
|
proto->fieldData(
|
||||||
|
SampleProtocol::sample_a,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toString());
|
||||||
|
sampleB->setText(
|
||||||
|
proto->fieldData(
|
||||||
|
SampleProtocol::sample_b,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toString());
|
||||||
|
|
||||||
|
samplePayloadLength->setText(
|
||||||
|
proto->fieldData(
|
||||||
|
SampleProtocol::sample_payloadLength,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toString());
|
||||||
|
|
||||||
|
isChecksumOverride->setChecked(
|
||||||
|
proto->fieldData(
|
||||||
|
SampleProtocol::sample_is_override_checksum,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toBool());
|
||||||
|
sampleChecksum->setText(uintToHexStr(
|
||||||
|
proto->fieldData(
|
||||||
|
SampleProtocol::sample_checksum,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toUInt(), 2));
|
||||||
|
|
||||||
|
sampleX->setText(
|
||||||
|
proto->fieldData(
|
||||||
|
SampleProtocol::sample_x,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toString());
|
||||||
|
sampleY->setText(
|
||||||
|
proto->fieldData(
|
||||||
|
SampleProtocol::sample_y,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
TODO: Edit this function to store each field's data from the config Widget
|
||||||
|
|
||||||
|
See AbstractProtocolConfigForm::storeWidget() for more info
|
||||||
|
*/
|
||||||
|
void SampleConfigForm::storeWidget(AbstractProtocol *proto)
|
||||||
|
{
|
||||||
|
proto->setFieldData(
|
||||||
|
SampleProtocol::sample_a,
|
||||||
|
sampleA->text());
|
||||||
|
proto->setFieldData(
|
||||||
|
SampleProtocol::sample_b,
|
||||||
|
sampleB->text());
|
||||||
|
|
||||||
|
proto->setFieldData(
|
||||||
|
SampleProtocol::sample_payloadLength,
|
||||||
|
samplePayloadLength->text());
|
||||||
|
proto->setFieldData(
|
||||||
|
SampleProtocol::sample_is_override_checksum,
|
||||||
|
|
||||||
|
isChecksumOverride->isChecked());
|
||||||
|
proto->setFieldData(
|
||||||
|
SampleProtocol::sample_checksum,
|
||||||
|
hexStrToUInt(sampleChecksum->text()));
|
||||||
|
|
||||||
|
proto->setFieldData(
|
||||||
|
SampleProtocol::sample_x,
|
||||||
|
sampleX->text());
|
||||||
|
proto->setFieldData(
|
||||||
|
SampleProtocol::sample_y,
|
||||||
|
sampleY->text());
|
||||||
|
}
|
||||||
|
|
43
common/sampleconfig.h
Normal file
43
common/sampleconfig.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2010, 2014 Srivats P.
|
||||||
|
|
||||||
|
This file is part of "Ostinato"
|
||||||
|
|
||||||
|
This is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SAMPLE_CONFIG_H
|
||||||
|
#define _SAMPLE_CONFIG_H
|
||||||
|
|
||||||
|
#include "abstractprotocolconfig.h"
|
||||||
|
#include "ui_sample.h"
|
||||||
|
|
||||||
|
class SampleConfigForm :
|
||||||
|
public AbstractProtocolConfigForm,
|
||||||
|
private Ui::Sample
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
SampleConfigForm(QWidget *parent = 0);
|
||||||
|
virtual ~SampleConfigForm();
|
||||||
|
|
||||||
|
static SampleConfigForm* createInstance();
|
||||||
|
|
||||||
|
virtual void loadWidget(AbstractProtocol *proto);
|
||||||
|
virtual void storeWidget(AbstractProtocol *proto);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user