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>
|
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
|
|
|
|
|
|
|
class DeviceManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DeviceManager(AbstractPort *parent = 0);
|
|
|
|
~DeviceManager();
|
|
|
|
|
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-09-14 07:49:52 -05:00
|
|
|
|
|
|
|
void receivePacket(PacketBuffer *pktBuf);
|
|
|
|
void transmitPacket(PacketBuffer *pktBuf);
|
2015-09-20 07:19:15 -05:00
|
|
|
|
2015-11-04 07:20:08 -06:00
|
|
|
void clearDeviceNeighbors();
|
|
|
|
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-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);
|
|
|
|
|
2015-09-14 07:49:52 -05:00
|
|
|
AbstractPort *port_;
|
2015-09-20 07:19:15 -05:00
|
|
|
QHash<uint, OstProto::DeviceGroup*> deviceGroupList_;
|
|
|
|
QHash<DeviceKey, Device*> deviceList_;
|
|
|
|
QMultiHash<DeviceKey, Device*> bcastList_;
|
2015-09-14 07:49:52 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|