NOX: TCP - Separated protocol and widget as per new framework
This commit is contained in:
parent
3ba67e9ee3
commit
21b606e9ea
@ -62,7 +62,8 @@ HEADERS += \
|
|||||||
ip4over4.h \
|
ip4over4.h \
|
||||||
ip4over6.h \
|
ip4over6.h \
|
||||||
ip6over4.h \
|
ip6over4.h \
|
||||||
ip6over6.h
|
ip6over6.h \
|
||||||
|
tcp.h
|
||||||
|
|
||||||
HEADERS1 += \
|
HEADERS1 += \
|
||||||
ipv4addressdelegate.h \
|
ipv4addressdelegate.h \
|
||||||
@ -71,7 +72,6 @@ HEADERS1 += \
|
|||||||
gmp.h \
|
gmp.h \
|
||||||
igmp.h \
|
igmp.h \
|
||||||
mld.h \
|
mld.h \
|
||||||
tcp.h \
|
|
||||||
udp.h \
|
udp.h \
|
||||||
textproto.h \
|
textproto.h \
|
||||||
userscript.h \
|
userscript.h \
|
||||||
@ -97,14 +97,14 @@ SOURCES += \
|
|||||||
snap.cpp \
|
snap.cpp \
|
||||||
arp.cpp \
|
arp.cpp \
|
||||||
ip4.cpp \
|
ip4.cpp \
|
||||||
ip6.cpp
|
ip6.cpp \
|
||||||
|
tcp.cpp
|
||||||
|
|
||||||
SOURCES1 += \
|
SOURCES1 += \
|
||||||
icmp.cpp \
|
icmp.cpp \
|
||||||
gmp.cpp \
|
gmp.cpp \
|
||||||
igmp.cpp \
|
igmp.cpp \
|
||||||
mld.cpp \
|
mld.cpp \
|
||||||
tcp.cpp \
|
|
||||||
udp.cpp \
|
udp.cpp \
|
||||||
textproto.cpp \
|
textproto.cpp \
|
||||||
userscript.cpp \
|
userscript.cpp \
|
||||||
|
@ -17,12 +17,12 @@ FORMS += \
|
|||||||
snap.ui \
|
snap.ui \
|
||||||
arp.ui \
|
arp.ui \
|
||||||
ip4.ui \
|
ip4.ui \
|
||||||
ip6.ui
|
ip6.ui \
|
||||||
|
tcp.ui
|
||||||
|
|
||||||
FORMS1 += \
|
FORMS1 += \
|
||||||
icmp.ui \
|
icmp.ui \
|
||||||
gmp.ui \
|
gmp.ui \
|
||||||
tcp.ui \
|
|
||||||
udp.ui \
|
udp.ui \
|
||||||
textproto.ui \
|
textproto.ui \
|
||||||
userscript.ui \
|
userscript.ui \
|
||||||
@ -61,7 +61,8 @@ HEADERS += \
|
|||||||
arpconfig.h \
|
arpconfig.h \
|
||||||
ip4config.h \
|
ip4config.h \
|
||||||
ip6config.h \
|
ip6config.h \
|
||||||
ip4over4config.h
|
ip4over4config.h \
|
||||||
|
tcpconfig.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
ostprotolib.cpp \
|
ostprotolib.cpp \
|
||||||
@ -84,7 +85,8 @@ SOURCES += \
|
|||||||
snapconfig.cpp \
|
snapconfig.cpp \
|
||||||
arpconfig.cpp \
|
arpconfig.cpp \
|
||||||
ip4config.cpp \
|
ip4config.cpp \
|
||||||
ip6config.cpp
|
ip6config.cpp \
|
||||||
|
tcpconfig.cpp
|
||||||
|
|
||||||
QMAKE_DISTCLEAN += object_script.*
|
QMAKE_DISTCLEAN += object_script.*
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "icmp.h"
|
#include "icmp.h"
|
||||||
#include "igmp.h"
|
#include "igmp.h"
|
||||||
#include "mld.h"
|
#include "mld.h"
|
||||||
#include "tcp.h"
|
|
||||||
#include "udp.h"
|
#include "udp.h"
|
||||||
#include "textproto.h"
|
#include "textproto.h"
|
||||||
#include "userscript.h"
|
#include "userscript.h"
|
||||||
@ -43,6 +42,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "snap.h"
|
#include "snap.h"
|
||||||
#include "dot2snap.h"
|
#include "dot2snap.h"
|
||||||
#include "eth2.h"
|
#include "eth2.h"
|
||||||
|
// L3 Protos
|
||||||
#include "arp.h"
|
#include "arp.h"
|
||||||
#include "ip4.h"
|
#include "ip4.h"
|
||||||
#include "ip6.h"
|
#include "ip6.h"
|
||||||
@ -50,6 +50,8 @@ 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
|
||||||
|
#include "tcp.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ProtocolManager *OstProtocolManager;
|
ProtocolManager *OstProtocolManager;
|
||||||
@ -66,8 +68,6 @@ ProtocolManager::ProtocolManager()
|
|||||||
(void*) IgmpProtocol::createInstance);
|
(void*) IgmpProtocol::createInstance);
|
||||||
registerProtocol(OstProto::Protocol::kMldFieldNumber,
|
registerProtocol(OstProto::Protocol::kMldFieldNumber,
|
||||||
(void*) MldProtocol::createInstance);
|
(void*) MldProtocol::createInstance);
|
||||||
registerProtocol(OstProto::Protocol::kTcpFieldNumber,
|
|
||||||
(void*) TcpProtocol::createInstance);
|
|
||||||
registerProtocol(OstProto::Protocol::kUdpFieldNumber,
|
registerProtocol(OstProto::Protocol::kUdpFieldNumber,
|
||||||
(void*) UdpProtocol::createInstance);
|
(void*) UdpProtocol::createInstance);
|
||||||
registerProtocol(OstProto::Protocol::kTextProtocolFieldNumber,
|
registerProtocol(OstProto::Protocol::kTextProtocolFieldNumber,
|
||||||
@ -106,6 +106,7 @@ ProtocolManager::ProtocolManager()
|
|||||||
registerProtocol(OstProto::Protocol::kDot2SnapFieldNumber,
|
registerProtocol(OstProto::Protocol::kDot2SnapFieldNumber,
|
||||||
(void*) Dot2SnapProtocol::createInstance);
|
(void*) Dot2SnapProtocol::createInstance);
|
||||||
|
|
||||||
|
// Layer 3 Protocols
|
||||||
registerProtocol(OstProto::Protocol::kArpFieldNumber,
|
registerProtocol(OstProto::Protocol::kArpFieldNumber,
|
||||||
(void*) ArpProtocol::createInstance);
|
(void*) ArpProtocol::createInstance);
|
||||||
registerProtocol(OstProto::Protocol::kIp4FieldNumber,
|
registerProtocol(OstProto::Protocol::kIp4FieldNumber,
|
||||||
@ -121,6 +122,10 @@ ProtocolManager::ProtocolManager()
|
|||||||
(void*) Ip6over4Protocol::createInstance);
|
(void*) Ip6over4Protocol::createInstance);
|
||||||
registerProtocol(OstProto::Protocol::kIp6over6FieldNumber,
|
registerProtocol(OstProto::Protocol::kIp6over6FieldNumber,
|
||||||
(void*) Ip6over6Protocol::createInstance);
|
(void*) Ip6over6Protocol::createInstance);
|
||||||
|
|
||||||
|
// Layer 4 Protocols
|
||||||
|
registerProtocol(OstProto::Protocol::kTcpFieldNumber,
|
||||||
|
(void*) TcpProtocol::createInstance);
|
||||||
#endif
|
#endif
|
||||||
populateNeighbourProtocols();
|
populateNeighbourProtocols();
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "ip4over6config.h"
|
#include "ip4over6config.h"
|
||||||
#include "ip6over4config.h"
|
#include "ip6over4config.h"
|
||||||
#include "ip6over6config.h"
|
#include "ip6over6config.h"
|
||||||
|
#include "tcpconfig.h"
|
||||||
|
|
||||||
ProtocolWidgetFactory *OstProtocolWidgetFactory;
|
ProtocolWidgetFactory *OstProtocolWidgetFactory;
|
||||||
QMap<int, void*> ProtocolWidgetFactory::configWidgetFactory;
|
QMap<int, void*> ProtocolWidgetFactory::configWidgetFactory;
|
||||||
@ -83,6 +84,7 @@ ProtocolWidgetFactory::ProtocolWidgetFactory()
|
|||||||
OstProto::Protocol::kDot2SnapFieldNumber,
|
OstProto::Protocol::kDot2SnapFieldNumber,
|
||||||
(void*) Dot2SnapConfigForm::createInstance);
|
(void*) Dot2SnapConfigForm::createInstance);
|
||||||
|
|
||||||
|
// Layer 3 Protocols
|
||||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||||
OstProto::Protocol::kArpFieldNumber,
|
OstProto::Protocol::kArpFieldNumber,
|
||||||
(void*) ArpConfigForm::createInstance);
|
(void*) ArpConfigForm::createInstance);
|
||||||
@ -105,6 +107,11 @@ ProtocolWidgetFactory::ProtocolWidgetFactory()
|
|||||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||||
OstProto::Protocol::kIp6over6FieldNumber,
|
OstProto::Protocol::kIp6over6FieldNumber,
|
||||||
(void*) Ip6over6ConfigForm::createInstance);
|
(void*) Ip6over6ConfigForm::createInstance);
|
||||||
|
|
||||||
|
// Layer 4 Protocols
|
||||||
|
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||||
|
OstProto::Protocol::kTcpFieldNumber,
|
||||||
|
(void*) TcpConfigForm::createInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolWidgetFactory::~ProtocolWidgetFactory()
|
ProtocolWidgetFactory::~ProtocolWidgetFactory()
|
||||||
|
103
common/tcp.cpp
103
common/tcp.cpp
@ -17,26 +17,16 @@ 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 "tcp.h"
|
#include "tcp.h"
|
||||||
|
|
||||||
TcpConfigForm::TcpConfigForm(QWidget *parent)
|
|
||||||
: QWidget(parent)
|
|
||||||
{
|
|
||||||
setupUi(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
TcpProtocol::TcpProtocol(StreamBase *stream, AbstractProtocol *parent)
|
TcpProtocol::TcpProtocol(StreamBase *stream, AbstractProtocol *parent)
|
||||||
: AbstractProtocol(stream, parent)
|
: AbstractProtocol(stream, parent)
|
||||||
{
|
{
|
||||||
configForm = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TcpProtocol::~TcpProtocol()
|
TcpProtocol::~TcpProtocol()
|
||||||
{
|
{
|
||||||
delete configForm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractProtocol* TcpProtocol::createInstance(StreamBase *stream,
|
AbstractProtocol* TcpProtocol::createInstance(StreamBase *stream,
|
||||||
@ -614,96 +604,3 @@ int TcpProtocol::protocolFrameVariableCount() const
|
|||||||
return protocolFramePayloadVariableCount();
|
return protocolFramePayloadVariableCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* TcpProtocol::configWidget()
|
|
||||||
{
|
|
||||||
if (configForm == NULL)
|
|
||||||
{
|
|
||||||
configForm = new TcpConfigForm;
|
|
||||||
loadConfigWidget();
|
|
||||||
}
|
|
||||||
return configForm;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TcpProtocol::loadConfigWidget()
|
|
||||||
{
|
|
||||||
configWidget();
|
|
||||||
|
|
||||||
configForm->leTcpSrcPort->setText(
|
|
||||||
fieldData(tcp_src_port, FieldValue).toString());
|
|
||||||
configForm->cbTcpSrcPortOverride->setChecked(
|
|
||||||
fieldData(tcp_is_override_src_port, FieldValue).toBool());
|
|
||||||
|
|
||||||
configForm->leTcpDstPort->setText(
|
|
||||||
fieldData(tcp_dst_port, FieldValue).toString());
|
|
||||||
configForm->cbTcpDstPortOverride->setChecked(
|
|
||||||
fieldData(tcp_is_override_dst_port, FieldValue).toBool());
|
|
||||||
|
|
||||||
configForm->leTcpSeqNum->setText(
|
|
||||||
fieldData(tcp_seq_num, FieldValue).toString());
|
|
||||||
configForm->leTcpAckNum->setText(
|
|
||||||
fieldData(tcp_ack_num, FieldValue).toString());
|
|
||||||
|
|
||||||
configForm->leTcpHdrLen->setText(
|
|
||||||
fieldData(tcp_hdrlen, FieldValue).toString());
|
|
||||||
configForm->cbTcpHdrLenOverride->setChecked(
|
|
||||||
fieldData(tcp_is_override_hdrlen, FieldValue).toBool());
|
|
||||||
|
|
||||||
configForm->leTcpWindow->setText(
|
|
||||||
fieldData(tcp_window, FieldValue).toString());
|
|
||||||
|
|
||||||
configForm->leTcpCksum->setText(QString("%1").arg(
|
|
||||||
fieldData(tcp_cksum, FieldValue).toUInt(), 4, BASE_HEX, QChar('0')));
|
|
||||||
configForm->cbTcpCksumOverride->setChecked(
|
|
||||||
fieldData(tcp_is_override_cksum, FieldValue).toBool());
|
|
||||||
|
|
||||||
configForm->leTcpUrgentPointer->setText(
|
|
||||||
fieldData(tcp_urg_ptr, FieldValue).toString());
|
|
||||||
|
|
||||||
uint flags = fieldData(tcp_flags, FieldValue).toUInt();
|
|
||||||
configForm->cbTcpFlagsUrg->setChecked((flags & TCP_FLAG_URG) > 0);
|
|
||||||
configForm->cbTcpFlagsAck->setChecked((flags & TCP_FLAG_ACK) > 0);
|
|
||||||
configForm->cbTcpFlagsPsh->setChecked((flags & TCP_FLAG_PSH) > 0);
|
|
||||||
configForm->cbTcpFlagsRst->setChecked((flags & TCP_FLAG_RST) > 0);
|
|
||||||
configForm->cbTcpFlagsSyn->setChecked((flags & TCP_FLAG_SYN) > 0);
|
|
||||||
configForm->cbTcpFlagsFin->setChecked((flags & TCP_FLAG_FIN) > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TcpProtocol::storeConfigWidget()
|
|
||||||
{
|
|
||||||
bool isOk;
|
|
||||||
int ff = 0;
|
|
||||||
|
|
||||||
configWidget();
|
|
||||||
|
|
||||||
setFieldData(tcp_src_port, configForm->leTcpSrcPort->text());
|
|
||||||
setFieldData(tcp_is_override_src_port,
|
|
||||||
configForm->cbTcpSrcPortOverride->isChecked());
|
|
||||||
setFieldData(tcp_dst_port, configForm->leTcpDstPort->text());
|
|
||||||
setFieldData(tcp_is_override_dst_port,
|
|
||||||
configForm->cbTcpDstPortOverride->isChecked());
|
|
||||||
|
|
||||||
setFieldData(tcp_seq_num, configForm->leTcpSeqNum->text());
|
|
||||||
setFieldData(tcp_ack_num, configForm->leTcpAckNum->text());
|
|
||||||
|
|
||||||
setFieldData(tcp_hdrlen, configForm->leTcpHdrLen->text());
|
|
||||||
setFieldData(tcp_is_override_hdrlen,
|
|
||||||
configForm->cbTcpHdrLenOverride->isChecked());
|
|
||||||
|
|
||||||
setFieldData(tcp_window, configForm->leTcpWindow->text());
|
|
||||||
|
|
||||||
setFieldData(tcp_cksum, configForm->leTcpCksum->text().remove(QChar(' '))
|
|
||||||
.toUInt(&isOk, BASE_HEX));
|
|
||||||
setFieldData(tcp_is_override_cksum,
|
|
||||||
configForm->cbTcpCksumOverride->isChecked());
|
|
||||||
|
|
||||||
setFieldData(tcp_urg_ptr, configForm->leTcpUrgentPointer->text());
|
|
||||||
|
|
||||||
if (configForm->cbTcpFlagsUrg->isChecked()) ff |= TCP_FLAG_URG;
|
|
||||||
if (configForm->cbTcpFlagsAck->isChecked()) ff |= TCP_FLAG_ACK;
|
|
||||||
if (configForm->cbTcpFlagsPsh->isChecked()) ff |= TCP_FLAG_PSH;
|
|
||||||
if (configForm->cbTcpFlagsRst->isChecked()) ff |= TCP_FLAG_RST;
|
|
||||||
if (configForm->cbTcpFlagsSyn->isChecked()) ff |= TCP_FLAG_SYN;
|
|
||||||
if (configForm->cbTcpFlagsFin->isChecked()) ff |= TCP_FLAG_FIN;
|
|
||||||
setFieldData(tcp_flags, ff);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
18
common/tcp.h
18
common/tcp.h
@ -23,7 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "abstractprotocol.h"
|
#include "abstractprotocol.h"
|
||||||
|
|
||||||
#include "tcp.pb.h"
|
#include "tcp.pb.h"
|
||||||
#include "ui_tcp.h"
|
|
||||||
|
|
||||||
#define TCP_FLAG_URG 0x20
|
#define TCP_FLAG_URG 0x20
|
||||||
#define TCP_FLAG_ACK 0x10
|
#define TCP_FLAG_ACK 0x10
|
||||||
@ -32,18 +31,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#define TCP_FLAG_SYN 0x02
|
#define TCP_FLAG_SYN 0x02
|
||||||
#define TCP_FLAG_FIN 0x01
|
#define TCP_FLAG_FIN 0x01
|
||||||
|
|
||||||
class TcpConfigForm : public QWidget, public Ui::tcp
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
TcpConfigForm(QWidget *parent = 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
class TcpProtocol : public AbstractProtocol
|
class TcpProtocol : public AbstractProtocol
|
||||||
{
|
{
|
||||||
private:
|
public:
|
||||||
OstProto::Tcp data;
|
|
||||||
TcpConfigForm *configForm;
|
|
||||||
enum tcpfield
|
enum tcpfield
|
||||||
{
|
{
|
||||||
tcp_src_port = 0,
|
tcp_src_port = 0,
|
||||||
@ -65,7 +55,6 @@ private:
|
|||||||
tcp_fieldCount
|
tcp_fieldCount
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
TcpProtocol(StreamBase *stream, AbstractProtocol *parent = 0);
|
TcpProtocol(StreamBase *stream, AbstractProtocol *parent = 0);
|
||||||
virtual ~TcpProtocol();
|
virtual ~TcpProtocol();
|
||||||
|
|
||||||
@ -93,9 +82,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::Tcp data;
|
||||||
virtual void storeConfigWidget();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
175
common/tcpconfig.cpp
Normal file
175
common/tcpconfig.cpp
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
/*
|
||||||
|
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 "tcpconfig.h"
|
||||||
|
#include "tcp.h"
|
||||||
|
|
||||||
|
TcpConfigForm::TcpConfigForm(QWidget *parent)
|
||||||
|
: AbstractProtocolConfigForm(parent)
|
||||||
|
{
|
||||||
|
setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
TcpConfigForm::~TcpConfigForm()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TcpConfigForm* TcpConfigForm::createInstance()
|
||||||
|
{
|
||||||
|
return new TcpConfigForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TcpConfigForm::loadWidget(AbstractProtocol *proto)
|
||||||
|
{
|
||||||
|
leTcpSrcPort->setText(
|
||||||
|
proto->fieldData(
|
||||||
|
TcpProtocol::tcp_src_port,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toString());
|
||||||
|
cbTcpSrcPortOverride->setChecked(
|
||||||
|
proto->fieldData(
|
||||||
|
TcpProtocol::tcp_is_override_src_port,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toBool());
|
||||||
|
|
||||||
|
leTcpDstPort->setText(
|
||||||
|
proto->fieldData(
|
||||||
|
TcpProtocol::tcp_dst_port,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toString());
|
||||||
|
cbTcpDstPortOverride->setChecked(
|
||||||
|
proto->fieldData(
|
||||||
|
TcpProtocol::tcp_is_override_dst_port,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toBool());
|
||||||
|
|
||||||
|
leTcpSeqNum->setText(
|
||||||
|
proto->fieldData(
|
||||||
|
TcpProtocol::tcp_seq_num,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toString());
|
||||||
|
leTcpAckNum->setText(
|
||||||
|
proto->fieldData(
|
||||||
|
TcpProtocol::tcp_ack_num,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toString());
|
||||||
|
|
||||||
|
leTcpHdrLen->setText(
|
||||||
|
proto->fieldData(
|
||||||
|
TcpProtocol::tcp_hdrlen,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toString());
|
||||||
|
cbTcpHdrLenOverride->setChecked(
|
||||||
|
proto->fieldData(
|
||||||
|
TcpProtocol::tcp_is_override_hdrlen,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toBool());
|
||||||
|
|
||||||
|
leTcpWindow->setText(
|
||||||
|
proto->fieldData(
|
||||||
|
TcpProtocol::tcp_window,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toString());
|
||||||
|
|
||||||
|
leTcpCksum->setText(uintToHexStr(
|
||||||
|
proto->fieldData(
|
||||||
|
TcpProtocol::tcp_cksum,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toUInt(), 2));
|
||||||
|
cbTcpCksumOverride->setChecked(
|
||||||
|
proto->fieldData(
|
||||||
|
TcpProtocol::tcp_is_override_cksum,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toBool());
|
||||||
|
|
||||||
|
leTcpUrgentPointer->setText(
|
||||||
|
proto->fieldData(
|
||||||
|
TcpProtocol::tcp_urg_ptr,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toString());
|
||||||
|
|
||||||
|
uint flags = proto->fieldData(
|
||||||
|
TcpProtocol::tcp_flags,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toUInt();
|
||||||
|
|
||||||
|
cbTcpFlagsUrg->setChecked((flags & TCP_FLAG_URG) > 0);
|
||||||
|
cbTcpFlagsAck->setChecked((flags & TCP_FLAG_ACK) > 0);
|
||||||
|
cbTcpFlagsPsh->setChecked((flags & TCP_FLAG_PSH) > 0);
|
||||||
|
cbTcpFlagsRst->setChecked((flags & TCP_FLAG_RST) > 0);
|
||||||
|
cbTcpFlagsSyn->setChecked((flags & TCP_FLAG_SYN) > 0);
|
||||||
|
cbTcpFlagsFin->setChecked((flags & TCP_FLAG_FIN) > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TcpConfigForm::storeWidget(AbstractProtocol *proto)
|
||||||
|
{
|
||||||
|
int ff = 0;
|
||||||
|
|
||||||
|
proto->setFieldData(
|
||||||
|
TcpProtocol::tcp_src_port,
|
||||||
|
leTcpSrcPort->text());
|
||||||
|
proto->setFieldData(
|
||||||
|
TcpProtocol::tcp_is_override_src_port,
|
||||||
|
cbTcpSrcPortOverride->isChecked());
|
||||||
|
proto->setFieldData(
|
||||||
|
TcpProtocol::tcp_dst_port,
|
||||||
|
leTcpDstPort->text());
|
||||||
|
proto->setFieldData(
|
||||||
|
TcpProtocol::tcp_is_override_dst_port,
|
||||||
|
cbTcpDstPortOverride->isChecked());
|
||||||
|
|
||||||
|
proto->setFieldData(
|
||||||
|
TcpProtocol::tcp_seq_num,
|
||||||
|
leTcpSeqNum->text());
|
||||||
|
proto->setFieldData(
|
||||||
|
TcpProtocol::tcp_ack_num,
|
||||||
|
leTcpAckNum->text());
|
||||||
|
|
||||||
|
proto->setFieldData(
|
||||||
|
TcpProtocol::tcp_hdrlen,
|
||||||
|
leTcpHdrLen->text());
|
||||||
|
proto->setFieldData(
|
||||||
|
TcpProtocol::tcp_is_override_hdrlen,
|
||||||
|
cbTcpHdrLenOverride->isChecked());
|
||||||
|
|
||||||
|
proto->setFieldData(
|
||||||
|
TcpProtocol::tcp_window,
|
||||||
|
leTcpWindow->text());
|
||||||
|
|
||||||
|
proto->setFieldData(
|
||||||
|
TcpProtocol::tcp_cksum,
|
||||||
|
hexStrToUInt(leTcpCksum->text()));
|
||||||
|
proto->setFieldData(
|
||||||
|
TcpProtocol::tcp_is_override_cksum,
|
||||||
|
cbTcpCksumOverride->isChecked());
|
||||||
|
|
||||||
|
proto->setFieldData(
|
||||||
|
TcpProtocol::tcp_urg_ptr,
|
||||||
|
leTcpUrgentPointer->text());
|
||||||
|
|
||||||
|
if (cbTcpFlagsUrg->isChecked()) ff |= TCP_FLAG_URG;
|
||||||
|
if (cbTcpFlagsAck->isChecked()) ff |= TCP_FLAG_ACK;
|
||||||
|
if (cbTcpFlagsPsh->isChecked()) ff |= TCP_FLAG_PSH;
|
||||||
|
if (cbTcpFlagsRst->isChecked()) ff |= TCP_FLAG_RST;
|
||||||
|
if (cbTcpFlagsSyn->isChecked()) ff |= TCP_FLAG_SYN;
|
||||||
|
if (cbTcpFlagsFin->isChecked()) ff |= TCP_FLAG_FIN;
|
||||||
|
|
||||||
|
proto->setFieldData(TcpProtocol::tcp_flags, ff);
|
||||||
|
}
|
||||||
|
|
41
common/tcpconfig.h
Normal file
41
common/tcpconfig.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 _TCP_CONFIG_H
|
||||||
|
#define _TCP_CONFIG_H
|
||||||
|
|
||||||
|
#include "abstractprotocolconfig.h"
|
||||||
|
#include "ui_tcp.h"
|
||||||
|
|
||||||
|
class TcpConfigForm :
|
||||||
|
public AbstractProtocolConfigForm,
|
||||||
|
private Ui::tcp
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
TcpConfigForm(QWidget *parent = 0);
|
||||||
|
virtual ~TcpConfigForm();
|
||||||
|
|
||||||
|
static TcpConfigForm* createInstance();
|
||||||
|
|
||||||
|
virtual void loadWidget(AbstractProtocol *proto);
|
||||||
|
virtual void storeWidget(AbstractProtocol *proto);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user