NOX: TextProtocol - Separated protocol and widget as per new framework
This commit is contained in:
parent
30c70a73e4
commit
bacee5dd18
@ -68,10 +68,10 @@ HEADERS += \
|
|||||||
igmp.h \
|
igmp.h \
|
||||||
mld.h \
|
mld.h \
|
||||||
tcp.h \
|
tcp.h \
|
||||||
udp.h
|
udp.h \
|
||||||
|
textproto.h
|
||||||
|
|
||||||
HEADERS1 += \
|
HEADERS1 += \
|
||||||
textproto.h \
|
|
||||||
userscript.h \
|
userscript.h \
|
||||||
hexdump.h \
|
hexdump.h \
|
||||||
sample.h
|
sample.h
|
||||||
@ -101,10 +101,10 @@ SOURCES += \
|
|||||||
igmp.cpp \
|
igmp.cpp \
|
||||||
mld.cpp \
|
mld.cpp \
|
||||||
tcp.cpp \
|
tcp.cpp \
|
||||||
udp.cpp
|
udp.cpp \
|
||||||
|
textproto.cpp
|
||||||
|
|
||||||
SOURCES1 += \
|
SOURCES1 += \
|
||||||
textproto.cpp \
|
|
||||||
userscript.cpp \
|
userscript.cpp \
|
||||||
hexdump.cpp \
|
hexdump.cpp \
|
||||||
sample.cpp
|
sample.cpp
|
||||||
|
@ -21,10 +21,10 @@ FORMS += \
|
|||||||
gmp.ui \
|
gmp.ui \
|
||||||
icmp.ui \
|
icmp.ui \
|
||||||
tcp.ui \
|
tcp.ui \
|
||||||
udp.ui
|
udp.ui \
|
||||||
|
textproto.ui
|
||||||
|
|
||||||
FORMS1 += \
|
FORMS1 += \
|
||||||
textproto.ui \
|
|
||||||
userscript.ui \
|
userscript.ui \
|
||||||
hexdump.ui \
|
hexdump.ui \
|
||||||
sample.ui
|
sample.ui
|
||||||
@ -69,7 +69,8 @@ HEADERS += \
|
|||||||
igmpconfig.h \
|
igmpconfig.h \
|
||||||
mldconfig.h \
|
mldconfig.h \
|
||||||
tcpconfig.h \
|
tcpconfig.h \
|
||||||
udpconfig.h
|
udpconfig.h \
|
||||||
|
textprotoconfig.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
ostprotolib.cpp \
|
ostprotolib.cpp \
|
||||||
@ -98,7 +99,8 @@ SOURCES += \
|
|||||||
igmpconfig.cpp \
|
igmpconfig.cpp \
|
||||||
mldconfig.cpp \
|
mldconfig.cpp \
|
||||||
tcpconfig.cpp \
|
tcpconfig.cpp \
|
||||||
udpconfig.cpp
|
udpconfig.cpp \
|
||||||
|
textprotoconfig.cpp
|
||||||
|
|
||||||
QMAKE_DISTCLEAN += object_script.*
|
QMAKE_DISTCLEAN += object_script.*
|
||||||
|
|
||||||
|
@ -22,7 +22,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 "textproto.h"
|
|
||||||
#include "userscript.h"
|
#include "userscript.h"
|
||||||
#include "hexdump.h"
|
#include "hexdump.h"
|
||||||
#include "sample.h"
|
#include "sample.h"
|
||||||
@ -52,6 +51,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "mld.h"
|
#include "mld.h"
|
||||||
#include "tcp.h"
|
#include "tcp.h"
|
||||||
#include "udp.h"
|
#include "udp.h"
|
||||||
|
// L5 Protos
|
||||||
|
#include "textproto.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ProtocolManager *OstProtocolManager;
|
ProtocolManager *OstProtocolManager;
|
||||||
@ -62,9 +63,6 @@ ProtocolManager::ProtocolManager()
|
|||||||
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
|
#if 0
|
||||||
registerProtocol(OstProto::Protocol::kTextProtocolFieldNumber,
|
|
||||||
(void*) TextProtocol::createInstance);
|
|
||||||
|
|
||||||
registerProtocol(OstProto::Protocol::kHexDumpFieldNumber,
|
registerProtocol(OstProto::Protocol::kHexDumpFieldNumber,
|
||||||
(void*) HexDumpProtocol::createInstance);
|
(void*) HexDumpProtocol::createInstance);
|
||||||
|
|
||||||
@ -126,6 +124,11 @@ ProtocolManager::ProtocolManager()
|
|||||||
(void*) TcpProtocol::createInstance);
|
(void*) TcpProtocol::createInstance);
|
||||||
registerProtocol(OstProto::Protocol::kUdpFieldNumber,
|
registerProtocol(OstProto::Protocol::kUdpFieldNumber,
|
||||||
(void*) UdpProtocol::createInstance);
|
(void*) UdpProtocol::createInstance);
|
||||||
|
|
||||||
|
// Layer 5 Protocols
|
||||||
|
registerProtocol(OstProto::Protocol::kTextProtocolFieldNumber,
|
||||||
|
(void*) TextProtocol::createInstance);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
populateNeighbourProtocols();
|
populateNeighbourProtocols();
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "mldconfig.h"
|
#include "mldconfig.h"
|
||||||
#include "tcpconfig.h"
|
#include "tcpconfig.h"
|
||||||
#include "udpconfig.h"
|
#include "udpconfig.h"
|
||||||
|
// L5 Protocol Widgets
|
||||||
|
#include "textprotoconfig.h"
|
||||||
|
|
||||||
ProtocolWidgetFactory *OstProtocolWidgetFactory;
|
ProtocolWidgetFactory *OstProtocolWidgetFactory;
|
||||||
QMap<int, void*> ProtocolWidgetFactory::configWidgetFactory;
|
QMap<int, void*> ProtocolWidgetFactory::configWidgetFactory;
|
||||||
@ -130,6 +132,11 @@ ProtocolWidgetFactory::ProtocolWidgetFactory()
|
|||||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||||
OstProto::Protocol::kUdpFieldNumber,
|
OstProto::Protocol::kUdpFieldNumber,
|
||||||
(void*) UdpConfigForm::createInstance);
|
(void*) UdpConfigForm::createInstance);
|
||||||
|
|
||||||
|
// Layer 5 Protocols
|
||||||
|
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||||
|
OstProto::Protocol::kTextProtocolFieldNumber,
|
||||||
|
(void*) TextProtocolConfigForm::createInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolWidgetFactory::~ProtocolWidgetFactory()
|
ProtocolWidgetFactory::~ProtocolWidgetFactory()
|
||||||
|
@ -17,32 +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 "textproto.h"
|
#include "textproto.h"
|
||||||
|
|
||||||
TextProtocolConfigForm::TextProtocolConfigForm(QWidget *parent)
|
|
||||||
: QWidget(parent)
|
|
||||||
{
|
|
||||||
setupUi(this);
|
|
||||||
|
|
||||||
portNumCombo->setValidator(new QIntValidator(0, 0xFFFF, this));
|
|
||||||
portNumCombo->addItem(0, "Reserved");
|
|
||||||
portNumCombo->addItem(80, "HTTP");
|
|
||||||
portNumCombo->addItem(554, "RTSP");
|
|
||||||
portNumCombo->addItem(5060, "SIP");
|
|
||||||
}
|
|
||||||
|
|
||||||
TextProtocol::TextProtocol(StreamBase *stream, AbstractProtocol *parent)
|
TextProtocol::TextProtocol(StreamBase *stream, AbstractProtocol *parent)
|
||||||
: AbstractProtocol(stream, parent)
|
: AbstractProtocol(stream, parent)
|
||||||
{
|
{
|
||||||
/* The configWidget is created lazily */
|
|
||||||
configForm = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextProtocol::~TextProtocol()
|
TextProtocol::~TextProtocol()
|
||||||
{
|
{
|
||||||
delete configForm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractProtocol* TextProtocol::createInstance(StreamBase *stream,
|
AbstractProtocol* TextProtocol::createInstance(StreamBase *stream,
|
||||||
@ -255,41 +238,3 @@ int TextProtocol::protocolFrameSize(int streamIndex) const
|
|||||||
return fieldData(textProto_text, FieldFrameValue, streamIndex)
|
return fieldData(textProto_text, FieldFrameValue, streamIndex)
|
||||||
.toByteArray().size() ;
|
.toByteArray().size() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* TextProtocol::configWidget()
|
|
||||||
{
|
|
||||||
/* Lazy creation of the configWidget */
|
|
||||||
if (configForm == NULL)
|
|
||||||
{
|
|
||||||
configForm = new TextProtocolConfigForm;
|
|
||||||
loadConfigWidget();
|
|
||||||
}
|
|
||||||
|
|
||||||
return configForm;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextProtocol::loadConfigWidget()
|
|
||||||
{
|
|
||||||
configWidget();
|
|
||||||
|
|
||||||
configForm->portNumCombo->setValue(
|
|
||||||
fieldData(textProto_portNum, FieldValue).toUInt());
|
|
||||||
configForm->eolCombo->setCurrentIndex(
|
|
||||||
fieldData(textProto_eol, FieldValue).toUInt());
|
|
||||||
configForm->encodingCombo->setCurrentIndex(
|
|
||||||
fieldData(textProto_encoding, FieldValue).toUInt());
|
|
||||||
configForm->protoText->setText(
|
|
||||||
fieldData(textProto_text, FieldValue).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextProtocol::storeConfigWidget()
|
|
||||||
{
|
|
||||||
configWidget();
|
|
||||||
|
|
||||||
setFieldData(textProto_portNum, configForm->portNumCombo->currentValue());
|
|
||||||
setFieldData(textProto_eol, configForm->eolCombo->currentIndex());
|
|
||||||
setFieldData(textProto_encoding, configForm->encodingCombo->currentIndex());
|
|
||||||
|
|
||||||
setFieldData(textProto_text, configForm->protoText->toPlainText());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -20,10 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#ifndef _TEXT_PROTOCOL_H
|
#ifndef _TEXT_PROTOCOL_H
|
||||||
#define _TEXT_PROTOCOL_H
|
#define _TEXT_PROTOCOL_H
|
||||||
|
|
||||||
#include "textproto.pb.h"
|
|
||||||
#include "ui_textproto.h"
|
|
||||||
|
|
||||||
#include "abstractprotocol.h"
|
#include "abstractprotocol.h"
|
||||||
|
#include "textproto.pb.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TextProtocol Protocol Frame Format -
|
TextProtocol Protocol Frame Format -
|
||||||
@ -31,19 +29,9 @@ TextProtocol Protocol Frame Format -
|
|||||||
specified encoding
|
specified encoding
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TextProtocolConfigForm : public QWidget, public Ui::TextProtocol
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
TextProtocolConfigForm(QWidget *parent = 0);
|
|
||||||
private slots:
|
|
||||||
};
|
|
||||||
|
|
||||||
class TextProtocol : public AbstractProtocol
|
class TextProtocol : public AbstractProtocol
|
||||||
{
|
{
|
||||||
private:
|
public:
|
||||||
OstProto::TextProtocol data;
|
|
||||||
TextProtocolConfigForm *configForm;
|
|
||||||
enum textProtocolField
|
enum textProtocolField
|
||||||
{
|
{
|
||||||
// Frame Fields
|
// Frame Fields
|
||||||
@ -57,7 +45,6 @@ private:
|
|||||||
textProto_fieldCount
|
textProto_fieldCount
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
TextProtocol(StreamBase *stream, AbstractProtocol *parent = 0);
|
TextProtocol(StreamBase *stream, AbstractProtocol *parent = 0);
|
||||||
virtual ~TextProtocol();
|
virtual ~TextProtocol();
|
||||||
|
|
||||||
@ -83,9 +70,8 @@ public:
|
|||||||
|
|
||||||
virtual int protocolFrameSize(int streamIndex = 0) const;
|
virtual int protocolFrameSize(int streamIndex = 0) const;
|
||||||
|
|
||||||
virtual QWidget* configWidget();
|
private:
|
||||||
virtual void loadConfigWidget();
|
OstProto::TextProtocol data;
|
||||||
virtual void storeConfigWidget();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<ui version="4.0" >
|
<ui version="4.0" >
|
||||||
<class>TextProtocol</class>
|
<class>TextProto</class>
|
||||||
<widget class="QWidget" name="TextProtocol" >
|
<widget class="QWidget" name="TextProto" >
|
||||||
<property name="geometry" >
|
<property name="geometry" >
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
|
84
common/textprotoconfig.cpp
Normal file
84
common/textprotoconfig.cpp
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
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 "textprotoconfig.h"
|
||||||
|
#include "textproto.h"
|
||||||
|
|
||||||
|
TextProtocolConfigForm::TextProtocolConfigForm(QWidget *parent)
|
||||||
|
: AbstractProtocolConfigForm(parent)
|
||||||
|
{
|
||||||
|
setupUi(this);
|
||||||
|
|
||||||
|
portNumCombo->setValidator(new QIntValidator(0, 0xFFFF, this));
|
||||||
|
portNumCombo->addItem(0, "Reserved");
|
||||||
|
portNumCombo->addItem(80, "HTTP");
|
||||||
|
portNumCombo->addItem(554, "RTSP");
|
||||||
|
portNumCombo->addItem(5060, "SIP");
|
||||||
|
}
|
||||||
|
|
||||||
|
TextProtocolConfigForm::~TextProtocolConfigForm()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TextProtocolConfigForm* TextProtocolConfigForm::createInstance()
|
||||||
|
{
|
||||||
|
return new TextProtocolConfigForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextProtocolConfigForm::loadWidget(AbstractProtocol *proto)
|
||||||
|
{
|
||||||
|
portNumCombo->setValue(
|
||||||
|
proto->fieldData(
|
||||||
|
TextProtocol::textProto_portNum,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toUInt());
|
||||||
|
eolCombo->setCurrentIndex(
|
||||||
|
proto->fieldData(
|
||||||
|
TextProtocol::textProto_eol,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toUInt());
|
||||||
|
encodingCombo->setCurrentIndex(
|
||||||
|
proto->fieldData(
|
||||||
|
TextProtocol::textProto_encoding,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toUInt());
|
||||||
|
protoText->setText(
|
||||||
|
proto->fieldData(
|
||||||
|
TextProtocol::textProto_text,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextProtocolConfigForm::storeWidget(AbstractProtocol *proto)
|
||||||
|
{
|
||||||
|
proto->setFieldData(
|
||||||
|
TextProtocol::textProto_portNum,
|
||||||
|
portNumCombo->currentValue());
|
||||||
|
proto->setFieldData(
|
||||||
|
TextProtocol::textProto_eol,
|
||||||
|
eolCombo->currentIndex());
|
||||||
|
proto->setFieldData(
|
||||||
|
TextProtocol::textProto_encoding,
|
||||||
|
encodingCombo->currentIndex());
|
||||||
|
|
||||||
|
proto->setFieldData(
|
||||||
|
TextProtocol::textProto_text,
|
||||||
|
protoText->toPlainText());
|
||||||
|
}
|
||||||
|
|
41
common/textprotoconfig.h
Normal file
41
common/textprotoconfig.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 _TEXT_PROTOCOL_CONFIG_H
|
||||||
|
#define _TEXT_PROTOCOL_CONFIG_H
|
||||||
|
|
||||||
|
#include "abstractprotocolconfig.h"
|
||||||
|
#include "ui_textproto.h"
|
||||||
|
|
||||||
|
class TextProtocolConfigForm :
|
||||||
|
public AbstractProtocolConfigForm,
|
||||||
|
private Ui::TextProto
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
TextProtocolConfigForm(QWidget *parent = 0);
|
||||||
|
virtual ~TextProtocolConfigForm();
|
||||||
|
|
||||||
|
static TextProtocolConfigForm* createInstance();
|
||||||
|
|
||||||
|
virtual void loadWidget(AbstractProtocol *proto);
|
||||||
|
virtual void storeWidget(AbstractProtocol *proto);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user