NOX: SNAP - Separated protocl and widget as per new framework
This commit is contained in:
parent
4608edf771
commit
38c17d5e5b
@ -78,6 +78,20 @@ public:
|
|||||||
{
|
{
|
||||||
// Do nothing!
|
// Do nothing!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Convenience Method - can be used by storeConfigWidget() implementations
|
||||||
|
*/
|
||||||
|
uint hexStrToUInt(QString text, bool *ok=NULL)
|
||||||
|
{
|
||||||
|
bool isOk;
|
||||||
|
uint a_uint = text.remove(QChar(' ')).toUInt(&isOk, 16);
|
||||||
|
|
||||||
|
if (ok)
|
||||||
|
*ok = isOk;
|
||||||
|
|
||||||
|
return a_uint;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -54,10 +54,10 @@ HEADERS += \
|
|||||||
dot3.h \
|
dot3.h \
|
||||||
llc.h \
|
llc.h \
|
||||||
dot2llc.h \
|
dot2llc.h \
|
||||||
|
snap.h \
|
||||||
ip6.h
|
ip6.h
|
||||||
|
|
||||||
HEADERS1 += \
|
HEADERS1 += \
|
||||||
snap.h \
|
|
||||||
dot2snap.h \
|
dot2snap.h \
|
||||||
arp.h \
|
arp.h \
|
||||||
ip4.h \
|
ip4.h \
|
||||||
@ -94,10 +94,10 @@ SOURCES += \
|
|||||||
eth2.cpp \
|
eth2.cpp \
|
||||||
dot3.cpp \
|
dot3.cpp \
|
||||||
llc.cpp \
|
llc.cpp \
|
||||||
|
snap.cpp \
|
||||||
ip6.cpp
|
ip6.cpp
|
||||||
|
|
||||||
SOURCES1 += \
|
SOURCES1 += \
|
||||||
snap.cpp \
|
|
||||||
arp.cpp \
|
arp.cpp \
|
||||||
ip4.cpp \
|
ip4.cpp \
|
||||||
icmp.cpp \
|
icmp.cpp \
|
||||||
|
@ -14,10 +14,10 @@ FORMS += \
|
|||||||
eth2.ui \
|
eth2.ui \
|
||||||
dot3.ui \
|
dot3.ui \
|
||||||
llc.ui \
|
llc.ui \
|
||||||
|
snap.ui \
|
||||||
ip6.ui \
|
ip6.ui \
|
||||||
|
|
||||||
FORMS1 += \
|
FORMS1 += \
|
||||||
snap.ui \
|
|
||||||
arp.ui \
|
arp.ui \
|
||||||
ip4.ui \
|
ip4.ui \
|
||||||
icmp.ui \
|
icmp.ui \
|
||||||
@ -56,6 +56,7 @@ HEADERS += \
|
|||||||
dot3config.h \
|
dot3config.h \
|
||||||
llcconfig.h \
|
llcconfig.h \
|
||||||
dot2llcconfig.h \
|
dot2llcconfig.h \
|
||||||
|
snapconfig.h \
|
||||||
ip6config.h
|
ip6config.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
@ -76,6 +77,7 @@ SOURCES += \
|
|||||||
eth2config.cpp \
|
eth2config.cpp \
|
||||||
dot3config.cpp \
|
dot3config.cpp \
|
||||||
llcconfig.cpp \
|
llcconfig.cpp \
|
||||||
|
snapconfig.cpp \
|
||||||
ip6config.cpp
|
ip6config.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 "snap.h"
|
|
||||||
#include "dot2snap.h"
|
#include "dot2snap.h"
|
||||||
#include "arp.h"
|
#include "arp.h"
|
||||||
#include "ip4.h"
|
#include "ip4.h"
|
||||||
@ -48,6 +47,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "dot3.h"
|
#include "dot3.h"
|
||||||
#include "llc.h"
|
#include "llc.h"
|
||||||
#include "dot2llc.h"
|
#include "dot2llc.h"
|
||||||
|
#include "snap.h"
|
||||||
#include "eth2.h"
|
#include "eth2.h"
|
||||||
#include "ip6.h"
|
#include "ip6.h"
|
||||||
#endif
|
#endif
|
||||||
@ -60,8 +60,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::kSnapFieldNumber,
|
|
||||||
(void*) SnapProtocol::createInstance);
|
|
||||||
registerProtocol(OstProto::Protocol::kDot2SnapFieldNumber,
|
registerProtocol(OstProto::Protocol::kDot2SnapFieldNumber,
|
||||||
(void*) Dot2SnapProtocol::createInstance);
|
(void*) Dot2SnapProtocol::createInstance);
|
||||||
|
|
||||||
@ -119,6 +117,8 @@ ProtocolManager::ProtocolManager()
|
|||||||
(void*) LlcProtocol::createInstance);
|
(void*) LlcProtocol::createInstance);
|
||||||
registerProtocol(OstProto::Protocol::kDot2LlcFieldNumber,
|
registerProtocol(OstProto::Protocol::kDot2LlcFieldNumber,
|
||||||
(void*) Dot2LlcProtocol::createInstance);
|
(void*) Dot2LlcProtocol::createInstance);
|
||||||
|
registerProtocol(OstProto::Protocol::kSnapFieldNumber,
|
||||||
|
(void*) SnapProtocol::createInstance);
|
||||||
|
|
||||||
registerProtocol(OstProto::Protocol::kIp6FieldNumber,
|
registerProtocol(OstProto::Protocol::kIp6FieldNumber,
|
||||||
(void*) Ip6Protocol::createInstance);
|
(void*) Ip6Protocol::createInstance);
|
||||||
|
@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "dot3config.h"
|
#include "dot3config.h"
|
||||||
#include "llcconfig.h"
|
#include "llcconfig.h"
|
||||||
#include "dot2llcconfig.h"
|
#include "dot2llcconfig.h"
|
||||||
|
#include "snapconfig.h"
|
||||||
#include "ip6config.h"
|
#include "ip6config.h"
|
||||||
|
|
||||||
ProtocolWidgetFactory *OstProtocolWidgetFactory;
|
ProtocolWidgetFactory *OstProtocolWidgetFactory;
|
||||||
@ -68,6 +69,9 @@ ProtocolWidgetFactory::ProtocolWidgetFactory()
|
|||||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||||
OstProto::Protocol::kDot2LlcFieldNumber,
|
OstProto::Protocol::kDot2LlcFieldNumber,
|
||||||
(void*) Dot2LlcConfigForm::createInstance);
|
(void*) Dot2LlcConfigForm::createInstance);
|
||||||
|
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||||
|
OstProto::Protocol::kSnapFieldNumber,
|
||||||
|
(void*) SnapConfigForm::createInstance);
|
||||||
|
|
||||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||||
OstProto::Protocol::kIp6FieldNumber,
|
OstProto::Protocol::kIp6FieldNumber,
|
||||||
|
@ -17,28 +17,17 @@ 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 "snap.h"
|
#include "snap.h"
|
||||||
|
|
||||||
quint32 kStdOui = 0x000000;
|
quint32 kStdOui = 0x000000;
|
||||||
|
|
||||||
SnapConfigForm::SnapConfigForm(QWidget *parent)
|
|
||||||
: QWidget(parent)
|
|
||||||
{
|
|
||||||
setupUi(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
SnapProtocol::SnapProtocol(StreamBase *stream, AbstractProtocol *parent)
|
SnapProtocol::SnapProtocol(StreamBase *stream, AbstractProtocol *parent)
|
||||||
: AbstractProtocol(stream, parent)
|
: AbstractProtocol(stream, parent)
|
||||||
{
|
{
|
||||||
configForm = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SnapProtocol::~SnapProtocol()
|
SnapProtocol::~SnapProtocol()
|
||||||
{
|
{
|
||||||
delete configForm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractProtocol* SnapProtocol::createInstance(StreamBase *stream,
|
AbstractProtocol* SnapProtocol::createInstance(StreamBase *stream,
|
||||||
@ -264,44 +253,3 @@ bool SnapProtocol::setFieldData(int index, const QVariant &value,
|
|||||||
return isOk;
|
return isOk;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* SnapProtocol::configWidget()
|
|
||||||
{
|
|
||||||
if (configForm == NULL)
|
|
||||||
{
|
|
||||||
configForm = new SnapConfigForm;
|
|
||||||
loadConfigWidget();
|
|
||||||
}
|
|
||||||
return configForm;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SnapProtocol::loadConfigWidget()
|
|
||||||
{
|
|
||||||
configWidget();
|
|
||||||
|
|
||||||
configForm->cbOverrideOui->setChecked(
|
|
||||||
fieldData(snap_is_override_oui, FieldValue).toBool());
|
|
||||||
configForm->leOui->setText(uintToHexStr(
|
|
||||||
fieldData(snap_oui, FieldValue).toUInt(), 3));
|
|
||||||
|
|
||||||
configForm->cbOverrideType->setChecked(
|
|
||||||
fieldData(snap_is_override_type, FieldValue).toBool());
|
|
||||||
configForm->leType->setText(uintToHexStr(
|
|
||||||
fieldData(snap_type, FieldValue).toUInt(), 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SnapProtocol::storeConfigWidget()
|
|
||||||
{
|
|
||||||
bool isOk;
|
|
||||||
configWidget();
|
|
||||||
|
|
||||||
setFieldData(snap_is_override_oui,
|
|
||||||
configForm->cbOverrideOui->isChecked());
|
|
||||||
setFieldData(snap_oui, configForm->leOui->text().remove(QChar(' '))
|
|
||||||
.toUInt(&isOk, BASE_HEX));
|
|
||||||
|
|
||||||
setFieldData(snap_is_override_type,
|
|
||||||
configForm->cbOverrideType->isChecked());
|
|
||||||
setFieldData(snap_type, configForm->leType->text().remove(QChar(' '))
|
|
||||||
.toUInt(&isOk, BASE_HEX));
|
|
||||||
}
|
|
||||||
|
@ -23,20 +23,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "abstractprotocol.h"
|
#include "abstractprotocol.h"
|
||||||
|
|
||||||
#include "snap.pb.h"
|
#include "snap.pb.h"
|
||||||
#include "ui_snap.h"
|
|
||||||
|
|
||||||
class SnapConfigForm : public QWidget, public Ui::snap
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
SnapConfigForm(QWidget *parent = 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
class SnapProtocol : public AbstractProtocol
|
class SnapProtocol : public AbstractProtocol
|
||||||
{
|
{
|
||||||
private:
|
public:
|
||||||
OstProto::Snap data;
|
|
||||||
SnapConfigForm *configForm;
|
|
||||||
enum snapfield
|
enum snapfield
|
||||||
{
|
{
|
||||||
snap_oui = 0,
|
snap_oui = 0,
|
||||||
@ -49,7 +39,6 @@ private:
|
|||||||
snap_fieldCount
|
snap_fieldCount
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
SnapProtocol(StreamBase *stream, AbstractProtocol *parent = 0);
|
SnapProtocol(StreamBase *stream, AbstractProtocol *parent = 0);
|
||||||
virtual ~SnapProtocol();
|
virtual ~SnapProtocol();
|
||||||
|
|
||||||
@ -74,9 +63,8 @@ public:
|
|||||||
virtual bool setFieldData(int index, const QVariant &value,
|
virtual bool setFieldData(int index, const QVariant &value,
|
||||||
FieldAttrib attrib = FieldValue);
|
FieldAttrib attrib = FieldValue);
|
||||||
|
|
||||||
virtual QWidget* configWidget();
|
private:
|
||||||
virtual void loadConfigWidget();
|
OstProto::Snap data;
|
||||||
virtual void storeConfigWidget();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
78
common/snapconfig.cpp
Normal file
78
common/snapconfig.cpp
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
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 "snapconfig.h"
|
||||||
|
#include "snap.h"
|
||||||
|
|
||||||
|
SnapConfigForm::SnapConfigForm(QWidget *parent)
|
||||||
|
: AbstractProtocolConfigForm(parent)
|
||||||
|
{
|
||||||
|
setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
SnapConfigForm::~SnapConfigForm()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SnapConfigForm* SnapConfigForm::createInstance()
|
||||||
|
{
|
||||||
|
return new SnapConfigForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SnapConfigForm::loadWidget(AbstractProtocol *proto)
|
||||||
|
{
|
||||||
|
cbOverrideOui->setChecked(
|
||||||
|
proto->fieldData(
|
||||||
|
SnapProtocol::snap_is_override_oui,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toBool());
|
||||||
|
leOui->setText(uintToHexStr(
|
||||||
|
proto->fieldData(
|
||||||
|
SnapProtocol::snap_oui,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toUInt(), 3));
|
||||||
|
|
||||||
|
cbOverrideType->setChecked(
|
||||||
|
proto->fieldData(
|
||||||
|
SnapProtocol::snap_is_override_type,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toBool());
|
||||||
|
leType->setText(uintToHexStr(
|
||||||
|
proto->fieldData(
|
||||||
|
SnapProtocol::snap_type,
|
||||||
|
AbstractProtocol::FieldValue
|
||||||
|
).toUInt(), 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SnapConfigForm::storeWidget(AbstractProtocol *proto)
|
||||||
|
{
|
||||||
|
proto->setFieldData(
|
||||||
|
SnapProtocol::snap_is_override_oui,
|
||||||
|
cbOverrideOui->isChecked());
|
||||||
|
proto->setFieldData(
|
||||||
|
SnapProtocol::snap_oui,
|
||||||
|
hexStrToUInt(leOui->text()));
|
||||||
|
|
||||||
|
proto->setFieldData(
|
||||||
|
SnapProtocol::snap_is_override_type,
|
||||||
|
cbOverrideType->isChecked());
|
||||||
|
proto->setFieldData(
|
||||||
|
SnapProtocol::snap_type,
|
||||||
|
hexStrToUInt(leType->text()));
|
||||||
|
}
|
41
common/snapconfig.h
Normal file
41
common/snapconfig.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 _SNAP_CONFIG_H
|
||||||
|
#define _SNAP_CONFIG_H
|
||||||
|
|
||||||
|
#include "abstractprotocolconfig.h"
|
||||||
|
#include "ui_snap.h"
|
||||||
|
|
||||||
|
class SnapConfigForm :
|
||||||
|
public AbstractProtocolConfigForm,
|
||||||
|
private Ui::snap
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
SnapConfigForm(QWidget *parent = 0);
|
||||||
|
virtual ~SnapConfigForm();
|
||||||
|
|
||||||
|
static SnapConfigForm* createInstance();
|
||||||
|
|
||||||
|
virtual void loadWidget(AbstractProtocol *proto);
|
||||||
|
virtual void storeWidget(AbstractProtocol *proto);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user