blob: 05aafbdb5719422cf24c9580d215c53097902b1e [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 IIIc2e5e0e2019-04-22 01:26:06 -07007#include <string_view>
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
11namespace phosphor
12{
13namespace network
14{
15
Patrick Williamsc38b0712022-07-22 19:26:54 -050016using IPIfaces = sdbusplus::server::object_t<
Gunnar Mills57d9c502018-09-14 14:42:34 -050017 sdbusplus::xyz::openbmc_project::Network::server::IP,
18 sdbusplus::xyz::openbmc_project::Object::server::Delete>;
Ratan Gupta4af36762017-04-20 19:12:29 +053019
20using IP = sdbusplus::xyz::openbmc_project::Network::server::IP;
21
22class EthernetInterface;
23
24/** @class IPAddress
25 * @brief OpenBMC IPAddress implementation.
26 * @details A concrete implementation for the
27 * xyz.openbmc_project.Network.IPProtocol
28 * xyz.openbmc_project.Network.IP Dbus interfaces.
29 */
30class IPAddress : public IPIfaces
31{
Gunnar Mills57d9c502018-09-14 14:42:34 -050032 public:
33 IPAddress() = delete;
34 IPAddress(const IPAddress&) = delete;
35 IPAddress& operator=(const IPAddress&) = delete;
36 IPAddress(IPAddress&&) = delete;
37 IPAddress& operator=(IPAddress&&) = delete;
38 virtual ~IPAddress() = default;
Ratan Gupta4af36762017-04-20 19:12:29 +053039
Gunnar Mills57d9c502018-09-14 14:42:34 -050040 /** @brief Constructor to put object onto bus at a dbus path.
41 * @param[in] bus - Bus to attach to.
William A. Kennington III59e5b912022-11-02 02:49:46 -070042 * @param[in] objRoot - Path to attach at.
Gunnar Mills57d9c502018-09-14 14:42:34 -050043 * @param[in] parent - Parent object.
William A. Kennington III59e5b912022-11-02 02:49:46 -070044 * @param[in] addr - The ip address and prefix.
Gunnar Mills57d9c502018-09-14 14:42:34 -050045 * @param[in] origin - origin of ipaddress(dhcp/static/SLAAC/LinkLocal).
Gunnar Mills57d9c502018-09-14 14:42:34 -050046 */
William A. Kennington III59e5b912022-11-02 02:49:46 -070047 IPAddress(sdbusplus::bus_t& bus, std::string_view objRoot,
48 EthernetInterface& parent, IfAddr addr, IP::AddressOrigin origin);
Ratan Gupta4af36762017-04-20 19:12:29 +053049
William A. Kennington III5e72d082022-09-01 13:10:17 -070050 std::string address(std::string ipAddress) override;
51 uint8_t prefixLength(uint8_t) override;
52 std::string gateway(std::string gateway) override;
53 IP::Protocol type(IP::Protocol type) override;
54 IP::AddressOrigin origin(IP::AddressOrigin origin) override;
55
Gunnar Mills57d9c502018-09-14 14:42:34 -050056 /** @brief Delete this d-bus object.
57 */
58 void delete_() override;
Ratan Gupta4af36762017-04-20 19:12:29 +053059
Ravi Teja2fd2f7d2019-06-06 03:27:55 -050060 using IP::address;
61 using IP::gateway;
62 using IP::origin;
63 using IP::prefixLength;
64 using IP::type;
65
William A. Kennington III59e5b912022-11-02 02:49:46 -070066 inline const auto& getObjPath() const
67 {
68 return objPath;
69 }
70
Gunnar Mills57d9c502018-09-14 14:42:34 -050071 private:
72 /** @brief Parent Object. */
73 EthernetInterface& parent;
William A. Kennington III59e5b912022-11-02 02:49:46 -070074
75 /** @brief Dbus object path */
76 sdbusplus::message::object_path objPath;
77
78 IPAddress(sdbusplus::bus_t& bus, sdbusplus::message::object_path objPath,
79 EthernetInterface& parent, IfAddr addr, IP::AddressOrigin origin);
Ratan Gupta4af36762017-04-20 19:12:29 +053080};
81
Ratan Gupta4af36762017-04-20 19:12:29 +053082} // namespace network
83} // namespace phosphor