blob: 3ed551a8caaa41df876d875c9e25b739400e81e4 [file] [log] [blame]
Ratan Gupta4af36762017-04-20 19:12:29 +05301#pragma once
2
Ratan Gupta4af36762017-04-20 19:12:29 +05303#include <sdbusplus/bus.hpp>
4#include <sdbusplus/server/object.hpp>
Ratan Gupta4af36762017-04-20 19:12:29 +05305#include <string>
Patrick Venture189d44e2018-07-09 12:30:59 -07006#include <xyz/openbmc_project/Network/IP/server.hpp>
7#include <xyz/openbmc_project/Object/Delete/server.hpp>
Ratan Gupta4af36762017-04-20 19:12:29 +05308
9namespace phosphor
10{
11namespace network
12{
13
Gunnar Mills57d9c502018-09-14 14:42:34 -050014using IPIfaces = sdbusplus::server::object::object<
15 sdbusplus::xyz::openbmc_project::Network::server::IP,
16 sdbusplus::xyz::openbmc_project::Object::server::Delete>;
Ratan Gupta4af36762017-04-20 19:12:29 +053017
18using IP = sdbusplus::xyz::openbmc_project::Network::server::IP;
19
20class 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 */
28class IPAddress : public IPIfaces
29{
Gunnar Mills57d9c502018-09-14 14:42:34 -050030 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;
Ratan Gupta4af36762017-04-20 19:12:29 +053037
Gunnar Mills57d9c502018-09-14 14:42:34 -050038 /** @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);
Ratan Gupta4af36762017-04-20 19:12:29 +053052
Ravi Teja2fd2f7d2019-06-06 03:27:55 -050053 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
Gunnar Mills57d9c502018-09-14 14:42:34 -050059 /** @brief Delete this d-bus object.
60 */
61 void delete_() override;
Ratan Gupta4af36762017-04-20 19:12:29 +053062
Ravi Teja2fd2f7d2019-06-06 03:27:55 -050063 using IP::address;
64 using IP::gateway;
65 using IP::origin;
66 using IP::prefixLength;
67 using IP::type;
68
Gunnar Mills57d9c502018-09-14 14:42:34 -050069 private:
70 /** @brief Parent Object. */
71 EthernetInterface& parent;
Ratan Gupta4af36762017-04-20 19:12:29 +053072};
73
74} // namespace network
75} // namespace phosphor