sign: added sign protocol
This commit is contained in:
parent
2185bf2855
commit
3ed956eebc
@ -38,7 +38,8 @@ PROTOS += \
|
||||
textproto.proto \
|
||||
userscript.proto \
|
||||
hexdump.proto \
|
||||
sample.proto
|
||||
sample.proto \
|
||||
sign.proto
|
||||
|
||||
HEADERS = \
|
||||
abstractprotocol.h \
|
||||
@ -77,6 +78,7 @@ HEADERS += \
|
||||
hexdump.h \
|
||||
payload.h \
|
||||
sample.h \
|
||||
sign.h \
|
||||
userscript.h
|
||||
|
||||
SOURCES = \
|
||||
@ -110,6 +112,7 @@ SOURCES += \
|
||||
hexdump.cpp \
|
||||
payload.cpp \
|
||||
sample.cpp \
|
||||
sign.cpp \
|
||||
userscript.cpp
|
||||
|
||||
QMAKE_DISTCLEAN += object_script.*
|
||||
|
@ -27,6 +27,7 @@ FORMS += \
|
||||
hexdump.ui \
|
||||
payload.ui \
|
||||
sample.ui \
|
||||
sign.ui \
|
||||
userscript.ui
|
||||
|
||||
PROTOS = \
|
||||
@ -79,6 +80,7 @@ HEADERS += \
|
||||
hexdumpconfig.h \
|
||||
payloadconfig.h \
|
||||
sampleconfig.h \
|
||||
signconfig.h \
|
||||
userscriptconfig.h
|
||||
|
||||
SOURCES += \
|
||||
@ -118,6 +120,7 @@ SOURCES += \
|
||||
hexdumpconfig.cpp \
|
||||
payloadconfig.cpp \
|
||||
sampleconfig.cpp \
|
||||
signconfig.cpp \
|
||||
userscriptconfig.cpp
|
||||
|
||||
SOURCES += \
|
||||
|
@ -128,6 +128,7 @@ message Protocol {
|
||||
kSampleFieldNumber = 102;
|
||||
kUserScriptFieldNumber = 103;
|
||||
kHexDumpFieldNumber = 104;
|
||||
kSignFieldNumber = 105;
|
||||
|
||||
kEth2FieldNumber = 200;
|
||||
kDot3FieldNumber = 201;
|
||||
|
@ -59,6 +59,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#include "hexdump.h"
|
||||
#include "payload.h"
|
||||
#include "sample.h"
|
||||
#include "sign.h"
|
||||
#include "userscript.h"
|
||||
|
||||
ProtocolManager *OstProtocolManager;
|
||||
@ -133,6 +134,8 @@ ProtocolManager::ProtocolManager()
|
||||
(void*) PayloadProtocol::createInstance);
|
||||
registerProtocol(OstProto::Protocol::kSampleFieldNumber,
|
||||
(void*) SampleProtocol::createInstance);
|
||||
registerProtocol(OstProto::Protocol::kSignFieldNumber,
|
||||
(void*) SignProtocol::createInstance);
|
||||
registerProtocol(OstProto::Protocol::kUserScriptFieldNumber,
|
||||
(void*) UserScriptProtocol::createInstance);
|
||||
|
||||
|
@ -51,6 +51,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#include "hexdumpconfig.h"
|
||||
#include "payloadconfig.h"
|
||||
#include "sampleconfig.h"
|
||||
#include "signconfig.h"
|
||||
#include "userscriptconfig.h"
|
||||
|
||||
ProtocolWidgetFactory *OstProtocolWidgetFactory;
|
||||
@ -154,6 +155,9 @@ ProtocolWidgetFactory::ProtocolWidgetFactory()
|
||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||
OstProto::Protocol::kSampleFieldNumber,
|
||||
(void*) SampleConfigForm::createInstance);
|
||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||
OstProto::Protocol::kSignFieldNumber,
|
||||
(void*) SignConfigForm::createInstance);
|
||||
OstProtocolWidgetFactory->registerProtocolConfigWidget(
|
||||
OstProto::Protocol::kUserScriptFieldNumber,
|
||||
(void*) UserScriptConfigForm::createInstance);
|
||||
|
125
common/sign.cpp
Normal file
125
common/sign.cpp
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
Copyright (C) 2016 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 "sign.h"
|
||||
|
||||
SignProtocol::SignProtocol(StreamBase *stream, AbstractProtocol *parent)
|
||||
: AbstractProtocol(stream, parent)
|
||||
{
|
||||
}
|
||||
|
||||
SignProtocol::~SignProtocol()
|
||||
{
|
||||
}
|
||||
|
||||
AbstractProtocol* SignProtocol::createInstance(StreamBase *stream,
|
||||
AbstractProtocol *parent)
|
||||
{
|
||||
return new SignProtocol(stream, parent);
|
||||
}
|
||||
|
||||
quint32 SignProtocol::protocolNumber() const
|
||||
{
|
||||
return OstProto::Protocol::kSignFieldNumber;
|
||||
}
|
||||
|
||||
void SignProtocol::protoDataCopyInto(OstProto::Protocol &protocol) const
|
||||
{
|
||||
protocol.MutableExtension(OstProto::sign)->CopyFrom(data);
|
||||
protocol.mutable_protocol_id()->set_id(protocolNumber());
|
||||
}
|
||||
|
||||
void SignProtocol::protoDataCopyFrom(const OstProto::Protocol &protocol)
|
||||
{
|
||||
if (protocol.protocol_id().id() == protocolNumber() &&
|
||||
protocol.HasExtension(OstProto::sign))
|
||||
data.MergeFrom(protocol.GetExtension(OstProto::sign));
|
||||
}
|
||||
|
||||
QString SignProtocol::name() const
|
||||
{
|
||||
return QString("Signature");
|
||||
}
|
||||
|
||||
QString SignProtocol::shortName() const
|
||||
{
|
||||
return QString("SIGN");
|
||||
}
|
||||
|
||||
int SignProtocol::fieldCount() const
|
||||
{
|
||||
return sign_fieldCount;
|
||||
}
|
||||
|
||||
AbstractProtocol::FieldFlags SignProtocol::fieldFlags(int index) const
|
||||
{
|
||||
AbstractProtocol::FieldFlags flags;
|
||||
|
||||
flags = AbstractProtocol::fieldFlags(index);
|
||||
|
||||
switch (index)
|
||||
{
|
||||
case sign_magic:
|
||||
break;
|
||||
|
||||
default:
|
||||
qFatal("%s: unimplemented case %d in switch", __PRETTY_FUNCTION__,
|
||||
index);
|
||||
break;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
QVariant SignProtocol::fieldData(int index, FieldAttrib attrib,
|
||||
int streamIndex) const
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case sign_magic:
|
||||
{
|
||||
switch(attrib)
|
||||
{
|
||||
case FieldName:
|
||||
return QString("Magic");
|
||||
case FieldValue:
|
||||
return kSignMagic;
|
||||
case FieldTextValue:
|
||||
return QString("%1").arg(kSignMagic);
|
||||
case FieldFrameValue:
|
||||
{
|
||||
QByteArray fv;
|
||||
fv.resize(4);
|
||||
qToBigEndian(kSignMagic, (uchar*) fv.data());
|
||||
return fv;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
default:
|
||||
qFatal("%s: unimplemented case %d in switch", __PRETTY_FUNCTION__,
|
||||
index);
|
||||
break;
|
||||
}
|
||||
|
||||
return AbstractProtocol::fieldData(index, attrib, streamIndex);
|
||||
}
|
73
common/sign.h
Normal file
73
common/sign.h
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
Copyright (C) 2016 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 _SIGN_H
|
||||
#define _SIGN_H
|
||||
|
||||
#include "abstractprotocol.h"
|
||||
#include "sign.pb.h"
|
||||
|
||||
/*
|
||||
Sign Protocol is expected at the end of the frame (just before the Eth FCS)
|
||||
--+-------+
|
||||
. . .| Magic |
|
||||
| (32) |
|
||||
--+-------+
|
||||
Figures in brackets represent field width in bits
|
||||
*/
|
||||
|
||||
class SignProtocol : public AbstractProtocol
|
||||
{
|
||||
public:
|
||||
enum samplefield
|
||||
{
|
||||
// Frame Fields
|
||||
sign_magic = 0,
|
||||
|
||||
// Meta Fields
|
||||
// - None
|
||||
|
||||
sign_fieldCount
|
||||
};
|
||||
|
||||
SignProtocol(StreamBase *stream, AbstractProtocol *parent = 0);
|
||||
virtual ~SignProtocol();
|
||||
|
||||
static AbstractProtocol* createInstance(StreamBase *stream,
|
||||
AbstractProtocol *parent = 0);
|
||||
virtual quint32 protocolNumber() const;
|
||||
|
||||
virtual void protoDataCopyInto(OstProto::Protocol &protocol) const;
|
||||
virtual void protoDataCopyFrom(const OstProto::Protocol &protocol);
|
||||
|
||||
virtual QString name() const;
|
||||
virtual QString shortName() const;
|
||||
|
||||
virtual int fieldCount() const;
|
||||
|
||||
virtual AbstractProtocol::FieldFlags fieldFlags(int index) const;
|
||||
virtual QVariant fieldData(int index, FieldAttrib attrib,
|
||||
int streamIndex = 0) const;
|
||||
|
||||
private:
|
||||
static const quint32 kSignMagic = 0xa1b2c3d4; // FIXME
|
||||
OstProto::Sign data;
|
||||
};
|
||||
|
||||
#endif
|
30
common/sign.proto
Normal file
30
common/sign.proto
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
Copyright (C) 2016 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/>
|
||||
*/
|
||||
|
||||
import "protocol.proto";
|
||||
|
||||
package OstProto;
|
||||
|
||||
// Sign Protocol
|
||||
message Sign {
|
||||
}
|
||||
|
||||
extend Protocol {
|
||||
optional Sign sign = 105;
|
||||
}
|
30
common/sign.ui
Normal file
30
common/sign.ui
Normal file
@ -0,0 +1,30 @@
|
||||
<ui version="4.0" >
|
||||
<class>Sign</class>
|
||||
<widget class="QWidget" name="Sign" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>Signature: No configurable fields</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
45
common/signconfig.cpp
Normal file
45
common/signconfig.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
Copyright (C) 2016 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 "signconfig.h"
|
||||
#include "sign.h"
|
||||
|
||||
SignConfigForm::SignConfigForm(QWidget *parent)
|
||||
: AbstractProtocolConfigForm(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
SignConfigForm::~SignConfigForm()
|
||||
{
|
||||
}
|
||||
|
||||
SignConfigForm* SignConfigForm::createInstance()
|
||||
{
|
||||
return new SignConfigForm;
|
||||
}
|
||||
|
||||
void SignConfigForm::loadWidget(AbstractProtocol *proto)
|
||||
{
|
||||
}
|
||||
|
||||
void SignConfigForm::storeWidget(AbstractProtocol *proto)
|
||||
{
|
||||
}
|
||||
|
43
common/signconfig.h
Normal file
43
common/signconfig.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
Copyright (C) 2016 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 _SIGN_CONFIG_H
|
||||
#define _SIGN_CONFIG_H
|
||||
|
||||
#include "abstractprotocolconfig.h"
|
||||
#include "ui_sign.h"
|
||||
|
||||
class SignConfigForm :
|
||||
public AbstractProtocolConfigForm,
|
||||
private Ui::Sign
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SignConfigForm(QWidget *parent = 0);
|
||||
virtual ~SignConfigForm();
|
||||
|
||||
static SignConfigForm* createInstance();
|
||||
|
||||
virtual void loadWidget(AbstractProtocol *proto);
|
||||
virtual void storeWidget(AbstractProtocol *proto);
|
||||
|
||||
private slots:
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user