summaryrefslogtreecommitdiffstats
path: root/process.cpp
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2019-03-07 12:48:32 -0800
committerPatrick Venture <venture@google.com>2019-03-08 13:10:01 -0800
commitde8a16e2e85f49e142461b7e6fe901d3f8740fdf (patch)
tree065055f299e232874190c8e921d7960b9f434cd4 /process.cpp
parentb15d654ed1f6804fb2e82a5cfe97eaf35b83529e (diff)
downloadphosphor-ipmi-blobs-de8a16e2e85f49e142461b7e6fe901d3f8740fdf.tar.gz
phosphor-ipmi-blobs-de8a16e2e85f49e142461b7e6fe901d3f8740fdf.zip
use ipmiblob library from ipmi-blob-tool
Drop all code that is now handled by the ipmiblob library provided by the new ipmi-blob-tool. This is a library that can be included on the BMC if necessary, but relies on nothing that is strictly meant for the BMC. Change-Id: I2b02ae0d432e84c08e598d27eef85b57c06a70fc Signed-off-by: Patrick Venture <venture@google.com>
Diffstat (limited to 'process.cpp')
-rw-r--r--process.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/process.cpp b/process.cpp
index a73f70e..661f59d 100644
--- a/process.cpp
+++ b/process.cpp
@@ -19,6 +19,7 @@
#include "ipmi.hpp"
#include <cstring>
+#include <ipmiblob/crc.hpp>
#include <unordered_map>
#include <vector>
@@ -47,9 +48,8 @@ static const std::unordered_map<BlobOEMCommands, IpmiBlobHandler> handlers = {
{BlobOEMCommands::bmcBlobWriteMeta, writeMeta},
};
-IpmiBlobHandler validateBlobCommand(CrcInterface* crc, const uint8_t* reqBuf,
- uint8_t* replyCmdBuf, size_t* dataLen,
- ipmi_ret_t* code)
+IpmiBlobHandler validateBlobCommand(const uint8_t* reqBuf, uint8_t* replyCmdBuf,
+ size_t* dataLen, ipmi_ret_t* code)
{
size_t requestLength = (*dataLen);
/* We know dataLen is at least 1 already */
@@ -88,11 +88,8 @@ IpmiBlobHandler validateBlobCommand(CrcInterface* crc, const uint8_t* reqBuf,
/* Set the in-place CRC to zero. */
std::memcpy(bytes.data(), &reqBuf[3], requestBodyLen);
- crc->clear();
- crc->compute(bytes.data(), bytes.size());
-
/* Crc expected but didn't match. */
- if (crcValue != crc->get())
+ if (crcValue != ipmiblob::generateCrc(bytes))
{
*code = IPMI_CC_UNSPECIFIED_ERROR;
return nullptr;
@@ -111,8 +108,8 @@ IpmiBlobHandler validateBlobCommand(CrcInterface* crc, const uint8_t* reqBuf,
}
ipmi_ret_t processBlobCommand(IpmiBlobHandler cmd, ManagerInterface* mgr,
- CrcInterface* crc, const uint8_t* reqBuf,
- uint8_t* replyCmdBuf, size_t* dataLen)
+ const uint8_t* reqBuf, uint8_t* replyCmdBuf,
+ size_t* dataLen)
{
ipmi_ret_t result = cmd(mgr, reqBuf, replyCmdBuf, dataLen);
if (result != IPMI_CC_OK)
@@ -137,12 +134,10 @@ ipmi_ret_t processBlobCommand(IpmiBlobHandler cmd, ManagerInterface* mgr,
}
/* The command, whatever it was, replied, so let's set the CRC. */
- crc->clear();
- crc->compute(replyCmdBuf + sizeof(uint16_t),
- replyLength - sizeof(uint16_t));
-
+ std::vector<std::uint8_t> crcBuffer(replyCmdBuf + sizeof(uint16_t),
+ replyCmdBuf + replyLength);
/* Copy the CRC into place. */
- uint16_t crcValue = crc->get();
+ uint16_t crcValue = ipmiblob::generateCrc(crcBuffer);
std::memcpy(replyCmdBuf, &crcValue, sizeof(crcValue));
return result;
OpenPOWER on IntegriCloud