diff options
author | Tom Joseph <tomjoseph@in.ibm.com> | 2017-03-14 18:16:22 +0530 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-04-24 11:22:15 -0500 |
commit | 75e15db4629d0ca1f8a418abec2fb45b45babb31 (patch) | |
tree | c914604a79fa3cf1d77764ae309b856f14d8a7a3 | |
parent | fbcac2e7e71d907543963c27a212575289de22b9 (diff) | |
download | phosphor-net-ipmid-75e15db4629d0ca1f8a418abec2fb45b45babb31.tar.gz phosphor-net-ipmid-75e15db4629d0ca1f8a418abec2fb45b45babb31.zip |
Implement API to prepare response for inbound SOL payload
Change-Id: Ied9811e7e3176c5edf99fa299549ea1d14e9555f
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
-rw-r--r-- | sol/sol_context.cpp | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/sol/sol_context.cpp b/sol/sol_context.cpp index b81281b..ee0eb39 100644 --- a/sol/sol_context.cpp +++ b/sol/sol_context.cpp @@ -108,11 +108,46 @@ void Context::processInboundPayload(uint8_t seqNum, } } -void Context::prepareResponse(uint8_t ackSeqNum, - uint8_t count, - bool ack) +void Context::prepareResponse(uint8_t ackSeqNum, uint8_t count, bool ack) { + auto bufferSize = std::get<sol::Manager&>(singletonPool).dataBuffer. + size(); + /* Sent a ACK only response */ + if (payloadCache.size() != 0 || (bufferSize < sendThreshold)) + { + std::get<eventloop::EventLoop&>(singletonPool).switchTimer + (payloadInstance, eventloop::Timers::ACCUMULATE, true); + + Buffer outPayload(sizeof(Payload)); + auto response = reinterpret_cast<Payload*>(outPayload.data()); + response->packetSeqNum = 0; + response->packetAckSeqNum = ackSeqNum; + response->acceptedCharCount = count; + response->outOperation.ack = ack; + sendPayload(outPayload); + return; + } + + auto readSize = std::min(bufferSize, MAX_PAYLOAD_SIZE); + payloadCache.resize(sizeof(Payload) + readSize); + auto response = reinterpret_cast<Payload*>(payloadCache.data()); + response->packetAckSeqNum = ackSeqNum; + response->acceptedCharCount = count; + response->outOperation.ack = ack; + response->packetSeqNum = seqNums.incOutboundSeqNum(); + + + auto handle = std::get<sol::Manager&>(singletonPool).dataBuffer.read(); + std::copy_n(handle, readSize, payloadCache.data() + sizeof(Payload)); + expectedCharCount = readSize; + + std::get<eventloop::EventLoop&>(singletonPool).switchTimer( + payloadInstance, eventloop::Timers::RETRY, true); + std::get<eventloop::EventLoop&>(singletonPool).switchTimer + (payloadInstance, eventloop::Timers::ACCUMULATE, false); + + sendPayload(payloadCache); } void Context::resendPayload(bool clear) @@ -120,4 +155,9 @@ void Context::resendPayload(bool clear) } +void Context::sendPayload(const Buffer& out) const +{ + +} + } // namespace sol |