blob: 743025b13a107f08a88e981d6acb1cbadd5d99fb [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>
William A. Kennington IIIc2e5e0e2019-04-22 01:26:06 -07008#include <string_view>
Patrick Venture189d44e2018-07-09 12:30:59 -07009#include <xyz/openbmc_project/Network/IP/server.hpp>
10#include <xyz/openbmc_project/Object/Delete/server.hpp>
Ratan Gupta4af36762017-04-20 19:12:29 +053011
12namespace phosphor
13{
14namespace network
15{
16
Patrick Williamsc38b0712022-07-22 19:26:54 -050017using IPIfaces = sdbusplus::server::object_t<
Gunnar Mills57d9c502018-09-14 14:42:34 -050018 sdbusplus::xyz::openbmc_project::Network::server::IP,
19 sdbusplus::xyz::openbmc_project::Object::server::Delete>;
Ratan Gupta4af36762017-04-20 19:12:29 +053020
21using IP = sdbusplus::xyz::openbmc_project::Network::server::IP;
22
23class EthernetInterface;
24
25/** @class IPAddress
26 * @brief OpenBMC IPAddress implementation.
27 * @details A concrete implementation for the
28 * xyz.openbmc_project.Network.IPProtocol
29 * xyz.openbmc_project.Network.IP Dbus interfaces.
30 */
31class IPAddress : public IPIfaces
32{
Gunnar Mills57d9c502018-09-14 14:42:34 -050033 public:
Gunnar Mills57d9c502018-09-14 14:42:34 -050034 /** @brief Constructor to put object onto bus at a dbus path.
35 * @param[in] bus - Bus to attach to.
William A. Kennington III59e5b912022-11-02 02:49:46 -070036 * @param[in] objRoot - Path to attach at.
Gunnar Mills57d9c502018-09-14 14:42:34 -050037 * @param[in] parent - Parent object.
William A. Kennington III59e5b912022-11-02 02:49:46 -070038 * @param[in] addr - The ip address and prefix.
Gunnar Mills57d9c502018-09-14 14:42:34 -050039 * @param[in] origin - origin of ipaddress(dhcp/static/SLAAC/LinkLocal).
Gunnar Mills57d9c502018-09-14 14:42:34 -050040 */
William A. Kennington III59e5b912022-11-02 02:49:46 -070041 IPAddress(sdbusplus::bus_t& bus, std::string_view objRoot,
William A. Kennington III9ede1b72022-11-21 01:59:28 -080042 stdplus::PinnedRef<EthernetInterface> parent, IfAddr addr,
43 IP::AddressOrigin origin);
Ratan Gupta4af36762017-04-20 19:12:29 +053044
William A. Kennington III5e72d082022-09-01 13:10:17 -070045 std::string address(std::string ipAddress) override;
46 uint8_t prefixLength(uint8_t) override;
47 std::string gateway(std::string gateway) override;
48 IP::Protocol type(IP::Protocol type) override;
49 IP::AddressOrigin origin(IP::AddressOrigin origin) override;
50
Gunnar Mills57d9c502018-09-14 14:42:34 -050051 /** @brief Delete this d-bus object.
52 */
53 void delete_() override;
Ratan Gupta4af36762017-04-20 19:12:29 +053054
Ravi Teja2fd2f7d2019-06-06 03:27:55 -050055 using IP::address;
56 using IP::gateway;
57 using IP::origin;
58 using IP::prefixLength;
59 using IP::type;
60
William A. Kennington III59e5b912022-11-02 02:49:46 -070061 inline const auto& getObjPath() const
62 {
63 return objPath;
64 }
65
Gunnar Mills57d9c502018-09-14 14:42:34 -050066 private:
67 /** @brief Parent Object. */
William A. Kennington III9ede1b72022-11-21 01:59:28 -080068 stdplus::PinnedRef<EthernetInterface> parent;
William A. Kennington III59e5b912022-11-02 02:49:46 -070069
70 /** @brief Dbus object path */
71 sdbusplus::message::object_path objPath;
72
73 IPAddress(sdbusplus::bus_t& bus, sdbusplus::message::object_path objPath,
William A. Kennington III9ede1b72022-11-21 01:59:28 -080074 stdplus::PinnedRef<EthernetInterface> parent, IfAddr addr,
75 IP::AddressOrigin origin);
Ratan Gupta4af36762017-04-20 19:12:29 +053076};
77
Ratan Gupta4af36762017-04-20 19:12:29 +053078} // namespace network
79} // namespace phosphor