ostinato/client/portgroup.h

116 lines
3.3 KiB
C
Raw Normal View History

2008-05-03 09:37:10 -05:00
#ifndef _PORT_GROUP_H
#define _PORT_GROUP_H
#include "port.h"
#include <QHostAddress>
#include <QTcpSocket>
#include "../common/protocol.pb.h"
#include "pbrpcchannel.h"
2008-05-03 09:37:10 -05:00
/* TODO
HIGH
MED
LOW
- Allow hostnames in addition to IP Address as "server address"
*/
#define DEFAULT_SERVER_PORT 7878
class PortGroup : public QObject {
Q_OBJECT
private:
quint32 mPortGroupId;
static quint32 mPortGroupAllocId;
QString mUserAlias; // user defined
#if 0 // PB
2008-05-03 09:37:10 -05:00
QTcpSocket *mpSocket;
QHostAddress mServerAddress;
quint16 mServerPort;
#endif
PbRpcChannel *rpcChannel;
::google::protobuf::RpcController *rpcController;
::OstProto::OstService::Stub *serviceStub;
::OstProto::PortIdList portIdList;
2008-05-03 09:37:10 -05:00
public: // FIXME(HIGH): member access
QList<Port> mPorts;
public:
PortGroup(QHostAddress ip = QHostAddress::LocalHost,
quint16 port = DEFAULT_SERVER_PORT);
~PortGroup();
void connectToHost() { rpcChannel->establish(); }
void connectToHost(QHostAddress ip, quint16 port)
{ rpcChannel->establish(ip, port); }
void disconnectFromHost() { rpcChannel->tearDown(); }
2008-05-03 09:37:10 -05:00
int numPorts() const { return mPorts.size(); }
quint32 id() const { return mPortGroupId; }
const QString& userAlias() const { return mUserAlias; }
2008-05-03 09:37:10 -05:00
void setUserAlias(QString alias) { mUserAlias = alias; };
const QHostAddress& serverAddress() const
{ return rpcChannel->serverAddress(); }
quint16 serverPort() const
{ return rpcChannel->serverPort(); }
QAbstractSocket::SocketState state() const
{ return rpcChannel->state(); }
void processPortIdList(OstProto::PortIdList *portIdList);
void processPortConfigList(OstProto::PortConfigList *portConfigList);
void getStreamIdList(int portIndex = 0,
OstProto::StreamIdList *streamIdList = NULL);
void getStreamConfigList(int portIndex = 0,
OstProto::StreamConfigList *streamConfigList = NULL);
void processModifyStreamAck(OstProto::Ack *ack);
2008-09-14 07:03:53 -05:00
void startTx(QList<uint> *portList = NULL);
2008-09-14 07:03:53 -05:00
void processStartTxAck(OstProto::Ack *ack);
void stopTx(QList<uint> *portList = NULL);
void processStopTxAck(OstProto::Ack *ack);
2008-09-14 07:03:53 -05:00
Protocol Framework related -------------------------- - AbstractProtocol Constructor and Factory function now take an optional (default NULL) "parent" abstract protocol in addition to the stream; this "parent" protocol is non-NULL for protocols which are aggregated in a ComboProtocol - All subclasses of AbstractProtocol modified as per the above interface change - ProtocolManager also modifed as per the above interface change - new data members in AbstractProtocol - prev, next; the AbstractProtocol implementation now uses these members to traverse protocols on the list instead of ProtocolListIterator; this change required for ComboProtocol - ProtocolListIterator updates these new members - prev/next on insert/remove/replace - ComboProtocol and ProtocolListIterator classes made friends of AbstractProtocol - ComboProtocol implemented as a template class (completed) - Dot2LLc implemented as a combo of Dot3Raw and LLC - Dot2Snap implemented as a combo of Dot2Llc and SNAP - VlanStack implemented as a combo of VLAN + VLAN - ProtocolManager now uses the ProtocolId enums rather than hardcoded values Stream Config Dialog -------------------- - "None" radio button added to all protocol levels - Protocol Level 1 added with 'mac' as the only valid protocol in the "simple" mode widget - With Dot2Llc, Dot2Snap and VlanStack implemented as "combo" protocols, the protocol choice radiobuttons in the "simple" mode are now 1:1 with a protocol; this has the following implications/advantages: - Updates of the "simple" mode widget from/to stream's protocolList is simpler; this code has now been rewritten to take advantage of 1:1 - This paves the way for exporting tunneled protocols 4over4, 4over6, 6over4 etc. in the "simple" mode - This should also (hopefully) require less changes when adding a new protocol; more work needs to be done to reach this goal Fixes ----- - Dot3Protocol now derives "length" correctly for VLAN tagged packets - StreamBase now uses the ProtocolListIterator to append the default protocols in a stream instead of directly manipulating ProtocolList; also in protoDataCopyFrom() Others (Client/Server) ---------------------- - Port Packet Capture implemented; "view capture" is pending (hack put in place now for testing)
2009-10-14 10:16:56 -05:00
void startCapture(QList<uint> *portList = NULL);
void processStartCaptureAck(OstProto::Ack *ack);
void stopCapture(QList<uint> *portList = NULL);
void processStopCaptureAck(OstProto::Ack *ack);
void viewCapture(QList<uint> *portList = NULL);
void processViewCaptureAck(OstProto::CaptureBufferList *bufList);
2008-09-14 07:03:53 -05:00
void getPortStats();
void processPortStatsList(OstProto::PortStatsList *portStatsList);
void clearPortStats(QList<uint> *portList = NULL);
2008-09-14 07:03:53 -05:00
void processClearStatsAck(OstProto::Ack *ack);
2008-05-03 09:37:10 -05:00
signals:
void portGroupDataChanged(PortGroup* portGroup);
void portListAboutToBeChanged(quint32 portGroupId);
void portListChanged(quint32 portGroupId);
2008-09-14 07:03:53 -05:00
void statsChanged(quint32 portGroupId);
2008-05-03 09:37:10 -05:00
private slots:
void on_rpcChannel_stateChanged();
void on_rpcChannel_connected();
void on_rpcChannel_disconnected();
void on_rpcChannel_error(QAbstractSocket::SocketError socketError);
public slots:
void when_configApply(int portIndex, uint *cookie = NULL);
#if 0 // PB
void on_rpcChannel_when_dataAvail();
#endif
2008-05-03 09:37:10 -05:00
private:
#if 0 // PB
2008-05-03 09:37:10 -05:00
void ProcessCapabilityInfo(const char *msg, qint32 size);
void ProcessMsg(const char *msg, quint32 size);
#endif
2008-05-03 09:37:10 -05:00
};
#endif