2015-09-14 07:49:52 -05:00
|
|
|
/*
|
|
|
|
Copyright (C) 2015 Srivats P.
|
|
|
|
|
|
|
|
This file is part of "Ostinato"
|
|
|
|
|
|
|
|
This is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _DEVICE_MANAGER_H
|
|
|
|
#define _DEVICE_MANAGER_H
|
|
|
|
|
2015-09-20 07:19:15 -05:00
|
|
|
#include "device.h"
|
2015-09-14 07:49:52 -05:00
|
|
|
|
|
|
|
#include <QHash>
|
2016-03-15 07:45:35 -05:00
|
|
|
#include <QMap>
|
2015-09-20 07:19:15 -05:00
|
|
|
#include <QMultiHash>
|
2015-09-14 07:49:52 -05:00
|
|
|
#include <QtGlobal>
|
|
|
|
|
|
|
|
class AbstractPort;
|
|
|
|
class PacketBuffer;
|
2015-09-20 07:19:15 -05:00
|
|
|
namespace OstProto {
|
|
|
|
class DeviceGroup;
|
|
|
|
};
|
2015-09-14 07:49:52 -05:00
|
|
|
|
2015-11-14 05:36:43 -06:00
|
|
|
class DeviceManager
|
2015-09-14 07:49:52 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DeviceManager(AbstractPort *parent = 0);
|
|
|
|
~DeviceManager();
|
|
|
|
|
2018-07-26 10:23:33 -05:00
|
|
|
void createHostDevices();
|
|
|
|
|
2015-09-20 07:19:15 -05:00
|
|
|
int deviceGroupCount();
|
|
|
|
const OstProto::DeviceGroup* deviceGroupAtIndex(int index);
|
|
|
|
const OstProto::DeviceGroup* deviceGroup(uint deviceGroupId);
|
|
|
|
|
|
|
|
bool addDeviceGroup(uint deviceGroupId);
|
|
|
|
bool deleteDeviceGroup(uint deviceGroupId);
|
|
|
|
bool modifyDeviceGroup(const OstProto::DeviceGroup *deviceGroup);
|
2015-09-14 07:49:52 -05:00
|
|
|
|
2015-09-20 07:19:15 -05:00
|
|
|
int deviceCount();
|
2015-11-11 01:35:15 -06:00
|
|
|
void getDeviceList(OstProto::PortDeviceList *deviceList);
|
2015-09-14 07:49:52 -05:00
|
|
|
|
|
|
|
void receivePacket(PacketBuffer *pktBuf);
|
|
|
|
void transmitPacket(PacketBuffer *pktBuf);
|
2015-09-20 07:19:15 -05:00
|
|
|
|
2016-01-28 08:31:19 -06:00
|
|
|
void resolveDeviceGateways();
|
|
|
|
|
2016-03-17 09:42:13 -05:00
|
|
|
void clearDeviceNeighbors(Device::NeighborSet set = Device::kAllNeighbors);
|
2015-11-04 07:20:08 -06:00
|
|
|
void resolveDeviceNeighbor(PacketBuffer *pktBuf);
|
2015-11-10 23:22:29 -06:00
|
|
|
void getDeviceNeighbors(OstProto::PortNeighborList *neighborList);
|
2015-11-04 07:20:08 -06:00
|
|
|
|
2015-11-10 08:10:32 -06:00
|
|
|
quint64 deviceMacAddress(PacketBuffer *pktBuf);
|
|
|
|
quint64 neighborMacAddress(PacketBuffer *pktBuf);
|
2015-11-11 01:35:15 -06:00
|
|
|
|
2015-09-14 07:49:52 -05:00
|
|
|
private:
|
2015-09-20 07:19:15 -05:00
|
|
|
enum Operation { kAdd, kDelete };
|
|
|
|
|
2015-11-10 08:10:32 -06:00
|
|
|
Device* originDevice(PacketBuffer *pktBuf);
|
2015-09-20 07:19:15 -05:00
|
|
|
void enumerateDevices(
|
|
|
|
const OstProto::DeviceGroup *deviceGroup,
|
|
|
|
Operation oper);
|
2018-12-20 07:21:24 -06:00
|
|
|
bool insertDevice(DeviceKey key, Device *device);
|
|
|
|
bool deleteDevice(DeviceKey key);
|
2015-11-14 05:36:43 -06:00
|
|
|
|
2015-09-14 07:49:52 -05:00
|
|
|
AbstractPort *port_;
|
2018-07-26 10:23:33 -05:00
|
|
|
|
2015-09-20 07:19:15 -05:00
|
|
|
QHash<uint, OstProto::DeviceGroup*> deviceGroupList_;
|
2016-03-15 07:45:35 -05:00
|
|
|
QHash<DeviceKey, Device*> deviceList_; // fast access to devices
|
|
|
|
QMap<DeviceKey, Device*> sortedDeviceList_; // sorted access to devices
|
2015-09-20 07:19:15 -05:00
|
|
|
QMultiHash<DeviceKey, Device*> bcastList_;
|
2015-12-20 08:03:02 -06:00
|
|
|
QHash<quint16, uint> tpidList_; // Key: TPID, Value: RefCount
|
2018-07-26 10:23:33 -05:00
|
|
|
|
2018-12-12 10:30:09 -06:00
|
|
|
QList<Device*> hostDeviceList_;
|
2015-09-14 07:49:52 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|