diff options
author | Ratan Gupta <ratagupt@in.ibm.com> | 2017-07-27 07:07:48 +0530 |
---|---|---|
committer | Ratan Gupta <ratagupt@in.ibm.com> | 2017-08-13 06:46:22 +0530 |
commit | b8e9955db5216a0b170a2fb99125d1f22bb9d1c0 (patch) | |
tree | 122efef97394c3af93b4dc4bbc35fdef2a24c129 /utils.hpp | |
parent | 8c31d237f67caa5698fca5aedd449f8c98f0b0c0 (diff) | |
download | phosphor-host-ipmid-b8e9955db5216a0b170a2fb99125d1f22bb9d1c0.tar.gz phosphor-host-ipmid-b8e9955db5216a0b170a2fb99125d1f22bb9d1c0.zip |
Move LAN handling commands to the new xyz interfaces
Change-Id: I4631c79c171883e5f0d531cfb5957a09496e4b3a
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
Diffstat (limited to 'utils.hpp')
-rw-r--r-- | utils.hpp | 87 |
1 files changed, 83 insertions, 4 deletions
@@ -12,16 +12,14 @@ constexpr auto MAPPER_INTF = "xyz.openbmc_project.ObjectMapper"; constexpr auto ROOT = "/"; constexpr auto HOST_MATCH = "host0"; -constexpr auto PROP_INTF = "org.freedesktop.DBus.Properties"; -constexpr auto IP_INTERFACE = "xyz.openbmc_project.Network.IP"; -constexpr auto MAC_INTERFACE = "xyz.openbmc_project.Network.MACAddress"; +constexpr auto PROP_INTF = "org.freedesktop.DBus.Properties"; +constexpr auto DELETE_INTERFACE = "xyz.openbmc_project.Object.Delete"; constexpr auto METHOD_GET = "Get"; constexpr auto METHOD_GET_ALL = "GetAll"; constexpr auto METHOD_SET = "Set"; - /** * @brief Get the DBUS Service name for the input dbus path * @@ -90,6 +88,87 @@ void setDbusProperty(sdbusplus::bus::bus& bus, const std::string& property, const Value& value); +/** @brief Gets all the dbus objects from the given service root + * which matches the object identifier. + * @param[in] bus - DBUS Bus Object. + * @param[in] serviceRoot - Service root path. + * @param[in] interface - Dbus interface. + * @param[in] match - Identifier for a path. + * @returns map of object path and service info. + */ +ObjectTree getAllDbusObjects(sdbusplus::bus::bus& bus, + const std::string& serviceRoot, + const std::string& interface, + const std::string& match); + +/** @brief Deletes all the dbus objects from the given service root + which matches the object identifier. + * @param[in] bus - DBUS Bus Object. + * @param[in] serviceRoot - Service root path. + * @param[in] interface - Dbus interface. + * @param[in] match - Identifier for object. + */ +void deleteAllDbusObjects(sdbusplus::bus::bus& bus, + const std::string& serviceRoot, + const std::string& interface, + const std::string& match = {}); + +namespace method_no_args +{ + +/** @brief Calls the Dbus method which waits for response. + * @param[in] bus - DBUS Bus Object. + * @param[in] service - Dbus service name. + * @param[in] objPath - Dbus object path. + * @param[in] interface - Dbus interface. + * @param[in] method - Dbus method. + */ +void callDbusMethod(sdbusplus::bus::bus& bus, + const std::string& service, + const std::string& objPath, + const std::string& interface, + const std::string& method); + +} //namespace method_no_args + +namespace network +{ + +constexpr auto ROOT = "/xyz/openbmc_project/network"; +constexpr auto NETWORK_SERVICE = "xyz.openbmc_project.Network"; +constexpr auto INTERFACE = "eth0"; +constexpr auto IP_TYPE = "ipv4"; +constexpr auto IP_INTERFACE = "xyz.openbmc_project.Network.IP"; +constexpr auto MAC_INTERFACE = "xyz.openbmc_project.Network.MACAddress"; +constexpr auto SYSTEMCONFIG_INTERFACE = "xyz.openbmc_project.Network.SystemConfiguration"; +constexpr auto ETHERNET_INTERFACE = "xyz.openbmc_project.Network.EthernetInterface"; +constexpr auto IP_CREATE_INTERFACE = "xyz.openbmc_project.Network.IP.Create"; + +/* @brief converts the given subnet into prefix notation. + * @param[in] addressFamily - IP address family(AF_INET/AF_INET6). + * @param[in] mask - Subnet Mask. + * @returns prefix. + */ +uint8_t toPrefix(int addressFamily, const std::string& subnetMask); + + +/** @brief Sets the ip on the system. + * @param[in] bus - DBUS Bus Object. + * @param[in] service - Dbus service name. + * @param[in] objPath - Dbus object path. + * @param[in] protocolType - Protocol type + * @param[in] ipaddress - IPaddress. + * @param[in] prefix - Prefix length. + */ +void createIP(sdbusplus::bus::bus& bus, + const std::string& service, + const std::string& objPath, + const std::string& protocolType, + const std::string& ipaddress, + uint8_t prefix); + +}//namespace network + } // namespace ipmi |