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 \
|
gmp.h \
|
||||||
igmp.h \
|
igmp.h \
|
||||||
mld.h \
|
mld.h \
|
||||||
tcp.h
|
tcp.h \
|
||||||
|
udp.h
|
||||||
|
|
||||||
HEADERS1 += \
|
HEADERS1 += \
|
||||||
icmp.h \
|
icmp.h \
|
||||||
udp.h \
|
|
||||||
textproto.h \
|
textproto.h \
|
||||||
userscript.h \
|
userscript.h \
|
||||||
hexdump.h \
|
hexdump.h \
|
||||||
@ -99,11 +99,11 @@ SOURCES += \
|
|||||||
gmp.cpp \
|
gmp.cpp \
|
||||||
igmp.cpp \
|
igmp.cpp \
|
||||||
mld.cpp \
|
mld.cpp \
|
||||||
tcp.cpp
|
tcp.cpp \
|
||||||
|
udp.cpp
|
||||||
|
|
||||||
SOURCES1 += \
|
SOURCES1 += \
|
||||||
icmp.cpp \
|
icmp.cpp \
|
||||||
udp.cpp \
|
|
||||||
textproto.cpp \
|
textproto.cpp \
|
||||||
userscript.cpp \
|
userscript.cpp \
|
||||||
hexdump.cpp \
|
hexdump.cpp \
|
||||||
|
@ -19,11 +19,11 @@ FORMS += \
|
|||||||
ip4.ui \
|
ip4.ui \
|
||||||
ip6.ui \
|
ip6.ui \
|
||||||
gmp.ui \
|
gmp.ui \
|
||||||
tcp.ui
|
tcp.ui \
|
||||||
|
udp.ui
|
||||||
|
|
||||||
FORMS1 += \
|
FORMS1 += \
|
||||||
icmp.ui \
|
icmp.ui \
|
||||||
udp.ui \
|
|
||||||
textproto.ui \
|
textproto.ui \
|
||||||
userscript.ui \
|
userscript.ui \
|
||||||
hexdump.ui \
|
hexdump.ui \
|
||||||
@ -67,7 +67,8 @@ HEADERS += \
|
|||||||
gmpconfig.h \
|
gmpconfig.h \
|
||||||
igmpconfig.h \
|
igmpconfig.h \
|
||||||
mldconfig.h \
|
mldconfig.h \
|
||||||
tcpconfig.h
|
tcpconfig.h \
|
||||||
|
udpconfig.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
ostprotolib.cpp \
|
ostprotolib.cpp \
|
||||||
@ -94,7 +95,8 @@ SOURCES += \
|
|||||||
gmpconfig.cpp \
|
gmpconfig.cpp \
|
||||||
igmpconfig.cpp \
|
igmpconfig.cpp \
|
||||||
mldconfig.cpp \
|
mldconfig.cpp \
|
||||||
tcpconfig.cpp
|
tcpconfig.cpp \
|
||||||
|
udpconfig.cpp
|
||||||
|
|
||||||
QMAKE_DISTCLEAN += object_script.*
|
QMAKE_DISTCLEAN += object_script.*
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "protocol.pb.h"
|
#include "protocol.pb.h"
|
||||||
#if 0
|
#if 0
|
||||||
#include "icmp.h"
|
#include "icmp.h"
|
||||||
#include "udp.h"
|
|
||||||
#include "textproto.h"
|
#include "textproto.h"
|
||||||
#include "userscript.h"
|
#include "userscript.h"
|
||||||
#include "hexdump.h"
|
#include "hexdump.h"
|
||||||
@ -52,6 +51,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "igmp.h"
|
#include "igmp.h"
|
||||||
#include "mld.h"
|
#include "mld.h"
|
||||||
#include "tcp.h"
|
#include "tcp.h"
|
||||||
|
#include "udp.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ProtocolManager *OstProtocolManager;
|
ProtocolManager *OstProtocolManager;
|
||||||
@ -64,8 +64,6 @@ ProtocolManager::ProtocolManager()
|
|||||||
#if 0
|
#if 0
|
||||||
registerProtocol(OstProto::Protocol::kIcmpFieldNumber,
|
registerProtocol(OstProto::Protocol::kIcmpFieldNumber,
|
||||||
(void*) IcmpProtocol::createInstance);
|
(void*) IcmpProtocol::createInstance);
|
||||||
registerProtocol(OstProto::Protocol::kUdpFieldNumber,
|
|
||||||
(void*) UdpProtocol::createInstance);
|
|
||||||
registerProtocol(OstProto::Protocol::kTextProtocolFieldNumber,
|
registerProtocol(OstProto::Protocol::kTextProtocolFieldNumber,
|
||||||
(void*) TextProtocol::createInstance);
|
(void*) TextProtocol::createInstance);
|
||||||
|
|
||||||
@ -126,6 +124,8 @@ ProtocolManager::ProtocolManager()
|
|||||||
(void*) MldProtocol::createInstance);
|
(void*) MldProtocol::createInstance);
|
||||||
registerProtocol(OstProto::Protocol::kTcpFieldNumber,
|
registerProtocol(OstProto::Protocol::kTcpFieldNumber,
|
||||||
(void*) TcpProtocol::createInstance);
|
(void*) TcpProtocol::createInstance);
|
||||||
|
registerProtocol(OstProto::Protocol::kUdpFieldNumber,
|
||||||
|
(void*) UdpProtocol::createInstance);
|
||||||
#endif
|
#endif
|
||||||
populateNeighbourProtocols();
|
populateNeighbourProtocols();
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "igmpconfig.h"
|
#include "igmpconfig.h"
|
||||||
#include "mldconfig.h"
|
#include "mldconfig.h"
|
||||||
#include "tcpconfig.h"
|
#include "tcpconfig.h"
|
||||||
|
#include "udpconfig.h"
|
||||||
|
|
||||||
ProtocolWidgetFactory *OstProtocolWidgetFactory;
|
ProtocolWidgetFactory *OstProtocolWidgetFactory;
|
||||||
QMap<int, void*> ProtocolWidgetFactory::configWidgetFactory;
|
QMap<int, void*> ProtocolWidgetFactory::configWidgetFactory;
|
||||||
@ -122,6 +123,9 @@ ProtocolWidgetFactory::ProtocolWidgetFactory()
|
|||||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||||
OstProto::Protocol::kTcpFieldNumber,
|
OstProto::Protocol::kTcpFieldNumber,
|
||||||
(void*) TcpConfigForm::createInstance);
|
(void*) TcpConfigForm::createInstance);
|
||||||
|
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||||
|
OstProto::Protocol::kUdpFieldNumber,
|
||||||
|
(void*) UdpConfigForm::createInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolWidgetFactory::~ProtocolWidgetFactory()
|
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/>
|
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <qendian.h>
|
|
||||||
#include <QHostAddress>
|
|
||||||
|
|
||||||
#include "udp.h"
|
#include "udp.h"
|
||||||
|
|
||||||
UdpConfigForm::UdpConfigForm(QWidget *parent)
|
|
||||||
: QWidget(parent)
|
|
||||||
{
|
|
||||||
setupUi(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
UdpProtocol::UdpProtocol(StreamBase *stream, AbstractProtocol *parent)
|
UdpProtocol::UdpProtocol(StreamBase *stream, AbstractProtocol *parent)
|
||||||
: AbstractProtocol(stream, parent)
|
: AbstractProtocol(stream, parent)
|
||||||
{
|
{
|
||||||
configForm = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UdpProtocol::~UdpProtocol()
|
UdpProtocol::~UdpProtocol()
|
||||||
{
|
{
|
||||||
delete configForm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractProtocol* UdpProtocol::createInstance(StreamBase *stream,
|
AbstractProtocol* UdpProtocol::createInstance(StreamBase *stream,
|
||||||
@ -440,61 +429,3 @@ int UdpProtocol::protocolFrameVariableCount() const
|
|||||||
|
|
||||||
return protocolFramePayloadVariableCount();
|
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
|
#define _UDP_H
|
||||||
|
|
||||||
#include "abstractprotocol.h"
|
#include "abstractprotocol.h"
|
||||||
|
|
||||||
#include "udp.pb.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
|
class UdpProtocol : public AbstractProtocol
|
||||||
{
|
{
|
||||||
private:
|
public:
|
||||||
OstProto::Udp data;
|
|
||||||
UdpConfigForm *configForm;
|
|
||||||
enum udpfield
|
enum udpfield
|
||||||
{
|
{
|
||||||
udp_srcPort = 0,
|
udp_srcPort = 0,
|
||||||
@ -52,7 +41,6 @@ private:
|
|||||||
udp_fieldCount
|
udp_fieldCount
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
UdpProtocol(StreamBase *stream, AbstractProtocol *parent = 0);
|
UdpProtocol(StreamBase *stream, AbstractProtocol *parent = 0);
|
||||||
virtual ~UdpProtocol();
|
virtual ~UdpProtocol();
|
||||||
|
|
||||||
@ -80,9 +68,8 @@ public:
|
|||||||
virtual bool isProtocolFrameValueVariable() const;
|
virtual bool isProtocolFrameValueVariable() const;
|
||||||
virtual int protocolFrameVariableCount() const;
|
virtual int protocolFrameVariableCount() const;
|
||||||
|
|
||||||
virtual QWidget* configWidget();
|
private:
|
||||||
virtual void loadConfigWidget();
|
OstProto::Udp data;
|
||||||
virtual void storeConfigWidget();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#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