ostinato/client/portgroup.h
Srivats P. 2581562ec5 Fixes
- Queued RPC calls would cause crashes due to invalid pointers to request/response and/or controller; this has been fixed
    - PbRpcController now takes ownership of request and response messages and
      will delete them when it itself is being deleted
    - This design mandates that request and response messages for each RPC call
      have to be allocated on the heap.
    - The convention for the Closure 'done' call now is to allocate and pass a
      pointer to the controller object to it which will delete it after use;
      this requires that controller itself be also allocated on the heap
      (NOTE: this is just a convention - not mandatory)
    - All existing RPC calls (in portgroup.cpp) have been changed to follow the
      above convention
- Reordering of queued RPC calls has been fixed
- PortManager is now destroyed at exit; because of this fix the per port temporary capture files are auto-removed at exit
- WinPcapPort destructor no longer deletes the monitor threads because the parent class PcapPort already does it
- Capture does not automatically (and incorrectly) stop after one packet if started immediately after a View Capture operation
- User is prompted to stop transmit on a port first if he tries to apply configuration changes on a port in 'transmit' state
2010-02-17 15:26:42 +00:00

118 lines
3.6 KiB
C++

#ifndef _PORT_GROUP_H
#define _PORT_GROUP_H
#include "port.h"
#include <QHostAddress>
#include <QTcpSocket>
#include "../common/protocol.pb.h"
#include "pbrpcchannel.h"
/* TODO
HIGH
MED
LOW
- Allow hostnames in addition to IP Address as "server address"
*/
#define DEFAULT_SERVER_PORT 7878
class QFile;
class PortGroup : public QObject {
Q_OBJECT
private:
static quint32 mPortGroupAllocId;
quint32 mPortGroupId;
QString mUserAlias; // user defined
PbRpcChannel *rpcChannel;
PbRpcController *statsController;
bool isGetStatsPending_;
OstProto::OstService::Stub *serviceStub;
OstProto::PortIdList *portIdList_;
OstProto::PortStatsList *portStatsList_;
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(); }
int numPorts() const { return mPorts.size(); }
quint32 id() const { return mPortGroupId; }
const QString& userAlias() const { return mUserAlias; }
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(PbRpcController *controller);
void processPortConfigList(PbRpcController *controller);
void processAddStreamAck(PbRpcController *controller);
void processDeleteStreamAck(PbRpcController *controller);
void processModifyStreamAck(int portIndex, PbRpcController *controller);
void modifyPort(int portId, bool isExclusive);
void processModifyPortAck(PbRpcController *controller);
void processUpdatedPortConfig(PbRpcController *controller);
void getStreamIdList();
void processStreamIdList(int portIndex, PbRpcController *controller);
void getStreamConfigList();
void processStreamConfigList(int portIndex, PbRpcController *controller);
void processModifyStreamAck(OstProto::Ack *ack);
void startTx(QList<uint> *portList = NULL);
void processStartTxAck(PbRpcController *controller);
void stopTx(QList<uint> *portList = NULL);
void processStopTxAck(PbRpcController *controller);
void startCapture(QList<uint> *portList = NULL);
void processStartCaptureAck(PbRpcController *controller);
void stopCapture(QList<uint> *portList = NULL);
void processStopCaptureAck(PbRpcController *controller);
void viewCapture(QList<uint> *portList = NULL);
void processViewCaptureAck(PbRpcController *controller);
void getPortStats();
void processPortStatsList();
void clearPortStats(QList<uint> *portList = NULL);
void processClearStatsAck(PbRpcController *controller);
signals:
void portGroupDataChanged(int portGroupId, int portId = 0xFFFF);
void portListAboutToBeChanged(quint32 portGroupId);
void portListChanged(quint32 portGroupId);
void statsChanged(quint32 portGroupId);
private slots:
void on_rpcChannel_stateChanged(QAbstractSocket::SocketState state);
void on_rpcChannel_connected();
void on_rpcChannel_disconnected();
void on_rpcChannel_error(QAbstractSocket::SocketError socketError);
public slots:
void when_configApply(int portIndex);
};
#endif