Ratan Gupta | 1dc9178 | 2018-04-19 16:47:12 +0530 | [diff] [blame] | 1 | #pragma once |
Ratan Gupta | 1dc9178 | 2018-04-19 16:47:12 +0530 | [diff] [blame] | 2 | #include "xyz/openbmc_project/Network/Client/server.hpp" |
| 3 | #include "xyz/openbmc_project/Object/Delete/server.hpp" |
| 4 | |
| 5 | #include <sdbusplus/bus.hpp> |
| 6 | #include <sdbusplus/server/object.hpp> |
| 7 | |
Patrick Williams | 1334b7b | 2021-02-22 17:15:12 -0600 | [diff] [blame^] | 8 | #include <experimental/filesystem> |
Ratan Gupta | 1dc9178 | 2018-04-19 16:47:12 +0530 | [diff] [blame] | 9 | #include <string> |
| 10 | |
| 11 | namespace phosphor |
| 12 | { |
| 13 | namespace network |
| 14 | { |
| 15 | namespace snmp |
| 16 | { |
| 17 | |
| 18 | class ConfManager; |
| 19 | |
| 20 | using Ifaces = sdbusplus::server::object::object< |
| 21 | sdbusplus::xyz::openbmc_project::Network::server::Client, |
| 22 | sdbusplus::xyz::openbmc_project::Object::server::Delete>; |
| 23 | |
Ratan Gupta | a7ff385 | 2018-11-16 14:05:57 +0530 | [diff] [blame] | 24 | using Id = size_t; |
| 25 | |
Ratan Gupta | 1dc9178 | 2018-04-19 16:47:12 +0530 | [diff] [blame] | 26 | /** @class Client |
| 27 | * @brief represents the snmp client configuration |
| 28 | * @details A concrete implementation for the |
| 29 | * xyz.openbmc_project.Network.Client Dbus interface. |
| 30 | */ |
| 31 | class Client : public Ifaces |
| 32 | { |
| 33 | public: |
| 34 | Client() = delete; |
Patrick Williams | 1334b7b | 2021-02-22 17:15:12 -0600 | [diff] [blame^] | 35 | Client(const Client&) = delete; |
| 36 | Client& operator=(const Client&) = delete; |
| 37 | Client(Client&&) = delete; |
| 38 | Client& operator=(Client&&) = delete; |
Ratan Gupta | 1dc9178 | 2018-04-19 16:47:12 +0530 | [diff] [blame] | 39 | virtual ~Client() = default; |
| 40 | |
| 41 | /** @brief Constructor to put object onto bus at a dbus path. |
| 42 | * @param[in] bus - Bus to attach to. |
| 43 | * @param[in] objPath - Path to attach at. |
| 44 | * @param[in] parent - Parent D-bus Object. |
| 45 | * @param[in] address - IPaddress/Hostname. |
| 46 | * @param[in] port - network port. |
| 47 | */ |
Patrick Williams | 1334b7b | 2021-02-22 17:15:12 -0600 | [diff] [blame^] | 48 | Client(sdbusplus::bus::bus& bus, const char* objPath, ConfManager& parent, |
| 49 | const std::string& address, uint16_t port); |
Ratan Gupta | 1dc9178 | 2018-04-19 16:47:12 +0530 | [diff] [blame] | 50 | |
Ratan Gupta | 212f53e | 2018-04-30 17:28:05 +0530 | [diff] [blame] | 51 | /** @brief Constructor to put object onto bus at a dbus path. |
| 52 | * @param[in] bus - Bus to attach to. |
| 53 | * @param[in] objPath - Path to attach at. |
| 54 | * @param[in] parent - Parent D-bus Object. |
| 55 | */ |
Patrick Williams | 1334b7b | 2021-02-22 17:15:12 -0600 | [diff] [blame^] | 56 | Client(sdbusplus::bus::bus& bus, const char* objPath, ConfManager& parent) : |
Ratan Gupta | a7ff385 | 2018-11-16 14:05:57 +0530 | [diff] [blame] | 57 | Ifaces(bus, objPath, true), |
| 58 | id(std::stol(std::experimental::filesystem::path(objPath).filename())), |
| 59 | parent(parent) |
Patrick Williams | 1334b7b | 2021-02-22 17:15:12 -0600 | [diff] [blame^] | 60 | {} |
Ratan Gupta | 212f53e | 2018-04-30 17:28:05 +0530 | [diff] [blame] | 61 | |
Ratan Gupta | 9d18e56 | 2018-11-16 17:19:34 +0530 | [diff] [blame] | 62 | /** @brief Update the address of the object. |
| 63 | * |
| 64 | * @param[in] value - IP address |
| 65 | * |
| 66 | * @return On success the updated IP address |
| 67 | */ |
| 68 | std::string address(std::string value) override; |
| 69 | |
| 70 | /** @brief Update the port |
| 71 | * |
| 72 | * @param[in] value - port number |
| 73 | * |
| 74 | * @return On success the updated port number |
| 75 | */ |
| 76 | uint16_t port(uint16_t value) override; |
| 77 | |
| 78 | using sdbusplus::xyz::openbmc_project::Network::server::Client::address; |
| 79 | |
| 80 | using sdbusplus::xyz::openbmc_project::Network::server::Client::port; |
| 81 | |
Ratan Gupta | 1dc9178 | 2018-04-19 16:47:12 +0530 | [diff] [blame] | 82 | /** @brief Delete this d-bus object. |
| 83 | */ |
| 84 | void delete_() override; |
| 85 | |
| 86 | private: |
Ratan Gupta | a7ff385 | 2018-11-16 14:05:57 +0530 | [diff] [blame] | 87 | /** Client ID. */ |
| 88 | Id id; |
Ratan Gupta | 1dc9178 | 2018-04-19 16:47:12 +0530 | [diff] [blame] | 89 | /** @brief Parent D-Bus Object. */ |
Patrick Williams | 1334b7b | 2021-02-22 17:15:12 -0600 | [diff] [blame^] | 90 | ConfManager& parent; |
Ratan Gupta | 1dc9178 | 2018-04-19 16:47:12 +0530 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | } // namespace snmp |
| 94 | } // namespace network |
| 95 | } // namespace phosphor |