blob: 2ee7dacedf046301e53107211d1a07087db90e1c [file] [log] [blame]
Ratan Gupta63476192018-04-19 16:55:32 +05301#pragma once
2
Ratan Gupta63476192018-04-19 16:55:32 +05303#include <netdb.h>
Patrick Williams1334b7b2021-02-22 17:15:12 -06004#include <stdint.h>
5#include <sys/socket.h>
6#include <sys/types.h>
7
8#include <sdbusplus/server.hpp>
Ratan Gupta63476192018-04-19 16:55:32 +05309
10#include <map>
11#include <string>
12
Ratan Gupta63476192018-04-19 16:55:32 +053013namespace phosphor
14{
15
16/* Need a custom deleter for freeing up addrinfo */
17struct AddrDeleter
18{
19 void operator()(addrinfo* addrPtr) const
20 {
21 freeaddrinfo(addrPtr);
22 }
23};
24
25using AddrPtr = std::unique_ptr<addrinfo, AddrDeleter>;
26
27using DbusInterface = std::string;
28using DbusProperty = std::string;
29
Patrick Williamse5d90c32020-05-13 18:00:44 -050030using Value = std::variant<bool, uint8_t, int16_t, uint16_t, int32_t, uint32_t,
31 int64_t, uint64_t, std::string>;
Ratan Gupta63476192018-04-19 16:55:32 +053032
33using PropertyMap = std::map<DbusProperty, Value>;
34
35using DbusInterfaceMap = std::map<DbusInterface, PropertyMap>;
36
37using ObjectValueTree =
38 std::map<sdbusplus::message::object_path, DbusInterfaceMap>;
39
40/** @brief Gets all managed objects associated with the given object
41 * path and service.
42 * @param[in] bus - D-Bus Bus Object.
43 * @param[in] service - D-Bus service name.
44 * @param[in] objPath - D-Bus object path.
45 * @return On success returns the map of name value pair.
46 */
47ObjectValueTree getManagedObjects(sdbusplus::bus::bus& bus,
48 const std::string& service,
49 const std::string& objPath);
50
51namespace network
52{
53
54/** @brief Resolves the given address to IP address.
55 * Given address could be hostname or IP address.
56 * if given address is not valid then it throws an exception.
57 * @param[in] address - address which needs to be converted into IP address.
58 * @return the IP address.
59 */
60std::string resolveAddress(const std::string& address);
61
62namespace snmp
63{
64
65/** @brief Gets all the snmp manager info.
66 * @return the list of manager info in the format
67 * of ipaddress:port
68 */
69std::vector<std::string> getManagers();
70
71} // namespace snmp
72} // namespace network
73
74} // namespace phosphor