diff --git a/common/dot3.cpp b/common/dot3.cpp
index 6b7afb0..68ef9a6 100644
--- a/common/dot3.cpp
+++ b/common/dot3.cpp
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2010 Srivats P.
+Copyright (C) 2010-2014 Srivats P.
This file is part of "Ostinato"
@@ -18,28 +18,14 @@ along with this program. If not, see
*/
#include "dot3.h"
-#include "streambase.h"
-
-#include
-#include
-#include
-
-Dot3ConfigForm::Dot3ConfigForm(QWidget *parent)
- : QWidget(parent)
-{
- setupUi(this);
- leLength->setValidator(new QIntValidator(0, 16384, this));
-}
Dot3Protocol::Dot3Protocol(StreamBase *stream, AbstractProtocol *parent)
: AbstractProtocol(stream, parent)
{
- configForm = NULL;
}
Dot3Protocol::~Dot3Protocol()
{
- delete configForm;
}
AbstractProtocol* Dot3Protocol::createInstance(StreamBase *stream,
@@ -76,7 +62,7 @@ QString Dot3Protocol::shortName() const
return QString("802.3");
}
-int Dot3Protocol::fieldCount() const
+int Dot3Protocol::fieldCount() const
{
return dot3_fieldCount;
}
@@ -92,6 +78,7 @@ AbstractProtocol::FieldFlags Dot3Protocol::fieldFlags(int index) const
case dot3_length:
break;
+ // Meta fields
case dot3_is_override_length:
flags &= ~FrameField;
flags |= MetaField;
@@ -207,33 +194,3 @@ int Dot3Protocol::protocolFrameVariableCount() const
{
return protocolFramePayloadVariableCount();
}
-
-QWidget* Dot3Protocol::configWidget()
-{
- if (configForm == NULL)
- {
- configForm = new Dot3ConfigForm;
- loadConfigWidget();
- }
- return configForm;
-}
-
-void Dot3Protocol::loadConfigWidget()
-{
- configWidget();
-
- configForm->cbOverrideLength->setChecked(
- fieldData(dot3_is_override_length, FieldValue).toBool());
- configForm->leLength->setText(
- fieldData(dot3_length, FieldValue).toString());
-}
-
-void Dot3Protocol::storeConfigWidget()
-{
- configWidget();
-
- setFieldData(dot3_is_override_length,
- configForm->cbOverrideLength->isChecked());
- setFieldData(dot3_length,configForm->leLength->text());
-}
-
diff --git a/common/dot3.h b/common/dot3.h
index 22c3f5b..ecade93 100644
--- a/common/dot3.h
+++ b/common/dot3.h
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2010 Srivats P.
+Copyright (C) 2010-2014 Srivats P.
This file is part of "Ostinato"
@@ -21,22 +21,11 @@ along with this program. If not, see
#define _DOT3_H
#include "abstractprotocol.h"
-
#include "dot3.pb.h"
-#include "ui_dot3.h"
-
-class Dot3ConfigForm : public QWidget, public Ui::dot3
-{
- Q_OBJECT
-public:
- Dot3ConfigForm(QWidget *parent = 0);
-};
class Dot3Protocol : public AbstractProtocol
{
-private:
- OstProto::Dot3 data;
- Dot3ConfigForm *configForm;
+public:
enum Dot3field
{
dot3_length,
@@ -47,7 +36,6 @@ private:
dot3_fieldCount
};
-public:
Dot3Protocol(StreamBase *stream, AbstractProtocol *parent = 0);
virtual ~Dot3Protocol();
@@ -72,9 +60,8 @@ public:
virtual bool isProtocolFrameValueVariable() const;
virtual int protocolFrameVariableCount() const;
- virtual QWidget* configWidget();
- virtual void loadConfigWidget();
- virtual void storeConfigWidget();
+private:
+ OstProto::Dot3 data;
};
#endif
diff --git a/common/dot3config.cpp b/common/dot3config.cpp
new file mode 100644
index 0000000..d17094e
--- /dev/null
+++ b/common/dot3config.cpp
@@ -0,0 +1,63 @@
+/*
+Copyright (C) 2010-2014 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
+*/
+
+#include "dot3config.h"
+#include "dot3.h"
+#include
+
+Dot3ConfigForm::Dot3ConfigForm(QWidget *parent)
+ : AbstractProtocolConfigForm(parent)
+{
+ setupUi(this);
+ leLength->setValidator(new QIntValidator(0, 16384, this));
+}
+
+Dot3ConfigForm::~Dot3ConfigForm()
+{
+}
+
+Dot3ConfigForm* Dot3ConfigForm::createInstance()
+{
+ return new Dot3ConfigForm;
+}
+
+void Dot3ConfigForm::loadWidget(AbstractProtocol *proto)
+{
+ cbOverrideLength->setChecked(
+ proto->fieldData(
+ Dot3Protocol::dot3_is_override_length,
+ AbstractProtocol::FieldValue
+ ).toBool());
+ leLength->setText(
+ proto->fieldData(
+ Dot3Protocol::dot3_length,
+ AbstractProtocol::FieldValue
+ ).toString());
+}
+
+void Dot3ConfigForm::storeWidget(AbstractProtocol *proto)
+{
+ proto->setFieldData(
+ Dot3Protocol::dot3_is_override_length,
+ cbOverrideLength->isChecked());
+ proto->setFieldData(
+ Dot3Protocol::dot3_length,
+ leLength->text());
+}
+
diff --git a/common/dot3config.h b/common/dot3config.h
new file mode 100644
index 0000000..44e3e7e
--- /dev/null
+++ b/common/dot3config.h
@@ -0,0 +1,41 @@
+/*
+Copyright (C) 2010-2014 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
+*/
+
+#ifndef _DOT3_CONFIG_H
+#define _DOT3_CONFIG_H
+
+#include "abstractprotocolconfig.h"
+#include "ui_dot3.h"
+
+class Dot3ConfigForm :
+ public AbstractProtocolConfigForm,
+ private Ui::dot3
+{
+ Q_OBJECT
+public:
+ Dot3ConfigForm(QWidget *parent = 0);
+ virtual ~Dot3ConfigForm();
+
+ static Dot3ConfigForm* createInstance();
+
+ virtual void loadWidget(AbstractProtocol *proto);
+ virtual void storeWidget(AbstractProtocol *proto);
+};
+
+#endif
diff --git a/common/ostproto.pro b/common/ostproto.pro
index d20c300..92863ca 100644
--- a/common/ostproto.pro
+++ b/common/ostproto.pro
@@ -47,11 +47,11 @@ HEADERS = \
HEADERS += \
mac.h \
payload.h \
+ dot3.h \
eth2.h \
ip6.h
HEADERS1 += \
- dot3.h \
llc.h \
snap.h \
dot2llc.h \
@@ -89,11 +89,11 @@ SOURCES = \
SOURCES += \
mac.cpp \
payload.cpp \
+ dot3.cpp \
eth2.cpp \
ip6.cpp
SOURCES1 += \
- dot3.cpp \
llc.cpp \
snap.cpp \
vlan.cpp \
diff --git a/common/ostprotogui.pro b/common/ostprotogui.pro
index 86b39a5..8f3c4ee 100644
--- a/common/ostprotogui.pro
+++ b/common/ostprotogui.pro
@@ -10,11 +10,11 @@ FORMS = \
FORMS += \
mac.ui \
payload.ui \
+ dot3.ui \
eth2.ui \
ip6.ui \
FORMS1 += \
- dot3.ui \
llc.ui \
snap.ui \
vlan.ui \
@@ -48,6 +48,7 @@ HEADERS += \
protocolwidgetfactory.h \
macconfig.h \
payloadconfig.h \
+ dot3config.h \
eth2config.h \
ip6config.h
@@ -65,6 +66,7 @@ SOURCES += \
protocolwidgetfactory.cpp \
macconfig.cpp \
payloadconfig.cpp \
+ dot3config.cpp \
eth2config.cpp \
ip6config.cpp
diff --git a/common/protocolmanager.cpp b/common/protocolmanager.cpp
index e1b0225..c8c0bb7 100644
--- a/common/protocolmanager.cpp
+++ b/common/protocolmanager.cpp
@@ -22,7 +22,6 @@ along with this program. If not, see
#include "protocol.pb.h"
#if 0
-#include "dot3.h"
#include "llc.h"
#include "snap.h"
#include "dot2llc.h"
@@ -47,6 +46,7 @@ along with this program. If not, see
#else
#include "mac.h"
#include "payload.h"
+#include "dot3.h"
#include "eth2.h"
#include "ip6.h"
#endif
@@ -59,8 +59,6 @@ ProtocolManager::ProtocolManager()
themselves (once this is done remove the #includes for all the protocols)
*/
#if 0
- registerProtocol(OstProto::Protocol::kDot3FieldNumber,
- (void*) Dot3Protocol::createInstance);
registerProtocol(OstProto::Protocol::kLlcFieldNumber,
(void*) LlcProtocol::createInstance);
registerProtocol(OstProto::Protocol::kSnapFieldNumber,
@@ -116,6 +114,8 @@ ProtocolManager::ProtocolManager()
registerProtocol(OstProto::Protocol::kPayloadFieldNumber,
(void*) PayloadProtocol::createInstance);
+ registerProtocol(OstProto::Protocol::kDot3FieldNumber,
+ (void*) Dot3Protocol::createInstance);
registerProtocol(OstProto::Protocol::kEth2FieldNumber,
(void*) Eth2Protocol::createInstance);
registerProtocol(OstProto::Protocol::kIp6FieldNumber,
@@ -185,7 +185,8 @@ AbstractProtocol* ProtocolManager::createProtocol(int protoNumber,
Q_ASSERT_X(pc != NULL,
__FUNCTION__,
- numberToNameMap.value(protoNumber).toAscii().constData());
+ QString("No Protocol Creator registered for protocol %1")
+ .arg(protoNumber).toAscii().constData());
p = (*pc)(stream, parent);
diff --git a/common/protocolwidgetfactory.cpp b/common/protocolwidgetfactory.cpp
index b25c876..82a7231 100644
--- a/common/protocolwidgetfactory.cpp
+++ b/common/protocolwidgetfactory.cpp
@@ -21,6 +21,7 @@ along with this program. If not, see
#include "macconfig.h"
#include "payloadconfig.h"
+#include "dot3config.h"
#include "eth2config.h"
#include "ip6config.h"
@@ -40,6 +41,9 @@ ProtocolWidgetFactory::ProtocolWidgetFactory()
OstProto::Protocol::kPayloadFieldNumber,
(void*) PayloadConfigForm::createInstance);
+ OstProtocolWidgetFactory->registerProtocolConfigWidget(
+ OstProto::Protocol::kDot3FieldNumber,
+ (void*) Dot3ConfigForm::createInstance);
OstProtocolWidgetFactory->registerProtocolConfigWidget(
OstProto::Protocol::kEth2FieldNumber,
(void*) Eth2ConfigForm::createInstance);