diff options
Diffstat (limited to 'redfish-core')
-rw-r--r-- | redfish-core/lib/log_services.hpp | 62 |
1 files changed, 50 insertions, 12 deletions
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp index 149b9f6889..9bf661a161 100644 --- a/redfish-core/lib/log_services.hpp +++ b/redfish-core/lib/log_services.hpp @@ -1926,23 +1926,62 @@ class SendRawPECI : public Node const std::vector<std::string> ¶ms) override { std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res); - uint8_t clientAddress = 0; - uint8_t readLength = 0; - std::vector<uint8_t> peciCommand; - if (!json_util::readJson(req, res, "ClientAddress", clientAddress, - "ReadLength", readLength, "PECICommand", - peciCommand)) + std::vector<std::vector<uint8_t>> peciCommands; + + nlohmann::json reqJson = + nlohmann::json::parse(req.body, nullptr, false); + if (reqJson.find("PECICommands") != reqJson.end()) { - return; + if (!json_util::readJson(req, res, "PECICommands", peciCommands)) + { + return; + } + uint32_t idx = 0; + for (auto const &cmd : peciCommands) + { + if (cmd.size() < 3) + { + std::string s("["); + for (auto const &val : cmd) + { + if (val != *cmd.begin()) + { + s += ","; + } + s += std::to_string(val); + } + s += "]"; + messages::actionParameterValueFormatError( + res, s, "PECICommands[" + std::to_string(idx) + "]", + "SendRawPeci"); + return; + } + idx++; + } + } + else + { + /* This interface is deprecated */ + uint8_t clientAddress = 0; + uint8_t readLength = 0; + std::vector<uint8_t> peciCommand; + if (!json_util::readJson(req, res, "ClientAddress", clientAddress, + "ReadLength", readLength, "PECICommand", + peciCommand)) + { + return; + } + peciCommands.push_back({clientAddress, 0, readLength}); + peciCommands[0].insert(peciCommands[0].end(), peciCommand.begin(), + peciCommand.end()); } - // Callback to return the Raw PECI response auto sendRawPECICallback = [asyncResp](const boost::system::error_code ec, - const std::vector<uint8_t> &resp) { + const std::vector<std::vector<uint8_t>> &resp) { if (ec) { - BMCWEB_LOG_DEBUG << "failed to send PECI command ec: " + BMCWEB_LOG_DEBUG << "failed to process PECI commands ec: " << ec.message(); messages::internalError(asyncResp->res); return; @@ -1953,8 +1992,7 @@ class SendRawPECI : public Node // Call the SendRawPECI command with the provided data crow::connections::systemBus->async_method_call( std::move(sendRawPECICallback), crashdumpObject, crashdumpPath, - crashdumpRawPECIInterface, "SendRawPeci", clientAddress, readLength, - peciCommand); + crashdumpRawPECIInterface, "SendRawPeci", peciCommands); } }; |