1 #pragma once 2 3 #include <netdb.h> 4 #include <stdint.h> 5 #include <sys/socket.h> 6 #include <sys/types.h> 7 8 #include <sdbusplus/server.hpp> 9 10 #include <map> 11 #include <string> 12 13 namespace phosphor 14 { 15 16 /* Need a custom deleter for freeing up addrinfo */ 17 struct AddrDeleter 18 { operator ()phosphor::AddrDeleter19 void operator()(addrinfo* addrPtr) const 20 { 21 freeaddrinfo(addrPtr); 22 } 23 }; 24 25 using AddrPtr = std::unique_ptr<addrinfo, AddrDeleter>; 26 27 using DbusInterface = std::string; 28 using DbusProperty = std::string; 29 30 using Value = std::variant<bool, uint8_t, int16_t, uint16_t, int32_t, uint32_t, 31 int64_t, uint64_t, std::string>; 32 33 using PropertyMap = std::map<DbusProperty, Value>; 34 35 using DbusInterfaceMap = std::map<DbusInterface, PropertyMap>; 36 37 using 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 */ 47 ObjectValueTree getManagedObjects(sdbusplus::bus_t& bus, 48 const std::string& service, 49 const std::string& objPath); 50 51 namespace 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 */ 60 std::string resolveAddress(const std::string& address); 61 62 namespace 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 */ 69 std::vector<std::string> getManagers(); 70 71 } // namespace snmp 72 } // namespace network 73 74 } // namespace phosphor 75