summaryrefslogtreecommitdiffstats
path: root/src/ipmiblob/blob_handler.cpp
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2019-05-14 13:29:10 -0700
committerPatrick Venture <venture@google.com>2019-05-14 13:42:05 -0700
commit8865e40b6e54384fc3c9911d15d6261b414a3d91 (patch)
treeb82fb451998bcf64f547431088494414e3bd58cd /src/ipmiblob/blob_handler.cpp
parent22fcc84469975fe5ca3597f78fe8103e8a8bbc52 (diff)
downloadipmi-blob-tool-8865e40b6e54384fc3c9911d15d6261b414a3d91.tar.gz
ipmi-blob-tool-8865e40b6e54384fc3c9911d15d6261b414a3d91.zip
blob: implement commit command
Implement the commit command for the blob handler. Change-Id: Ia3be86083991cbdf7fe85c15986f4e1cb60971f5 Signed-off-by: Patrick Venture <venture@google.com>
Diffstat (limited to 'src/ipmiblob/blob_handler.cpp')
-rw-r--r--src/ipmiblob/blob_handler.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/ipmiblob/blob_handler.cpp b/src/ipmiblob/blob_handler.cpp
index 77fcb6c..e5b78e1 100644
--- a/src/ipmiblob/blob_handler.cpp
+++ b/src/ipmiblob/blob_handler.cpp
@@ -162,6 +162,30 @@ std::string BlobHandler::enumerateBlob(std::uint32_t index)
}
}
+void BlobHandler::commit(std::uint16_t session,
+ const std::vector<std::uint8_t>& bytes)
+{
+ std::vector<std::uint8_t> request;
+ auto addrSession = reinterpret_cast<const std::uint8_t*>(&session);
+ std::copy(addrSession, addrSession + sizeof(session),
+ std::back_inserter(request));
+
+ /* You have one byte to describe the length. */
+ if (bytes.size() > std::numeric_limits<std::uint8_t>::max())
+ {
+ throw BlobException("Commit data length greater than 8-bit limit\n");
+ }
+
+ std::uint8_t length = static_cast<std::uint8_t>(bytes.size());
+ auto addrLength = reinterpret_cast<const std::uint8_t*>(&length);
+ std::copy(addrLength, addrLength + sizeof(length),
+ std::back_inserter(request));
+
+ std::copy(bytes.begin(), bytes.end(), std::back_inserter(request));
+
+ sendIpmiPayload(BlobOEMCommands::bmcBlobCommit, request);
+}
+
void BlobHandler::writeGeneric(BlobOEMCommands command, std::uint16_t session,
std::uint32_t offset,
const std::vector<std::uint8_t>& bytes)
OpenPOWER on IntegriCloud