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 | |
Ratan Gupta | 34d129a | 2021-12-04 21:04:51 +0530 | [diff] [blame] | 8 | #include <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) : |
Patrick Williams | b9b4c7d | 2022-04-05 16:20:37 -0500 | [diff] [blame] | 57 | Ifaces(bus, objPath, Ifaces::action::defer_emit), |
Ratan Gupta | 34d129a | 2021-12-04 21:04:51 +0530 | [diff] [blame] | 58 | id(std::stol(std::filesystem::path(objPath).filename())), parent(parent) |
Patrick Williams | 1334b7b | 2021-02-22 17:15:12 -0600 | [diff] [blame] | 59 | {} |
Ratan Gupta | 212f53e | 2018-04-30 17:28:05 +0530 | [diff] [blame] | 60 | |
Ratan Gupta | 9d18e56 | 2018-11-16 17:19:34 +0530 | [diff] [blame] | 61 | /** @brief Update the address of the object. |
| 62 | * |
| 63 | * @param[in] value - IP address |
| 64 | * |
| 65 | * @return On success the updated IP address |
| 66 | */ |
| 67 | std::string address(std::string value) override; |
| 68 | |
| 69 | /** @brief Update the port |
| 70 | * |
| 71 | * @param[in] value - port number |
| 72 | * |
| 73 | * @return On success the updated port number |
| 74 | */ |
| 75 | uint16_t port(uint16_t value) override; |
| 76 | |
| 77 | using sdbusplus::xyz::openbmc_project::Network::server::Client::address; |
| 78 | |
| 79 | using sdbusplus::xyz::openbmc_project::Network::server::Client::port; |
| 80 | |
Ratan Gupta | 1dc9178 | 2018-04-19 16:47:12 +0530 | [diff] [blame] | 81 | /** @brief Delete this d-bus object. |
| 82 | */ |
| 83 | void delete_() override; |
| 84 | |
| 85 | private: |
Ratan Gupta | a7ff385 | 2018-11-16 14:05:57 +0530 | [diff] [blame] | 86 | /** Client ID. */ |
| 87 | Id id; |
Ratan Gupta | 1dc9178 | 2018-04-19 16:47:12 +0530 | [diff] [blame] | 88 | /** @brief Parent D-Bus Object. */ |
Patrick Williams | 1334b7b | 2021-02-22 17:15:12 -0600 | [diff] [blame] | 89 | ConfManager& parent; |
Ratan Gupta | 1dc9178 | 2018-04-19 16:47:12 +0530 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | } // namespace snmp |
| 93 | } // namespace network |
| 94 | } // namespace phosphor |