blob: 5c668345d762ced71802b9f565bb70ef9d095a19 [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 =
21 sdbusplus::server::object::object<
22 sdbusplus::xyz::openbmc_project::Network::server::EthernetInterface>;
23
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,
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