blob: 13ab94f76b7099c6b59a85a09b5dbbf82a70530d [file] [log] [blame]
Ratan Gupta4af36762017-04-20 19:12:29 +05301#pragma once
William A. Kennington IIIc2e5e0e2019-04-22 01:26:06 -07002#include "types.hpp"
Ratan Gupta4af36762017-04-20 19:12:29 +05303
Ratan Gupta4af36762017-04-20 19:12:29 +05304#include <sdbusplus/bus.hpp>
William A. Kennington III59e5b912022-11-02 02:49:46 -07005#include <sdbusplus/message/native_types.hpp>
Ratan Gupta4af36762017-04-20 19:12:29 +05306#include <sdbusplus/server/object.hpp>
William A. Kennington III9ede1b72022-11-21 01:59:28 -08007#include <stdplus/pinned.hpp>
Patrick Venture189d44e2018-07-09 12:30:59 -07008#include <xyz/openbmc_project/Network/IP/server.hpp>
9#include <xyz/openbmc_project/Object/Delete/server.hpp>
Ratan Gupta4af36762017-04-20 19:12:29 +053010
Patrick Williams89d734b2023-05-10 07:50:25 -050011#include <string_view>
12
Ratan Gupta4af36762017-04-20 19:12:29 +053013namespace phosphor
14{
15namespace network
16{
17
Patrick Williamsc38b0712022-07-22 19:26:54 -050018using IPIfaces = sdbusplus::server::object_t<
Gunnar Mills57d9c502018-09-14 14:42:34 -050019 sdbusplus::xyz::openbmc_project::Network::server::IP,
20 sdbusplus::xyz::openbmc_project::Object::server::Delete>;
Ratan Gupta4af36762017-04-20 19:12:29 +053021
22using IP = sdbusplus::xyz::openbmc_project::Network::server::IP;
23
24class EthernetInterface;
25
26/** @class IPAddress
27 * @brief OpenBMC IPAddress implementation.
28 * @details A concrete implementation for the
29 * xyz.openbmc_project.Network.IPProtocol
30 * xyz.openbmc_project.Network.IP Dbus interfaces.
31 */
32class IPAddress : public IPIfaces
33{
Gunnar Mills57d9c502018-09-14 14:42:34 -050034 public:
Gunnar Mills57d9c502018-09-14 14:42:34 -050035 /** @brief Constructor to put object onto bus at a dbus path.
36 * @param[in] bus - Bus to attach to.
William A. Kennington III59e5b912022-11-02 02:49:46 -070037 * @param[in] objRoot - Path to attach at.
Gunnar Mills57d9c502018-09-14 14:42:34 -050038 * @param[in] parent - Parent object.
William A. Kennington III59e5b912022-11-02 02:49:46 -070039 * @param[in] addr - The ip address and prefix.
Gunnar Mills57d9c502018-09-14 14:42:34 -050040 * @param[in] origin - origin of ipaddress(dhcp/static/SLAAC/LinkLocal).
Gunnar Mills57d9c502018-09-14 14:42:34 -050041 */
William A. Kennington III59e5b912022-11-02 02:49:46 -070042 IPAddress(sdbusplus::bus_t& bus, std::string_view objRoot,
William A. Kennington III9b2a20d2023-06-17 14:05:48 -070043 stdplus::PinnedRef<EthernetInterface> parent,
44 stdplus::SubnetAny addr, IP::AddressOrigin origin);
Ratan Gupta4af36762017-04-20 19:12:29 +053045
William A. Kennington III5e72d082022-09-01 13:10:17 -070046 std::string address(std::string ipAddress) override;
47 uint8_t prefixLength(uint8_t) override;
48 std::string gateway(std::string gateway) override;
49 IP::Protocol type(IP::Protocol type) override;
50 IP::AddressOrigin origin(IP::AddressOrigin origin) override;
51
Gunnar Mills57d9c502018-09-14 14:42:34 -050052 /** @brief Delete this d-bus object.
53 */
54 void delete_() override;
Ratan Gupta4af36762017-04-20 19:12:29 +053055
Ravi Teja2fd2f7d2019-06-06 03:27:55 -050056 using IP::address;
57 using IP::gateway;
58 using IP::origin;
59 using IP::prefixLength;
60 using IP::type;
61
William A. Kennington III59e5b912022-11-02 02:49:46 -070062 inline const auto& getObjPath() const
63 {
64 return objPath;
65 }
66
Gunnar Mills57d9c502018-09-14 14:42:34 -050067 private:
68 /** @brief Parent Object. */
William A. Kennington III9ede1b72022-11-21 01:59:28 -080069 stdplus::PinnedRef<EthernetInterface> parent;
William A. Kennington III59e5b912022-11-02 02:49:46 -070070
71 /** @brief Dbus object path */
72 sdbusplus::message::object_path objPath;
73
74 IPAddress(sdbusplus::bus_t& bus, sdbusplus::message::object_path objPath,
William A. Kennington III9b2a20d2023-06-17 14:05:48 -070075 stdplus::PinnedRef<EthernetInterface> parent,
76 stdplus::SubnetAny addr, IP::AddressOrigin origin);
Ratan Gupta4af36762017-04-20 19:12:29 +053077};
78
Ratan Gupta4af36762017-04-20 19:12:29 +053079} // namespace network
80} // namespace phosphor