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 = |
Ratan Gupta | 91a99cc | 2017-04-14 16:32:09 +0530 | [diff] [blame] | 21 | sdbusplus::server::object::object < |
| 22 | sdbusplus::xyz::openbmc_project::Network::server::EthernetInterface >; |
Ratan Gupta | 8c83493 | 2017-04-14 16:30:24 +0530 | [diff] [blame] | 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, |
Ratan Gupta | 91a99cc | 2017-04-14 16:32:09 +0530 | [diff] [blame] | 54 | const std::string& objPath, |
Ratan Gupta | 8c83493 | 2017-04-14 16:30:24 +0530 | [diff] [blame] | 55 | bool dhcpEnabled); |
| 56 | |
| 57 | |
| 58 | |
| 59 | private: |
| 60 | |
| 61 | /** @brief get the info of the ethernet interface. |
| 62 | * @return tuple having the link speed,autonegotiation,duplexmode . |
| 63 | */ |
| 64 | |
| 65 | InterfaceInfo getInterfaceInfo() const; |
| 66 | |
| 67 | /** @brief get the mac address of the interface. |
| 68 | * @return macaddress on success |
| 69 | */ |
| 70 | |
| 71 | std::string getMACAddress() const; |
| 72 | |
| 73 | }; |
| 74 | |
| 75 | } // namespace network |
| 76 | } // namespace phosphor |