blob: 0f1ee4b448fa240a7bdd68715f2b6227b3546c46 [file] [log] [blame]
Ratan Gupta1dc91782018-04-19 16:47:12 +05301#pragma once
2
3#include "snmp_client.hpp"
4
5#include <xyz/openbmc_project/Network/Client/Create/server.hpp>
6#include <sdbusplus/bus.hpp>
7
8#include <string>
9
10namespace phosphor
11{
12namespace network
13{
14namespace snmp
15{
16using IPAddress = std::string;
17using ClientList = std::map<IPAddress, std::unique_ptr<Client>>;
18
19namespace details
20{
21
22using CreateIface = sdbusplus::server::object::object<
23 sdbusplus::xyz::openbmc_project::Network::Client::server::Create>;
24
25} // namespace details
26
27class TestSNMPConfManager;
28/** @class Manager
29 * @brief OpenBMC SNMP config implementation.
30 */
31class ConfManager : public details::CreateIface
32{
33 public:
34 ConfManager() = delete;
35 ConfManager(const ConfManager&) = delete;
36 ConfManager& operator=(const ConfManager&) = delete;
37 ConfManager(ConfManager&&) = delete;
38 ConfManager& operator=(ConfManager&&) = delete;
39 virtual ~ConfManager() = 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 */
45 ConfManager(sdbusplus::bus::bus& bus, const char* objPath);
46
47 /** @brief Function to create snmp manager details D-Bus object.
48 * @param[in] address- IP address/Hostname.
49 * @param[in] port - network port.
50 */
51 void client(std::string address, uint16_t port) override;
52
53 /* @brief delete the dbus object of the given ipaddress.
54 * @param[in] address - IP address/Hostname.
55 */
56 void deleteSNMPClient(const std::string& address);
57
58 protected:
59 /** @brief generates the id by doing hash of ipaddress, port
60 * @param[in] address - IP address/Hostname.
61 * @param[in] port - network port.
62 * @return hash string.
63 */
64 static std::string generateId(const std::string& address, uint16_t port);
65
66 private:
67 /** @brief sdbusplus DBus bus object. */
68 sdbusplus::bus::bus& bus;
69
70 /** @brief Path of Object. */
71 std::string objectPath;
72
73 /** @brief map of IPAddress dbus objects and their names */
74 ClientList clients;
75
76 friend class TestSNMPConfManager;
77};
78
79} // namespace snmp
80} // namespace network
81} // namespace phosphor