blob: 4c75f29a974750d99105118cf1a9a7ed6e077236 [file] [log] [blame]
Ratan Gupta8c834932017-04-14 16:30:24 +05301#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
10namespace phosphor
11{
12namespace network
13{
14namespace details
15{
16
17template <typename T>
18using ServerObject = typename sdbusplus::server::object::object<T>;
19
20using EthernetIface =
Ratan Gupta91a99cc2017-04-14 16:32:09 +053021 sdbusplus::server::object::object <
22 sdbusplus::xyz::openbmc_project::Network::server::EthernetInterface >;
Ratan Gupta8c834932017-04-14 16:30:24 +053023
24} // namespace details
25
26using LinkSpeed = uint16_t;
27using DuplexMode = uint8_t;
28using Autoneg = uint8_t;
29using 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 */
37class 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 Gupta91a99cc2017-04-14 16:32:09 +053054 const std::string& objPath,
Ratan Gupta8c834932017-04-14 16:30:24 +053055 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