diff options
-rw-r--r-- | redfish-core/lib/network_protocol.hpp | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp index e0b5dac541..d82c2525a1 100644 --- a/redfish-core/lib/network_protocol.hpp +++ b/redfish-core/lib/network_protocol.hpp @@ -351,28 +351,23 @@ void handleNTPServersPatch(const std::vector<std::string>& ntpServers, std::variant<std::vector<std::string>>{ntpServers}); } -void handleIpmiProtocolEnabled( - const bool ipmiProtocolEnabled, - const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) +void handleProtocolEnabled(const bool protocolEnabled, + const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, + const std::string_view netBasePath) { crow::connections::systemBus->async_method_call( - [ipmiProtocolEnabled, - asyncResp](const boost::system::error_code ec, - const crow::openbmc_mapper::GetSubTreeType& subtree) { + [protocolEnabled, asyncResp, + netBasePath](const boost::system::error_code ec, + const crow::openbmc_mapper::GetSubTreeType& subtree) { if (ec) { messages::internalError(asyncResp->res); return; } - constexpr char const* netipmidBasePath = - "/xyz/openbmc_project/control/service/" - "phosphor_2dipmi_2dnet_40"; - for (const auto& entry : subtree) { - if (boost::algorithm::starts_with(entry.first, - netipmidBasePath)) + if (boost::algorithm::starts_with(entry.first, netBasePath)) { crow::connections::systemBus->async_method_call( [asyncResp](const boost::system::error_code ec2) { @@ -385,7 +380,7 @@ void handleIpmiProtocolEnabled( entry.second.begin()->first, entry.first, "org.freedesktop.DBus.Properties", "Set", "xyz.openbmc_project.Control.Service.Attributes", - "Running", std::variant<bool>{ipmiProtocolEnabled}); + "Running", std::variant<bool>{protocolEnabled}); crow::connections::systemBus->async_method_call( [asyncResp](const boost::system::error_code ec2) { @@ -398,7 +393,7 @@ void handleIpmiProtocolEnabled( entry.second.begin()->first, entry.first, "org.freedesktop.DBus.Properties", "Set", "xyz.openbmc_project.Control.Service.Attributes", - "Enabled", std::variant<bool>{ipmiProtocolEnabled}); + "Enabled", std::variant<bool>{protocolEnabled}); } } }, @@ -459,9 +454,11 @@ inline void requestRoutesNetworkProtocol(App& app) std::optional<std::string> newHostName; std::optional<nlohmann::json> ntp; std::optional<nlohmann::json> ipmi; + std::optional<nlohmann::json> ssh; if (!json_util::readJson(req, asyncResp->res, "NTP", ntp, - "HostName", newHostName, "IPMI", ipmi)) + "HostName", newHostName, "IPMI", ipmi, + "SSH", ssh)) { return; } @@ -515,8 +512,28 @@ inline void requestRoutesNetworkProtocol(App& app) if (ipmiProtocolEnabled) { - handleIpmiProtocolEnabled(*ipmiProtocolEnabled, - asyncResp); + handleProtocolEnabled( + *ipmiProtocolEnabled, asyncResp, + "/xyz/openbmc_project/control/service/" + "phosphor_2dipmi_2dnet_40"); + } + } + + if (ssh) + { + std::optional<bool> sshProtocolEnabled; + if (!json_util::readJson(*ssh, asyncResp->res, + "ProtocolEnabled", + sshProtocolEnabled)) + { + return; + } + + if (sshProtocolEnabled) + { + handleProtocolEnabled( + *sshProtocolEnabled, asyncResp, + "/xyz/openbmc_project/control/service/dropbear"); } } }); |