1 #pragma once
2 
3 #include <sdbusplus/bus.hpp>
4 #include <sdbusplus/server/object.hpp>
5 #include <string>
6 #include <xyz/openbmc_project/Network/IP/server.hpp>
7 #include <xyz/openbmc_project/Object/Delete/server.hpp>
8 
9 namespace phosphor
10 {
11 namespace network
12 {
13 
14 using IPIfaces = sdbusplus::server::object::object<
15     sdbusplus::xyz::openbmc_project::Network::server::IP,
16     sdbusplus::xyz::openbmc_project::Object::server::Delete>;
17 
18 using IP = sdbusplus::xyz::openbmc_project::Network::server::IP;
19 
20 class EthernetInterface;
21 
22 /** @class IPAddress
23  *  @brief OpenBMC IPAddress implementation.
24  *  @details A concrete implementation for the
25  *  xyz.openbmc_project.Network.IPProtocol
26  *  xyz.openbmc_project.Network.IP Dbus interfaces.
27  */
28 class IPAddress : public IPIfaces
29 {
30   public:
31     IPAddress() = delete;
32     IPAddress(const IPAddress&) = delete;
33     IPAddress& operator=(const IPAddress&) = delete;
34     IPAddress(IPAddress&&) = delete;
35     IPAddress& operator=(IPAddress&&) = delete;
36     virtual ~IPAddress() = default;
37 
38     /** @brief Constructor to put object onto bus at a dbus path.
39      *  @param[in] bus - Bus to attach to.
40      *  @param[in] objPath - Path to attach at.
41      *  @param[in] parent - Parent object.
42      *  @param[in] type - ipaddress type(v4/v6).
43      *  @param[in] ipAddress - ipadress.
44      *  @param[in] origin - origin of ipaddress(dhcp/static/SLAAC/LinkLocal).
45      *  @param[in] prefixLength - Length of prefix.
46      *  @param[in] gateway - gateway address.
47      */
48     IPAddress(sdbusplus::bus::bus& bus, const char* objPath,
49               EthernetInterface& parent, IP::Protocol type,
50               const std::string& ipAddress, IP::AddressOrigin origin,
51               uint8_t prefixLength, const std::string& gateway);
52 
53     std::string address(std::string ipAddress) override;
54     uint8_t prefixLength(uint8_t) override;
55     std::string gateway(std::string gateway) override;
56     IP::Protocol type(IP::Protocol type) override;
57     IP::AddressOrigin origin(IP::AddressOrigin origin) override;
58 
59     /** @brief Delete this d-bus object.
60      */
61     void delete_() override;
62 
63     using IP::address;
64     using IP::gateway;
65     using IP::origin;
66     using IP::prefixLength;
67     using IP::type;
68 
69   private:
70     /** @brief Parent Object. */
71     EthernetInterface& parent;
72 };
73 
74 } // namespace network
75 } // namespace phosphor
76