Refactor to use new version of OEM IPMI Handler
Using the new version of ipmi handler provide a higher level wrapper
over the same functionalities. It helps us parse the input and output to
have more control of the input/output we see.
Changes to note,
- All cmd are removed from the request data. That is automatically
extracted now.
Tested:
Unit Test Passed.
All IPMI OEM command still works the same as before this change.
```
$ burn_my_bmc -command stage -image /tmp/test.txt -interface ipmipci
Set up ipmi flash updater with /flash/dummy
Received failure on delete: Received IPMI_CC: 255
Sending over the firmware image.
Find [0x1050 0x750]
bar0[0x94000000]
Upload to BMC 100% |Goooooooooooooooooooooooooooooooooooooooooooooooooooooooogle| Time: 00:00:00
Opening the verification file
Committing to /flash/verify to trigger service
Calling stat on /flash/verify session to check status
success
succeeded
```
Also tested gBMC Update workflow which worked fine.
Change-Id: Ib2bfeab0c2ec5aa72ede1ff457ef5f90e488053c
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/process.hpp b/process.hpp
index da0031c..6b89413 100644
--- a/process.hpp
+++ b/process.hpp
@@ -1,30 +1,30 @@
#pragma once
+#include "ipmi.hpp"
#include "manager.hpp"
#include <ipmid/api.h>
#include <functional>
+#include <ipmid/api-types.hpp>
+#include <span>
+#include <utility>
+#include <vector>
namespace blobs
{
using IpmiBlobHandler =
- std::function<ipmi_ret_t(ManagerInterface* mgr, const uint8_t* reqBuf,
- uint8_t* replyCmdBuf, size_t* dataLen)>;
+ std::function<Resp(ManagerInterface* mgr, std::span<const uint8_t> data)>;
/**
* Validate the IPMI request and determine routing.
*
- * @param[in] reqBuf - a pointer to the ipmi request packet buffer.
- * @param[in,out] replyCmdBuf - a pointer to the ipmi reply packet buffer.
- * @param[in,out] dataLen - initially the request length, set to reply length
- * on return.
- * @param[out] code - set to the IPMI error on failure, otherwise unset.
- * @return the ipmi command handler, or nullptr on failure.
+ * @param[in] cmd Requested command
+ * @param[in] data Requested data
+ * @return the ipmi command handler, or nullopt on failure.
*/
-IpmiBlobHandler validateBlobCommand(const uint8_t* reqBuf, uint8_t* replyCmdBuf,
- size_t* dataLen, ipmi_ret_t* code);
+IpmiBlobHandler validateBlobCommand(uint8_t cmd, std::span<const uint8_t> data);
/**
* Call the IPMI command and process the result, including running the CRC
@@ -32,20 +32,16 @@
*
* @param[in] cmd - a funtion pointer to the ipmi command to process.
* @param[in] mgr - a pointer to the manager interface.
- * @param[in] reqBuf - a pointer to the ipmi request packet buffer.
- * @param[in,out] replyCmdBuf - a pointer to the ipmi reply packet buffer.
- * @param[in,out] dataLen - initially the request length, set to reply length
- * on return.
+ * @param[in] data - Requested data.
+ * @param[in,out] maxSize - Maximum ipmi reply size
* @return the ipmi command result.
*/
-ipmi_ret_t processBlobCommand(IpmiBlobHandler cmd, ManagerInterface* mgr,
- const uint8_t* reqBuf, uint8_t* replyCmdBuf,
- size_t* dataLen);
+Resp processBlobCommand(IpmiBlobHandler cmd, ManagerInterface* mgr,
+ std::span<const uint8_t> data);
/**
* Given an IPMI command, request buffer, and reply buffer, validate the request
* and call processBlobCommand.
*/
-ipmi_ret_t handleBlobCommand(ipmi_cmd_t cmd, const uint8_t* reqBuf,
- uint8_t* replyCmdBuf, size_t* dataLen);
+Resp handleBlobCommand(uint8_t cmd, std::vector<uint8_t> data);
} // namespace blobs