blob: 71a3003db0b0f9c68f1f7dc7ddb8d546cbf135bc [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
Ratan Gupta2eff84f2017-04-20 19:19:15 +053057 /** @brief delete the dbus object of the given ipaddress.
58 */
59
60 void deleteObject(const std::string& ipaddress);
Ratan Gupta8c834932017-04-14 16:30:24 +053061
62
63 private:
64
65 /** @brief get the info of the ethernet interface.
66 * @return tuple having the link speed,autonegotiation,duplexmode .
67 */
68
69 InterfaceInfo getInterfaceInfo() const;
70
71 /** @brief get the mac address of the interface.
72 * @return macaddress on success
73 */
74
75 std::string getMACAddress() const;
76
77};
78
79} // namespace network
80} // namespace phosphor