0103696016
- new method: fieldFlags() - isCksum, isMeta; Note: isMeta is a flag now not a attrib - fieldData() bit fields are now in lsb not msb - protocolFrameValue() and subclasses changed accordingly - protocolFrameValue() now takes an additional bool param indicating whether the frameValue is being requested for a checksum calculation; if so fields which are checksum fields are assumed to be zero and their value is not fetched to prevent infinite recursion - Other Protocols - mac: srcMac/dstMac modes is now working - vlan: implemented VLAN protocol - ip4: src/dst Addr modes is now working - udp/tcp: checksum done - Basic testing done for MAC, VLAN, IPv4, UDP and TCP protocols - sample protocol: .cpp/.h added to repos - need to be made compilable - StreamConfigDialog - Redesigned the protocol selection tab to accomodate "Advanced Protocol Selection" - L2 Tab config widgets are now in 2 columns - Packet Tree View is no longer collapsed if selected protocols don't change
116 lines
2.8 KiB
C++
116 lines
2.8 KiB
C++
#ifndef _ABSTRACT_PROTOCOL_H
|
|
#define _ABSTRACT_PROTOCOL_H
|
|
|
|
#include <QString>
|
|
#include <QVariant>
|
|
#include <QByteArray>
|
|
#include <QWidget>
|
|
#include <QLinkedList>
|
|
#include <QFlags>
|
|
|
|
//#include "../rpc/pbhelper.h"
|
|
#include "../common/protocol.pb.h"
|
|
|
|
#define BASE_BIN (2)
|
|
#define BASE_OCT (8)
|
|
#define BASE_DEC (10)
|
|
#define BASE_HEX (16)
|
|
|
|
#define uintToHexStr(num, bytes) \
|
|
QString("%1").arg(num, bytes*2, BASE_HEX, QChar('0'))
|
|
|
|
class OstProto::StreamCore;
|
|
class AbstractProtocol;
|
|
|
|
typedef QLinkedList<const AbstractProtocol*> ProtocolList;
|
|
|
|
class AbstractProtocol
|
|
{
|
|
private:
|
|
mutable int metaCount;
|
|
mutable int protoSize;
|
|
mutable QString protoAbbr;
|
|
|
|
protected:
|
|
OstProto::StreamCore *stream;
|
|
ProtocolList &frameProtocols;
|
|
|
|
public:
|
|
enum FieldFlag {
|
|
FieldIsNormal = 0x0,
|
|
FieldIsMeta = 0x1,
|
|
FieldIsCksum = 0x2
|
|
};
|
|
Q_DECLARE_FLAGS(FieldFlags, FieldFlag);
|
|
|
|
enum FieldAttrib {
|
|
FieldName, //! name
|
|
FieldValue, //! value in host byte order (user editable)
|
|
FieldTextValue, //! value as text
|
|
FieldFrameValue, //! frame encoded value in network byte order
|
|
FieldBitSize, //! size in bits
|
|
};
|
|
|
|
enum ProtocolIdType {
|
|
ProtocolIdLlc,
|
|
ProtocolIdEth,
|
|
ProtocolIdIp,
|
|
};
|
|
|
|
enum CksumType {
|
|
CksumIp,
|
|
CksumIpPseudo,
|
|
CksumTcpUdp,
|
|
|
|
CksumMax
|
|
};
|
|
|
|
AbstractProtocol(ProtocolList &frameProtoList,
|
|
OstProto::StreamCore *parent = 0);
|
|
virtual ~AbstractProtocol();
|
|
|
|
static AbstractProtocol* createInstance(
|
|
ProtocolList &frameProtoList,
|
|
OstProto::StreamCore *streamCore = 0);
|
|
|
|
virtual void protoDataCopyInto(OstProto::Stream &stream) = 0;
|
|
virtual void protoDataCopyFrom(const OstProto::Stream &stream) = 0;
|
|
|
|
virtual QString name() const;
|
|
virtual QString shortName() const;
|
|
|
|
virtual quint32 protocolId(ProtocolIdType type) const;
|
|
quint32 payloadProtocolId(ProtocolIdType type) const;
|
|
|
|
virtual int fieldCount() const;
|
|
virtual int metaFieldCount() const;
|
|
int frameFieldCount() const;
|
|
|
|
virtual FieldFlags fieldFlags(int index) const;
|
|
virtual QVariant fieldData(int index, FieldAttrib attrib,
|
|
int streamIndex = 0) const;
|
|
virtual bool setFieldData(int index, const QVariant &value,
|
|
FieldAttrib attrib = FieldValue);
|
|
|
|
QByteArray protocolFrameValue(int streamIndex = 0,
|
|
bool forCksum = false) const;
|
|
virtual int protocolFrameSize() const;
|
|
int protocolFrameOffset() const;
|
|
int protocolFramePayloadSize() const;
|
|
|
|
virtual quint32 protocolFrameCksum(int streamIndex = 0,
|
|
CksumType cksumType = CksumIp) const;
|
|
quint32 protocolFrameHeaderCksum(int streamIndex = 0,
|
|
CksumType cksumType = CksumIp) const;
|
|
quint32 protocolFramePayloadCksum(int streamIndex = 0,
|
|
CksumType cksumType = CksumIp) const;
|
|
|
|
virtual QWidget* configWidget() = 0;
|
|
virtual void loadConfigWidget() = 0;
|
|
virtual void storeConfigWidget() = 0;
|
|
};
|
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractProtocol::FieldFlags);
|
|
|
|
#endif
|