#include #include #include "main.hpp" #include "payload_cmds.hpp" #include "sol/sol_manager.hpp" #include "sol_cmds.hpp" namespace sol { namespace command { using namespace phosphor::logging; std::vector activatePayload(std::vector& inPayload, const message::Handler& handler) { std::vector outPayload(sizeof(ActivatePayloadResponse)); auto request = reinterpret_cast(inPayload.data()); auto response = reinterpret_cast (outPayload.data()); response->completionCode = IPMI_CC_OK; // SOL is the payload currently supported for activation. if (static_cast(message::PayloadType::SOL) != request->payloadType) { response->completionCode = IPMI_CC_INVALID_FIELD_REQUEST; return outPayload; } // Only one instance of SOL is currently supported. if (request->payloadInstance != 1) { response->completionCode = IPMI_CC_INVALID_FIELD_REQUEST; return outPayload; } auto session = (std::get(singletonPool).getSession( handler.sessionID)).lock(); if (!request->encryption && session->isCryptAlgoEnabled()) { response->completionCode = IPMI_CC_PAYLOAD_WITHOUT_ENCRYPTION; return outPayload; } auto status = std::get(singletonPool).isPayloadActive( request->payloadInstance); if (status) { response->completionCode = IPMI_CC_PAYLOAD_ALREADY_ACTIVE; return outPayload; } // Set the current command's socket channel to the session handler.setChannelInSession(); // Start the SOL payload try { std::get(singletonPool).startPayloadInstance( request->payloadInstance, handler.sessionID); } catch (std::exception& e) { log(e.what()); response->completionCode = IPMI_CC_UNSPECIFIED_ERROR; return outPayload; } response->inPayloadSize = endian::to_ipmi(MAX_PAYLOAD_SIZE); response->outPayloadSize = endian::to_ipmi(MAX_PAYLOAD_SIZE); response->portNum = endian::to_ipmi(IPMI_STD_PORT); // VLAN addressing is not used response->vlanNum = 0xFFFF; return outPayload; } } // namespace command } // namespace sol