2008-05-03 09:37:10 -05:00
|
|
|
#include <QHostAddress>
|
|
|
|
#include "streamconfigdialog.h"
|
|
|
|
#include "stream.h"
|
|
|
|
|
2008-05-25 06:30:30 -05:00
|
|
|
#include "modeltest.h"
|
|
|
|
|
2009-04-05 02:19:37 -05:00
|
|
|
int StreamConfigDialog::lastTopLevelTabIndex = 0;
|
|
|
|
int StreamConfigDialog::lastProtoTabIndex = 0;
|
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
// TODO(HI): Write HexLineEdit::setNum() and num() and use it in
|
|
|
|
// Load/Store stream methods
|
|
|
|
|
|
|
|
StreamConfigDialog::StreamConfigDialog(Port &port, uint streamIndex,
|
|
|
|
QWidget *parent) : QDialog (parent), mPort(port)
|
2008-05-03 09:37:10 -05:00
|
|
|
{
|
2009-04-27 11:51:44 -05:00
|
|
|
mCurrentStreamIndex = streamIndex;
|
|
|
|
|
|
|
|
mpStream = new Stream;
|
|
|
|
mpStream->protoDataCopyFrom(*(mPort.streamByIndex(mCurrentStreamIndex)));
|
|
|
|
|
2008-05-03 09:37:10 -05:00
|
|
|
setupUi(this);
|
|
|
|
setupUiExtra();
|
2008-10-05 12:07:33 -05:00
|
|
|
|
|
|
|
// setupUi
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-09-28 13:01:52 -05:00
|
|
|
// Time to play match the signals and slots!
|
|
|
|
connect(rbFtNone, SIGNAL(toggled(bool)), rbL3None, SLOT(setChecked(bool)));
|
|
|
|
|
|
|
|
// Show/Hide FrameType related inputs for FT None
|
|
|
|
connect(rbFtNone, SIGNAL(toggled(bool)), lblDsap, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFtNone, SIGNAL(toggled(bool)), leDsap, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFtNone, SIGNAL(toggled(bool)), lblSsap, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFtNone, SIGNAL(toggled(bool)), leSsap, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFtNone, SIGNAL(toggled(bool)), lblControl, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFtNone, SIGNAL(toggled(bool)), leControl, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFtNone, SIGNAL(toggled(bool)), lblOui, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFtNone, SIGNAL(toggled(bool)), leOui, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFtNone, SIGNAL(toggled(bool)), lblType, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFtNone, SIGNAL(toggled(bool)), leType, SLOT(setHidden(bool)));
|
|
|
|
|
2008-10-05 12:07:33 -05:00
|
|
|
// Enable/Disable L3 Protocol Choices for FT None
|
|
|
|
connect(rbFtNone, SIGNAL(toggled(bool)), rbL3None, SLOT(setEnabled(bool)));
|
|
|
|
connect(rbFtNone, SIGNAL(toggled(bool)), rbL3Ipv4, SLOT(setDisabled(bool)));
|
|
|
|
connect(rbFtNone, SIGNAL(toggled(bool)), rbL3Arp, SLOT(setDisabled(bool)));
|
|
|
|
|
2008-09-28 13:01:52 -05:00
|
|
|
// Show/Hide FrameType related inputs for FT Ethernet2
|
|
|
|
connect(rbFtEthernet2, SIGNAL(toggled(bool)), lblDsap, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFtEthernet2, SIGNAL(toggled(bool)), leDsap, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFtEthernet2, SIGNAL(toggled(bool)), lblSsap, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFtEthernet2, SIGNAL(toggled(bool)), leSsap, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFtEthernet2, SIGNAL(toggled(bool)), lblControl, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFtEthernet2, SIGNAL(toggled(bool)), leControl, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFtEthernet2, SIGNAL(toggled(bool)), lblOui, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFtEthernet2, SIGNAL(toggled(bool)), leOui, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFtEthernet2, SIGNAL(toggled(bool)), lblType, SLOT(setVisible(bool)));
|
|
|
|
connect(rbFtEthernet2, SIGNAL(toggled(bool)), leType, SLOT(setVisible(bool)));
|
|
|
|
|
2008-10-05 12:07:33 -05:00
|
|
|
// Enable/Disable L3 Protocol Choices for FT Ethernet2
|
|
|
|
connect(rbFtEthernet2, SIGNAL(toggled(bool)), rbL3None, SLOT(setEnabled(bool)));
|
|
|
|
connect(rbFtEthernet2, SIGNAL(toggled(bool)), rbL3Ipv4, SLOT(setEnabled(bool)));
|
|
|
|
connect(rbFtEthernet2, SIGNAL(toggled(bool)), rbL3Arp, SLOT(setEnabled(bool)));
|
|
|
|
|
2008-09-28 13:01:52 -05:00
|
|
|
// Show/Hide FrameType related inputs for FT 802.3 Raw
|
|
|
|
connect(rbFt802Dot3Raw, SIGNAL(toggled(bool)), lblDsap, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFt802Dot3Raw, SIGNAL(toggled(bool)), leDsap, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFt802Dot3Raw, SIGNAL(toggled(bool)), lblSsap, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFt802Dot3Raw, SIGNAL(toggled(bool)), leSsap, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFt802Dot3Raw, SIGNAL(toggled(bool)), lblControl, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFt802Dot3Raw, SIGNAL(toggled(bool)), leControl, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFt802Dot3Raw, SIGNAL(toggled(bool)), lblOui, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFt802Dot3Raw, SIGNAL(toggled(bool)), leOui, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFt802Dot3Raw, SIGNAL(toggled(bool)), lblType, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFt802Dot3Raw, SIGNAL(toggled(bool)), leType, SLOT(setHidden(bool)));
|
|
|
|
|
2008-10-05 12:07:33 -05:00
|
|
|
// Force L3 = None if FT = 802.3 Raw
|
|
|
|
connect(rbFt802Dot3Raw, SIGNAL(toggled(bool)), rbL3None, SLOT(setChecked(bool)));
|
|
|
|
|
|
|
|
// Enable/Disable L3 Protocol Choices for FT 802Dot3Raw
|
|
|
|
connect(rbFt802Dot3Raw, SIGNAL(toggled(bool)), rbL3None, SLOT(setEnabled(bool)));
|
|
|
|
connect(rbFt802Dot3Raw, SIGNAL(toggled(bool)), rbL3Ipv4, SLOT(setDisabled(bool)));
|
|
|
|
connect(rbFt802Dot3Raw, SIGNAL(toggled(bool)), rbL3Arp, SLOT(setDisabled(bool)));
|
|
|
|
|
2008-09-28 13:01:52 -05:00
|
|
|
// Show/Hide FrameType related inputs for FT 802.3 LLC
|
|
|
|
connect(rbFt802Dot3Llc, SIGNAL(toggled(bool)), lblDsap, SLOT(setVisible(bool)));
|
|
|
|
connect(rbFt802Dot3Llc, SIGNAL(toggled(bool)), leDsap, SLOT(setVisible(bool)));
|
|
|
|
connect(rbFt802Dot3Llc, SIGNAL(toggled(bool)), lblSsap, SLOT(setVisible(bool)));
|
|
|
|
connect(rbFt802Dot3Llc, SIGNAL(toggled(bool)), leSsap, SLOT(setVisible(bool)));
|
|
|
|
connect(rbFt802Dot3Llc, SIGNAL(toggled(bool)), lblControl, SLOT(setVisible(bool)));
|
|
|
|
connect(rbFt802Dot3Llc, SIGNAL(toggled(bool)), leControl, SLOT(setVisible(bool)));
|
|
|
|
connect(rbFt802Dot3Llc, SIGNAL(toggled(bool)), lblOui, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFt802Dot3Llc, SIGNAL(toggled(bool)), leOui, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFt802Dot3Llc, SIGNAL(toggled(bool)), lblType, SLOT(setHidden(bool)));
|
|
|
|
connect(rbFt802Dot3Llc, SIGNAL(toggled(bool)), leType, SLOT(setHidden(bool)));
|
|
|
|
|
2008-10-05 12:07:33 -05:00
|
|
|
// Force L3 = None if FT = 802.3 LLC (to ensure a valid L3 is selected)
|
|
|
|
connect(rbFt802Dot3Llc, SIGNAL(toggled(bool)), rbL3None, SLOT(setChecked(bool)));
|
|
|
|
|
|
|
|
// Enable/Disable L3 Protocol Choices for FT 802Dot3Llc
|
|
|
|
connect(rbFt802Dot3Llc, SIGNAL(toggled(bool)), rbL3None, SLOT(setEnabled(bool)));
|
|
|
|
connect(rbFt802Dot3Llc, SIGNAL(toggled(bool)), rbL3Ipv4, SLOT(setEnabled(bool)));
|
|
|
|
connect(rbFt802Dot3Llc, SIGNAL(toggled(bool)), rbL3Arp, SLOT(setDisabled(bool)));
|
|
|
|
|
2008-09-28 13:01:52 -05:00
|
|
|
// Show/Hide FrameType related inputs for FT 802.3 LLC SNAP
|
|
|
|
connect(rbFtLlcSnap, SIGNAL(toggled(bool)), lblDsap, SLOT(setVisible(bool)));
|
|
|
|
connect(rbFtLlcSnap, SIGNAL(toggled(bool)), leDsap, SLOT(setVisible(bool)));
|
|
|
|
connect(rbFtLlcSnap, SIGNAL(toggled(bool)), lblSsap, SLOT(setVisible(bool)));
|
|
|
|
connect(rbFtLlcSnap, SIGNAL(toggled(bool)), leSsap, SLOT(setVisible(bool)));
|
|
|
|
connect(rbFtLlcSnap, SIGNAL(toggled(bool)), lblControl, SLOT(setVisible(bool)));
|
|
|
|
connect(rbFtLlcSnap, SIGNAL(toggled(bool)), leControl, SLOT(setVisible(bool)));
|
|
|
|
connect(rbFtLlcSnap, SIGNAL(toggled(bool)), lblOui, SLOT(setVisible(bool)));
|
|
|
|
connect(rbFtLlcSnap, SIGNAL(toggled(bool)), leOui, SLOT(setVisible(bool)));
|
|
|
|
connect(rbFtLlcSnap, SIGNAL(toggled(bool)), lblType, SLOT(setVisible(bool)));
|
|
|
|
connect(rbFtLlcSnap, SIGNAL(toggled(bool)), leType, SLOT(setVisible(bool)));
|
|
|
|
|
2008-10-05 12:07:33 -05:00
|
|
|
// Enable/Disable L3 Protocol Choices for FT 802.3 LLC SNAP
|
|
|
|
connect(rbFtLlcSnap, SIGNAL(toggled(bool)), rbL3None, SLOT(setEnabled(bool)));
|
|
|
|
connect(rbFtLlcSnap, SIGNAL(toggled(bool)), rbL3Ipv4, SLOT(setEnabled(bool)));
|
|
|
|
connect(rbFtLlcSnap, SIGNAL(toggled(bool)), rbL3Arp, SLOT(setEnabled(bool)));
|
|
|
|
|
2008-09-28 13:01:52 -05:00
|
|
|
// Enable/Disable FrameType related inputs for FT 802.3 LLC SNAP
|
|
|
|
connect(rbFtLlcSnap, SIGNAL(toggled(bool)), lblDsap, SLOT(setDisabled(bool)));
|
|
|
|
connect(rbFtLlcSnap, SIGNAL(toggled(bool)), leDsap, SLOT(setDisabled(bool)));
|
|
|
|
connect(rbFtLlcSnap, SIGNAL(toggled(bool)), lblSsap, SLOT(setDisabled(bool)));
|
|
|
|
connect(rbFtLlcSnap, SIGNAL(toggled(bool)), leSsap, SLOT(setDisabled(bool)));
|
|
|
|
connect(rbFtLlcSnap, SIGNAL(toggled(bool)), lblControl, SLOT(setDisabled(bool)));
|
|
|
|
connect(rbFtLlcSnap, SIGNAL(toggled(bool)), leControl, SLOT(setDisabled(bool)));
|
|
|
|
|
|
|
|
// Enable/Disable L4 Protocol Choices for L3 Protocol None
|
|
|
|
connect(rbL3None, SIGNAL(toggled(bool)), rbL4None, SLOT(setEnabled(bool)));
|
|
|
|
connect(rbL3None, SIGNAL(toggled(bool)), rbL4Icmp, SLOT(setDisabled(bool)));
|
|
|
|
connect(rbL3None, SIGNAL(toggled(bool)), rbL4Igmp, SLOT(setDisabled(bool)));
|
|
|
|
connect(rbL3None, SIGNAL(toggled(bool)), rbL4Tcp, SLOT(setDisabled(bool)));
|
|
|
|
connect(rbL3None, SIGNAL(toggled(bool)), rbL4Udp, SLOT(setDisabled(bool)));
|
|
|
|
|
|
|
|
// Force L4 Protocol = None if L3 Protocol is set to None
|
|
|
|
connect(rbL3None, SIGNAL(toggled(bool)), rbL4None, SLOT(setChecked(bool)));
|
|
|
|
|
|
|
|
// Enable/Disable L4 Protocol Choices for L3 Protocol IPv4
|
|
|
|
connect(rbL3Ipv4, SIGNAL(toggled(bool)), rbL4None, SLOT(setEnabled(bool)));
|
|
|
|
connect(rbL3Ipv4, SIGNAL(toggled(bool)), rbL4Icmp, SLOT(setEnabled(bool)));
|
|
|
|
connect(rbL3Ipv4, SIGNAL(toggled(bool)), rbL4Igmp, SLOT(setEnabled(bool)));
|
|
|
|
connect(rbL3Ipv4, SIGNAL(toggled(bool)), rbL4Tcp, SLOT(setEnabled(bool)));
|
|
|
|
connect(rbL3Ipv4, SIGNAL(toggled(bool)), rbL4Udp, SLOT(setEnabled(bool)));
|
|
|
|
|
|
|
|
// Enable/Disable L4 Protocol Choices for L3 Protocol ARP
|
|
|
|
connect(rbL3Arp, SIGNAL(toggled(bool)), rbL4None, SLOT(setEnabled(bool)));
|
|
|
|
connect(rbL3Arp, SIGNAL(toggled(bool)), rbL4Icmp, SLOT(setDisabled(bool)));
|
|
|
|
connect(rbL3Arp, SIGNAL(toggled(bool)), rbL4Igmp, SLOT(setDisabled(bool)));
|
|
|
|
connect(rbL3Arp, SIGNAL(toggled(bool)), rbL4Tcp, SLOT(setDisabled(bool)));
|
|
|
|
connect(rbL3Arp, SIGNAL(toggled(bool)), rbL4Udp, SLOT(setDisabled(bool)));
|
|
|
|
|
|
|
|
// Force L4 Protocol = None if L3 Protocol is set to ARP
|
|
|
|
connect(rbL3Arp, SIGNAL(toggled(bool)), rbL4None, SLOT(setChecked(bool)));
|
|
|
|
|
2008-10-05 12:07:33 -05:00
|
|
|
//TODO: remove if not needed
|
|
|
|
#if 0
|
|
|
|
// This set of 'clicks' is a hack to trigger signals at dialog creation
|
|
|
|
// time so that a coherent 'set' is initialized
|
|
|
|
// Actual stream values will be initialized by LoadCurrentStream()
|
|
|
|
rbL3Ipv4->click();
|
|
|
|
rbL3None->click();
|
2008-09-28 13:01:52 -05:00
|
|
|
rbFtEthernet2->click();
|
|
|
|
rbFtNone->click();
|
2008-10-05 12:07:33 -05:00
|
|
|
#endif
|
2008-09-28 13:01:52 -05:00
|
|
|
|
2009-04-27 11:51:44 -05:00
|
|
|
//mmpStreamList = streamList;
|
2008-05-03 09:37:10 -05:00
|
|
|
LoadCurrentStream();
|
2009-04-27 11:51:44 -05:00
|
|
|
mpPacketModel = new PacketModel(QList<AbstractProtocol*>(), this);
|
2008-05-25 06:30:30 -05:00
|
|
|
tvPacketTree->setModel(mpPacketModel);
|
|
|
|
mpPacketModelTester = new ModelTest(mpPacketModel);
|
|
|
|
tvPacketTree->header()->hide();
|
2008-08-30 03:49:08 -05:00
|
|
|
vwPacketDump->setModel(mpPacketModel);
|
|
|
|
vwPacketDump->setSelectionModel(tvPacketTree->selectionModel());
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-09-28 13:01:52 -05:00
|
|
|
// TODO(MED):
|
|
|
|
//! \todo Enable navigation of streams
|
2008-08-23 23:39:08 -05:00
|
|
|
pbPrev->setDisabled(true);
|
|
|
|
pbNext->setDisabled(true);
|
2008-09-28 13:01:52 -05:00
|
|
|
//! \todo Support Goto Stream Id
|
2009-03-10 11:48:03 -05:00
|
|
|
leStreamId->setDisabled(true);
|
|
|
|
disconnect(rbActionGotoStream, SIGNAL(toggled(bool)), leStreamId, SLOT(setEnabled(bool)));
|
2008-09-28 13:01:52 -05:00
|
|
|
//! \todo Support Continuous Mode
|
|
|
|
rbModeContinuous->setDisabled(true);
|
2009-04-05 02:19:37 -05:00
|
|
|
// Finally, restore the saved last selected tab for the various tab widgets
|
|
|
|
twTopLevel->setCurrentIndex(lastTopLevelTabIndex);
|
|
|
|
if (twProto->isTabEnabled(lastProtoTabIndex))
|
|
|
|
twProto->setCurrentIndex(lastProtoTabIndex);
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void StreamConfigDialog::setupUiExtra()
|
|
|
|
{
|
|
|
|
QRegExp reHex2B("[0-9,a-f,A-F]{1,4}");
|
|
|
|
QRegExp reHex4B("[0-9,a-f,A-F]{1,8}");
|
|
|
|
QRegExp reMac("([0-9,a-f,A-F]{2,2}[:-]){5,5}[0-9,a-f,A-F]{2,2}");
|
|
|
|
|
2009-04-27 11:51:44 -05:00
|
|
|
// Add the Payload widget to the dialog
|
|
|
|
{
|
|
|
|
QGridLayout *layout;
|
|
|
|
|
|
|
|
layout = static_cast<QGridLayout*>(twTopLevel->widget(0)->layout());
|
|
|
|
|
|
|
|
layout->addWidget(mpStream->protocolById(52)->configWidget(), 0, 1);
|
|
|
|
qDebug("setupUi wgt = %p", mpStream->protocolById(52)->configWidget());
|
|
|
|
}
|
|
|
|
|
2008-10-05 12:07:33 -05:00
|
|
|
// ---- Setup default stuff that cannot be done in designer ----
|
|
|
|
|
|
|
|
// Since the dialog defaults are FT = None, L3 = None, L4 = None;
|
|
|
|
// hide associated input fields since it can't be done in Designer
|
|
|
|
lblDsap->setHidden(true);
|
|
|
|
leDsap->setHidden(true);
|
|
|
|
lblSsap->setHidden(true);
|
|
|
|
leSsap->setHidden(true);
|
|
|
|
lblControl->setHidden(true);
|
|
|
|
leControl->setHidden(true);
|
|
|
|
lblOui->setHidden(true);
|
|
|
|
leOui->setHidden(true);
|
|
|
|
lblType->setHidden(true);
|
|
|
|
leType->setHidden(true);
|
|
|
|
|
2008-05-03 09:37:10 -05:00
|
|
|
twProto->setTabEnabled(2, FALSE);
|
|
|
|
twProto->setTabEnabled(3, FALSE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Setup Validators
|
|
|
|
*/
|
|
|
|
// Meta Data
|
|
|
|
lePktLen->setValidator(new QIntValidator(MIN_PKT_LEN, MAX_PKT_LEN, this));
|
|
|
|
|
|
|
|
// L2 Ethernet
|
2009-04-27 11:51:44 -05:00
|
|
|
#if 0 // Proto FW
|
2008-05-03 09:37:10 -05:00
|
|
|
leDstMac->setValidator(new QRegExpValidator(reMac, this));
|
|
|
|
leSrcMac->setValidator(new QRegExpValidator(reMac, this));
|
|
|
|
leDstMacCount->setValidator(new QIntValidator(1, MAX_MAC_ITER_COUNT, this));
|
|
|
|
leSrcMacCount->setValidator(new QIntValidator(1, MAX_MAC_ITER_COUNT, this));
|
|
|
|
leCvlanTpid->setValidator(new QRegExpValidator(reHex2B, this));
|
|
|
|
leSvlanTpid->setValidator(new QRegExpValidator(reHex2B, this));
|
|
|
|
//leEtherType->setValidator(new QRegExpValidator(reHex2B, this));
|
2009-04-27 11:51:44 -05:00
|
|
|
#endif
|
2008-05-03 09:37:10 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Setup Connections
|
|
|
|
*/
|
|
|
|
connect(rbSendPackets, SIGNAL(toggled(bool)),
|
|
|
|
this, SLOT(update_NumPacketsAndNumBursts()));
|
|
|
|
connect(rbSendBursts, SIGNAL(toggled(bool)),
|
|
|
|
this, SLOT(update_NumPacketsAndNumBursts()));
|
|
|
|
connect(rbModeFixed, SIGNAL(toggled(bool)),
|
|
|
|
this, SLOT(update_NumPacketsAndNumBursts()));
|
|
|
|
connect(rbModeContinuous, SIGNAL(toggled(bool)),
|
|
|
|
this, SLOT(update_NumPacketsAndNumBursts()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
StreamConfigDialog::~StreamConfigDialog()
|
|
|
|
{
|
2008-05-25 06:30:30 -05:00
|
|
|
delete mpPacketModelTester;
|
|
|
|
delete mpPacketModel;
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2009-04-27 11:51:44 -05:00
|
|
|
// Remove payload data widget so that it is not deleted when this object
|
|
|
|
// is destroyed
|
2008-10-05 12:07:33 -05:00
|
|
|
{
|
2009-04-27 11:51:44 -05:00
|
|
|
QLayout *layout = twTopLevel->widget(0)->layout();
|
|
|
|
if (layout)
|
|
|
|
{
|
|
|
|
qDebug("dstrct wgt = %p", mpStream->protocolById(52)->configWidget());
|
|
|
|
#if 0
|
|
|
|
int i = layout->indexOf(mpStream->protocolById(52)->configWidget());
|
|
|
|
if (i >= 0)
|
|
|
|
{
|
|
|
|
layout->takeAt(i);
|
|
|
|
mpStream->protocolById(52)->configWidget()->setParent(0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
layout->removeWidget(mpStream->protocolById(52)->configWidget());
|
|
|
|
mpStream->protocolById(52)->configWidget()->setParent(0);
|
|
|
|
|
|
|
|
}
|
2008-10-05 12:07:33 -05:00
|
|
|
}
|
2009-04-27 11:51:44 -05:00
|
|
|
|
|
|
|
// Remove any existing widget on the L2-L4 Tabs lest they are deleted
|
|
|
|
// when this object is destoryed
|
|
|
|
for (int i = 1; i <= 3; i++)
|
2008-10-05 12:07:33 -05:00
|
|
|
{
|
2009-04-27 11:51:44 -05:00
|
|
|
QLayout *layout = twProto->widget(i)->layout();
|
|
|
|
if (layout)
|
|
|
|
{
|
|
|
|
QLayoutItem *child;
|
|
|
|
while ((child = layout->takeAt(0)) != 0)
|
|
|
|
{
|
|
|
|
Q_ASSERT(child->widget() != 0);
|
|
|
|
// Don't delete the child widget - reparent it
|
|
|
|
child->widget()->setParent(0);
|
|
|
|
}
|
|
|
|
delete layout;
|
|
|
|
}
|
2008-10-05 12:07:33 -05:00
|
|
|
}
|
2009-04-27 11:51:44 -05:00
|
|
|
|
|
|
|
delete mpStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
void StreamConfigDialog::updateSelectedProtocols()
|
|
|
|
{
|
|
|
|
mSelectedProtocols.clear();
|
|
|
|
|
|
|
|
// FIXME: Hardcoded numbers!
|
|
|
|
|
|
|
|
// Mac
|
|
|
|
mSelectedProtocols.append(51);
|
|
|
|
|
|
|
|
if (rbFtEthernet2->isChecked())
|
|
|
|
mSelectedProtocols.append(121);
|
|
|
|
else if (rbFt802Dot3Raw->isChecked())
|
|
|
|
mSelectedProtocols.append(122);
|
|
|
|
else if (rbFt802Dot3Llc->isChecked())
|
2008-10-05 12:07:33 -05:00
|
|
|
{
|
2009-04-27 11:51:44 -05:00
|
|
|
mSelectedProtocols.append(122);
|
|
|
|
mSelectedProtocols.append(123);
|
2008-10-05 12:07:33 -05:00
|
|
|
}
|
2009-04-27 11:51:44 -05:00
|
|
|
else if (rbFtLlcSnap->isChecked())
|
2008-10-05 12:07:33 -05:00
|
|
|
{
|
2009-04-27 11:51:44 -05:00
|
|
|
mSelectedProtocols.append(122);
|
|
|
|
mSelectedProtocols.append(123);
|
|
|
|
mSelectedProtocols.append(124);
|
2008-10-05 12:07:33 -05:00
|
|
|
}
|
2009-04-27 11:51:44 -05:00
|
|
|
|
|
|
|
if (rbL3Ipv4->isChecked())
|
|
|
|
mSelectedProtocols.append(130);
|
|
|
|
else if (rbL3Arp->isChecked())
|
|
|
|
mSelectedProtocols.append(131);
|
|
|
|
|
|
|
|
if (rbL4Tcp->isChecked())
|
|
|
|
mSelectedProtocols.append(140);
|
|
|
|
else if (rbL4Udp->isChecked())
|
|
|
|
mSelectedProtocols.append(141);
|
|
|
|
else if (rbL4Icmp->isChecked())
|
|
|
|
mSelectedProtocols.append(142);
|
|
|
|
else if (rbL4Igmp->isChecked())
|
|
|
|
mSelectedProtocols.append(143);
|
|
|
|
|
|
|
|
// Payload
|
|
|
|
mSelectedProtocols.append(52);
|
2008-10-05 12:07:33 -05:00
|
|
|
}
|
2009-04-27 11:51:44 -05:00
|
|
|
|
|
|
|
|
2008-10-05 12:07:33 -05:00
|
|
|
void StreamConfigDialog::on_cmbPktLenMode_currentIndexChanged(QString mode)
|
|
|
|
{
|
|
|
|
if (mode == "Fixed")
|
|
|
|
{
|
|
|
|
lePktLen->setEnabled(true);
|
|
|
|
lePktLenMin->setDisabled(true);
|
|
|
|
lePktLenMax->setDisabled(true);
|
|
|
|
}
|
|
|
|
else if (mode == "Increment")
|
|
|
|
{
|
|
|
|
lePktLen->setDisabled(true);
|
|
|
|
lePktLenMin->setEnabled(true);
|
|
|
|
lePktLenMax->setEnabled(true);
|
|
|
|
}
|
|
|
|
else if (mode == "Decrement")
|
|
|
|
{
|
|
|
|
lePktLen->setDisabled(true);
|
|
|
|
lePktLenMin->setEnabled(true);
|
|
|
|
lePktLenMax->setEnabled(true);
|
|
|
|
}
|
|
|
|
else if (mode == "Random")
|
|
|
|
{
|
|
|
|
lePktLen->setDisabled(true);
|
|
|
|
lePktLenMin->setEnabled(true);
|
|
|
|
lePktLenMax->setEnabled(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qWarning("Unhandled/Unknown PktLenMode = %s", mode.toAscii().data());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-03 09:37:10 -05:00
|
|
|
void StreamConfigDialog::on_pbPrev_clicked()
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
StoreCurrentStream(currStreamIdx);
|
|
|
|
currStreamIdx--;
|
|
|
|
LoadCurrentStream(currStreamIdx);
|
|
|
|
|
|
|
|
pbPrev->setDisabled((currStreamIdx == 0));
|
|
|
|
pbNext->setDisabled((currStreamIdx == 2));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void StreamConfigDialog::on_pbNext_clicked()
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
StoreCurrentStream(currStreamIdx);
|
|
|
|
currStreamIdx++;
|
|
|
|
LoadCurrentStream(currStreamIdx);
|
|
|
|
|
|
|
|
pbPrev->setDisabled((currStreamIdx == 0));
|
|
|
|
pbNext->setDisabled((currStreamIdx == 2));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-09-28 13:01:52 -05:00
|
|
|
void StreamConfigDialog::on_rbFtNone_toggled(bool checked)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void StreamConfigDialog::on_rbFtEthernet2_toggled(bool checked)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void StreamConfigDialog::on_rbFt802Dot3Raw_toggled(bool checked)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void StreamConfigDialog::on_rbFt802Dot3Llc_toggled(bool checked)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-05-03 09:37:10 -05:00
|
|
|
void StreamConfigDialog::on_rbFtLlcSnap_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (checked)
|
|
|
|
{
|
|
|
|
leDsap->setText("AA");
|
|
|
|
leSsap->setText("AA");
|
|
|
|
leControl->setText("03");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void StreamConfigDialog::on_rbL3Ipv4_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (checked)
|
|
|
|
{
|
|
|
|
twProto->setTabEnabled(2, TRUE);
|
|
|
|
twProto->setTabText(2, "L3 (IPv4)");
|
|
|
|
leType->setText("08 00");
|
2009-04-27 11:51:44 -05:00
|
|
|
|
|
|
|
// FIXME: Hardcoding
|
|
|
|
mpStream->protocolById(121)->setFieldData(0 /* type */, 0x800);
|
|
|
|
mpStream->loadProtocolWidgets(); // FIXME: pass protocol as param
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
twProto->setTabEnabled(2, FALSE);
|
|
|
|
twProto->setTabText(2, "L3");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void StreamConfigDialog::on_rbL3Arp_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (checked)
|
|
|
|
{
|
|
|
|
twProto->setTabEnabled(2, TRUE);
|
|
|
|
twProto->setTabText(2, "L3 (ARP)");
|
|
|
|
leType->setText("08 06");
|
2009-04-27 11:51:44 -05:00
|
|
|
|
|
|
|
// FIXME: Hardcoding
|
|
|
|
mpStream->protocolById(121)->setFieldData(0 /* type */, 0x806);
|
|
|
|
mpStream->loadProtocolWidgets(); // FIXME: pass protocol as param
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
twProto->setTabEnabled(2, FALSE);
|
|
|
|
twProto->setTabText(2, "L3");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void StreamConfigDialog::on_rbL4Icmp_toggled(bool checked)
|
|
|
|
{
|
|
|
|
QString str;
|
|
|
|
|
|
|
|
if (checked)
|
|
|
|
{
|
|
|
|
twProto->setTabEnabled(3, TRUE);
|
|
|
|
twProto->setTabText(3, "L4 (ICMP)");
|
2009-04-27 11:51:44 -05:00
|
|
|
// FIXME: Hardcoding
|
|
|
|
mpStream->protocolById(130)->setFieldData(8 /* proto */, IP_PROTO_ICMP);
|
|
|
|
mpStream->loadProtocolWidgets(); // FIXME: pass protocol as param
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
twProto->setTabEnabled(3, FALSE);
|
|
|
|
twProto->setTabText(3, "L4");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void StreamConfigDialog::on_rbL4Igmp_toggled(bool checked)
|
|
|
|
{
|
|
|
|
QString str;
|
|
|
|
|
|
|
|
if (checked)
|
|
|
|
{
|
|
|
|
twProto->setTabEnabled(3, TRUE);
|
|
|
|
twProto->setTabText(3, "L4 (IGMP)");
|
2009-04-27 11:51:44 -05:00
|
|
|
// FIXME: Hardcoding
|
|
|
|
mpStream->protocolById(130)->setFieldData(8 /* proto */, IP_PROTO_IGMP);
|
|
|
|
mpStream->loadProtocolWidgets(); // FIXME: pass protocol as param
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
twProto->setTabEnabled(3, FALSE);
|
|
|
|
twProto->setTabText(3, "L4");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void StreamConfigDialog::on_rbL4Tcp_toggled(bool checked)
|
|
|
|
{
|
|
|
|
QString str;
|
|
|
|
|
|
|
|
if (checked)
|
|
|
|
{
|
|
|
|
twProto->setTabEnabled(3, TRUE);
|
|
|
|
twProto->setTabText(3, "L4 (TCP)");
|
2009-04-27 11:51:44 -05:00
|
|
|
// FIXME: Hardcoding
|
|
|
|
mpStream->protocolById(130)->setFieldData(8 /* proto */, IP_PROTO_TCP);
|
|
|
|
mpStream->loadProtocolWidgets(); // FIXME: pass protocol as param
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
twProto->setTabEnabled(3, FALSE);
|
|
|
|
twProto->setTabText(3, "L4");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void StreamConfigDialog::on_rbL4Udp_toggled(bool checked)
|
|
|
|
{
|
|
|
|
QString str;
|
|
|
|
|
|
|
|
if (checked)
|
|
|
|
{
|
|
|
|
twProto->setTabEnabled(3, TRUE);
|
|
|
|
twProto->setTabText(3, "L4 (UDP)");
|
2009-04-27 11:51:44 -05:00
|
|
|
// FIXME: Hardcoding
|
|
|
|
mpStream->protocolById(130)->setFieldData(8 /* proto */, IP_PROTO_UDP);
|
|
|
|
mpStream->loadProtocolWidgets(); // FIXME: pass protocol as param
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
twProto->setTabEnabled(3, FALSE);
|
|
|
|
twProto->setTabText(3, "L4");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-27 11:51:44 -05:00
|
|
|
void StreamConfigDialog::on_twTopLevel_currentChanged(int index)
|
|
|
|
{
|
|
|
|
QList<AbstractProtocol*> protoList;
|
|
|
|
|
|
|
|
// We only process the "Packet View" tab
|
|
|
|
if (index != 2)
|
|
|
|
return;
|
|
|
|
|
|
|
|
updateSelectedProtocols();
|
|
|
|
foreach(int i, mSelectedProtocols)
|
|
|
|
if (mpStream->protocolById(i))
|
|
|
|
protoList.append(mpStream->protocolById(i));
|
|
|
|
|
|
|
|
mpPacketModel->setSelectedProtocols(protoList);
|
|
|
|
StoreCurrentStream(mpStream);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StreamConfigDialog::on_twProto_currentChanged(int index)
|
|
|
|
{
|
|
|
|
QLayout *layout;
|
|
|
|
QList<QWidget*> wl;
|
|
|
|
|
|
|
|
// We need to process only indices 1-3 i.e. the L2, L3 and L4 tabs
|
|
|
|
if ((index < 1) || (index > 3))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Remove any existing widget on the activated tab
|
|
|
|
layout = twProto->widget(index)->layout();
|
|
|
|
if (layout)
|
|
|
|
{
|
|
|
|
QLayoutItem *child;
|
|
|
|
while ((child = layout->takeAt(0)) != 0)
|
|
|
|
{
|
|
|
|
Q_ASSERT(child->widget() != 0);
|
|
|
|
// Don't delete the child widget - reparent it
|
|
|
|
child->widget()->setParent(0);
|
|
|
|
}
|
|
|
|
delete layout;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: protocol id hardcodings
|
|
|
|
switch(index)
|
|
|
|
{
|
|
|
|
case 1: // L2
|
|
|
|
wl.append(mpStream->protocolById(51)->configWidget());
|
|
|
|
if (rbFtEthernet2->isChecked())
|
|
|
|
wl.append(mpStream->protocolById(121)->configWidget());
|
|
|
|
else if (rbFt802Dot3Raw->isChecked())
|
|
|
|
wl.append(mpStream->protocolById(122)->configWidget());
|
|
|
|
else if (rbFt802Dot3Llc->isChecked())
|
|
|
|
{
|
|
|
|
wl.append(mpStream->protocolById(122)->configWidget());
|
|
|
|
wl.append(mpStream->protocolById(123)->configWidget());
|
|
|
|
}
|
|
|
|
else if (rbFtLlcSnap->isChecked())
|
|
|
|
{
|
|
|
|
wl.append(mpStream->protocolById(122)->configWidget());
|
|
|
|
wl.append(mpStream->protocolById(123)->configWidget());
|
|
|
|
wl.append(mpStream->protocolById(124)->configWidget());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2: // L3
|
|
|
|
if (rbL3Ipv4->isChecked())
|
|
|
|
wl.append(mpStream->protocolById(130)->configWidget());
|
|
|
|
break;
|
|
|
|
case 3: // L4
|
|
|
|
if (rbL4Tcp->isChecked())
|
|
|
|
wl.append(mpStream->protocolById(140)->configWidget());
|
|
|
|
else if (rbL4Udp->isChecked())
|
|
|
|
wl.append(mpStream->protocolById(141)->configWidget());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wl.size())
|
|
|
|
layout = new QVBoxLayout;
|
|
|
|
|
|
|
|
for (int i=0; i < wl.size(); i++)
|
|
|
|
layout->addWidget(wl.at(i));
|
|
|
|
|
|
|
|
twProto->widget(index)->setLayout(layout);
|
|
|
|
}
|
|
|
|
|
2008-05-03 09:37:10 -05:00
|
|
|
void StreamConfigDialog::update_NumPacketsAndNumBursts()
|
|
|
|
{
|
|
|
|
if (rbSendPackets->isChecked() && rbModeFixed->isChecked())
|
|
|
|
leNumPackets->setEnabled(true);
|
|
|
|
else
|
|
|
|
leNumPackets->setEnabled(false);
|
|
|
|
|
|
|
|
if (rbSendBursts->isChecked() && rbModeFixed->isChecked())
|
|
|
|
leNumBursts->setEnabled(true);
|
|
|
|
else
|
|
|
|
leNumBursts->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
void StreamConfigDialog::on_lePattern_editingFinished()
|
|
|
|
{
|
|
|
|
ulong num = 0;
|
|
|
|
bool isOk;
|
|
|
|
QString str;
|
|
|
|
|
|
|
|
num = lePattern->text().remove(QChar(' ')).toULong(&isOk, 16);
|
|
|
|
qDebug("editfinished (%s | %x)\n", lePattern->text().toAscii().data(), num);
|
|
|
|
lePattern->setText(uintToHexStr(num, str, 4));
|
|
|
|
qDebug("editfinished (%s | %x)\n", lePattern->text().toAscii().data(), num);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void StreamConfigDialog::LoadCurrentStream()
|
|
|
|
{
|
|
|
|
QString str;
|
|
|
|
|
2009-04-27 11:51:44 -05:00
|
|
|
qDebug("loading mpStream %p", mpStream);
|
2008-05-03 09:37:10 -05:00
|
|
|
|
|
|
|
// Meta Data
|
|
|
|
{
|
2009-04-27 11:51:44 -05:00
|
|
|
cmbPktLenMode->setCurrentIndex(mpStream->lenMode());
|
|
|
|
lePktLen->setText(str.setNum(mpStream->frameLen()));
|
|
|
|
lePktLenMin->setText(str.setNum(mpStream->frameLenMin()));
|
|
|
|
lePktLenMax->setText(str.setNum(mpStream->frameLenMax()));
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Protocols
|
|
|
|
{
|
2009-04-27 11:51:44 -05:00
|
|
|
int i;
|
|
|
|
|
|
|
|
qDebug("Selected Protocols.size() = %d", mSelectedProtocols.size());
|
|
|
|
mSelectedProtocols = mpStream->frameProtocol();
|
|
|
|
qDebug("Selected Protocols.size() = %d", mSelectedProtocols.size());
|
|
|
|
for (i = 0; i < mSelectedProtocols.size(); i++)
|
|
|
|
qDebug("%d: %d", i, mSelectedProtocols.at(i));
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2009-04-27 11:51:44 -05:00
|
|
|
Q_ASSERT(mSelectedProtocols.size() >= 2); // Mac + Payload: mandatory
|
2008-08-23 23:39:08 -05:00
|
|
|
|
2009-04-27 11:51:44 -05:00
|
|
|
i = 0;
|
|
|
|
Q_ASSERT(mSelectedProtocols.at(i) == 51); // Mac
|
|
|
|
i++;
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2009-04-27 11:51:44 -05:00
|
|
|
if (mSelectedProtocols.at(i) == 52) // Payload
|
2008-08-23 23:39:08 -05:00
|
|
|
{
|
2009-04-27 11:51:44 -05:00
|
|
|
i++;
|
|
|
|
goto _proto_parse_done;
|
2008-08-23 23:39:08 -05:00
|
|
|
}
|
2009-04-27 11:51:44 -05:00
|
|
|
else if (mSelectedProtocols.at(i) == 121) // Eth2
|
2008-08-23 23:39:08 -05:00
|
|
|
{
|
2009-04-27 11:51:44 -05:00
|
|
|
rbFtEthernet2->setChecked(true);
|
|
|
|
i++;
|
2008-08-23 23:39:08 -05:00
|
|
|
}
|
2009-04-27 11:51:44 -05:00
|
|
|
else if (mSelectedProtocols.at(i) == 122) // 802.3 RAW
|
2008-05-03 09:37:10 -05:00
|
|
|
{
|
2009-04-27 11:51:44 -05:00
|
|
|
if ((mSelectedProtocols.size() > (i+1)) &&
|
|
|
|
(mSelectedProtocols.at(i+1) == 123)) // 802.3 LLC
|
2008-08-23 23:39:08 -05:00
|
|
|
{
|
2009-04-27 11:51:44 -05:00
|
|
|
if ((mSelectedProtocols.size() > (i+2)) &&
|
|
|
|
(mSelectedProtocols.at(i+2) == 124)) // SNAP
|
|
|
|
{
|
|
|
|
rbFtLlcSnap->setChecked(true);
|
|
|
|
i+=3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rbFt802Dot3Llc->setChecked(true);
|
|
|
|
i+=2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rbFt802Dot3Raw->setChecked(true);
|
|
|
|
i++;
|
2008-08-23 23:39:08 -05:00
|
|
|
}
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
2009-04-27 11:51:44 -05:00
|
|
|
else
|
|
|
|
rbFtNone->setChecked(true);
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2009-04-27 11:51:44 -05:00
|
|
|
// L3
|
|
|
|
if (mSelectedProtocols.at(i) == 52) // Payload
|
2008-05-03 09:37:10 -05:00
|
|
|
{
|
2009-04-27 11:51:44 -05:00
|
|
|
i++;
|
|
|
|
goto _proto_parse_done;
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
2009-04-27 11:51:44 -05:00
|
|
|
else if (mSelectedProtocols.at(i) == 130) // IP4
|
2008-05-03 09:37:10 -05:00
|
|
|
{
|
2009-04-27 11:51:44 -05:00
|
|
|
rbL3Ipv4->setChecked(true);
|
|
|
|
i++;
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
2009-04-27 11:51:44 -05:00
|
|
|
else if (mSelectedProtocols.at(i) == 131) // ARP
|
2008-05-03 09:37:10 -05:00
|
|
|
{
|
2009-04-27 11:51:44 -05:00
|
|
|
rbL3Arp->setChecked(true);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rbL3None->setChecked(true);
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2009-04-27 11:51:44 -05:00
|
|
|
if (i == mSelectedProtocols.size())
|
|
|
|
goto _proto_parse_done;
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2009-04-27 11:51:44 -05:00
|
|
|
// L4
|
|
|
|
if (mSelectedProtocols.at(i) == 52) // Payload
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
goto _proto_parse_done;
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
2009-04-27 11:51:44 -05:00
|
|
|
else if (mSelectedProtocols.at(i) == 140) // TCP
|
2008-05-03 09:37:10 -05:00
|
|
|
{
|
2009-04-27 11:51:44 -05:00
|
|
|
rbL4Tcp->setChecked(true);
|
|
|
|
i++;
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
2009-04-27 11:51:44 -05:00
|
|
|
else if (mSelectedProtocols.at(i) == 141) // UDP
|
2008-05-03 09:37:10 -05:00
|
|
|
{
|
2009-04-27 11:51:44 -05:00
|
|
|
rbL4Udp->setChecked(true);
|
|
|
|
i++;
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
2009-04-27 11:51:44 -05:00
|
|
|
else if (mSelectedProtocols.at(i) == 142) // ICMP
|
2008-05-03 09:37:10 -05:00
|
|
|
{
|
2009-04-27 11:51:44 -05:00
|
|
|
rbL4Icmp->setChecked(true);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
else if (mSelectedProtocols.at(i) == 143) // IGMP
|
|
|
|
{
|
|
|
|
rbL4Igmp->setChecked(true);
|
|
|
|
i++;
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
2009-04-27 11:51:44 -05:00
|
|
|
else
|
|
|
|
rbL4None->setChecked(true);
|
|
|
|
|
|
|
|
Q_ASSERT(mSelectedProtocols.at(i) == 52); // Payload
|
|
|
|
i++;
|
|
|
|
|
|
|
|
_proto_parse_done:
|
|
|
|
Q_ASSERT(i == mSelectedProtocols.size());
|
|
|
|
|
|
|
|
mpStream->loadProtocolWidgets();
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
2008-09-28 13:01:52 -05:00
|
|
|
|
|
|
|
// Stream Control
|
|
|
|
{
|
2009-04-27 11:51:44 -05:00
|
|
|
switch (mpStream->sendUnit())
|
2008-09-28 13:01:52 -05:00
|
|
|
{
|
|
|
|
case Stream::e_su_packets:
|
|
|
|
rbSendPackets->setChecked(true);
|
|
|
|
break;
|
|
|
|
case Stream::e_su_bursts:
|
|
|
|
rbSendBursts->setChecked(true);
|
|
|
|
break;
|
|
|
|
default:
|
2009-04-27 11:51:44 -05:00
|
|
|
qWarning("Unhandled sendUnit = %d\n", mpStream->sendUnit());
|
2008-09-28 13:01:52 -05:00
|
|
|
}
|
|
|
|
|
2009-04-27 11:51:44 -05:00
|
|
|
switch (mpStream->sendMode())
|
2008-09-28 13:01:52 -05:00
|
|
|
{
|
|
|
|
case Stream::e_sm_fixed:
|
|
|
|
rbModeFixed->setChecked(true);
|
|
|
|
break;
|
|
|
|
case Stream::e_sm_continuous:
|
|
|
|
rbModeContinuous->setChecked(true);
|
|
|
|
break;
|
|
|
|
default:
|
2009-04-27 11:51:44 -05:00
|
|
|
qWarning("Unhandled sendMode = %d\n", mpStream->sendMode());
|
2008-09-28 13:01:52 -05:00
|
|
|
}
|
|
|
|
|
2009-04-27 11:51:44 -05:00
|
|
|
switch(mpStream->nextWhat())
|
2008-09-28 13:01:52 -05:00
|
|
|
{
|
|
|
|
case Stream::e_nw_stop:
|
|
|
|
rbActionStop->setChecked(true);
|
|
|
|
break;
|
|
|
|
case Stream::e_nw_goto_next:
|
|
|
|
rbActionGotoNext->setChecked(true);
|
|
|
|
break;
|
|
|
|
case Stream::e_nw_goto_id:
|
|
|
|
rbActionGotoStream->setChecked(true);
|
|
|
|
break;
|
|
|
|
default:
|
2009-04-27 11:51:44 -05:00
|
|
|
qWarning("Unhandled nextAction = %d\n", mpStream->nextWhat());
|
2008-09-28 13:01:52 -05:00
|
|
|
}
|
|
|
|
|
2009-04-27 11:51:44 -05:00
|
|
|
leNumPackets->setText(QString().setNum(mpStream->numPackets()));
|
|
|
|
leNumBursts->setText(QString().setNum(mpStream->numBursts()));
|
|
|
|
lePacketsPerBurst->setText(QString().setNum(mpStream->burstSize()));
|
|
|
|
lePacketsPerSec->setText(QString().setNum(mpStream->packetRate()));
|
|
|
|
leBurstsPerSec->setText(QString().setNum(mpStream->burstRate()));
|
2009-03-10 11:48:03 -05:00
|
|
|
// TODO(MED): Change this when we support goto to specific stream
|
|
|
|
leStreamId->setText(QString("0"));
|
2008-09-28 13:01:52 -05:00
|
|
|
}
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
|
|
|
|
2009-04-27 11:51:44 -05:00
|
|
|
void StreamConfigDialog::StoreCurrentStream(Stream *pStream)
|
2008-05-03 09:37:10 -05:00
|
|
|
{
|
|
|
|
QString str;
|
|
|
|
bool isOk;
|
|
|
|
|
|
|
|
qDebug("storing pStream %p", pStream);
|
|
|
|
|
|
|
|
// Meta Data
|
2008-08-08 22:22:13 -05:00
|
|
|
pStream->setLenMode((Stream::FrameLengthMode) cmbPktLenMode->currentIndex());
|
|
|
|
pStream->setFrameLen(lePktLen->text().toULong(&isOk));
|
|
|
|
pStream->setFrameLenMin(lePktLenMin->text().toULong(&isOk));
|
|
|
|
pStream->setFrameLenMax(lePktLenMax->text().toULong(&isOk));
|
2008-08-23 23:39:08 -05:00
|
|
|
|
2008-05-03 09:37:10 -05:00
|
|
|
// Protocols
|
|
|
|
{
|
2009-04-27 11:51:44 -05:00
|
|
|
updateSelectedProtocols();
|
|
|
|
pStream->setFrameProtocol(mSelectedProtocols);
|
|
|
|
pStream->storeProtocolWidgets();
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
2008-09-28 13:01:52 -05:00
|
|
|
|
|
|
|
// Stream Control
|
|
|
|
{
|
|
|
|
if (rbSendPackets->isChecked())
|
|
|
|
pStream->setSendUnit(Stream::e_su_packets);
|
|
|
|
if (rbSendBursts->isChecked())
|
|
|
|
pStream->setSendUnit(Stream::e_su_bursts);
|
|
|
|
|
|
|
|
if (rbModeFixed->isChecked())
|
|
|
|
pStream->setSendMode(Stream::e_sm_fixed);
|
|
|
|
if (rbModeContinuous->isChecked())
|
|
|
|
pStream->setSendMode(Stream::e_sm_continuous);
|
|
|
|
|
|
|
|
if (rbActionStop->isChecked())
|
|
|
|
pStream->setNextWhat(Stream::e_nw_stop);
|
|
|
|
if (rbActionGotoNext->isChecked())
|
|
|
|
pStream->setNextWhat(Stream::e_nw_goto_next);
|
|
|
|
if (rbActionGotoStream->isChecked())
|
|
|
|
pStream->setNextWhat(Stream::e_nw_goto_id);
|
|
|
|
|
|
|
|
pStream->setNumPackets(leNumPackets->text().toULong(&isOk));
|
|
|
|
pStream->setNumBursts(leNumBursts->text().toULong(&isOk));
|
|
|
|
pStream->setBurstSize(lePacketsPerBurst->text().toULong(&isOk));
|
|
|
|
pStream->setPacketRate(lePacketsPerSec->text().toULong(&isOk));
|
|
|
|
pStream->setBurstRate(leBurstsPerSec->text().toULong(&isOk));
|
|
|
|
}
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
2008-08-23 23:39:08 -05:00
|
|
|
|
2008-05-03 09:37:10 -05:00
|
|
|
void StreamConfigDialog::on_pbOk_clicked()
|
|
|
|
{
|
|
|
|
// Store dialog contents into stream
|
2009-04-27 11:51:44 -05:00
|
|
|
StoreCurrentStream(mPort.streamByIndex(mCurrentStreamIndex));
|
2008-05-03 09:37:10 -05:00
|
|
|
qDebug("stream stored");
|
2009-04-05 02:19:37 -05:00
|
|
|
lastTopLevelTabIndex = twTopLevel->currentIndex();
|
|
|
|
lastProtoTabIndex = twProto->currentIndex();
|
2008-05-03 09:37:10 -05:00
|
|
|
}
|
|
|
|
|