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