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