Device Emulation (contd.): Optimize getDeviceMac() and getNeighborMac() to return 0 if no devices are configured
This commit is contained in:
parent
f6c852495d
commit
3040c72181
@ -321,6 +321,10 @@ Device* DeviceManager::originDevice(PacketBuffer *pktBuf)
|
||||
quint16 vlan;
|
||||
int idx = 0;
|
||||
|
||||
// Do we have any devices at all?
|
||||
if (!deviceCount())
|
||||
return NULL;
|
||||
|
||||
// pktBuf will not have the correct dstMac populated, so use bcastMac
|
||||
// and search for device by IP
|
||||
|
||||
|
@ -933,11 +933,18 @@ _invalid_port:
|
||||
quint64 getDeviceMacAddress(int portId, int streamId, int frameIndex)
|
||||
{
|
||||
MyService *service = drone->rpcService();
|
||||
DeviceManager *devMgr = NULL;
|
||||
quint64 mac;
|
||||
|
||||
if (!service)
|
||||
return 0;
|
||||
|
||||
if ((portId >= 0) && (portId < service->portInfo.size()))
|
||||
devMgr = service->portInfo[portId]->deviceManager();
|
||||
|
||||
if (!devMgr || !devMgr->deviceCount())
|
||||
return 0;
|
||||
|
||||
service->portLock[portId]->lockForWrite();
|
||||
mac = service->portInfo[portId]->deviceMacAddress(streamId, frameIndex);
|
||||
service->portLock[portId]->unlock();
|
||||
@ -948,11 +955,18 @@ quint64 getDeviceMacAddress(int portId, int streamId, int frameIndex)
|
||||
quint64 getNeighborMacAddress(int portId, int streamId, int frameIndex)
|
||||
{
|
||||
MyService *service = drone->rpcService();
|
||||
DeviceManager *devMgr = NULL;
|
||||
quint64 mac;
|
||||
|
||||
if (!service)
|
||||
return 0;
|
||||
|
||||
if ((portId >= 0) && (portId < service->portInfo.size()))
|
||||
devMgr = service->portInfo[portId]->deviceManager();
|
||||
|
||||
if (!devMgr || !devMgr->deviceCount())
|
||||
return 0;
|
||||
|
||||
service->portLock[portId]->lockForWrite();
|
||||
mac = service->portInfo[portId]->neighborMacAddress(streamId, frameIndex);
|
||||
service->portLock[portId]->unlock();
|
||||
|
Loading…
Reference in New Issue
Block a user