blob: b5b0eb2c81dab99a48769bc100e914479a13aa9f [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
Patrick Williams1334b7b2021-02-22 17:15:12 -06008#include <experimental/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) :
Ratan Guptaa7ff3852018-11-16 14:05:57 +053057 Ifaces(bus, objPath, true),
58 id(std::stol(std::experimental::filesystem::path(objPath).filename())),
59 parent(parent)
Patrick Williams1334b7b2021-02-22 17:15:12 -060060 {}
Ratan Gupta212f53e2018-04-30 17:28:05 +053061
Ratan Gupta9d18e562018-11-16 17:19:34 +053062 /** @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 Gupta1dc91782018-04-19 16:47:12 +053082 /** @brief Delete this d-bus object.
83 */
84 void delete_() override;
85
86 private:
Ratan Guptaa7ff3852018-11-16 14:05:57 +053087 /** Client ID. */
88 Id id;
Ratan Gupta1dc91782018-04-19 16:47:12 +053089 /** @brief Parent D-Bus Object. */
Patrick Williams1334b7b2021-02-22 17:15:12 -060090 ConfManager& parent;
Ratan Gupta1dc91782018-04-19 16:47:12 +053091};
92
93} // namespace snmp
94} // namespace network
95} // namespace phosphor