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"
|
2009-04-27 11:51:44 -05:00
|
|
|
#include "../common/abstractprotocol.h"
|
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-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
|
|
|
|
2009-04-27 11:51:44 -05:00
|
|
|
QList<AbstractProtocol*> mProtocolList;
|
2008-08-23 23:39:08 -05:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2008-08-30 03:49:08 -05:00
|
|
|
void* core() { return mCore; } // FIXME(HI): Debug ONLY
|
2009-04-27 11:51:44 -05:00
|
|
|
void loadProtocolWidgets();
|
|
|
|
void storeProtocolWidgets();
|
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 {
|
2008-10-05 12:07:33 -05:00
|
|
|
e_dp_fixed_word,
|
|
|
|
e_dp_inc_byte,
|
|
|
|
e_dp_dec_byte,
|
2008-08-08 22:22:13 -05:00
|
|
|
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();
|
2009-04-27 11:51:44 -05:00
|
|
|
~Stream();
|
|
|
|
|
|
|
|
void protoDataCopyFrom(Stream& stream);
|
2008-05-03 09:37:10 -05:00
|
|
|
|
2008-08-23 23:39:08 -05:00
|
|
|
bool operator < (const Stream &s) const
|
|
|
|
{ return(mCore->ordinal() < s.mCore->ordinal()); }
|
|
|
|
|
|
|
|
|
2009-04-27 11:51:44 -05:00
|
|
|
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; }
|
|
|
|
|
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-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
|
|
|
|
//---------------------------------------------------------------
|
2009-04-27 11:51:44 -05:00
|
|
|
QList<int> frameProtocol();
|
|
|
|
void setFrameProtocol(QList<int> protocolList);
|
2008-08-30 03:49:08 -05:00
|
|
|
|
|
|
|
//! Includes ALL protocol headers excluding payload data
|
|
|
|
int protocolHeaderSize();
|
2009-04-27 11:51:44 -05:00
|
|
|
AbstractProtocol* protocolById(int id);
|
2008-05-03 09:37:10 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|