summaryrefslogtreecommitdiffstats
path: root/command/session_cmds.hpp
blob: 9737fdb4c989774ac66db828f1ecafc54ff06263 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#pragma once

#include "message_handler.hpp"

#include <vector>

namespace command
{

constexpr uint8_t IPMI_CC_INVALID_PRIV_LEVEL = 0x80;
constexpr uint8_t IPMI_CC_EXCEEDS_USER_PRIV = 0x81;

/**
 * @struct SetSessionPrivLevelReq
 *
 * IPMI Request data for Set Session Privilege Level command
 */
struct SetSessionPrivLevelReq
{

#if BYTE_ORDER == LITTLE_ENDIAN
    uint8_t reqPrivLevel : 4;
    uint8_t reserved : 4;
#endif

#if BYTE_ORDER == BIG_ENDIAN
    uint8_t reserved : 4;
    uint8_t reqPrivLevel : 4;
#endif

} __attribute__((packed));

/**
 * @struct SetSessionPrivLevelResp
 *
 * IPMI Response data for Set Session Privilege Level command
 */
struct SetSessionPrivLevelResp
{
    uint8_t completionCode;

#if BYTE_ORDER == LITTLE_ENDIAN
    uint8_t newPrivLevel : 4;
    uint8_t reserved : 4;
#endif

#if BYTE_ORDER == BIG_ENDIAN
    uint8_t reserved : 4;
    uint8_t newPrivLevel : 4;
#endif

} __attribute__((packed));

/**
 * @brief Set Session Privilege Command
 *
 * This command is sent in authenticated format. When a session is activated,
 * the session is set to an initial privilege level. A session that is
 * activated at a maximum privilege level of Callback is set to an initial
 * privilege level of Callback and cannot be changed. All other sessions are
 * initially set to USER level, regardless of the maximum privilege level
 * requested in the RAKP Message 1.
 *
 * This command cannot be used to set a privilege level higher than the lowest
 * of the privilege level set for the user(via the Set User Access command) and
 * the privilege limit for the channel that was set via the Set Channel Access
 * command.
 *
 * @param[in] inPayload - Request Data for the command
 * @param[in] handler - Reference to the Message Handler
 *
 * @return Response data for the command
 */
std::vector<uint8_t>
    setSessionPrivilegeLevel(const std::vector<uint8_t>& inPayload,
                             const message::Handler& handler);

constexpr uint8_t IPMI_CC_INVALID_SESSIONID = 0x87;

/**
 * @struct CloseSessionRequest
 *
 * IPMI Request data for Close Session command
 */
struct CloseSessionRequest
{
    uint32_t sessionID;
    uint8_t sessionHandle;
} __attribute__((packed));

/**
 * @struct CloseSessionResponse
 *
 * IPMI Response data for Close Session command
 */
struct CloseSessionResponse
{
    uint8_t completionCode;
} __attribute__((packed));

/**
 * @brief Close Session Command
 *
 * This command is used to immediately terminate a session in progress. It is
 * typically used to close the session that the user is communicating over,
 * though it can be used to other terminate sessions in progress (provided that
 * the user is operating at the appropriate privilege level, or the command is
 * executed over a local channel - e.g. the system interface). Closing
 * sessionless session ( session zero) is restricted in this command
 *
 * @param[in] inPayload - Request Data for the command
 * @param[in] handler - Reference to the Message Handler
 *
 * @return Response data for the command
 */
std::vector<uint8_t> closeSession(const std::vector<uint8_t>& inPayload,
                                  const message::Handler& handler);

} // namespace command
OpenPOWER on IntegriCloud