blob: d6206ff2a72b00960c35dc3f9683cc318ec2b53a [file] [log] [blame]
Ratan Gupta1dc91782018-04-19 16:47:12 +05301#pragma once
Ratan Gupta1dc91782018-04-19 16:47:12 +05302#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 Gupta34d129a2021-12-04 21:04:51 +05308#include <filesystem>
Ratan Gupta1dc91782018-04-19 16:47:12 +05309#include <string>
10
11namespace phosphor
12{
13namespace network
14{
15namespace snmp
16{
17
18class ConfManager;
19
20using Ifaces = sdbusplus::server::object::object<
21 sdbusplus::xyz::openbmc_project::Network::server::Client,
22 sdbusplus::xyz::openbmc_project::Object::server::Delete>;
23
Ratan Guptaa7ff3852018-11-16 14:05:57 +053024using Id = size_t;
25
Ratan Gupta1dc91782018-04-19 16:47:12 +053026/** @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 */
31class Client : public Ifaces
32{
33 public:
34 Client() = delete;
Patrick Williams1334b7b2021-02-22 17:15:12 -060035 Client(const Client&) = delete;
36 Client& operator=(const Client&) = delete;
37 Client(Client&&) = delete;
38 Client& operator=(Client&&) = delete;
Ratan Gupta1dc91782018-04-19 16:47:12 +053039 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 Williams1334b7b2021-02-22 17:15:12 -060048 Client(sdbusplus::bus::bus& bus, const char* objPath, ConfManager& parent,
49 const std::string& address, uint16_t port);
Ratan Gupta1dc91782018-04-19 16:47:12 +053050
Ratan Gupta212f53e2018-04-30 17:28:05 +053051 /** @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 Williams1334b7b2021-02-22 17:15:12 -060056 Client(sdbusplus::bus::bus& bus, const char* objPath, ConfManager& parent) :
Patrick Williamsb9b4c7d2022-04-05 16:20:37 -050057 Ifaces(bus, objPath, Ifaces::action::defer_emit),
Ratan Gupta34d129a2021-12-04 21:04:51 +053058 id(std::stol(std::filesystem::path(objPath).filename())), parent(parent)
Patrick Williams1334b7b2021-02-22 17:15:12 -060059 {}
Ratan Gupta212f53e2018-04-30 17:28:05 +053060
Ratan Gupta9d18e562018-11-16 17:19:34 +053061 /** @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 Gupta1dc91782018-04-19 16:47:12 +053081 /** @brief Delete this d-bus object.
82 */
83 void delete_() override;
84
85 private:
Ratan Guptaa7ff3852018-11-16 14:05:57 +053086 /** Client ID. */
87 Id id;
Ratan Gupta1dc91782018-04-19 16:47:12 +053088 /** @brief Parent D-Bus Object. */
Patrick Williams1334b7b2021-02-22 17:15:12 -060089 ConfManager& parent;
Ratan Gupta1dc91782018-04-19 16:47:12 +053090};
91
92} // namespace snmp
93} // namespace network
94} // namespace phosphor