Tom Joseph | 64b3dec | 2017-04-03 01:53:44 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <vector> |
| 4 | #include "message_handler.hpp" |
| 5 | |
| 6 | namespace sol |
| 7 | { |
| 8 | |
| 9 | namespace command |
| 10 | { |
| 11 | |
| 12 | /** @brief SOL Payload Handler |
| 13 | * |
| 14 | * This command is used for activating and deactivating a payload type under a |
| 15 | * given IPMI session. The UDP Port number for SOL is the same as the port that |
| 16 | * was used to establish the IPMI session. |
| 17 | * |
| 18 | * @param[in] inPayload - Request data for the command. |
| 19 | * @param[in] handler - Reference to the message handler. |
| 20 | * |
| 21 | * @return Response data for the command. |
| 22 | */ |
Tom Joseph | 18a45e9 | 2017-04-11 11:30:44 +0530 | [diff] [blame] | 23 | std::vector<uint8_t> payloadHandler(const std::vector<uint8_t>& inPayload, |
Tom Joseph | 64b3dec | 2017-04-03 01:53:44 +0530 | [diff] [blame] | 24 | const message::Handler& handler); |
Tom Joseph | e14ac96 | 2017-04-03 01:56:04 +0530 | [diff] [blame] | 25 | |
| 26 | constexpr uint8_t netfnTransport = 0x0C; |
| 27 | constexpr uint8_t solActivatingCmd = 0x20; |
| 28 | |
| 29 | /** @struct ActivatingRequest |
| 30 | * |
| 31 | * IPMI payload for SOL Activating command. |
| 32 | */ |
| 33 | struct ActivatingRequest |
| 34 | { |
| 35 | #if BYTE_ORDER == LITTLE_ENDIAN |
| 36 | uint8_t sessionState : 4; //!< SOL session state. |
| 37 | uint8_t reserved : 4; //!< Reserved. |
| 38 | #endif |
| 39 | |
| 40 | #if BYTE_ORDER == BIG_ENDIAN |
| 41 | uint8_t reserved : 4; //!< Reserved. |
| 42 | uint8_t sessionState : 4; //!< SOL session state. |
| 43 | #endif |
| 44 | |
| 45 | uint8_t payloadInstance; //!< Payload instance. |
| 46 | uint8_t majorVersion; //!< SOL format major version |
| 47 | uint8_t minorVersion; //!< SOL format minor version |
| 48 | } __attribute__((packed)); |
| 49 | |
| 50 | /** @brief SOL Activating Command. |
| 51 | * |
| 52 | * This command provides a mechanism for the BMC to notify a remote application |
| 53 | * that a SOL payload is activating on another channel.The request message is a |
| 54 | * message that is asynchronously generated by the BMC. The BMC will not wait |
| 55 | * for a response from the remote console before dropping the serial connection |
| 56 | * to proceed with SOL, therefore the remote console does not need to respond |
| 57 | * to this command. |
| 58 | * |
| 59 | * @param[in] payloadInstance - SOL payload instance. |
| 60 | * @param[in] sessionID - IPMI session ID. |
| 61 | */ |
| 62 | void activating(uint8_t payloadInstance, uint32_t sessionID); |
| 63 | |
Tom Joseph | 48b9951 | 2017-04-28 01:31:08 +0530 | [diff] [blame] | 64 | /** @enum Parameter |
| 65 | * |
| 66 | * SOL parameters are volatile, they are initialized by the SOL manager. |
| 67 | * They can be read using Get SOL configuration parameters command and updated |
| 68 | * using Set SOL configuration parameters command. |
| 69 | */ |
| 70 | enum class Parameter |
| 71 | { |
| 72 | PROGRESS, //!< Set In Progress. |
| 73 | ENABLE, //!< SOL Enable. |
| 74 | AUTHENTICATION, //!< SOL Authentication. |
| 75 | ACCUMULATE, //!< Character Accumulate Interval & Send Threshold. |
| 76 | RETRY, //!< SOL Retry. |
| 77 | NVBITRATE, //!< SOL non-volatile bit rate. |
| 78 | VBITRATE, //!< SOL volatile bit rate. |
| 79 | CHANNEL, //!< SOL payload channel. |
| 80 | PORT, //!< SOL payload port. |
| 81 | }; |
| 82 | |
| 83 | constexpr uint8_t progressMask = 0x03; |
| 84 | constexpr uint8_t enableMask = 0x01; |
| 85 | |
| 86 | /** @struct Auth |
| 87 | * |
| 88 | * SOL authentication parameter. |
| 89 | */ |
| 90 | struct Auth |
| 91 | { |
| 92 | #if BYTE_ORDER == LITTLE_ENDIAN |
| 93 | uint8_t privilege : 4; //!< SOL privilege level. |
| 94 | uint8_t reserved : 2; //!< Reserved. |
| 95 | uint8_t auth : 1; //!< Force SOL payload Authentication. |
| 96 | uint8_t encrypt : 1; //!< Force SOL payload encryption. |
| 97 | #endif |
| 98 | |
| 99 | #if BYTE_ORDER == BIG_ENDIAN |
| 100 | uint8_t encrypt : 1; //!< Force SOL payload encryption. |
| 101 | uint8_t auth : 1; //!< Force SOL payload Authentication. |
| 102 | uint8_t reserved : 2; //!< Reserved. |
| 103 | uint8_t privilege : 4; //!< SOL privilege level. |
| 104 | #endif |
| 105 | } __attribute__((packed)); |
| 106 | |
| 107 | /** @struct Accumulate |
| 108 | * |
| 109 | * Character accumulate interval & Character send threshold. |
| 110 | */ |
| 111 | struct Accumulate |
| 112 | { |
| 113 | uint8_t interval; //!< Character accumulate interval. |
| 114 | uint8_t threshold; //!< Character send threshold. |
| 115 | } __attribute__((packed)); |
| 116 | |
| 117 | constexpr uint8_t retryCountMask = 0x07; |
| 118 | |
| 119 | /** @struct Retry |
| 120 | * |
| 121 | * SOL retry count and interval. |
| 122 | */ |
| 123 | struct Retry |
| 124 | { |
| 125 | #if BYTE_ORDER == LITTLE_ENDIAN |
| 126 | uint8_t count : 3; //!< SOL retry count. |
| 127 | uint8_t reserved : 5; //!< Reserved. |
| 128 | #endif |
| 129 | |
| 130 | #if BYTE_ORDER == BIG_ENDIAN |
| 131 | uint8_t reserved : 5; //!< Reserved. |
| 132 | uint8_t count : 3; //!< SOL retry count. |
| 133 | #endif |
| 134 | |
| 135 | uint8_t interval; //!< SOL retry interval. |
| 136 | } __attribute__((packed)); |
| 137 | |
| 138 | constexpr uint8_t ipmiCCParamNotSupported = 0x80; |
| 139 | constexpr uint8_t ipmiCCInvalidSetInProgress = 0x81; |
| 140 | constexpr uint8_t ipmiCCWriteReadParameter = 0x82; |
| 141 | constexpr uint8_t ipmiCCReadWriteParameter = 0x83; |
| 142 | constexpr uint8_t parameterRevision = 0x11; |
| 143 | |
| 144 | /** @struct SetConfParamsRequest |
| 145 | * |
| 146 | * IPMI payload for Set SOL configuration parameters command request. |
| 147 | */ |
| 148 | struct SetConfParamsRequest |
| 149 | { |
| 150 | #if BYTE_ORDER == LITTLE_ENDIAN |
| 151 | uint8_t channelNumber : 4; //!< Channel number. |
| 152 | uint8_t reserved : 4; //!< Reserved. |
| 153 | #endif |
| 154 | |
| 155 | #if BYTE_ORDER == BIG_ENDIAN |
| 156 | uint8_t reserved : 4; //!< Reserved. |
| 157 | uint8_t channelNumber : 4; //!< Channel number. |
| 158 | #endif |
| 159 | |
| 160 | uint8_t paramSelector; //!< Parameter selector. |
| 161 | union |
| 162 | { |
| 163 | uint8_t value; //!< Represents one byte SOL parameters. |
| 164 | struct Accumulate acc; //!< Character accumulate values. |
| 165 | struct Retry retry; //!< Retry values. |
| 166 | struct Auth auth; //!< Authentication parameters. |
| 167 | }; |
| 168 | } __attribute__((packed)); |
| 169 | |
| 170 | /** @struct SetConfParamsResponse |
| 171 | * |
| 172 | * IPMI payload for Set SOL configuration parameters command response. |
| 173 | */ |
| 174 | struct SetConfParamsResponse |
| 175 | { |
| 176 | uint8_t completionCode; //!< Completion code. |
| 177 | } __attribute__((packed)); |
| 178 | |
| 179 | /** @brief Set SOL configuration parameters command. |
| 180 | * |
| 181 | * @param[in] inPayload - Request data for the command. |
| 182 | * @param[in] handler - Reference to the message handler. |
| 183 | * |
| 184 | * @return Response data for the command. |
| 185 | */ |
| 186 | std::vector<uint8_t> setConfParams(const std::vector<uint8_t>& inPayload, |
| 187 | const message::Handler& handler); |
| 188 | |
Tom Joseph | 20aef33 | 2017-04-28 01:34:10 +0530 | [diff] [blame] | 189 | /** @struct GetConfParamsRequest |
| 190 | * |
| 191 | * IPMI payload for Get SOL configuration parameters command request. |
| 192 | */ |
| 193 | struct GetConfParamsRequest |
| 194 | { |
| 195 | #if BYTE_ORDER == LITTLE_ENDIAN |
| 196 | uint8_t channelNum : 4; //!< Channel number. |
| 197 | uint8_t reserved : 3; //!< Reserved. |
| 198 | uint8_t getParamRev : 1; //!< Get parameter or Get parameter revision |
| 199 | #endif |
| 200 | |
| 201 | #if BYTE_ORDER == BIG_ENDIAN |
| 202 | uint8_t getParamRev : 1; //!< Get parameter or Get parameter revision |
| 203 | uint8_t reserved : 3; //!< Reserved. |
| 204 | uint8_t channelNum : 4; //!< Channel number. |
| 205 | #endif |
| 206 | |
| 207 | uint8_t paramSelector; //!< Parameter selector. |
| 208 | uint8_t setSelector; //!< Set selector. |
| 209 | uint8_t blockSelector; //!< Block selector. |
| 210 | } __attribute__((packed)); |
| 211 | |
| 212 | /** @struct GetConfParamsResponse |
| 213 | * |
| 214 | * IPMI payload for Get SOL configuration parameters command response. |
| 215 | */ |
| 216 | struct GetConfParamsResponse |
| 217 | { |
| 218 | uint8_t completionCode; //!< Completion code. |
| 219 | uint8_t paramRev; //!< Parameter revision. |
| 220 | } __attribute__((packed)); |
| 221 | |
| 222 | /** @brief Get SOL configuration parameters command. |
| 223 | * |
| 224 | * @param[in] inPayload - Request data for the command. |
| 225 | * @param[in] handler - Reference to the message handler. |
| 226 | * |
| 227 | * @return Response data for the command. |
| 228 | */ |
| 229 | std::vector<uint8_t> getConfParams(const std::vector<uint8_t>& inPayload, |
| 230 | const message::Handler& handler); |
| 231 | |
Tom Joseph | 64b3dec | 2017-04-03 01:53:44 +0530 | [diff] [blame] | 232 | } // namespace command |
| 233 | |
| 234 | } // namespace sol |