Tom Joseph | 9662c3a | 2016-12-06 17:52:16 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Tom Joseph | 9662c3a | 2016-12-06 17:52:16 +0530 | [diff] [blame] | 3 | #include "message_handler.hpp" |
| 4 | |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 5 | #include <vector> |
| 6 | |
Tom Joseph | 9662c3a | 2016-12-06 17:52:16 +0530 | [diff] [blame] | 7 | namespace command |
| 8 | { |
| 9 | |
| 10 | constexpr uint8_t IPMI_CC_INVALID_PRIV_LEVEL = 0x80; |
| 11 | constexpr uint8_t IPMI_CC_EXCEEDS_USER_PRIV = 0x81; |
Rajashekar Gade Reddy | dafe364 | 2019-07-12 17:35:06 +0000 | [diff] [blame] | 12 | // bits 30 & 31 (MSB) hold the instanceID, hence shifting by 30 bits |
| 13 | constexpr uint8_t myNetInstanceSessionIdShiftMask = 30; |
| 14 | // bits 6 & 7 (MSB) hold the instanceID, hence shifting by 6 bits |
| 15 | constexpr uint8_t myNetInstanceSessionHandleShiftMask = 6; |
Tom Joseph | 9662c3a | 2016-12-06 17:52:16 +0530 | [diff] [blame] | 16 | |
Tom Joseph | 3563f8f | 2017-05-08 15:42:54 +0530 | [diff] [blame] | 17 | /** |
| 18 | * @struct SetSessionPrivLevelReq |
Tom Joseph | 9662c3a | 2016-12-06 17:52:16 +0530 | [diff] [blame] | 19 | * |
| 20 | * IPMI Request data for Set Session Privilege Level command |
| 21 | */ |
| 22 | struct SetSessionPrivLevelReq |
| 23 | { |
Tom Joseph | 9662c3a | 2016-12-06 17:52:16 +0530 | [diff] [blame] | 24 | #if BYTE_ORDER == LITTLE_ENDIAN |
| 25 | uint8_t reqPrivLevel : 4; |
| 26 | uint8_t reserved : 4; |
| 27 | #endif |
| 28 | |
| 29 | #if BYTE_ORDER == BIG_ENDIAN |
| 30 | uint8_t reserved : 4; |
| 31 | uint8_t reqPrivLevel : 4; |
| 32 | #endif |
| 33 | |
| 34 | } __attribute__((packed)); |
| 35 | |
Tom Joseph | 3563f8f | 2017-05-08 15:42:54 +0530 | [diff] [blame] | 36 | /** |
| 37 | * @struct SetSessionPrivLevelResp |
Tom Joseph | 9662c3a | 2016-12-06 17:52:16 +0530 | [diff] [blame] | 38 | * |
| 39 | * IPMI Response data for Set Session Privilege Level command |
| 40 | */ |
| 41 | struct SetSessionPrivLevelResp |
| 42 | { |
| 43 | uint8_t completionCode; |
| 44 | |
| 45 | #if BYTE_ORDER == LITTLE_ENDIAN |
| 46 | uint8_t newPrivLevel : 4; |
| 47 | uint8_t reserved : 4; |
| 48 | #endif |
| 49 | |
| 50 | #if BYTE_ORDER == BIG_ENDIAN |
| 51 | uint8_t reserved : 4; |
| 52 | uint8_t newPrivLevel : 4; |
| 53 | #endif |
| 54 | |
| 55 | } __attribute__((packed)); |
| 56 | |
Tom Joseph | 3563f8f | 2017-05-08 15:42:54 +0530 | [diff] [blame] | 57 | /** |
Tom Joseph | 9662c3a | 2016-12-06 17:52:16 +0530 | [diff] [blame] | 58 | * @brief Set Session Privilege Command |
| 59 | * |
| 60 | * This command is sent in authenticated format. When a session is activated, |
| 61 | * the session is set to an initial privilege level. A session that is |
| 62 | * activated at a maximum privilege level of Callback is set to an initial |
| 63 | * privilege level of Callback and cannot be changed. All other sessions are |
| 64 | * initially set to USER level, regardless of the maximum privilege level |
| 65 | * requested in the RAKP Message 1. |
| 66 | * |
| 67 | * This command cannot be used to set a privilege level higher than the lowest |
| 68 | * of the privilege level set for the user(via the Set User Access command) and |
| 69 | * the privilege limit for the channel that was set via the Set Channel Access |
| 70 | * command. |
| 71 | * |
| 72 | * @param[in] inPayload - Request Data for the command |
| 73 | * @param[in] handler - Reference to the Message Handler |
| 74 | * |
| 75 | * @return Response data for the command |
| 76 | */ |
Vernon Mauery | 9e801a2 | 2018-10-12 13:20:49 -0700 | [diff] [blame] | 77 | std::vector<uint8_t> |
| 78 | setSessionPrivilegeLevel(const std::vector<uint8_t>& inPayload, |
Vernon Mauery | 41ff9b5 | 2021-06-11 11:37:40 -0700 | [diff] [blame] | 79 | std::shared_ptr<message::Handler>& handler); |
Tom Joseph | 3563f8f | 2017-05-08 15:42:54 +0530 | [diff] [blame] | 80 | /** |
| 81 | * @struct CloseSessionRequest |
Tom Joseph | 9662c3a | 2016-12-06 17:52:16 +0530 | [diff] [blame] | 82 | * |
| 83 | * IPMI Request data for Close Session command |
| 84 | */ |
| 85 | struct CloseSessionRequest |
| 86 | { |
| 87 | uint32_t sessionID; |
| 88 | uint8_t sessionHandle; |
| 89 | } __attribute__((packed)); |
| 90 | |
Tom Joseph | 3563f8f | 2017-05-08 15:42:54 +0530 | [diff] [blame] | 91 | /** |
| 92 | * @struct CloseSessionResponse |
Tom Joseph | 9662c3a | 2016-12-06 17:52:16 +0530 | [diff] [blame] | 93 | * |
| 94 | * IPMI Response data for Close Session command |
| 95 | */ |
| 96 | struct CloseSessionResponse |
| 97 | { |
| 98 | uint8_t completionCode; |
| 99 | } __attribute__((packed)); |
| 100 | |
Tom Joseph | 3563f8f | 2017-05-08 15:42:54 +0530 | [diff] [blame] | 101 | /** |
Tom Joseph | 9662c3a | 2016-12-06 17:52:16 +0530 | [diff] [blame] | 102 | * @brief Close Session Command |
| 103 | * |
| 104 | * This command is used to immediately terminate a session in progress. It is |
| 105 | * typically used to close the session that the user is communicating over, |
| 106 | * though it can be used to other terminate sessions in progress (provided that |
| 107 | * the user is operating at the appropriate privilege level, or the command is |
| 108 | * executed over a local channel - e.g. the system interface). Closing |
| 109 | * sessionless session ( session zero) is restricted in this command |
| 110 | * |
| 111 | * @param[in] inPayload - Request Data for the command |
| 112 | * @param[in] handler - Reference to the Message Handler |
| 113 | * |
| 114 | * @return Response data for the command |
| 115 | */ |
Tom Joseph | 18a45e9 | 2017-04-11 11:30:44 +0530 | [diff] [blame] | 116 | std::vector<uint8_t> closeSession(const std::vector<uint8_t>& inPayload, |
Vernon Mauery | 41ff9b5 | 2021-06-11 11:37:40 -0700 | [diff] [blame] | 117 | std::shared_ptr<message::Handler>& handler); |
Tom Joseph | 9662c3a | 2016-12-06 17:52:16 +0530 | [diff] [blame] | 118 | |
| 119 | } // namespace command |