From 8865e40b6e54384fc3c9911d15d6261b414a3d91 Mon Sep 17 00:00:00 2001 From: Patrick Venture Date: Tue, 14 May 2019 13:29:10 -0700 Subject: blob: implement commit command Implement the commit command for the blob handler. Change-Id: Ia3be86083991cbdf7fe85c15986f4e1cb60971f5 Signed-off-by: Patrick Venture --- src/ipmiblob/blob_handler.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/ipmiblob/blob_handler.cpp') 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& bytes) +{ + std::vector request; + auto addrSession = reinterpret_cast(&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::max()) + { + throw BlobException("Commit data length greater than 8-bit limit\n"); + } + + std::uint8_t length = static_cast(bytes.size()); + auto addrLength = reinterpret_cast(&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& bytes) -- cgit v1.2.3