2008-08-08 22:22:13 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
#include "myservice.h"
|
|
|
|
|
|
|
|
#if 0
|
2008-09-28 13:01:52 -05:00
|
|
|
#include <qglobal.h>
|
2008-09-14 07:03:53 -05:00
|
|
|
#include <qendian.h>
|
2009-08-02 09:52:34 -05:00
|
|
|
#include "qdebug.h"
|
|
|
|
|
2009-11-03 08:02:09 -06:00
|
|
|
#include "../common/protocollistiterator.h"
|
2009-08-02 09:52:34 -05:00
|
|
|
#include "../common/abstractprotocol.h"
|
2009-11-08 02:20:34 -06:00
|
|
|
#endif
|
2009-02-22 01:53:14 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
#include "../common/streambase.h"
|
|
|
|
#include "../rpc/pbrpccontroller.h"
|
|
|
|
#include "portmanager.h"
|
2008-09-14 07:03:53 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
MyService::MyService()
|
2009-10-14 10:16:56 -05:00
|
|
|
{
|
2009-12-26 11:33:27 -06:00
|
|
|
PortManager *portManager = PortManager::instance();
|
|
|
|
int n = portManager->portCount();
|
2009-10-14 10:16:56 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
for (int i = 0; i < n; i++)
|
|
|
|
portInfo.append(portManager->port(i));
|
2009-10-14 10:16:56 -05:00
|
|
|
}
|
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
MyService::~MyService()
|
2009-10-14 10:16:56 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
void MyService::getPortIdList(::google::protobuf::RpcController* controller,
|
|
|
|
const ::OstProto::Void* request,
|
|
|
|
::OstProto::PortIdList* response,
|
|
|
|
::google::protobuf::Closure* done)
|
2008-09-14 07:03:53 -05:00
|
|
|
{
|
2009-12-26 11:33:27 -06:00
|
|
|
qDebug("In %s", __PRETTY_FUNCTION__);
|
2008-09-14 07:03:53 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
for (int i = 0; i < portInfo.size(); i++)
|
|
|
|
{
|
|
|
|
::OstProto::PortId *p;
|
2008-09-14 07:03:53 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
p = response->add_port_id();
|
|
|
|
p->set_id(portInfo[i]->id());
|
|
|
|
}
|
2009-02-02 04:08:57 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
done->Run();
|
2008-09-14 07:03:53 -05:00
|
|
|
}
|
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
void MyService::getPortConfig(::google::protobuf::RpcController* controller,
|
|
|
|
const ::OstProto::PortIdList* request,
|
|
|
|
::OstProto::PortConfigList* response,
|
|
|
|
::google::protobuf::Closure* done)
|
2009-02-02 04:08:57 -06:00
|
|
|
{
|
2009-12-26 11:33:27 -06:00
|
|
|
qDebug("In %s", __PRETTY_FUNCTION__);
|
2009-02-02 04:08:57 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
for (int i = 0; i < request->port_id_size(); i++)
|
|
|
|
{
|
|
|
|
int id;
|
2009-02-02 04:08:57 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
id = request->port_id(i).id();
|
|
|
|
if (id < portInfo.size())
|
|
|
|
{
|
|
|
|
OstProto::Port *p;
|
2009-02-02 04:08:57 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
p = response->add_port();
|
|
|
|
portInfo[id]->protoDataCopyInto(p);
|
|
|
|
}
|
|
|
|
}
|
2009-02-02 04:08:57 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
done->Run();
|
2009-02-02 04:08:57 -06:00
|
|
|
}
|
2008-09-28 13:01:52 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
void MyService::getStreamIdList(::google::protobuf::RpcController* controller,
|
|
|
|
const ::OstProto::PortId* request,
|
|
|
|
::OstProto::StreamIdList* response,
|
|
|
|
::google::protobuf::Closure* done)
|
2009-01-17 04:13:46 -06:00
|
|
|
{
|
2009-12-26 11:33:27 -06:00
|
|
|
int portId;
|
2008-09-14 07:03:53 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
qDebug("In %s", __PRETTY_FUNCTION__);
|
2009-01-17 04:13:46 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
portId = request->id();
|
|
|
|
if ((portId < 0) || (portId >= portInfo.size()))
|
|
|
|
goto _invalid_port;
|
2009-01-17 04:13:46 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
response->mutable_port_id()->set_id(portId);
|
|
|
|
for (int i = 0; i < portInfo[portId]->streamCount(); i++)
|
|
|
|
{
|
|
|
|
OstProto::StreamId *s;
|
2009-01-17 04:13:46 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
s = response->add_stream_id();
|
|
|
|
s->set_id(portInfo[portId]->stream(i)->id());
|
|
|
|
}
|
|
|
|
done->Run();
|
|
|
|
return;
|
2009-01-17 04:13:46 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
_invalid_port:
|
|
|
|
controller->SetFailed("Invalid Port Id");
|
|
|
|
done->Run();
|
2009-02-02 04:08:57 -06:00
|
|
|
}
|
2009-01-17 04:13:46 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
void MyService::getStreamConfig(::google::protobuf::RpcController* controller,
|
|
|
|
const ::OstProto::StreamIdList* request,
|
|
|
|
::OstProto::StreamConfigList* response,
|
|
|
|
::google::protobuf::Closure* done)
|
2009-02-02 04:08:57 -06:00
|
|
|
{
|
2009-12-26 11:33:27 -06:00
|
|
|
int portId;
|
2009-02-02 04:08:57 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
qDebug("In %s", __PRETTY_FUNCTION__);
|
2009-02-02 04:08:57 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
portId = request->port_id().id();
|
|
|
|
if ((portId < 0) || (portId >= portInfo.size()))
|
|
|
|
goto _invalid_port;
|
2009-02-02 04:08:57 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
response->mutable_port_id()->set_id(portId);
|
|
|
|
for (int i = 0; i < request->stream_id_size(); i++)
|
|
|
|
{
|
|
|
|
StreamBase *stream;
|
|
|
|
OstProto::Stream *s;
|
2009-02-02 04:08:57 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
stream = portInfo[portId]->stream(request->stream_id(i).id());
|
|
|
|
if (!stream)
|
|
|
|
continue; //! \todo(LOW): Partial status of RPC
|
2009-02-02 04:08:57 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
s = response->add_stream();
|
|
|
|
stream->protoDataCopyInto(*s);
|
|
|
|
}
|
|
|
|
done->Run();
|
|
|
|
return;
|
2009-01-17 04:13:46 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
_invalid_port:
|
|
|
|
controller->SetFailed("invalid portid");
|
|
|
|
done->Run();
|
2009-02-02 04:08:57 -06:00
|
|
|
}
|
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
void MyService::addStream(::google::protobuf::RpcController* controller,
|
|
|
|
const ::OstProto::StreamIdList* request,
|
|
|
|
::OstProto::Ack* response,
|
|
|
|
::google::protobuf::Closure* done)
|
2008-09-14 07:03:53 -05:00
|
|
|
{
|
2009-12-26 11:33:27 -06:00
|
|
|
int portId;
|
2009-02-12 11:07:19 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
qDebug("In %s", __PRETTY_FUNCTION__);
|
2009-02-12 11:07:19 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
portId = request->port_id().id();
|
|
|
|
if ((portId < 0) || (portId >= portInfo.size()))
|
|
|
|
goto _invalid_port;
|
2009-02-12 11:07:19 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
for (int i = 0; i < request->stream_id_size(); i++)
|
|
|
|
{
|
|
|
|
StreamBase *stream;
|
2009-02-22 01:53:14 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
// If stream with same id as in request exists already ==> error!!
|
|
|
|
stream = portInfo[portId]->stream(request->stream_id(i).id());
|
|
|
|
if (stream)
|
|
|
|
continue; //! \todo (LOW): Partial status of RPC
|
2008-09-14 07:03:53 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
// Append a new "default" stream - actual contents of the new stream is
|
|
|
|
// expected in a subsequent "modifyStream" request - set the stream id
|
|
|
|
// now itself however!!!
|
|
|
|
stream = new StreamBase;
|
|
|
|
stream->setId(request->stream_id(i).id());
|
|
|
|
portInfo[portId]->addStream(stream);
|
2009-10-14 10:16:56 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
}
|
2009-10-14 10:16:56 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
//! \todo (LOW): fill-in response "Ack"????
|
2009-11-03 08:02:09 -06:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
done->Run();
|
|
|
|
return;
|
2009-10-14 10:16:56 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
_invalid_port:
|
|
|
|
controller->SetFailed("invalid portid");
|
|
|
|
done->Run();
|
2009-10-14 10:16:56 -05:00
|
|
|
}
|
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
void MyService::deleteStream(::google::protobuf::RpcController* controller,
|
|
|
|
const ::OstProto::StreamIdList* request,
|
|
|
|
::OstProto::Ack* response,
|
|
|
|
::google::protobuf::Closure* done)
|
2009-10-14 10:16:56 -05:00
|
|
|
{
|
2009-12-26 11:33:27 -06:00
|
|
|
int portId;
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
qDebug("In %s", __PRETTY_FUNCTION__);
|
2008-08-23 23:39:08 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
portId = request->port_id().id();
|
|
|
|
if ((portId < 0) || (portId >= portInfo.size()))
|
|
|
|
goto _invalid_port;
|
2008-08-23 23:39:08 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
for (int i = 0; i < request->stream_id_size(); i++)
|
|
|
|
portInfo[portId]->deleteStream(request->stream_id(i).id());
|
2008-08-23 23:39:08 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
//! \todo (LOW): fill-in response "Ack"????
|
2008-08-23 23:39:08 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
done->Run();
|
|
|
|
return;
|
2008-08-23 23:39:08 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
_invalid_port:
|
|
|
|
controller->SetFailed("invalid portid");
|
|
|
|
done->Run();
|
2008-08-23 23:39:08 -05:00
|
|
|
}
|
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
void MyService::modifyStream(::google::protobuf::RpcController* controller,
|
|
|
|
const ::OstProto::StreamConfigList* request,
|
|
|
|
::OstProto::Ack* response,
|
|
|
|
::google::protobuf::Closure* done)
|
2008-08-08 22:22:13 -05:00
|
|
|
{
|
2009-12-26 11:33:27 -06:00
|
|
|
int portId;
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
qDebug("In %s", __PRETTY_FUNCTION__);
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
portId = request->port_id().id();
|
|
|
|
if ((portId < 0) || (portId >= portInfo.size()))
|
|
|
|
goto _invalid_port;
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
for (int i = 0; i < request->stream_size(); i++)
|
2008-08-08 22:22:13 -05:00
|
|
|
{
|
2009-12-26 11:33:27 -06:00
|
|
|
StreamBase *stream;
|
|
|
|
|
|
|
|
stream = portInfo[portId]->stream(request->stream(i).stream_id().id());
|
|
|
|
if (stream)
|
|
|
|
{
|
|
|
|
stream->protoDataCopyFrom(request->stream(i));
|
|
|
|
portInfo[portId]->setDirty();
|
|
|
|
}
|
2008-08-08 22:22:13 -05:00
|
|
|
}
|
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
//! \todo(LOW): fill-in response "Ack"????
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
done->Run();
|
|
|
|
return;
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
_invalid_port:
|
|
|
|
controller->SetFailed("invalid portid");
|
|
|
|
done->Run();
|
2008-08-08 22:22:13 -05:00
|
|
|
}
|
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
void MyService::startTx(::google::protobuf::RpcController* controller,
|
|
|
|
const ::OstProto::PortIdList* request,
|
|
|
|
::OstProto::Ack* response,
|
|
|
|
::google::protobuf::Closure* done)
|
2008-08-08 22:22:13 -05:00
|
|
|
{
|
2009-12-26 11:33:27 -06:00
|
|
|
qDebug("In %s", __PRETTY_FUNCTION__);
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
for (int i = 0; i < request->port_id_size(); i++)
|
|
|
|
{
|
|
|
|
int portId;
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
portId = request->port_id(i).id();
|
|
|
|
if ((portId < 0) || (portId >= portInfo.size()))
|
|
|
|
continue; //! \todo (LOW): partial RPC?
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
portInfo[portId]->startTransmit();
|
|
|
|
}
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
//! \todo (LOW): fill-in response "Ack"????
|
2008-08-23 23:39:08 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
done->Run();
|
2008-08-08 22:22:13 -05:00
|
|
|
}
|
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
void MyService::stopTx(::google::protobuf::RpcController* controller,
|
|
|
|
const ::OstProto::PortIdList* request,
|
|
|
|
::OstProto::Ack* response,
|
|
|
|
::google::protobuf::Closure* done)
|
2008-08-08 22:22:13 -05:00
|
|
|
{
|
2009-12-26 11:33:27 -06:00
|
|
|
qDebug("In %s", __PRETTY_FUNCTION__);
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
for (int i = 0; i < request->port_id_size(); i++)
|
|
|
|
{
|
|
|
|
int portId;
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
portId = request->port_id(i).id();
|
|
|
|
if ((portId < 0) || (portId >= portInfo.size()))
|
|
|
|
continue; //! \todo (LOW): partial RPC?
|
2009-04-27 11:51:44 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
portInfo[portId]->stopTransmit();
|
|
|
|
}
|
2008-08-23 23:39:08 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
//! \todo (LOW): fill-in response "Ack"????
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
done->Run();
|
2008-08-08 22:22:13 -05:00
|
|
|
}
|
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
void MyService::startCapture(::google::protobuf::RpcController* controller,
|
|
|
|
const ::OstProto::PortIdList* request,
|
|
|
|
::OstProto::Ack* response,
|
|
|
|
::google::protobuf::Closure* done)
|
2008-08-08 22:22:13 -05:00
|
|
|
{
|
2009-12-26 11:33:27 -06:00
|
|
|
qDebug("In %s", __PRETTY_FUNCTION__);
|
2008-08-23 23:39:08 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
for (int i = 0; i < request->port_id_size(); i++)
|
|
|
|
{
|
|
|
|
int portId;
|
2008-08-23 23:39:08 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
portId = request->port_id(i).id();
|
|
|
|
if ((portId < 0) || (portId >= portInfo.size()))
|
|
|
|
continue; //! \todo (LOW): partial RPC?
|
2008-08-23 23:39:08 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
portInfo[portId]->startCapture();
|
|
|
|
}
|
2008-08-23 23:39:08 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
//! \todo (LOW): fill-in response "Ack"????
|
2008-08-23 23:39:08 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
done->Run();
|
2008-08-08 22:22:13 -05:00
|
|
|
}
|
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
void MyService::stopCapture(::google::protobuf::RpcController* controller,
|
|
|
|
const ::OstProto::PortIdList* request,
|
|
|
|
::OstProto::Ack* response,
|
|
|
|
::google::protobuf::Closure* done)
|
2008-08-08 22:22:13 -05:00
|
|
|
{
|
2009-12-26 11:33:27 -06:00
|
|
|
qDebug("In %s", __PRETTY_FUNCTION__);
|
|
|
|
for (int i=0; i < request->port_id_size(); i++)
|
|
|
|
{
|
|
|
|
int portId;
|
2008-09-14 07:03:53 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
portId = request->port_id(i).id();
|
|
|
|
if ((portId < 0) || (portId >= portInfo.size()))
|
|
|
|
continue; //! \todo (LOW): partial RPC?
|
2008-09-14 07:03:53 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
portInfo[portId]->stopCapture();
|
|
|
|
}
|
2008-09-14 07:03:53 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
//! \todo (LOW): fill-in response "Ack"????
|
2008-09-14 07:03:53 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
done->Run();
|
2008-08-08 22:22:13 -05:00
|
|
|
}
|
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
void MyService::getCaptureBuffer(::google::protobuf::RpcController* controller,
|
|
|
|
const ::OstProto::PortId* request,
|
|
|
|
::OstProto::CaptureBuffer* response,
|
|
|
|
::google::protobuf::Closure* done)
|
2008-08-08 22:22:13 -05:00
|
|
|
{
|
2009-12-26 11:33:27 -06:00
|
|
|
int portId;
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
qDebug("In %s", __PRETTY_FUNCTION__);
|
2009-10-14 10:16:56 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
portId = request->id();
|
|
|
|
if ((portId < 0) || (portId >= portInfo.size()))
|
|
|
|
goto _invalid_port;
|
2009-10-14 10:16:56 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
portInfo[portId]->stopCapture();
|
|
|
|
static_cast<PbRpcController*>(controller)->setBinaryBlob(
|
|
|
|
portInfo[portId]->captureData());
|
2009-10-14 10:16:56 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
done->Run();
|
|
|
|
return;
|
2009-10-14 10:16:56 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
_invalid_port:
|
|
|
|
controller->SetFailed("invalid portid");
|
|
|
|
done->Run();
|
2008-08-08 22:22:13 -05:00
|
|
|
}
|
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
void MyService::getStats(::google::protobuf::RpcController* controller,
|
|
|
|
const ::OstProto::PortIdList* request,
|
|
|
|
::OstProto::PortStatsList* response,
|
|
|
|
::google::protobuf::Closure* done)
|
2008-08-08 22:22:13 -05:00
|
|
|
{
|
2009-12-26 11:33:27 -06:00
|
|
|
//qDebug("In %s", __PRETTY_FUNCTION__);
|
2009-10-14 10:16:56 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
for (int i = 0; i < request->port_id_size(); i++)
|
|
|
|
{
|
|
|
|
int portId;
|
|
|
|
AbstractPort::PortStats stats;
|
|
|
|
OstProto::PortStats *s;
|
|
|
|
OstProto::PortState *st;
|
2008-08-08 22:22:13 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
portId = request->port_id(i).id();
|
|
|
|
if ((portId < 0) || (portId >= portInfo.size()))
|
|
|
|
continue; //! \todo(LOW): partial rpc?
|
2008-09-14 07:03:53 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
s = response->add_port_stats();
|
|
|
|
s->mutable_port_id()->set_id(request->port_id(i).id());
|
2008-09-14 07:03:53 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
st = s->mutable_state();
|
|
|
|
st->set_link_state(portInfo[portId]->linkState());
|
|
|
|
st->set_is_transmit_on(portInfo[portId]->isTransmitOn());
|
|
|
|
st->set_is_capture_on(portInfo[portId]->isCaptureOn());
|
2008-09-14 07:03:53 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
portInfo[portId]->stats(&stats);
|
2008-09-14 07:03:53 -05:00
|
|
|
|
2009-02-22 01:53:14 -06:00
|
|
|
#if 0
|
2009-12-26 11:33:27 -06:00
|
|
|
if (portId == 2)
|
|
|
|
qDebug(">%llu", stats.rxPkts);
|
2009-02-22 01:53:14 -06:00
|
|
|
#endif
|
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
s->set_rx_pkts(stats.rxPkts);
|
|
|
|
s->set_rx_bytes(stats.rxBytes);
|
|
|
|
s->set_rx_pps(stats.rxPps);
|
|
|
|
s->set_rx_bps(stats.rxBps);
|
|
|
|
|
|
|
|
s->set_tx_pkts(stats.txPkts);
|
|
|
|
s->set_tx_bytes(stats.txBytes);
|
|
|
|
s->set_tx_pps(stats.txPps);
|
|
|
|
s->set_tx_bps(stats.txBps);
|
|
|
|
}
|
|
|
|
|
|
|
|
done->Run();
|
2008-08-08 22:22:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyService::clearStats(::google::protobuf::RpcController* controller,
|
2009-12-26 11:33:27 -06:00
|
|
|
const ::OstProto::PortIdList* request,
|
|
|
|
::OstProto::Ack* response,
|
|
|
|
::google::protobuf::Closure* done)
|
2008-08-08 22:22:13 -05:00
|
|
|
{
|
2009-12-26 11:33:27 -06:00
|
|
|
qDebug("In %s", __PRETTY_FUNCTION__);
|
2008-09-14 07:03:53 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
for (int i = 0; i < request->port_id_size(); i++)
|
|
|
|
{
|
|
|
|
int portId;
|
|
|
|
|
|
|
|
portId = request->port_id(i).id();
|
|
|
|
if ((portId < 0) || (portId >= portInfo.size()))
|
|
|
|
continue; //! \todo (LOW): partial RPC?
|
2008-09-14 07:03:53 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
portInfo[portId]->resetStats();
|
|
|
|
}
|
2008-09-14 07:03:53 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
//! \todo (LOW): fill-in response "Ack"????
|
2008-09-14 07:03:53 -05:00
|
|
|
|
2009-12-26 11:33:27 -06:00
|
|
|
done->Run();
|
2008-08-08 22:22:13 -05:00
|
|
|
}
|