blob: 51ebabb044a9318b4332edcbb04a7c94b20e2fa9 [file] [log] [blame]
Ratan Gupta1dc91782018-04-19 16:47:12 +05301#pragma once
Ratan Guptaa7ff3852018-11-16 14:05:57 +05302#include <experimental/filesystem>
Ratan Gupta1dc91782018-04-19 16:47:12 +05303
4#include "xyz/openbmc_project/Network/Client/server.hpp"
5#include "xyz/openbmc_project/Object/Delete/server.hpp"
6
7#include <sdbusplus/bus.hpp>
8#include <sdbusplus/server/object.hpp>
9
10#include <string>
11
12namespace phosphor
13{
14namespace network
15{
16namespace snmp
17{
18
19class ConfManager;
20
21using Ifaces = sdbusplus::server::object::object<
22 sdbusplus::xyz::openbmc_project::Network::server::Client,
23 sdbusplus::xyz::openbmc_project::Object::server::Delete>;
24
Ratan Guptaa7ff3852018-11-16 14:05:57 +053025using Id = size_t;
26
Ratan Gupta1dc91782018-04-19 16:47:12 +053027/** @class Client
28 * @brief represents the snmp client configuration
29 * @details A concrete implementation for the
30 * xyz.openbmc_project.Network.Client Dbus interface.
31 */
32class Client : public Ifaces
33{
34 public:
35 Client() = delete;
36 Client(const Client &) = delete;
37 Client &operator=(const Client &) = delete;
38 Client(Client &&) = delete;
39 Client &operator=(Client &&) = delete;
40 virtual ~Client() = default;
41
42 /** @brief Constructor to put object onto bus at a dbus path.
43 * @param[in] bus - Bus to attach to.
44 * @param[in] objPath - Path to attach at.
45 * @param[in] parent - Parent D-bus Object.
46 * @param[in] address - IPaddress/Hostname.
47 * @param[in] port - network port.
48 */
49 Client(sdbusplus::bus::bus &bus, const char *objPath, ConfManager &parent,
50 const std::string &address, uint16_t port);
51
Ratan Gupta212f53e2018-04-30 17:28:05 +053052 /** @brief Constructor to put object onto bus at a dbus path.
53 * @param[in] bus - Bus to attach to.
54 * @param[in] objPath - Path to attach at.
55 * @param[in] parent - Parent D-bus Object.
56 */
57 Client(sdbusplus::bus::bus &bus, const char *objPath, ConfManager &parent) :
Ratan Guptaa7ff3852018-11-16 14:05:57 +053058 Ifaces(bus, objPath, true),
59 id(std::stol(std::experimental::filesystem::path(objPath).filename())),
60 parent(parent)
Ratan Gupta212f53e2018-04-30 17:28:05 +053061 {
62 }
63
Ratan Gupta9d18e562018-11-16 17:19:34 +053064 /** @brief Update the address of the object.
65 *
66 * @param[in] value - IP address
67 *
68 * @return On success the updated IP address
69 */
70 std::string address(std::string value) override;
71
72 /** @brief Update the port
73 *
74 * @param[in] value - port number
75 *
76 * @return On success the updated port number
77 */
78 uint16_t port(uint16_t value) override;
79
80 using sdbusplus::xyz::openbmc_project::Network::server::Client::address;
81
82 using sdbusplus::xyz::openbmc_project::Network::server::Client::port;
83
Ratan Gupta1dc91782018-04-19 16:47:12 +053084 /** @brief Delete this d-bus object.
85 */
86 void delete_() override;
87
88 private:
Ratan Guptaa7ff3852018-11-16 14:05:57 +053089 /** Client ID. */
90 Id id;
Ratan Gupta1dc91782018-04-19 16:47:12 +053091 /** @brief Parent D-Bus Object. */
92 ConfManager &parent;
93};
94
95} // namespace snmp
96} // namespace network
97} // namespace phosphor