NOX: Udp - separated protocol and widget as per new framework
This commit is contained in:
parent
481e517fa6
commit
bbe645725a
@ -66,11 +66,11 @@ HEADERS += \
|
||||
gmp.h \
|
||||
igmp.h \
|
||||
mld.h \
|
||||
tcp.h
|
||||
tcp.h \
|
||||
udp.h
|
||||
|
||||
HEADERS1 += \
|
||||
icmp.h \
|
||||
udp.h \
|
||||
textproto.h \
|
||||
userscript.h \
|
||||
hexdump.h \
|
||||
@ -99,11 +99,11 @@ SOURCES += \
|
||||
gmp.cpp \
|
||||
igmp.cpp \
|
||||
mld.cpp \
|
||||
tcp.cpp
|
||||
tcp.cpp \
|
||||
udp.cpp
|
||||
|
||||
SOURCES1 += \
|
||||
icmp.cpp \
|
||||
udp.cpp \
|
||||
textproto.cpp \
|
||||
userscript.cpp \
|
||||
hexdump.cpp \
|
||||
|
@ -19,11 +19,11 @@ FORMS += \
|
||||
ip4.ui \
|
||||
ip6.ui \
|
||||
gmp.ui \
|
||||
tcp.ui
|
||||
tcp.ui \
|
||||
udp.ui
|
||||
|
||||
FORMS1 += \
|
||||
icmp.ui \
|
||||
udp.ui \
|
||||
textproto.ui \
|
||||
userscript.ui \
|
||||
hexdump.ui \
|
||||
@ -67,7 +67,8 @@ HEADERS += \
|
||||
gmpconfig.h \
|
||||
igmpconfig.h \
|
||||
mldconfig.h \
|
||||
tcpconfig.h
|
||||
tcpconfig.h \
|
||||
udpconfig.h
|
||||
|
||||
SOURCES += \
|
||||
ostprotolib.cpp \
|
||||
@ -94,7 +95,8 @@ SOURCES += \
|
||||
gmpconfig.cpp \
|
||||
igmpconfig.cpp \
|
||||
mldconfig.cpp \
|
||||
tcpconfig.cpp
|
||||
tcpconfig.cpp \
|
||||
udpconfig.cpp
|
||||
|
||||
QMAKE_DISTCLEAN += object_script.*
|
||||
|
||||
|
@ -23,7 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#include "protocol.pb.h"
|
||||
#if 0
|
||||
#include "icmp.h"
|
||||
#include "udp.h"
|
||||
#include "textproto.h"
|
||||
#include "userscript.h"
|
||||
#include "hexdump.h"
|
||||
@ -52,6 +51,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#include "igmp.h"
|
||||
#include "mld.h"
|
||||
#include "tcp.h"
|
||||
#include "udp.h"
|
||||
#endif
|
||||
|
||||
ProtocolManager *OstProtocolManager;
|
||||
@ -64,8 +64,6 @@ ProtocolManager::ProtocolManager()
|
||||
#if 0
|
||||
registerProtocol(OstProto::Protocol::kIcmpFieldNumber,
|
||||
(void*) IcmpProtocol::createInstance);
|
||||
registerProtocol(OstProto::Protocol::kUdpFieldNumber,
|
||||
(void*) UdpProtocol::createInstance);
|
||||
registerProtocol(OstProto::Protocol::kTextProtocolFieldNumber,
|
||||
(void*) TextProtocol::createInstance);
|
||||
|
||||
@ -126,6 +124,8 @@ ProtocolManager::ProtocolManager()
|
||||
(void*) MldProtocol::createInstance);
|
||||
registerProtocol(OstProto::Protocol::kTcpFieldNumber,
|
||||
(void*) TcpProtocol::createInstance);
|
||||
registerProtocol(OstProto::Protocol::kUdpFieldNumber,
|
||||
(void*) UdpProtocol::createInstance);
|
||||
#endif
|
||||
populateNeighbourProtocols();
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#include "igmpconfig.h"
|
||||
#include "mldconfig.h"
|
||||
#include "tcpconfig.h"
|
||||
#include "udpconfig.h"
|
||||
|
||||
ProtocolWidgetFactory *OstProtocolWidgetFactory;
|
||||
QMap<int, void*> ProtocolWidgetFactory::configWidgetFactory;
|
||||
@ -122,6 +123,9 @@ ProtocolWidgetFactory::ProtocolWidgetFactory()
|
||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||
OstProto::Protocol::kTcpFieldNumber,
|
||||
(void*) TcpConfigForm::createInstance);
|
||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||
OstProto::Protocol::kUdpFieldNumber,
|
||||
(void*) UdpConfigForm::createInstance);
|
||||
}
|
||||
|
||||
ProtocolWidgetFactory::~ProtocolWidgetFactory()
|
||||
|
@ -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/>
|
||||
*/
|
||||
|
||||
#include <qendian.h>
|
||||
#include <QHostAddress>
|
||||
|
||||
#include "udp.h"
|
||||
|
||||
UdpConfigForm::UdpConfigForm(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
UdpProtocol::UdpProtocol(StreamBase *stream, AbstractProtocol *parent)
|
||||
: AbstractProtocol(stream, parent)
|
||||
{
|
||||
configForm = NULL;
|
||||
}
|
||||
|
||||
UdpProtocol::~UdpProtocol()
|
||||
{
|
||||
delete configForm;
|
||||
}
|
||||
|
||||
AbstractProtocol* UdpProtocol::createInstance(StreamBase *stream,
|
||||
@ -440,61 +429,3 @@ int UdpProtocol::protocolFrameVariableCount() const
|
||||
|
||||
return protocolFramePayloadVariableCount();
|
||||
}
|
||||
|
||||
QWidget* UdpProtocol::configWidget()
|
||||
{
|
||||
if (configForm == NULL)
|
||||
{
|
||||
configForm = new UdpConfigForm;
|
||||
loadConfigWidget();
|
||||
}
|
||||
return configForm;
|
||||
}
|
||||
|
||||
void UdpProtocol::loadConfigWidget()
|
||||
{
|
||||
configWidget();
|
||||
|
||||
configForm->leUdpSrcPort->setText(
|
||||
fieldData(udp_srcPort, FieldValue).toString());
|
||||
configForm->cbUdpSrcPortOverride->setChecked(
|
||||
fieldData(udp_isOverrideSrcPort, FieldValue).toBool());
|
||||
configForm->leUdpDstPort->setText(
|
||||
fieldData(udp_dstPort, FieldValue).toString());
|
||||
configForm->cbUdpDstPortOverride->setChecked(
|
||||
fieldData(udp_isOverrideDstPort, FieldValue).toBool());
|
||||
|
||||
configForm->leUdpLength->setText(
|
||||
fieldData(udp_totLen, FieldValue).toString());
|
||||
configForm->cbUdpLengthOverride->setChecked(
|
||||
fieldData(udp_isOverrideTotLen, FieldValue).toBool());
|
||||
|
||||
configForm->leUdpCksum->setText(QString("%1").arg(
|
||||
fieldData(udp_cksum, FieldValue).toUInt(), 4, BASE_HEX, QChar('0')));
|
||||
configForm->cbUdpCksumOverride->setChecked(
|
||||
fieldData(udp_isOverrideCksum, FieldValue).toBool());
|
||||
}
|
||||
|
||||
void UdpProtocol::storeConfigWidget()
|
||||
{
|
||||
bool isOk;
|
||||
|
||||
configWidget();
|
||||
|
||||
setFieldData(udp_srcPort, configForm->leUdpSrcPort->text());
|
||||
setFieldData(udp_isOverrideSrcPort,
|
||||
configForm->cbUdpSrcPortOverride->isChecked());
|
||||
setFieldData(udp_dstPort, configForm->leUdpDstPort->text());
|
||||
setFieldData(udp_isOverrideDstPort,
|
||||
configForm->cbUdpDstPortOverride->isChecked());
|
||||
|
||||
setFieldData(udp_totLen, configForm->leUdpLength->text());
|
||||
setFieldData(udp_isOverrideTotLen,
|
||||
configForm->cbUdpLengthOverride->isChecked());
|
||||
|
||||
setFieldData(udp_cksum, configForm->leUdpCksum->text().remove(QChar(' '))
|
||||
.toUInt(&isOk, BASE_HEX));
|
||||
setFieldData(udp_isOverrideCksum,
|
||||
configForm->cbUdpCksumOverride->isChecked());
|
||||
}
|
||||
|
||||
|
19
common/udp.h
19
common/udp.h
@ -21,22 +21,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#define _UDP_H
|
||||
|
||||
#include "abstractprotocol.h"
|
||||
|
||||
#include "udp.pb.h"
|
||||
#include "ui_udp.h"
|
||||
|
||||
class UdpConfigForm : public QWidget, public Ui::udp
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UdpConfigForm(QWidget *parent = 0);
|
||||
};
|
||||
|
||||
class UdpProtocol : public AbstractProtocol
|
||||
{
|
||||
private:
|
||||
OstProto::Udp data;
|
||||
UdpConfigForm *configForm;
|
||||
public:
|
||||
enum udpfield
|
||||
{
|
||||
udp_srcPort = 0,
|
||||
@ -52,7 +41,6 @@ private:
|
||||
udp_fieldCount
|
||||
};
|
||||
|
||||
public:
|
||||
UdpProtocol(StreamBase *stream, AbstractProtocol *parent = 0);
|
||||
virtual ~UdpProtocol();
|
||||
|
||||
@ -80,9 +68,8 @@ public:
|
||||
virtual bool isProtocolFrameValueVariable() const;
|
||||
virtual int protocolFrameVariableCount() const;
|
||||
|
||||
virtual QWidget* configWidget();
|
||||
virtual void loadConfigWidget();
|
||||
virtual void storeConfigWidget();
|
||||
private:
|
||||
OstProto::Udp data;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
114
common/udpconfig.cpp
Normal file
114
common/udpconfig.cpp
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
Copyright (C) 2010 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 "udpconfig.h"
|
||||
#include "udp.h"
|
||||
|
||||
UdpConfigForm::UdpConfigForm(QWidget *parent)
|
||||
: AbstractProtocolConfigForm(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
UdpConfigForm::~UdpConfigForm()
|
||||
{
|
||||
}
|
||||
|
||||
UdpConfigForm* UdpConfigForm::createInstance()
|
||||
{
|
||||
return new UdpConfigForm;
|
||||
}
|
||||
|
||||
|
||||
void UdpConfigForm::loadWidget(AbstractProtocol *proto)
|
||||
{
|
||||
leUdpSrcPort->setText(
|
||||
proto->fieldData(
|
||||
UdpProtocol::udp_srcPort,
|
||||
AbstractProtocol::FieldValue
|
||||
).toString());
|
||||
cbUdpSrcPortOverride->setChecked(
|
||||
proto->fieldData(
|
||||
UdpProtocol::udp_isOverrideSrcPort,
|
||||
AbstractProtocol::FieldValue
|
||||
).toBool());
|
||||
leUdpDstPort->setText(
|
||||
proto->fieldData(
|
||||
UdpProtocol::udp_dstPort,
|
||||
AbstractProtocol::FieldValue
|
||||
).toString());
|
||||
cbUdpDstPortOverride->setChecked(
|
||||
proto->fieldData(
|
||||
UdpProtocol::udp_isOverrideDstPort,
|
||||
AbstractProtocol::FieldValue
|
||||
).toBool());
|
||||
|
||||
leUdpLength->setText(
|
||||
proto->fieldData(
|
||||
UdpProtocol::udp_totLen,
|
||||
AbstractProtocol::FieldValue
|
||||
).toString());
|
||||
cbUdpLengthOverride->setChecked(
|
||||
proto->fieldData(
|
||||
UdpProtocol::udp_isOverrideTotLen,
|
||||
AbstractProtocol::FieldValue
|
||||
).toBool());
|
||||
|
||||
leUdpCksum->setText(uintToHexStr(
|
||||
proto->fieldData(
|
||||
UdpProtocol::udp_cksum,
|
||||
AbstractProtocol::FieldValue
|
||||
).toUInt(), 2));
|
||||
cbUdpCksumOverride->setChecked(
|
||||
proto->fieldData(
|
||||
UdpProtocol::udp_isOverrideCksum,
|
||||
AbstractProtocol::FieldValue
|
||||
).toBool());
|
||||
}
|
||||
|
||||
void UdpConfigForm::storeWidget(AbstractProtocol *proto)
|
||||
{
|
||||
proto->setFieldData(
|
||||
UdpProtocol::udp_srcPort,
|
||||
leUdpSrcPort->text());
|
||||
proto->setFieldData(
|
||||
UdpProtocol::udp_isOverrideSrcPort,
|
||||
cbUdpSrcPortOverride->isChecked());
|
||||
proto->setFieldData(
|
||||
UdpProtocol::udp_dstPort,
|
||||
leUdpDstPort->text());
|
||||
proto->setFieldData(
|
||||
UdpProtocol::udp_isOverrideDstPort,
|
||||
cbUdpDstPortOverride->isChecked());
|
||||
|
||||
proto->setFieldData(
|
||||
UdpProtocol::udp_totLen,
|
||||
leUdpLength->text());
|
||||
proto->setFieldData(
|
||||
UdpProtocol::udp_isOverrideTotLen,
|
||||
cbUdpLengthOverride->isChecked());
|
||||
|
||||
proto->setFieldData(
|
||||
UdpProtocol::udp_cksum,
|
||||
hexStrToUInt(leUdpCksum->text()));
|
||||
proto->setFieldData(
|
||||
UdpProtocol::udp_isOverrideCksum,
|
||||
cbUdpCksumOverride->isChecked());
|
||||
}
|
||||
|
41
common/udpconfig.h
Normal file
41
common/udpconfig.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright (C) 2010 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 _UDP_CONFIG_H
|
||||
#define _UDP_CONFIG_H
|
||||
|
||||
#include "abstractprotocolconfig.h"
|
||||
#include "ui_udp.h"
|
||||
|
||||
class UdpConfigForm :
|
||||
public AbstractProtocolConfigForm,
|
||||
private Ui::udp
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UdpConfigForm(QWidget *parent = 0);
|
||||
virtual ~UdpConfigForm();
|
||||
|
||||
static UdpConfigForm* createInstance();
|
||||
|
||||
virtual void loadWidget(AbstractProtocol *proto);
|
||||
virtual void storeWidget(AbstractProtocol *proto);
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user