Ratan Gupta | 8c83493 | 2017-04-14 16:30:24 +0530 | [diff] [blame^] | 1 | #pragma once |
| 2 | |
| 3 | #include "xyz/openbmc_project/Network/EthernetInterface/server.hpp" |
| 4 | |
| 5 | #include <sdbusplus/bus.hpp> |
| 6 | #include <sdbusplus/server/object.hpp> |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | namespace phosphor |
| 11 | { |
| 12 | namespace network |
| 13 | { |
| 14 | namespace details |
| 15 | { |
| 16 | |
| 17 | template <typename T> |
| 18 | using ServerObject = typename sdbusplus::server::object::object<T>; |
| 19 | |
| 20 | using EthernetIface = |
| 21 | sdbusplus::server::object::object< |
| 22 | sdbusplus::xyz::openbmc_project::Network::server::EthernetInterface>; |
| 23 | |
| 24 | } // namespace details |
| 25 | |
| 26 | using LinkSpeed = uint16_t; |
| 27 | using DuplexMode = uint8_t; |
| 28 | using Autoneg = uint8_t; |
| 29 | using InterfaceInfo = std::tuple<LinkSpeed, DuplexMode, Autoneg>; |
| 30 | |
| 31 | |
| 32 | /** @class EthernetInterface |
| 33 | * @brief OpenBMC Ethernet Interface implementation. |
| 34 | * @details A concrete implementation for the |
| 35 | * xyz.openbmc_project.Network.EthernetInterface DBus API. |
| 36 | */ |
| 37 | class EthernetInterface : public details::EthernetIface |
| 38 | { |
| 39 | public: |
| 40 | EthernetInterface() = delete; |
| 41 | EthernetInterface(const EthernetInterface&) = delete; |
| 42 | EthernetInterface& operator=(const EthernetInterface&) = delete; |
| 43 | EthernetInterface(EthernetInterface&&) = delete; |
| 44 | EthernetInterface& operator=(EthernetInterface&&) = delete; |
| 45 | virtual ~EthernetInterface() = default; |
| 46 | |
| 47 | /** @brief Constructor to put object onto bus at a dbus path. |
| 48 | * @param[in] bus - Bus to attach to. |
| 49 | * @param[in] objPath - Path to attach at. |
| 50 | * @param[in] intfName - name of the ethernet interface. |
| 51 | * @param[in] dhcpEnabled - is dhcp enabled(true/false). |
| 52 | */ |
| 53 | EthernetInterface(sdbusplus::bus::bus& bus, |
| 54 | const char* objPath, |
| 55 | const std::string& intfName, |
| 56 | bool dhcpEnabled); |
| 57 | |
| 58 | |
| 59 | |
| 60 | private: |
| 61 | |
| 62 | /** @brief get the info of the ethernet interface. |
| 63 | * @return tuple having the link speed,autonegotiation,duplexmode . |
| 64 | */ |
| 65 | |
| 66 | InterfaceInfo getInterfaceInfo() const; |
| 67 | |
| 68 | /** @brief get the mac address of the interface. |
| 69 | * @return macaddress on success |
| 70 | */ |
| 71 | |
| 72 | std::string getMACAddress() const; |
| 73 | |
| 74 | }; |
| 75 | |
| 76 | } // namespace network |
| 77 | } // namespace phosphor |