-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathipmi.hpp
205 lines (169 loc) · 4.53 KB
/
ipmi.hpp
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#pragma once
#include "manager.hpp"
#include <ipmid/api.h>
#include <blobs-ipmid/blobs.hpp>
#include <ipmid/api-types.hpp>
#include <span>
#include <string>
#include <vector>
namespace blobs
{
using Resp = ipmi::RspType<std::vector<uint8_t>>;
/* Used by bmcBlobGetCount */
struct BmcBlobCountTx
{
} __attribute__((packed));
struct BmcBlobCountRx
{
uint16_t crc;
uint32_t blobCount;
} __attribute__((packed));
/* Used by bmcBlobEnumerate */
struct BmcBlobEnumerateTx
{
uint16_t crc;
uint32_t blobIdx;
} __attribute__((packed));
struct BmcBlobEnumerateRx
{
uint16_t crc;
} __attribute__((packed));
/* Used by bmcBlobOpen */
struct BmcBlobOpenTx
{
uint16_t crc;
uint16_t flags;
} __attribute__((packed));
struct BmcBlobOpenRx
{
uint16_t crc;
uint16_t sessionId;
} __attribute__((packed));
/* Used by bmcBlobClose */
struct BmcBlobCloseTx
{
uint16_t crc;
uint16_t sessionId; /* Returned from BmcBlobOpen. */
} __attribute__((packed));
/* Used by bmcBlobDelete */
struct BmcBlobDeleteTx
{
uint16_t crc;
} __attribute__((packed));
/* Used by bmcBlobStat */
struct BmcBlobStatTx
{
uint16_t crc;
} __attribute__((packed));
struct BmcBlobStatRx
{
uint16_t crc;
uint16_t blobState;
uint32_t size; /* Size in bytes of the blob. */
uint8_t metadataLen;
} __attribute__((packed));
/* Used by bmcBlobSessionStat */
struct BmcBlobSessionStatTx
{
uint16_t crc;
uint16_t sessionId;
} __attribute__((packed));
/* Used by bmcBlobCommit */
struct BmcBlobCommitTx
{
uint16_t crc;
uint16_t sessionId;
uint8_t commitDataLen;
} __attribute__((packed));
/* Used by bmcBlobRead */
struct BmcBlobReadTx
{
uint16_t crc;
uint16_t sessionId;
uint32_t offset; /* The byte sequence start, 0-based. */
uint32_t requestedSize; /* The number of bytes requested for reading. */
} __attribute__((packed));
struct BmcBlobReadRx
{
uint16_t crc;
} __attribute__((packed));
/* Used by bmcBlobWrite */
struct BmcBlobWriteTx
{
uint16_t crc;
uint16_t sessionId;
uint32_t offset; /* The byte sequence start, 0-based. */
} __attribute__((packed));
/* Used by bmcBlobWriteMeta */
struct BmcBlobWriteMetaTx
{
uint16_t crc;
uint16_t sessionId; /* Returned from BmcBlobOpen. */
uint32_t offset; /* The byte sequence start, 0-based. */
} __attribute__((packed));
/**
* Validate the minimum request length if there is one.
*
* @param[in] subcommand - the command
* @param[in] requestLength - the length of the request
* @return bool - true if valid.
*/
bool validateRequestLength(BlobOEMCommands command, size_t requestLen);
/**
* Given a pointer into an IPMI request buffer and the length of the remaining
* buffer, builds a string. This does no string validation w.r.t content.
*
* @param[in] data - Buffer containing the string.
* @return the string if valid otherwise an empty string.
*/
std::string stringFromBuffer(std::span<const uint8_t> data);
/**
* Writes out a BmcBlobCountRx structure and returns IPMI_OK.
*/
Resp getBlobCount(ManagerInterface* mgr, std::span<const uint8_t> data);
/**
* Writes out a BmcBlobEnumerateRx in response to a BmcBlobEnumerateTx
* request. If the index does not correspond to a blob, then this will
* return failure.
*
* It will also return failure if the response buffer is of an invalid
* length.
*/
Resp enumerateBlob(ManagerInterface* mgr, std::span<const uint8_t> data);
/**
* Attempts to open the blobId specified and associate with a session id.
*/
Resp openBlob(ManagerInterface* mgr, std::span<const uint8_t> data);
/**
* Attempts to close the session specified.
*/
Resp closeBlob(ManagerInterface* mgr, std::span<const uint8_t> data);
/**
* Attempts to delete the blobId specified.
*/
Resp deleteBlob(ManagerInterface* mgr, std::span<const uint8_t> data);
/**
* Attempts to retrieve the Stat for the blobId specified.
*/
Resp statBlob(ManagerInterface* mgr, std::span<const uint8_t> data);
/**
* Attempts to retrieve the Stat for the session specified.
*/
Resp sessionStatBlob(ManagerInterface* mgr, std::span<const uint8_t> data);
/**
* Attempts to commit the data in the blob.
*/
Resp commitBlob(ManagerInterface* mgr, std::span<const uint8_t> data);
/**
* Attempt to read data from the blob.
*/
Resp readBlob(ManagerInterface* mgr, std::span<const uint8_t> data);
/**
* Attempt to write data to the blob.
*/
Resp writeBlob(ManagerInterface* mgr, std::span<const uint8_t> data);
/**
* Attempt to write metadata to the blob.
*/
Resp writeMeta(ManagerInterface* mgr, std::span<const uint8_t> data);
} // namespace blobs