2008-05-03 09:37:10 -05:00
|
|
|
#ifndef _STREAM_H
|
|
|
|
#define _STREAM_H
|
|
|
|
|
|
|
|
#include <QtGlobal>
|
2008-08-30 03:49:08 -05:00
|
|
|
|
2008-05-03 09:37:10 -05:00
|
|
|
#include <QString>
|
2008-08-23 23:39:08 -05:00
|
|
|
#include <QList>
|
2008-08-08 22:22:13 -05:00
|
|
|
#include "../common/protocol.pb.h"
|
2008-05-03 09:37:10 -05:00
|
|
|
|
|
|
|
class StreamConfigDialog;
|
|
|
|
class StreamModel;
|
2008-05-25 06:30:30 -05:00
|
|
|
class PacketModel;
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
// Convenience Defines FIXME
|
|
|
|
#define IP_PROTO_ICMP 0x01
|
|
|
|
#define IP_PROTO_IGMP 0x02
|
|
|
|
#define IP_PROTO_TCP 0x06
|
|
|
|
#define IP_PROTO_UDP 0x11
|
2008-05-03 09:37:10 -05:00
|
|
|
|
|
|
|
|
2008-08-30 03:49:08 -05:00
|
|
|
class Stream;
|
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
class AbstractProtocol
|
|
|
|
{
|
2008-08-23 23:39:08 -05:00
|
|
|
// TODO(LOW)
|
|
|
|
public:
|
|
|
|
/*!
|
|
|
|
Subclasses should return reference to their protocol specific
|
|
|
|
::google::protobuf::Message
|
|
|
|
*/
|
|
|
|
virtual ::google::protobuf::Message& data() = 0;
|
|
|
|
/*! Subclasses can directly use this method. No need for overload */
|
|
|
|
void getConfig(::google::protobuf::Message *msg)
|
|
|
|
{ msg->CopyFrom(data()); }
|
|
|
|
|
|
|
|
virtual QString protocolName()
|
|
|
|
{ return QString("AbstractProtocol"); }
|
|
|
|
virtual QString protocolShortName()
|
|
|
|
{ return QString("AbsProto"); }
|
|
|
|
virtual int numFields()
|
|
|
|
{ return 1; }
|
2008-08-30 03:49:08 -05:00
|
|
|
QByteArray protocolRawValue()
|
|
|
|
{
|
|
|
|
QByteArray ba;
|
|
|
|
#ifndef SRIVATSP
|
|
|
|
#else
|
|
|
|
for (int i=0; i < numFields(); i++)
|
|
|
|
ba.append(fieldRawValue(i));
|
|
|
|
#endif
|
|
|
|
return ba;
|
|
|
|
}
|
2008-08-23 23:39:08 -05:00
|
|
|
virtual QString fieldName(int index)
|
|
|
|
{ return QString("AbstractField"); }
|
|
|
|
virtual QString fieldTextValue(int index)
|
|
|
|
{ return QString("AbstractFieldValue"); }
|
|
|
|
virtual QByteArray fieldRawValue(int index)
|
|
|
|
{ return QByteArray(4, '\0'); }
|
|
|
|
};
|
|
|
|
|
|
|
|
class UnknownProtocol: public AbstractProtocol
|
|
|
|
{
|
|
|
|
OstProto::Ack d; // FIXME(HI): replace 'Ack' with something else
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~UnknownProtocol() {}
|
|
|
|
|
|
|
|
virtual ::google::protobuf::Message& data() { return d; }
|
|
|
|
|
|
|
|
virtual QString protocolName()
|
|
|
|
{ return QString("UnknownProtocol"); }
|
|
|
|
QString protocolShortName()
|
|
|
|
{ return QString("???Proto"); }
|
|
|
|
int numFields()
|
|
|
|
{ return 1; }
|
|
|
|
QString fieldName(int index)
|
|
|
|
{ return QString("UnknownField"); }
|
|
|
|
QString fieldTextValue(int index)
|
|
|
|
{ return QString("UnknownFieldValue"); }
|
|
|
|
QByteArray fieldRawValue(int index)
|
2008-08-30 03:49:08 -05:00
|
|
|
{ return QByteArray(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
class PayloadProtocol: public AbstractProtocol
|
|
|
|
{
|
|
|
|
Stream *parentStream;
|
|
|
|
OstProto::Ack d; // FIXME(HI): move payload related vars from
|
|
|
|
// stream into here
|
|
|
|
|
|
|
|
public:
|
|
|
|
PayloadProtocol (Stream *stream = NULL) { parentStream = stream; }
|
|
|
|
virtual ~PayloadProtocol() {}
|
|
|
|
|
|
|
|
virtual ::google::protobuf::Message& data() { return d; }
|
|
|
|
|
|
|
|
virtual QString protocolName()
|
|
|
|
{ return QString("Payload Data"); }
|
|
|
|
QString protocolShortName()
|
|
|
|
{ return QString("DATA"); }
|
|
|
|
int numFields()
|
|
|
|
{ return 1; }
|
|
|
|
QString fieldName(int index)
|
|
|
|
{ return QString("Data"); }
|
|
|
|
QString fieldTextValue(int index);
|
|
|
|
QByteArray fieldRawValue(int index);
|
2008-08-08 22:22:13 -05:00
|
|
|
};
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
class MacProtocol : public AbstractProtocol
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
OstProto::Mac d;
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
public:
|
|
|
|
enum MacAddrMode {
|
|
|
|
MacAddrFixed,
|
|
|
|
MacAddrInc,
|
|
|
|
MacAddrDec
|
|
|
|
};
|
2008-08-23 23:39:08 -05:00
|
|
|
virtual ~MacProtocol() {}
|
|
|
|
virtual ::google::protobuf::Message& data() {return d;}
|
|
|
|
|
|
|
|
bool update(OstProto::Mac mac) { d.MergeFrom(mac); return true; }
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
// Dst Mac
|
|
|
|
quint64 dstMac()
|
|
|
|
{ return d.dst_mac(); }
|
|
|
|
|
|
|
|
bool setDstMac(quint64 dstMac)
|
|
|
|
{ d.set_dst_mac(dstMac); return true; }
|
|
|
|
|
|
|
|
MacAddrMode dstMacMode()
|
|
|
|
{ return (MacAddrMode) d.dst_mac_mode(); }
|
|
|
|
bool setDstMacMode(MacAddrMode dstMacMode)
|
|
|
|
{ d.set_dst_mac_mode((OstProto::Mac::MacAddrMode)dstMacMode); return true; }
|
|
|
|
|
|
|
|
quint16 dstMacCount()
|
|
|
|
{ return d.dst_mac_count(); }
|
|
|
|
bool setDstMacCount(quint16 dstMacCount)
|
|
|
|
{ d.set_dst_mac_count(dstMacCount); return true; }
|
|
|
|
|
|
|
|
quint16 dstMacStep()
|
|
|
|
{ return d.dst_mac_step(); }
|
|
|
|
bool setDstMacStep(quint16 dstMacStep)
|
|
|
|
{ d.set_dst_mac_step(dstMacStep); return true; }
|
|
|
|
|
|
|
|
// Src Mac
|
|
|
|
quint64 srcMac()
|
|
|
|
{ return d.src_mac(); }
|
|
|
|
|
|
|
|
bool setSrcMac(quint64 srcMac)
|
|
|
|
{ d.set_src_mac(srcMac); return true; }
|
|
|
|
|
|
|
|
MacAddrMode srcMacMode()
|
|
|
|
{ return (MacAddrMode) d.src_mac_mode(); }
|
|
|
|
bool setSrcMacMode(MacAddrMode srcMacMode)
|
|
|
|
{ d.set_src_mac_mode((OstProto::Mac::MacAddrMode)srcMacMode); return true; }
|
|
|
|
|
|
|
|
quint16 srcMacCount()
|
|
|
|
{ return d.src_mac_count(); }
|
|
|
|
bool setSrcMacCount(quint16 srcMacCount)
|
|
|
|
{ d.set_src_mac_count(srcMacCount); return true; }
|
|
|
|
|
|
|
|
quint16 srcMacStep()
|
|
|
|
{ return d.src_mac_step(); }
|
|
|
|
bool setSrcMacStep(quint16 srcMacStep)
|
|
|
|
{ d.set_src_mac_step(srcMacStep); return true; }
|
2008-08-23 23:39:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
virtual QString protocolName()
|
|
|
|
{ return QString("Media Access Control"); }
|
|
|
|
QString protocolShortName()
|
|
|
|
{ return QString("MAC"); }
|
|
|
|
int numFields()
|
|
|
|
{ return 2; }
|
|
|
|
QString fieldName(int index);
|
|
|
|
QString fieldTextValue(int index);
|
|
|
|
QByteArray fieldRawValue(int index);
|
2008-08-08 22:22:13 -05:00
|
|
|
};
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
class LlcProtocol : public AbstractProtocol
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
OstProto::Llc d;
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
public:
|
2008-08-23 23:39:08 -05:00
|
|
|
virtual ~LlcProtocol() {}
|
|
|
|
virtual ::google::protobuf::Message& data() {return d;}
|
|
|
|
|
|
|
|
bool update(OstProto::Llc llc) { d.MergeFrom(llc); return true; }
|
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
quint8 dsap()
|
|
|
|
{ return d.dsap(); }
|
|
|
|
bool setDsap(quint8 dsap)
|
|
|
|
{ d.set_dsap(dsap); return true; }
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
quint8 ssap()
|
|
|
|
{ return d.ssap(); }
|
|
|
|
bool setSsap(quint8 ssap)
|
|
|
|
{ d.set_ssap(ssap); return true; }
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
quint8 ctl()
|
|
|
|
{ return d.ctl(); }
|
|
|
|
bool setCtl(quint8 ctl)
|
|
|
|
{ d.set_ctl(ctl); return true; }
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
|
|
|
|
virtual QString protocolName()
|
|
|
|
{ return QString("802.3 Logical Link Control"); }
|
|
|
|
QString protocolShortName()
|
|
|
|
{ return QString("LLC"); }
|
|
|
|
int numFields()
|
|
|
|
{ return 3; }
|
|
|
|
QString fieldName(int index);
|
|
|
|
QString fieldTextValue(int index);
|
|
|
|
QByteArray fieldRawValue(int index);
|
2008-08-08 22:22:13 -05:00
|
|
|
};
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
class SnapProtocol : public AbstractProtocol
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
OstProto::Snap d;
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
public:
|
2008-08-23 23:39:08 -05:00
|
|
|
virtual ~SnapProtocol() {}
|
|
|
|
virtual ::google::protobuf::Message& data() {return d;}
|
|
|
|
bool update(OstProto::Snap snap) { d.MergeFrom(snap); return true; }
|
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
quint32 oui()
|
|
|
|
{ return d.oui(); }
|
|
|
|
bool setOui(quint32 oui)
|
|
|
|
{ d.set_oui(oui); return true; }
|
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
// "Type" field: use from eth2
|
|
|
|
#if 0
|
2008-08-08 22:22:13 -05:00
|
|
|
quint16 type()
|
|
|
|
{ return d.type(); }
|
|
|
|
bool setType(quint16 type)
|
|
|
|
{ d.set_type(type); return true; }
|
2008-08-23 23:39:08 -05:00
|
|
|
#endif
|
|
|
|
virtual QString protocolName()
|
|
|
|
{ return QString("SubNetwork Access Protocol"); }
|
|
|
|
QString protocolShortName()
|
|
|
|
{ return QString("SNAP"); }
|
|
|
|
int numFields()
|
|
|
|
{ return 1; }
|
|
|
|
QString fieldName(int index);
|
|
|
|
QString fieldTextValue(int index);
|
|
|
|
QByteArray fieldRawValue(int index);
|
2008-08-08 22:22:13 -05:00
|
|
|
};
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
class Eth2Protocol : public AbstractProtocol
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
OstProto::Eth2 d;
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
public:
|
2008-08-23 23:39:08 -05:00
|
|
|
virtual ~Eth2Protocol() {}
|
|
|
|
virtual ::google::protobuf::Message& data() {return d;}
|
|
|
|
bool update(OstProto::Eth2 eth2) { d.MergeFrom(eth2); return true; }
|
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
quint16 type()
|
|
|
|
{ return d.type(); }
|
|
|
|
bool setType(quint16 type)
|
|
|
|
{ d.set_type(type); return true; }
|
2008-08-23 23:39:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
virtual QString protocolName()
|
|
|
|
{ return QString("Protocol Type"); }
|
|
|
|
QString protocolShortName()
|
|
|
|
{ return QString("TYPE"); }
|
|
|
|
int numFields()
|
|
|
|
{ return 1; }
|
|
|
|
QString fieldName(int index);
|
|
|
|
QString fieldTextValue(int index);
|
|
|
|
QByteArray fieldRawValue(int index);
|
2008-08-08 22:22:13 -05:00
|
|
|
};
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-30 03:49:08 -05:00
|
|
|
|
|
|
|
class Dot3Protocol : public AbstractProtocol
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
Stream *parentStream;
|
|
|
|
OstProto::Ack d; // FIXME(HI): replace 'ack' with somehting else
|
|
|
|
|
|
|
|
public:
|
|
|
|
Dot3Protocol(Stream *stream = NULL)
|
|
|
|
{ parentStream = stream; qDebug("parentStream = %p", stream); }
|
|
|
|
virtual ~Dot3Protocol() {}
|
|
|
|
virtual ::google::protobuf::Message& data() {return d;}
|
|
|
|
|
|
|
|
#if 0 // FIXME(HI): remove?
|
|
|
|
quint16 length()
|
|
|
|
{ return d.length(); }
|
|
|
|
bool setLength(quint16 length)
|
|
|
|
{ return true; }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
virtual QString protocolName()
|
|
|
|
{ return QString("802.3 Length"); }
|
|
|
|
QString protocolShortName()
|
|
|
|
{ return QString("LEN"); }
|
|
|
|
int numFields()
|
|
|
|
{ return 1; }
|
|
|
|
QString fieldName(int index);
|
|
|
|
QString fieldTextValue(int index);
|
|
|
|
QByteArray fieldRawValue(int index);
|
|
|
|
};
|
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
class VlanProtocol : public AbstractProtocol
|
|
|
|
{
|
2008-08-23 23:39:08 -05:00
|
|
|
OstProto::Vlan d;
|
|
|
|
public:
|
|
|
|
virtual ~VlanProtocol() {}
|
|
|
|
virtual ::google::protobuf::Message& data() {return d;}
|
|
|
|
bool update(OstProto::Vlan vlan) { d.MergeFrom(vlan); return true; }
|
|
|
|
|
|
|
|
enum VlanFlag {
|
|
|
|
VlanCvlanTagged = 0x01,
|
|
|
|
VlanCtpidOverride = 0x02,
|
|
|
|
VlanSvlanTagged = 0x04,
|
|
|
|
VlanStpidOverride = 0x08,
|
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(VlanFlags, VlanFlag);
|
|
|
|
|
|
|
|
VlanFlags vlanFlags()
|
|
|
|
{
|
|
|
|
VlanFlags f;
|
|
|
|
|
|
|
|
if (d.is_cvlan_tagged()) f|= VlanCvlanTagged;
|
|
|
|
if (d.is_ctpid_override()) f|= VlanCtpidOverride;
|
|
|
|
if (d.is_svlan_tagged()) f|= VlanSvlanTagged;
|
|
|
|
if (d.is_stpid_override()) f|= VlanStpidOverride;
|
|
|
|
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool setVlanFlags(VlanFlags vlanFlags)
|
|
|
|
{
|
|
|
|
d.set_is_cvlan_tagged(vlanFlags.testFlag(VlanCvlanTagged));
|
|
|
|
d.set_is_ctpid_override(vlanFlags.testFlag(VlanCtpidOverride));
|
|
|
|
d.set_is_svlan_tagged(vlanFlags.testFlag(VlanSvlanTagged));
|
|
|
|
d.set_is_stpid_override(vlanFlags.testFlag(VlanStpidOverride));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isUntagged()
|
|
|
|
{
|
|
|
|
if (!d.is_cvlan_tagged() && !d.is_svlan_tagged())
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isSingleTagged()
|
|
|
|
{
|
|
|
|
if (( d.is_cvlan_tagged() && !d.is_svlan_tagged()) ||
|
|
|
|
(!d.is_cvlan_tagged() && d.is_svlan_tagged()) )
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isDoubleTagged()
|
|
|
|
{
|
|
|
|
if (d.is_cvlan_tagged() && d.is_svlan_tagged())
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CVLAN
|
|
|
|
quint16 ctpid()
|
|
|
|
{ return d.ctpid(); }
|
|
|
|
bool setCtpid(quint16 ctpid)
|
|
|
|
{ d.set_ctpid(ctpid); return true; }
|
|
|
|
|
|
|
|
quint8 cvlanPrio()
|
|
|
|
{ return (d.cvlan_tag() >> 13); }
|
|
|
|
bool setCvlanPrio(quint8 cvlanPrio)
|
|
|
|
{ d.set_cvlan_tag((d.cvlan_tag() & 0x1FFF) | ((cvlanPrio & 0x3) << 13));
|
|
|
|
return true; }
|
|
|
|
|
|
|
|
quint8 cvlanCfi()
|
|
|
|
{ return ((d.cvlan_tag() & 0x1000) >> 12); }
|
|
|
|
bool setCvlanCfi(quint8 cvlanCfi)
|
|
|
|
{ d.set_cvlan_tag((d.cvlan_tag() & 0xEFFF) | ((cvlanCfi & 0x01) << 12));
|
|
|
|
return true; }
|
|
|
|
|
|
|
|
quint16 cvlanId()
|
|
|
|
{ return (d.cvlan_tag() & 0x0FFF); }
|
|
|
|
bool setCvlanId(quint16 cvlanId)
|
|
|
|
{ d.set_cvlan_tag((d.cvlan_tag() & 0xF000) | ((cvlanId & 0x0FFF)));
|
|
|
|
return true; }
|
|
|
|
|
|
|
|
// SVLAN
|
|
|
|
quint16 stpid()
|
|
|
|
{ return d.stpid(); }
|
|
|
|
bool setStpid(quint16 stpid)
|
|
|
|
{ d.set_stpid(stpid); return true; }
|
|
|
|
quint8 svlanPrio()
|
|
|
|
{ return (d.svlan_tag() >> 13); }
|
|
|
|
bool setSvlanPrio(quint8 svlanPrio)
|
|
|
|
{ d.set_svlan_tag((d.svlan_tag() & 0x1FFF) | ((svlanPrio & 0x3) << 13));
|
|
|
|
return true; }
|
|
|
|
|
|
|
|
quint8 svlanCfi()
|
|
|
|
{ return ((d.svlan_tag() & 0x1000) >> 12); }
|
|
|
|
bool setSvlanCfi(quint8 svlanCfi)
|
|
|
|
{ d.set_svlan_tag((d.svlan_tag() & 0xEFFF) | ((svlanCfi & 0x01) << 12));
|
|
|
|
return true; }
|
|
|
|
|
|
|
|
quint16 svlanId()
|
|
|
|
{ return (d.svlan_tag() & 0x0FFF); }
|
|
|
|
bool setSvlanId(quint16 svlanId)
|
|
|
|
{ d.set_svlan_tag((d.svlan_tag() & 0xF000) | ((svlanId & 0x0FFF)));
|
|
|
|
return true; }
|
|
|
|
|
|
|
|
virtual QString protocolName()
|
|
|
|
{ return QString("Virtual Local Access Network"); }
|
|
|
|
QString protocolShortName()
|
|
|
|
{ return QString("VLAN"); }
|
|
|
|
int numFields();
|
|
|
|
QString fieldName(int index);
|
|
|
|
QString fieldTextValue(int index);
|
|
|
|
QByteArray fieldRawValue(int index);
|
2008-08-08 22:22:13 -05:00
|
|
|
};
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
// IP
|
|
|
|
class IpProtocol : public AbstractProtocol
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
OstProto::Ip d;
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
public:
|
2008-08-23 23:39:08 -05:00
|
|
|
virtual ~IpProtocol() {}
|
|
|
|
virtual ::google::protobuf::Message& data() {return d;}
|
|
|
|
|
|
|
|
bool update(OstProto::Ip ip) { d.MergeFrom(ip); return true; }
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
enum IpAddrMode {
|
|
|
|
IpAddrFixed,
|
|
|
|
IpAddrIncHost,
|
|
|
|
IpAddrDecHost,
|
|
|
|
IpAddrRandomHost
|
|
|
|
};
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
enum IpFlag {
|
|
|
|
IpOverrideVersion = 0x01,
|
|
|
|
IpOverrideHdrLen = 0x02,
|
2008-08-23 23:39:08 -05:00
|
|
|
IpOverrideTotLen = 0x04,
|
|
|
|
IpOverrideCksum = 0x08
|
2008-08-08 22:22:13 -05:00
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(IpFlags, IpFlag);
|
|
|
|
|
|
|
|
IpFlags ipFlags()
|
|
|
|
{
|
|
|
|
IpFlags f;
|
|
|
|
|
|
|
|
if (d.is_override_ver()) f|= IpOverrideVersion;
|
|
|
|
if (d.is_override_hdrlen()) f|= IpOverrideHdrLen;
|
|
|
|
if (d.is_override_totlen()) f|= IpOverrideTotLen;
|
|
|
|
if (d.is_override_cksum()) f|= IpOverrideCksum;
|
|
|
|
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool setIpFlags(IpFlags ipFlags)
|
|
|
|
{
|
|
|
|
if (ipFlags.testFlag(IpOverrideVersion))
|
|
|
|
d.set_is_override_ver(true);
|
|
|
|
else
|
|
|
|
d.set_is_override_ver(false);
|
|
|
|
|
|
|
|
if (ipFlags.testFlag(IpOverrideHdrLen))
|
|
|
|
d.set_is_override_hdrlen(true);
|
|
|
|
else
|
|
|
|
d.set_is_override_hdrlen(false);
|
|
|
|
|
|
|
|
if (ipFlags.testFlag(IpOverrideTotLen))
|
|
|
|
d.set_is_override_totlen(true);
|
|
|
|
else
|
|
|
|
d.set_is_override_totlen(false);
|
|
|
|
|
|
|
|
if (ipFlags.testFlag(IpOverrideCksum))
|
|
|
|
d.set_is_override_cksum(true);
|
|
|
|
else
|
|
|
|
d.set_is_override_cksum(false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 ver()
|
|
|
|
{ return (d.ver_hdrlen() >> 4); }
|
|
|
|
bool setVer(quint8 ver)
|
|
|
|
{ d.set_ver_hdrlen((d.ver_hdrlen() & 0x0F) | (ver << 4)); return true; }
|
|
|
|
|
|
|
|
quint8 hdrLen()
|
|
|
|
{ return (d.ver_hdrlen() & 0xF); }
|
|
|
|
bool setHdrLen(quint8 hdrLen)
|
|
|
|
{ d.set_ver_hdrlen((d.ver_hdrlen() & 0xF0) | hdrLen); return true; }
|
|
|
|
|
|
|
|
quint8 tos()
|
|
|
|
{ return d.tos(); }
|
|
|
|
bool setTos(quint8 tos)
|
|
|
|
{ d.set_tos(tos); return true; }
|
|
|
|
|
|
|
|
quint16 totLen()
|
|
|
|
{ return d.tot_len(); }
|
|
|
|
bool setTotLen(quint16 totLen)
|
|
|
|
{ d.set_tot_len(totLen); return true; }
|
|
|
|
|
|
|
|
quint16 id()
|
|
|
|
{ return d.id(); }
|
|
|
|
bool setId(quint16 id)
|
|
|
|
{ d.set_id(id); return true; }
|
|
|
|
|
|
|
|
quint16 flags()
|
|
|
|
{ return d.flags(); }
|
|
|
|
bool setFlags(quint16 flags)
|
|
|
|
{ d.set_flags(flags); return true; }
|
|
|
|
#define IP_FLAG_UNUSED 0x1
|
|
|
|
#define IP_FLAG_DF 0x2
|
|
|
|
#define IP_FLAG_MF 0x4
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
quint16 fragOfs()
|
|
|
|
{ return d.frag_ofs(); }
|
|
|
|
bool setFragOfs(quint16 fragOfs)
|
|
|
|
{ d.set_frag_ofs(fragOfs); return true; }
|
|
|
|
|
|
|
|
quint8 ttl()
|
|
|
|
{ return d.ttl(); }
|
|
|
|
bool setTtl(quint8 ttl)
|
|
|
|
{ d.set_ttl(ttl); return true; }
|
|
|
|
|
|
|
|
quint8 proto()
|
|
|
|
{ return d.proto(); }
|
|
|
|
bool setProto(quint8 proto)
|
|
|
|
{ d.set_proto(proto); return true; }
|
|
|
|
|
|
|
|
quint16 cksum()
|
|
|
|
{ return d.cksum(); }
|
|
|
|
bool setCksum(quint16 cksum)
|
|
|
|
{ d.set_cksum(cksum); return true; }
|
|
|
|
|
|
|
|
// Source IP
|
|
|
|
quint32 srcIp()
|
|
|
|
{ return d.src_ip(); }
|
|
|
|
bool setSrcIp(quint32 srcIp)
|
|
|
|
{ d.set_src_ip(srcIp); return true; }
|
|
|
|
|
|
|
|
IpAddrMode srcIpMode()
|
|
|
|
{ return (IpAddrMode) d.src_ip_mode(); }
|
|
|
|
bool setSrcIpMode(IpAddrMode srcIpMode)
|
|
|
|
{ d.set_src_ip_mode((OstProto::Ip::IpAddrMode)srcIpMode); return true; }
|
|
|
|
|
|
|
|
quint16 srcIpCount()
|
|
|
|
{ return d.src_ip_count(); }
|
|
|
|
bool setSrcIpCount(quint16 srcIpCount)
|
|
|
|
{ d.set_src_ip_count(srcIpCount); return true; }
|
|
|
|
|
|
|
|
quint32 srcIpMask()
|
|
|
|
{ return d.src_ip_mask(); }
|
|
|
|
bool setSrcIpMask(quint32 srcIpMask)
|
|
|
|
{ d.set_src_ip_mask(srcIpMask); return true; }
|
|
|
|
|
|
|
|
// Destination IP
|
|
|
|
quint32 dstIp()
|
|
|
|
{ return d.dst_ip(); }
|
|
|
|
bool setDstIp(quint32 dstIp)
|
|
|
|
{ d.set_dst_ip(dstIp); return true; }
|
|
|
|
|
|
|
|
IpAddrMode dstIpMode()
|
|
|
|
{ return (IpAddrMode) d.dst_ip_mode(); }
|
|
|
|
bool setDstIpMode(IpAddrMode dstIpMode)
|
|
|
|
{ d.set_dst_ip_mode((OstProto::Ip::IpAddrMode)dstIpMode); return true; }
|
|
|
|
|
|
|
|
quint16 dstIpCount()
|
|
|
|
{ return d.dst_ip_count(); }
|
|
|
|
bool setDstIpCount(quint16 dstIpCount)
|
|
|
|
{ d.set_dst_ip_count(dstIpCount); return true; }
|
|
|
|
|
|
|
|
quint32 dstIpMask()
|
|
|
|
{ return d.dst_ip_mask(); }
|
|
|
|
bool setDstIpMask(quint32 dstIpMask)
|
|
|
|
{ d.set_dst_ip_mask(dstIpMask); return true; }
|
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
// TODO(LOW): Options
|
|
|
|
|
|
|
|
|
|
|
|
virtual QString protocolName()
|
|
|
|
{ return QString("Internet Protocol version 4"); }
|
|
|
|
QString protocolShortName()
|
|
|
|
{ return QString("IPv4"); }
|
|
|
|
int numFields()
|
|
|
|
{ return 12; }
|
|
|
|
QString fieldName(int index);
|
|
|
|
QString fieldTextValue(int index);
|
|
|
|
QByteArray fieldRawValue(int index);
|
2008-08-08 22:22:13 -05:00
|
|
|
};
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(IpProtocol::IpFlags)
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
class ArpProtocol: public AbstractProtocol
|
|
|
|
{
|
2008-08-23 23:39:08 -05:00
|
|
|
// TODO(LOW): ARP
|
|
|
|
OstProto::Arp d;
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~ArpProtocol() {}
|
|
|
|
virtual ::google::protobuf::Message& data() {return d;}
|
|
|
|
bool update(OstProto::Arp arp) { d.MergeFrom(arp); return true; }
|
2008-08-08 22:22:13 -05:00
|
|
|
};
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
// TCP
|
|
|
|
class TcpProtocol : public AbstractProtocol
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
OstProto::Tcp d;
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
public:
|
2008-08-23 23:39:08 -05:00
|
|
|
virtual ~TcpProtocol() {}
|
|
|
|
virtual ::google::protobuf::Message& data() {return d;}
|
|
|
|
|
|
|
|
bool update(OstProto::Tcp tcp) { d.MergeFrom(tcp); return true; }
|
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
enum TcpFlag
|
|
|
|
{
|
|
|
|
TcpOverrideHdrLen = 0x01,
|
|
|
|
TcpOverrideCksum = 0x02
|
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(TcpFlags, TcpFlag);
|
|
|
|
|
|
|
|
TcpFlags tcpFlags()
|
|
|
|
{
|
|
|
|
TcpFlags f;
|
|
|
|
|
|
|
|
if (d.is_override_hdrlen()) f|= TcpOverrideHdrLen;
|
|
|
|
if (d.is_override_cksum()) f|= TcpOverrideCksum;
|
|
|
|
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool setTcpFlags(TcpFlags tcpFlags)
|
|
|
|
{
|
|
|
|
if (tcpFlags.testFlag(TcpOverrideHdrLen))
|
|
|
|
d.set_is_override_hdrlen(true);
|
|
|
|
else
|
|
|
|
d.set_is_override_hdrlen(false);
|
|
|
|
|
|
|
|
if (tcpFlags.testFlag(TcpOverrideCksum))
|
|
|
|
d.set_is_override_cksum(true);
|
|
|
|
else
|
|
|
|
d.set_is_override_cksum(false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint16 srcPort()
|
|
|
|
{ return d.src_port(); }
|
|
|
|
bool setSrcPort(quint16 srcPort)
|
|
|
|
{ d.set_src_port(srcPort); return true; }
|
|
|
|
|
|
|
|
quint16 dstPort()
|
|
|
|
{ return d.dst_port(); }
|
2008-08-23 23:39:08 -05:00
|
|
|
bool setDstPort(quint16 dstPort)
|
2008-08-08 22:22:13 -05:00
|
|
|
{ d.set_dst_port(dstPort); return true; }
|
|
|
|
|
|
|
|
quint32 seqNum()
|
|
|
|
{ return d.seq_num(); }
|
|
|
|
bool setSeqNum(quint32 seqNum)
|
|
|
|
{ d.set_seq_num(seqNum); return true;}
|
|
|
|
|
|
|
|
quint32 ackNum()
|
|
|
|
{ return d.ack_num(); }
|
|
|
|
bool setAckNum(quint32 ackNum)
|
|
|
|
{ d.set_ack_num(ackNum); return true;}
|
|
|
|
|
|
|
|
quint8 hdrLen()
|
|
|
|
{ return (d.hdrlen_rsvd() >> 4); }
|
|
|
|
bool setHdrLen(quint8 hdrLen)
|
|
|
|
{ d.set_hdrlen_rsvd((d.hdrlen_rsvd() & 0x0F) | (hdrLen << 4)); return true; }
|
|
|
|
|
|
|
|
quint8 rsvd()
|
|
|
|
{ return (d.hdrlen_rsvd() & 0xF); }
|
|
|
|
bool setRsvd(quint8 rsvd)
|
|
|
|
{ d.set_hdrlen_rsvd((d.hdrlen_rsvd() & 0xF0) | rsvd); return true; }
|
|
|
|
|
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
// TODO(MED): convert to enum maybe?
|
2008-08-08 22:22:13 -05:00
|
|
|
quint8 flags()
|
|
|
|
{ return d.flags(); }
|
|
|
|
bool setFlags(quint8 flags)
|
|
|
|
{ d.set_flags(flags); return true; }
|
2008-05-03 09:37:10 -05:00
|
|
|
#define TCP_FLAG_URG 0x01
|
|
|
|
#define TCP_FLAG_ACK 0x02
|
|
|
|
#define TCP_FLAG_PSH 0x04
|
|
|
|
#define TCP_FLAG_RST 0x08
|
|
|
|
#define TCP_FLAG_SYN 0x10
|
|
|
|
#define TCP_FLAG_FIN 0x20
|
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
quint16 window()
|
|
|
|
{ return d.window(); }
|
|
|
|
bool setWindow(quint16 window)
|
|
|
|
{ d.set_window(window); return true; }
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
quint16 cksum()
|
|
|
|
{ return d.cksum(); }
|
|
|
|
bool setCksum(quint16 cksum)
|
|
|
|
{ d.set_cksum(cksum); return true; }
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
quint16 urgPtr()
|
2008-08-08 22:22:13 -05:00
|
|
|
{ return d.urg_ptr(); }
|
2008-08-23 23:39:08 -05:00
|
|
|
bool setUrgPtr(quint16 urg_ptr)
|
2008-08-08 22:22:13 -05:00
|
|
|
{ d.set_urg_ptr(urg_ptr); return true; }
|
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
|
|
|
|
virtual QString protocolName()
|
|
|
|
{ return QString("Transmission Control Protocol"); }
|
|
|
|
QString protocolShortName()
|
|
|
|
{ return QString("TCP"); }
|
|
|
|
int numFields()
|
|
|
|
{ return 10; }
|
|
|
|
QString fieldName(int index);
|
|
|
|
QString fieldTextValue(int index);
|
|
|
|
QByteArray fieldRawValue(int index);
|
2008-08-08 22:22:13 -05:00
|
|
|
};
|
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(TcpProtocol::TcpFlags)
|
2008-05-03 09:37:10 -05:00
|
|
|
|
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
// UDP
|
|
|
|
class UdpProtocol : public AbstractProtocol
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
OstProto::Udp d;
|
|
|
|
|
|
|
|
public:
|
2008-08-23 23:39:08 -05:00
|
|
|
virtual ~UdpProtocol() {}
|
|
|
|
virtual ::google::protobuf::Message& data() {return d;}
|
|
|
|
|
|
|
|
bool update(OstProto::Udp udp) { d.MergeFrom(udp); return true; }
|
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
enum UdpFlag
|
|
|
|
{
|
|
|
|
UdpOverrideTotLen = 0x01,
|
|
|
|
UdpOverrideCksum = 0x02
|
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(UdpFlags, UdpFlag);
|
|
|
|
|
|
|
|
UdpFlags udpFlags()
|
|
|
|
{
|
|
|
|
UdpFlags f;
|
|
|
|
|
|
|
|
if (d.is_override_totlen()) f|= UdpOverrideTotLen;
|
|
|
|
if (d.is_override_cksum()) f|= UdpOverrideCksum;
|
|
|
|
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool setUdpFlags(UdpFlags udpFlags)
|
|
|
|
{
|
|
|
|
if (udpFlags.testFlag(UdpOverrideTotLen))
|
|
|
|
d.set_is_override_totlen(true);
|
|
|
|
else
|
|
|
|
d.set_is_override_totlen(false);
|
|
|
|
|
|
|
|
if (udpFlags.testFlag(UdpOverrideCksum))
|
|
|
|
d.set_is_override_cksum(true);
|
|
|
|
else
|
|
|
|
d.set_is_override_cksum(false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint16 srcPort()
|
|
|
|
{ return d.src_port(); }
|
|
|
|
bool setSrcPort(quint16 srcPort)
|
|
|
|
{ d.set_src_port(srcPort); return true; }
|
|
|
|
|
|
|
|
quint16 dstPort()
|
|
|
|
{ return d.dst_port(); }
|
2008-08-23 23:39:08 -05:00
|
|
|
bool setDstPort(quint16 dstPort)
|
2008-08-08 22:22:13 -05:00
|
|
|
{ d.set_dst_port(dstPort); return true; }
|
|
|
|
|
|
|
|
quint16 totLen()
|
|
|
|
{ return d.totlen(); }
|
|
|
|
bool setTotLen(quint16 totLen)
|
|
|
|
{ d.set_totlen(totLen); return true; }
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
quint16 cksum()
|
|
|
|
{ return d.cksum(); }
|
|
|
|
bool setCksum(quint16 cksum)
|
|
|
|
{ d.set_cksum(cksum); return true; }
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
|
|
|
|
virtual QString protocolName()
|
|
|
|
{ return QString("User Datagram Protocol"); }
|
|
|
|
QString protocolShortName()
|
|
|
|
{ return QString("UDP"); }
|
|
|
|
int numFields()
|
|
|
|
{ return 4; }
|
|
|
|
QString fieldName(int index);
|
|
|
|
QString fieldTextValue(int index);
|
|
|
|
QByteArray fieldRawValue(int index);
|
2008-08-08 22:22:13 -05:00
|
|
|
};
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
class IcmpProtocol : public AbstractProtocol
|
|
|
|
{
|
|
|
|
// TODO(LOW): ICMP
|
|
|
|
OstProto::Icmp d;
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~IcmpProtocol() {}
|
|
|
|
virtual ::google::protobuf::Message& data() {return d;}
|
|
|
|
bool update(OstProto::Icmp icmp) { d.MergeFrom(icmp); return true; }
|
2008-08-08 22:22:13 -05:00
|
|
|
};
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
class IgmpProtocol : public AbstractProtocol
|
|
|
|
{
|
|
|
|
// TODO(LOW): IGMP
|
|
|
|
OstProto::Igmp d;
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~IgmpProtocol() {}
|
|
|
|
virtual ::google::protobuf::Message& data() {return d;}
|
|
|
|
bool update(OstProto::Igmp igmp) { d.MergeFrom(igmp); return true; }
|
2008-08-08 22:22:13 -05:00
|
|
|
};
|
2008-05-03 09:37:10 -05:00
|
|
|
|
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
class Stream {
|
|
|
|
|
|
|
|
quint32 mId;
|
|
|
|
OstProto::StreamCore *mCore;
|
2008-09-28 13:01:52 -05:00
|
|
|
OstProto::StreamControl *mControl;
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
UnknownProtocol *mUnknown;
|
2008-08-30 03:49:08 -05:00
|
|
|
PayloadProtocol *mPayload;
|
2008-08-23 23:39:08 -05:00
|
|
|
MacProtocol *mMac;
|
|
|
|
|
|
|
|
LlcProtocol *mLlc;
|
|
|
|
SnapProtocol *mSnap;
|
|
|
|
Eth2Protocol *mEth2;
|
2008-08-30 03:49:08 -05:00
|
|
|
Dot3Protocol *mDot3;
|
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
VlanProtocol *mVlan;
|
|
|
|
|
|
|
|
IpProtocol *mIp;
|
|
|
|
ArpProtocol *mArp;
|
|
|
|
|
|
|
|
TcpProtocol *mTcp;
|
|
|
|
UdpProtocol *mUdp;
|
|
|
|
IcmpProtocol *mIcmp;
|
|
|
|
IgmpProtocol *mIgmp;
|
|
|
|
|
|
|
|
public:
|
2008-08-30 03:49:08 -05:00
|
|
|
//PayloadProtocol* Payload() { return mPayload; }
|
2008-08-23 23:39:08 -05:00
|
|
|
MacProtocol* mac() { return mMac; }
|
|
|
|
|
2008-08-30 03:49:08 -05:00
|
|
|
void* core() { return mCore; } // FIXME(HI): Debug ONLY
|
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
LlcProtocol* llc() { return mLlc; }
|
|
|
|
SnapProtocol* snap() { return mSnap; }
|
|
|
|
Eth2Protocol* eth2() { return mEth2; }
|
2008-08-30 03:49:08 -05:00
|
|
|
Dot3Protocol* dot3() { return mDot3; }
|
2008-08-23 23:39:08 -05:00
|
|
|
VlanProtocol* vlan() { return mVlan; }
|
|
|
|
|
|
|
|
IpProtocol* ip() { return mIp; }
|
|
|
|
ArpProtocol* arp() { return mArp; }
|
|
|
|
|
|
|
|
TcpProtocol* tcp() { return mTcp; }
|
|
|
|
UdpProtocol* udp() { return mUdp; }
|
|
|
|
IcmpProtocol* icmp() { return mIcmp; }
|
|
|
|
IgmpProtocol* igmp() { return mIgmp; }
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2008-05-03 09:37:10 -05:00
|
|
|
|
|
|
|
public:
|
2008-08-08 22:22:13 -05:00
|
|
|
enum FrameType {
|
|
|
|
e_ft_none,
|
|
|
|
e_ft_eth_2,
|
|
|
|
e_ft_802_3_raw,
|
|
|
|
e_ft_802_3_llc,
|
|
|
|
e_ft_snap
|
|
|
|
};
|
|
|
|
|
|
|
|
enum DataPatternMode {
|
|
|
|
e_dp_fixed,
|
|
|
|
e_dp_inc,
|
|
|
|
e_dp_dec,
|
|
|
|
e_dp_random
|
|
|
|
};
|
|
|
|
|
|
|
|
enum FrameLengthMode {
|
|
|
|
e_fl_fixed,
|
|
|
|
e_fl_inc,
|
|
|
|
e_fl_dec,
|
|
|
|
e_fl_random
|
|
|
|
};
|
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
enum L3Proto {
|
|
|
|
e_l3_none,
|
|
|
|
e_l3_ip,
|
|
|
|
e_l3_arp,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum L4Proto {
|
|
|
|
e_l4_none,
|
|
|
|
e_l4_tcp,
|
|
|
|
e_l4_udp,
|
|
|
|
e_l4_icmp,
|
|
|
|
e_l4_igmp,
|
|
|
|
};
|
|
|
|
|
2008-09-28 13:01:52 -05:00
|
|
|
enum SendUnit {
|
|
|
|
e_su_packets,
|
|
|
|
e_su_bursts
|
|
|
|
};
|
|
|
|
|
|
|
|
enum SendMode {
|
|
|
|
e_sm_fixed,
|
|
|
|
e_sm_continuous
|
|
|
|
};
|
|
|
|
|
|
|
|
enum NextWhat {
|
|
|
|
e_nw_stop,
|
|
|
|
e_nw_goto_next,
|
|
|
|
e_nw_goto_id
|
|
|
|
};
|
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
// -------------------------------------------------------
|
|
|
|
// Methods
|
|
|
|
// -------------------------------------------------------
|
2008-05-03 09:37:10 -05:00
|
|
|
Stream();
|
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
bool operator < (const Stream &s) const
|
|
|
|
{ return(mCore->ordinal() < s.mCore->ordinal()); }
|
|
|
|
|
|
|
|
|
|
|
|
void getConfig(uint portId, OstProto::Stream *s);
|
2008-09-28 13:01:52 -05:00
|
|
|
bool update(OstProto::Stream *stream);
|
2008-08-23 23:39:08 -05:00
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
quint32 id()
|
|
|
|
{ return mId;}
|
2008-08-23 23:39:08 -05:00
|
|
|
bool setId(quint32 id)
|
|
|
|
{ mId = id; return true;}
|
|
|
|
|
|
|
|
#if 0 // FIXME(HI): needed?
|
|
|
|
quint32 portId()
|
|
|
|
{ return mCore->port_id();}
|
|
|
|
bool setPortId(quint32 id)
|
|
|
|
{ mCore->set_port_id(id); return true;}
|
|
|
|
#endif
|
2008-08-08 22:22:13 -05:00
|
|
|
|
|
|
|
quint32 ordinal()
|
|
|
|
{ return mCore->ordinal();}
|
2008-08-23 23:39:08 -05:00
|
|
|
bool setOrdinal(quint32 ordinal)
|
2008-08-08 22:22:13 -05:00
|
|
|
{ mCore->set_ordinal(ordinal); return true; }
|
|
|
|
|
|
|
|
bool isEnabled() const
|
|
|
|
{ return mCore->is_enabled(); }
|
|
|
|
bool setIsEnabled(bool flag)
|
|
|
|
{ mCore->set_is_enabled(flag); return true; }
|
|
|
|
|
|
|
|
const QString name() const
|
|
|
|
{ return QString().fromStdString(mCore->name()); }
|
|
|
|
bool setName(QString name)
|
|
|
|
{ mCore->set_name(name.toStdString()); return true; }
|
|
|
|
|
|
|
|
FrameType frameType()
|
|
|
|
{ return (FrameType) mCore->ft(); }
|
|
|
|
bool setFrameType(FrameType frameType)
|
|
|
|
{ mCore->set_ft((OstProto::StreamCore::FrameType) frameType); return true; }
|
|
|
|
|
|
|
|
// Data Pattern
|
|
|
|
DataPatternMode patternMode()
|
|
|
|
{ return (DataPatternMode) mCore->pattern_mode(); }
|
|
|
|
bool setPatternMode(DataPatternMode patternMode)
|
|
|
|
{ mCore->set_pattern_mode(
|
|
|
|
(OstProto::StreamCore::DataPatternMode) patternMode); return true; }
|
|
|
|
|
|
|
|
quint32 pattern()
|
|
|
|
{ return mCore->pattern(); }
|
|
|
|
bool setPattern(quint32 pattern)
|
|
|
|
{ mCore->set_pattern(pattern); return true; }
|
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
// TODO(HI) : ?????
|
|
|
|
#if 0
|
|
|
|
quint16 dataStartOfs;
|
|
|
|
#endif
|
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
// Frame Length (includes CRC)
|
|
|
|
FrameLengthMode lenMode()
|
|
|
|
{ return (FrameLengthMode) mCore->len_mode(); }
|
|
|
|
bool setLenMode(FrameLengthMode lenMode)
|
|
|
|
{ mCore->set_len_mode(
|
|
|
|
(OstProto::StreamCore::FrameLengthMode) lenMode); return true; }
|
|
|
|
|
|
|
|
quint16 frameLen()
|
|
|
|
{ return mCore->frame_len(); }
|
|
|
|
bool setFrameLen(quint16 frameLen)
|
|
|
|
{ mCore->set_frame_len(frameLen); return true; }
|
|
|
|
|
|
|
|
quint16 frameLenMin()
|
|
|
|
{ return mCore->frame_len_min(); }
|
|
|
|
bool setFrameLenMin(quint16 frameLenMin)
|
|
|
|
{ mCore->set_frame_len_min(frameLenMin); return true; }
|
|
|
|
|
|
|
|
quint16 frameLenMax()
|
|
|
|
{ return mCore->frame_len_max(); }
|
|
|
|
bool setFrameLenMax(quint16 frameLenMax)
|
|
|
|
{ mCore->set_frame_len_max(frameLenMax); return true; }
|
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
L3Proto l3Proto()
|
|
|
|
{ return (L3Proto) mCore->l3_proto(); }
|
|
|
|
bool setL3Proto(L3Proto l3Proto)
|
|
|
|
{ mCore->set_l3_proto((OstProto::StreamCore::L3Proto) l3Proto);
|
|
|
|
return true; }
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
L4Proto l4Proto()
|
|
|
|
{ return (L4Proto) mCore->l4_proto(); }
|
|
|
|
bool setL4Proto(L4Proto l4Proto)
|
|
|
|
{ mCore->set_l4_proto((OstProto::StreamCore::L4Proto) l4Proto);
|
|
|
|
return true; }
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-09-28 13:01:52 -05:00
|
|
|
SendUnit sendUnit()
|
|
|
|
{ return (SendUnit) mControl->unit(); }
|
|
|
|
bool setSendUnit(SendUnit sendUnit)
|
|
|
|
{ mControl->set_unit(
|
|
|
|
(OstProto::StreamControl::SendUnit) sendUnit); return true; }
|
|
|
|
|
|
|
|
SendMode sendMode()
|
|
|
|
{ return (SendMode) mControl->mode(); }
|
|
|
|
bool setSendMode(SendMode sendMode)
|
|
|
|
{ mControl->set_mode(
|
|
|
|
(OstProto::StreamControl::SendMode) sendMode); return true; }
|
|
|
|
|
|
|
|
NextWhat nextWhat()
|
|
|
|
{ return (NextWhat) mControl->next(); }
|
|
|
|
bool setNextWhat(NextWhat nextWhat)
|
|
|
|
{ mControl->set_next(
|
|
|
|
(OstProto::StreamControl::NextWhat) nextWhat); return true; }
|
|
|
|
|
|
|
|
quint32 numPackets()
|
|
|
|
{ return (quint32) mControl->num_packets(); }
|
|
|
|
bool setNumPackets(quint32 numPackets)
|
|
|
|
{ mControl->set_num_packets(numPackets); return true; }
|
|
|
|
|
|
|
|
quint32 numBursts()
|
|
|
|
{ return (quint32) mControl->num_bursts(); }
|
|
|
|
bool setNumBursts(quint32 numBursts)
|
|
|
|
{ mControl->set_num_bursts(numBursts); return true; }
|
|
|
|
|
|
|
|
quint32 burstSize()
|
|
|
|
{ return (quint32) mControl->packets_per_burst(); }
|
|
|
|
bool setBurstSize(quint32 packetsPerBurst)
|
|
|
|
{ mControl->set_packets_per_burst(packetsPerBurst); return true; }
|
|
|
|
|
|
|
|
quint32 packetRate()
|
|
|
|
{ return (quint32) mControl->packets_per_sec(); }
|
|
|
|
bool setPacketRate(quint32 packetsPerSec)
|
|
|
|
{ mControl->set_packets_per_sec(packetsPerSec); return true; }
|
|
|
|
|
|
|
|
quint32 burstRate()
|
|
|
|
{ return (quint32) mControl->bursts_per_sec(); }
|
|
|
|
bool setBurstRate(quint32 burstsPerSec)
|
|
|
|
{ mControl->set_bursts_per_sec(burstsPerSec); return true; }
|
2008-08-23 23:39:08 -05:00
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
// Methods for use by Packet Model
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
|
|
|
|
int numProtocols();
|
2008-08-30 03:49:08 -05:00
|
|
|
|
|
|
|
//! Includes ALL protocol headers excluding payload data
|
|
|
|
int protocolHeaderSize();
|
2008-08-08 22:22:13 -05:00
|
|
|
#if 0
|
2008-08-23 23:39:08 -05:00
|
|
|
int protocolId(int index);
|
|
|
|
int protocolIndex(int id);
|
2008-08-08 22:22:13 -05:00
|
|
|
#endif
|
2008-08-23 23:39:08 -05:00
|
|
|
AbstractProtocol* protocol(int index);
|
|
|
|
private:
|
2008-08-30 03:49:08 -05:00
|
|
|
QList<int> selectedProtocols;
|
|
|
|
int mProtocolHeaderSize;
|
2008-08-23 23:39:08 -05:00
|
|
|
void updateSelectedProtocols();
|
|
|
|
|
2008-05-03 09:37:10 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|