1 #include "sol_cmds.hpp" 2 3 #include "sessions_manager.hpp" 4 #include "sol/sol_context.hpp" 5 #include "sol/sol_manager.hpp" 6 7 #include <phosphor-logging/log.hpp> 8 9 namespace sol 10 { 11 12 namespace command 13 { 14 15 using namespace phosphor::logging; 16 17 std::vector<uint8_t> payloadHandler(const std::vector<uint8_t>& inPayload, 18 std::shared_ptr<message::Handler>& handler) 19 { 20 // Check inPayload size is at least Payload 21 if (inPayload.size() < sizeof(Payload)) 22 { 23 return std::vector<uint8_t>(); 24 } 25 26 auto request = reinterpret_cast<const Payload*>(inPayload.data()); 27 auto solDataSize = inPayload.size() - sizeof(Payload); 28 29 std::vector<uint8_t> charData(solDataSize); 30 if (solDataSize > 0) 31 { 32 std::copy_n(inPayload.data() + sizeof(Payload), solDataSize, 33 charData.begin()); 34 } 35 36 try 37 { 38 auto& context = sol::Manager::get().getContext(handler->sessionID); 39 40 context.processInboundPayload( 41 request->packetSeqNum, request->packetAckSeqNum, 42 request->acceptedCharCount, request->inOperation.ack, charData); 43 } 44 catch (const std::exception& e) 45 { 46 log<level::ERR>(e.what()); 47 return std::vector<uint8_t>(); 48 } 49 50 return std::vector<uint8_t>(); 51 } 52 53 void activating(uint8_t payloadInstance, uint32_t sessionID) 54 { 55 std::vector<uint8_t> outPayload(sizeof(ActivatingRequest)); 56 57 auto request = reinterpret_cast<ActivatingRequest*>(outPayload.data()); 58 59 request->sessionState = 0; 60 request->payloadInstance = payloadInstance; 61 request->majorVersion = MAJOR_VERSION; 62 request->minorVersion = MINOR_VERSION; 63 64 auto session = session::Manager::get().getSession(sessionID); 65 66 message::Handler msgHandler(session->channelPtr, sessionID); 67 68 msgHandler.sendUnsolicitedIPMIPayload(netfnTransport, solActivatingCmd, 69 outPayload); 70 } 71 } // namespace command 72 73 } // namespace sol 74