NOX: LLC - Separated protocol and widget as per new framework
This commit is contained in:
parent
70937bd4a4
commit
a8dcc42d4c
@ -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 "llc.h"
|
||||
|
||||
LlcConfigForm::LlcConfigForm(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
LlcProtocol::LlcProtocol(StreamBase *stream, AbstractProtocol *parent)
|
||||
: AbstractProtocol(stream, parent)
|
||||
{
|
||||
configForm = NULL;
|
||||
}
|
||||
|
||||
LlcProtocol::~LlcProtocol()
|
||||
{
|
||||
delete configForm;
|
||||
}
|
||||
|
||||
AbstractProtocol* LlcProtocol::createInstance(StreamBase *stream,
|
||||
@ -273,59 +262,3 @@ bool LlcProtocol::setFieldData(int index, const QVariant &value,
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
|
||||
|
||||
QWidget* LlcProtocol::configWidget()
|
||||
{
|
||||
if (configForm == NULL)
|
||||
{
|
||||
configForm = new LlcConfigForm;
|
||||
loadConfigWidget();
|
||||
}
|
||||
return configForm;
|
||||
}
|
||||
|
||||
void LlcProtocol::loadConfigWidget()
|
||||
{
|
||||
#define uintToHexStr(num, bytes) \
|
||||
QString("%1").arg(num, bytes*2, BASE_HEX, QChar('0'))
|
||||
|
||||
configWidget();
|
||||
|
||||
configForm->cbOverrideDsap->setChecked(
|
||||
fieldData(llc_is_override_dsap, FieldValue).toBool());
|
||||
configForm->leDsap->setText(uintToHexStr(
|
||||
fieldData(llc_dsap, FieldValue).toUInt(), 1));
|
||||
|
||||
configForm->cbOverrideSsap->setChecked(
|
||||
fieldData(llc_is_override_ssap, FieldValue).toBool());
|
||||
configForm->leSsap->setText(uintToHexStr(
|
||||
fieldData(llc_ssap, FieldValue).toUInt(), 1));
|
||||
|
||||
configForm->cbOverrideControl->setChecked(
|
||||
fieldData(llc_is_override_ctl, FieldValue).toBool());
|
||||
configForm->leControl->setText(uintToHexStr(
|
||||
fieldData(llc_ctl, FieldValue).toUInt(), 1));
|
||||
#undef uintToHexStr
|
||||
}
|
||||
|
||||
void LlcProtocol::storeConfigWidget()
|
||||
{
|
||||
bool isOk;
|
||||
|
||||
configWidget();
|
||||
|
||||
setFieldData(llc_is_override_dsap,
|
||||
configForm->cbOverrideDsap->isChecked());
|
||||
setFieldData(llc_dsap, configForm->leDsap->text().toUInt(&isOk, BASE_HEX));
|
||||
|
||||
setFieldData(llc_is_override_ssap,
|
||||
configForm->cbOverrideSsap->isChecked());
|
||||
setFieldData(llc_ssap, configForm->leSsap->text().toUInt(&isOk, BASE_HEX));
|
||||
|
||||
setFieldData(llc_is_override_ctl,
|
||||
configForm->cbOverrideControl->isChecked());
|
||||
setFieldData(llc_ctl,
|
||||
configForm->leControl->text().toUInt(&isOk, BASE_HEX));
|
||||
}
|
||||
|
||||
|
21
common/llc.h
21
common/llc.h
@ -20,26 +20,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#ifndef _LLC_H
|
||||
#define _LLC_H
|
||||
|
||||
#include <QSize>
|
||||
#include <qdebug.h>
|
||||
|
||||
#include "abstractprotocol.h"
|
||||
|
||||
#include "llc.pb.h"
|
||||
#include "ui_llc.h"
|
||||
|
||||
class LlcConfigForm : public QWidget, public Ui::llc
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LlcConfigForm(QWidget *parent = 0);
|
||||
};
|
||||
|
||||
class LlcProtocol : public AbstractProtocol
|
||||
{
|
||||
private:
|
||||
OstProto::Llc data;
|
||||
LlcConfigForm *configForm;
|
||||
public:
|
||||
enum llcfield
|
||||
{
|
||||
llc_dsap = 0,
|
||||
@ -54,7 +41,6 @@ private:
|
||||
llc_fieldCount
|
||||
};
|
||||
|
||||
public:
|
||||
LlcProtocol(StreamBase *stream, AbstractProtocol *parent = 0);
|
||||
virtual ~LlcProtocol();
|
||||
|
||||
@ -78,9 +64,8 @@ public:
|
||||
virtual bool setFieldData(int index, const QVariant &value,
|
||||
FieldAttrib attrib = FieldValue);
|
||||
|
||||
virtual QWidget* configWidget();
|
||||
virtual void loadConfigWidget();
|
||||
virtual void storeConfigWidget();
|
||||
private:
|
||||
OstProto::Llc data;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
100
common/llcconfig.cpp
Normal file
100
common/llcconfig.cpp
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
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 "llcconfig.h"
|
||||
#include "llc.h"
|
||||
|
||||
LlcConfigForm::LlcConfigForm(QWidget *parent)
|
||||
: AbstractProtocolConfigForm(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
LlcConfigForm::~LlcConfigForm()
|
||||
{
|
||||
}
|
||||
|
||||
LlcConfigForm* LlcConfigForm::createInstance()
|
||||
{
|
||||
return new LlcConfigForm;
|
||||
}
|
||||
|
||||
void LlcConfigForm::loadWidget(AbstractProtocol *proto)
|
||||
{
|
||||
cbOverrideDsap->setChecked(
|
||||
proto->fieldData(
|
||||
LlcProtocol::llc_is_override_dsap,
|
||||
AbstractProtocol::FieldValue
|
||||
).toBool());
|
||||
leDsap->setText(uintToHexStr(
|
||||
proto->fieldData(
|
||||
LlcProtocol::llc_dsap,
|
||||
AbstractProtocol::FieldValue
|
||||
).toUInt(), 1));
|
||||
|
||||
cbOverrideSsap->setChecked(
|
||||
proto->fieldData(
|
||||
LlcProtocol::llc_is_override_ssap,
|
||||
AbstractProtocol::FieldValue
|
||||
).toBool());
|
||||
leSsap->setText(uintToHexStr(
|
||||
proto->fieldData(
|
||||
LlcProtocol::llc_ssap,
|
||||
AbstractProtocol::FieldValue
|
||||
).toUInt(), 1));
|
||||
|
||||
cbOverrideControl->setChecked(
|
||||
proto->fieldData(
|
||||
LlcProtocol::llc_is_override_ctl,
|
||||
AbstractProtocol::FieldValue
|
||||
).toBool());
|
||||
leControl->setText(uintToHexStr(
|
||||
proto->fieldData(
|
||||
LlcProtocol::llc_ctl,
|
||||
AbstractProtocol::FieldValue
|
||||
).toUInt(), 1));
|
||||
}
|
||||
|
||||
void
|
||||
LlcConfigForm::storeWidget(AbstractProtocol *proto)
|
||||
{
|
||||
bool isOk;
|
||||
|
||||
proto->setFieldData(
|
||||
LlcProtocol::llc_is_override_dsap,
|
||||
cbOverrideDsap->isChecked());
|
||||
proto->setFieldData(
|
||||
LlcProtocol::llc_dsap,
|
||||
leDsap->text().toUInt(&isOk, BASE_HEX));
|
||||
|
||||
proto->setFieldData(
|
||||
LlcProtocol::llc_is_override_ssap,
|
||||
cbOverrideSsap->isChecked());
|
||||
proto->setFieldData(
|
||||
LlcProtocol::llc_ssap,
|
||||
leSsap->text().toUInt(&isOk, BASE_HEX));
|
||||
|
||||
proto->setFieldData(
|
||||
LlcProtocol::llc_is_override_ctl,
|
||||
cbOverrideControl->isChecked());
|
||||
proto->setFieldData(
|
||||
LlcProtocol::llc_ctl,
|
||||
leControl->text().toUInt(&isOk, BASE_HEX));
|
||||
}
|
||||
|
41
common/llcconfig.h
Normal file
41
common/llcconfig.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 _LLC_CONFIG_H
|
||||
#define _LLC_CONFIG_H
|
||||
|
||||
#include "abstractprotocolconfig.h"
|
||||
#include "ui_llc.h"
|
||||
|
||||
class LlcConfigForm :
|
||||
public AbstractProtocolConfigForm,
|
||||
private Ui::llc
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LlcConfigForm(QWidget *parent = 0);
|
||||
virtual ~LlcConfigForm();
|
||||
|
||||
static LlcConfigForm* createInstance();
|
||||
|
||||
virtual void loadWidget(AbstractProtocol *proto);
|
||||
virtual void storeWidget(AbstractProtocol *proto);
|
||||
};
|
||||
|
||||
#endif
|
@ -47,15 +47,15 @@ HEADERS = \
|
||||
HEADERS += \
|
||||
mac.h \
|
||||
payload.h \
|
||||
dot3.h \
|
||||
vlan.h \
|
||||
svlan.h \
|
||||
vlanstack.h \
|
||||
eth2.h \
|
||||
dot3.h \
|
||||
llc.h \
|
||||
ip6.h
|
||||
|
||||
HEADERS1 += \
|
||||
llc.h \
|
||||
snap.h \
|
||||
dot2llc.h \
|
||||
dot2snap.h \
|
||||
@ -91,12 +91,12 @@ SOURCES += \
|
||||
payload.cpp \
|
||||
vlan.cpp \
|
||||
svlan.cpp \
|
||||
dot3.cpp \
|
||||
eth2.cpp \
|
||||
dot3.cpp \
|
||||
llc.cpp \
|
||||
ip6.cpp
|
||||
|
||||
SOURCES1 += \
|
||||
llc.cpp \
|
||||
snap.cpp \
|
||||
arp.cpp \
|
||||
ip4.cpp \
|
||||
|
@ -11,12 +11,12 @@ FORMS += \
|
||||
mac.ui \
|
||||
payload.ui \
|
||||
vlan.ui \
|
||||
dot3.ui \
|
||||
eth2.ui \
|
||||
dot3.ui \
|
||||
llc.ui \
|
||||
ip6.ui \
|
||||
|
||||
FORMS1 += \
|
||||
llc.ui \
|
||||
snap.ui \
|
||||
arp.ui \
|
||||
ip4.ui \
|
||||
@ -52,8 +52,9 @@ HEADERS += \
|
||||
vlanconfig.h \
|
||||
svlanconfig.h \
|
||||
vlanstackconfig.h \
|
||||
dot3config.h \
|
||||
eth2config.h \
|
||||
dot3config.h \
|
||||
llcconfig.h \
|
||||
ip6config.h
|
||||
|
||||
SOURCES += \
|
||||
@ -71,8 +72,9 @@ SOURCES += \
|
||||
macconfig.cpp \
|
||||
payloadconfig.cpp \
|
||||
vlanconfig.cpp \
|
||||
dot3config.cpp \
|
||||
eth2config.cpp \
|
||||
dot3config.cpp \
|
||||
llcconfig.cpp \
|
||||
ip6config.cpp
|
||||
|
||||
QMAKE_DISTCLEAN += object_script.*
|
||||
|
@ -22,7 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "protocol.pb.h"
|
||||
#if 0
|
||||
#include "llc.h"
|
||||
#include "snap.h"
|
||||
#include "dot2llc.h"
|
||||
#include "dot2snap.h"
|
||||
@ -44,10 +43,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#else
|
||||
#include "mac.h"
|
||||
#include "payload.h"
|
||||
#include "dot3.h"
|
||||
#include "vlan.h"
|
||||
#include "svlan.h"
|
||||
#include "vlanstack.h"
|
||||
#include "dot3.h"
|
||||
#include "llc.h"
|
||||
#include "eth2.h"
|
||||
#include "ip6.h"
|
||||
#endif
|
||||
@ -60,8 +60,6 @@ ProtocolManager::ProtocolManager()
|
||||
themselves (once this is done remove the #includes for all the protocols)
|
||||
*/
|
||||
#if 0
|
||||
registerProtocol(OstProto::Protocol::kLlcFieldNumber,
|
||||
(void*) LlcProtocol::createInstance);
|
||||
registerProtocol(OstProto::Protocol::kSnapFieldNumber,
|
||||
(void*) SnapProtocol::createInstance);
|
||||
registerProtocol(OstProto::Protocol::kDot2LlcFieldNumber,
|
||||
@ -108,9 +106,6 @@ ProtocolManager::ProtocolManager()
|
||||
registerProtocol(OstProto::Protocol::kPayloadFieldNumber,
|
||||
(void*) PayloadProtocol::createInstance);
|
||||
|
||||
registerProtocol(OstProto::Protocol::kDot3FieldNumber,
|
||||
(void*) Dot3Protocol::createInstance);
|
||||
|
||||
registerProtocol(OstProto::Protocol::kVlanFieldNumber,
|
||||
(void*) VlanProtocol::createInstance);
|
||||
registerProtocol(OstProto::Protocol::kSvlanFieldNumber,
|
||||
@ -120,6 +115,10 @@ ProtocolManager::ProtocolManager()
|
||||
|
||||
registerProtocol(OstProto::Protocol::kEth2FieldNumber,
|
||||
(void*) Eth2Protocol::createInstance);
|
||||
registerProtocol(OstProto::Protocol::kDot3FieldNumber,
|
||||
(void*) Dot3Protocol::createInstance);
|
||||
registerProtocol(OstProto::Protocol::kLlcFieldNumber,
|
||||
(void*) LlcProtocol::createInstance);
|
||||
|
||||
registerProtocol(OstProto::Protocol::kIp6FieldNumber,
|
||||
(void*) Ip6Protocol::createInstance);
|
||||
|
@ -21,11 +21,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "macconfig.h"
|
||||
#include "payloadconfig.h"
|
||||
#include "dot3config.h"
|
||||
#include "vlanconfig.h"
|
||||
#include "svlanconfig.h"
|
||||
#include "vlanstackconfig.h"
|
||||
#include "eth2config.h"
|
||||
#include "dot3config.h"
|
||||
#include "llcconfig.h"
|
||||
#include "ip6config.h"
|
||||
|
||||
ProtocolWidgetFactory *OstProtocolWidgetFactory;
|
||||
@ -44,10 +45,6 @@ ProtocolWidgetFactory::ProtocolWidgetFactory()
|
||||
OstProto::Protocol::kPayloadFieldNumber,
|
||||
(void*) PayloadConfigForm::createInstance);
|
||||
|
||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||
OstProto::Protocol::kDot3FieldNumber,
|
||||
(void*) Dot3ConfigForm::createInstance);
|
||||
|
||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||
OstProto::Protocol::kVlanFieldNumber,
|
||||
(void*) VlanConfigForm::createInstance);
|
||||
@ -61,6 +58,12 @@ ProtocolWidgetFactory::ProtocolWidgetFactory()
|
||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||
OstProto::Protocol::kEth2FieldNumber,
|
||||
(void*) Eth2ConfigForm::createInstance);
|
||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||
OstProto::Protocol::kDot3FieldNumber,
|
||||
(void*) Dot3ConfigForm::createInstance);
|
||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||
OstProto::Protocol::kLlcFieldNumber,
|
||||
(void*) LlcConfigForm::createInstance);
|
||||
|
||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||
OstProto::Protocol::kIp6FieldNumber,
|
||||
|
Loading…
Reference in New Issue
Block a user