#pragma once #include "console_buffer.hpp" #include "session.hpp" namespace sol { /** @struct Outbound * * Operation/Status in an outbound SOL payload format(BMC to Remote Console). */ struct Outbound { #if BYTE_ORDER == LITTLE_ENDIAN uint8_t testMode: 2; //!< Not supported. uint8_t breakDetected: 1; //!< Not supported. uint8_t transmitOverrun: 1; //!< Not supported. uint8_t SOLDeactivating: 1; //!< 0 : SOL is active, 1 : SOL deactivated. uint8_t charUnavailable: 1; //!< 0 : Available, 1 : Unavailable. uint8_t ack: 1; //!< 0 : ACK, 1 : NACK. uint8_t reserved: 1; //!< Reserved. #endif #if BYTE_ORDER == BIG_ENDIAN uint8_t reserved: 1; //!< Reserved. uint8_t ack: 1; //!< 0 : ACK, 1 : NACK. uint8_t charUnavailable: 1; //!< 0 : Available, 1 : Unavailable. uint8_t SOLDeactivating: 1; //!< 0 : SOL is active, 1 : SOL deactivated. uint8_t transmitOverrun: 1; //!< Not supported. uint8_t breakDetected: 1; //!< Not supported. uint8_t testMode: 2; //!< Not supported. #endif } __attribute__((packed)); /** @struct Inbound * * Operation/Status in an Inbound SOL Payload format(Remote Console to BMC). */ struct Inbound { #if BYTE_ORDER == LITTLE_ENDIAN uint8_t flushOut: 1; //!< Not supported. uint8_t flushIn: 1; //!< Not supported. uint8_t dcd: 1; //!< Not supported. uint8_t cts: 1; //!< Not supported. uint8_t generateBreak: 1; //!< Not supported. uint8_t ring: 1; //!< Not supported. uint8_t ack: 1; //!< 0 : ACK, 1 : NACK. uint8_t reserved: 1; //!< Reserved. #endif #if BYTE_ORDER == BIG_ENDIAN uint8_t reserved: 1; //!< Reserved. uint8_t ack: 1; //!< 0 : ACK, 1 : NACK. uint8_t ring: 1; //!< Not supported. uint8_t generateBreak: 1; //!< Not supported. uint8_t cts: 1; //!< Not supported. uint8_t dcd: 1; //!< Not supported. uint8_t flushIn: 1; //!< Not supported. uint8_t flushOut: 1; //!< Not supported. #endif } __attribute__((packed)); /** @struct Payload * * SOL Payload Data Format.The following fields make up the SOL payload in an * RMCP+ packet, followed by the console character data. */ struct Payload { uint8_t packetSeqNum; //!< Packet sequence number uint8_t packetAckSeqNum; //!< Packet ACK/NACK sequence number uint8_t acceptedCharCount; //!< Accepted character count union { uint8_t operation; //!& input); /** @brief Send the outbound SOL payload. * * @return zero on success and negative value if condition for sending * the payload fails. */ int sendOutboundPayload(); /** @brief Resend the SOL payload. * * @param[in] clear - if true then send the payload and clear the * cached payload, if false only send the payload. */ void resendPayload(bool clear); private: /** @brief Expected character count. * * Expected Sequence number and expected character count is set before * sending the SOL payload. The check is done against these values when * an incoming SOL payload is received. */ size_t expectedCharCount = 0; /** @brief Inbound and Outbound sequence numbers. */ internal::SequenceNumbers seqNums; /** @brief Copy of the last sent SOL payload. * * A copy of the SOL payload is kept here, so that when a retry needs * to be attempted the payload is sent again. */ std::vector payloadCache; /** * @brief Send Response for Incoming SOL payload. * * @param[in] ackSeqNum - Packet ACK/NACK Sequence Number. * @param[in] count - Accepted Character Count. * @param[in] ack - Set ACK/NACK in the Operation. */ void prepareResponse(uint8_t ackSeqNum, uint8_t count, bool ack); /** @brief Send the outgoing SOL payload. * * @param[in] out - buffer containing the SOL payload. */ void sendPayload(const std::vector& out) const; }; } // namespace sol