blob: 7a38745f1fd3d55f4435c16b7b3b1e66fa542dd3 [file] [log] [blame]
Ratan Gupta63476192018-04-19 16:55:32 +05301#pragma once
2
3#include <stdint.h>
4#include <sys/types.h>
5#include <sys/socket.h>
6#include <netdb.h>
7
8#include <map>
9#include <string>
10
11#include <sdbusplus/server.hpp>
12
13namespace 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
30using Value =
31 sdbusplus::message::variant<bool, uint8_t, int16_t, uint16_t, int32_t,
32 uint32_t, int64_t, uint64_t, std::string>;
33
34using PropertyMap = std::map<DbusProperty, Value>;
35
36using DbusInterfaceMap = std::map<DbusInterface, PropertyMap>;
37
38using ObjectValueTree =
39 std::map<sdbusplus::message::object_path, DbusInterfaceMap>;
40
41/** @brief Gets all managed objects associated with the given object
42 * path and service.
43 * @param[in] bus - D-Bus Bus Object.
44 * @param[in] service - D-Bus service name.
45 * @param[in] objPath - D-Bus object path.
46 * @return On success returns the map of name value pair.
47 */
48ObjectValueTree getManagedObjects(sdbusplus::bus::bus& bus,
49 const std::string& service,
50 const std::string& objPath);
51
52namespace network
53{
54
55/** @brief Resolves the given address to IP address.
56 * Given address could be hostname or IP address.
57 * if given address is not valid then it throws an exception.
58 * @param[in] address - address which needs to be converted into IP address.
59 * @return the IP address.
60 */
61std::string resolveAddress(const std::string& address);
62
63namespace snmp
64{
65
66/** @brief Gets all the snmp manager info.
67 * @return the list of manager info in the format
68 * of ipaddress:port
69 */
70std::vector<std::string> getManagers();
71
72} // namespace snmp
73} // namespace network
74
75} // namespace phosphor