1 #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 13 namespace phosphor 14 { 15 16 /* Need a custom deleter for freeing up addrinfo */ 17 struct AddrDeleter 18 { 19 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 = 31 sdbusplus::message::variant<bool, uint8_t, int16_t, uint16_t, int32_t, 32 uint32_t, int64_t, uint64_t, std::string>; 33 34 using PropertyMap = std::map<DbusProperty, Value>; 35 36 using DbusInterfaceMap = std::map<DbusInterface, PropertyMap>; 37 38 using 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 */ 48 ObjectValueTree getManagedObjects(sdbusplus::bus::bus& bus, 49 const std::string& service, 50 const std::string& objPath); 51 52 namespace 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 */ 61 std::string resolveAddress(const std::string& address); 62 63 namespace 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 */ 70 std::vector<std::string> getManagers(); 71 72 } // namespace snmp 73 } // namespace network 74 75 } // namespace phosphor 76