Ratan Gupta | 05eb109 | 2017-04-14 16:33:53 +0530 | [diff] [blame^] | 1 | #pragma once |
| 2 | |
| 3 | #include "ethernet_interface.hpp" |
| 4 | #include "xyz/openbmc_project/Network/VLAN/Create/server.hpp" |
| 5 | |
| 6 | #include <sdbusplus/bus.hpp> |
| 7 | |
| 8 | #include <list> |
| 9 | #include <string> |
| 10 | #include <vector> |
| 11 | |
| 12 | namespace phosphor |
| 13 | { |
| 14 | namespace network |
| 15 | { |
| 16 | |
| 17 | namespace details |
| 18 | { |
| 19 | |
| 20 | template <typename T> |
| 21 | using ServerObject = typename sdbusplus::server::object::object<T>; |
| 22 | |
| 23 | using VLANCreateIface = |
| 24 | details::ServerObject<sdbusplus::xyz::openbmc_project:: |
| 25 | Network::VLAN::server::Create>; |
| 26 | |
| 27 | using IntfName = std::string; |
| 28 | |
| 29 | struct AddrInfo { |
| 30 | short addrType; |
| 31 | std::string ipaddress; |
| 32 | }; |
| 33 | |
| 34 | using AddrList = std::list<AddrInfo>; |
| 35 | using IntfAddrMap = std::map<IntfName, AddrList>; |
| 36 | |
| 37 | } // namespace details |
| 38 | |
| 39 | /** @class Manager |
| 40 | * @brief OpenBMC network manager implementation. |
| 41 | */ |
| 42 | class Manager : public details::VLANCreateIface |
| 43 | { |
| 44 | public: |
| 45 | Manager() = delete; |
| 46 | Manager(const Manager&) = delete; |
| 47 | Manager& operator=(const Manager&) = delete; |
| 48 | Manager(Manager&&) = delete; |
| 49 | Manager& operator=(Manager&&) = delete; |
| 50 | virtual ~Manager() = default; |
| 51 | |
| 52 | /** @brief Constructor to put object onto bus at a dbus path. |
| 53 | * @param[in] bus - Bus to attach to. |
| 54 | * @param[in] objPath - Path to attach at. |
| 55 | */ |
| 56 | Manager(sdbusplus::bus::bus& bus, const char* objPath); |
| 57 | |
| 58 | void vLAN(details::IntfName interfaceName, uint16_t id) override; |
| 59 | |
| 60 | private: |
| 61 | /** @brief Get all the interfaces from the system. |
| 62 | * @returns list of interface names. |
| 63 | */ |
| 64 | details::IntfAddrMap getInterfaceAndaddrs() const; |
| 65 | |
| 66 | /** @brief Persistent map of EthernetInterface dbus objects and their names */ |
| 67 | std::map<details::IntfName, std::unique_ptr<EthernetInterface>> interfaces; |
| 68 | |
| 69 | }; |
| 70 | |
| 71 | } // namespace network |
| 72 | } // namespace phosphor |