blob: 9737fdb4c989774ac66db828f1ecafc54ff06263 [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;
12
Tom Joseph3563f8f2017-05-08 15:42:54 +053013/**
14 * @struct SetSessionPrivLevelReq
Tom Joseph9662c3a2016-12-06 17:52:16 +053015 *
16 * IPMI Request data for Set Session Privilege Level command
17 */
18struct SetSessionPrivLevelReq
19{
20
21#if BYTE_ORDER == LITTLE_ENDIAN
22 uint8_t reqPrivLevel : 4;
23 uint8_t reserved : 4;
24#endif
25
26#if BYTE_ORDER == BIG_ENDIAN
27 uint8_t reserved : 4;
28 uint8_t reqPrivLevel : 4;
29#endif
30
31} __attribute__((packed));
32
Tom Joseph3563f8f2017-05-08 15:42:54 +053033/**
34 * @struct SetSessionPrivLevelResp
Tom Joseph9662c3a2016-12-06 17:52:16 +053035 *
36 * IPMI Response data for Set Session Privilege Level command
37 */
38struct SetSessionPrivLevelResp
39{
40 uint8_t completionCode;
41
42#if BYTE_ORDER == LITTLE_ENDIAN
43 uint8_t newPrivLevel : 4;
44 uint8_t reserved : 4;
45#endif
46
47#if BYTE_ORDER == BIG_ENDIAN
48 uint8_t reserved : 4;
49 uint8_t newPrivLevel : 4;
50#endif
51
52} __attribute__((packed));
53
Tom Joseph3563f8f2017-05-08 15:42:54 +053054/**
Tom Joseph9662c3a2016-12-06 17:52:16 +053055 * @brief Set Session Privilege Command
56 *
57 * This command is sent in authenticated format. When a session is activated,
58 * the session is set to an initial privilege level. A session that is
59 * activated at a maximum privilege level of Callback is set to an initial
60 * privilege level of Callback and cannot be changed. All other sessions are
61 * initially set to USER level, regardless of the maximum privilege level
62 * requested in the RAKP Message 1.
63 *
64 * This command cannot be used to set a privilege level higher than the lowest
65 * of the privilege level set for the user(via the Set User Access command) and
66 * the privilege limit for the channel that was set via the Set Channel Access
67 * command.
68 *
69 * @param[in] inPayload - Request Data for the command
70 * @param[in] handler - Reference to the Message Handler
71 *
72 * @return Response data for the command
73 */
Vernon Mauery9e801a22018-10-12 13:20:49 -070074std::vector<uint8_t>
75 setSessionPrivilegeLevel(const std::vector<uint8_t>& inPayload,
76 const message::Handler& handler);
Tom Joseph9662c3a2016-12-06 17:52:16 +053077
78constexpr uint8_t IPMI_CC_INVALID_SESSIONID = 0x87;
79
Tom Joseph3563f8f2017-05-08 15:42:54 +053080/**
81 * @struct CloseSessionRequest
Tom Joseph9662c3a2016-12-06 17:52:16 +053082 *
83 * IPMI Request data for Close Session command
84 */
85struct CloseSessionRequest
86{
87 uint32_t sessionID;
88 uint8_t sessionHandle;
89} __attribute__((packed));
90
Tom Joseph3563f8f2017-05-08 15:42:54 +053091/**
92 * @struct CloseSessionResponse
Tom Joseph9662c3a2016-12-06 17:52:16 +053093 *
94 * IPMI Response data for Close Session command
95 */
96struct CloseSessionResponse
97{
98 uint8_t completionCode;
99} __attribute__((packed));
100
Tom Joseph3563f8f2017-05-08 15:42:54 +0530101/**
Tom Joseph9662c3a2016-12-06 17:52:16 +0530102 * @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 Joseph18a45e92017-04-11 11:30:44 +0530116std::vector<uint8_t> closeSession(const std::vector<uint8_t>& inPayload,
Tom Joseph9662c3a2016-12-06 17:52:16 +0530117 const message::Handler& handler);
118
119} // namespace command