1 #pragma once 2 3 #include "crc.hpp" 4 5 #include <host-ipmid/ipmid-api.h> 6 7 #include <blobs-ipmid/manager.hpp> 8 #include <functional> 9 10 namespace blobs 11 { 12 13 using IpmiBlobHandler = 14 std::function<ipmi_ret_t(ManagerInterface* mgr, const uint8_t* reqBuf, 15 uint8_t* replyCmdBuf, size_t* dataLen)>; 16 17 /** 18 * Validate the IPMI request and determine routing. 19 * 20 * @param[in] crc - a pointer to the crc interface. 21 * @param[in] reqBuf - a pointer to the ipmi request packet buffer. 22 * @param[in,out] replyCmdBuf - a pointer to the ipmi reply packet buffer. 23 * @param[in,out] dataLen - initially the request length, set to reply length 24 * on return. 25 * @param[out] code - set to the IPMI error on failure, otherwise unset. 26 * @return the ipmi command handler, or nullptr on failure. 27 */ 28 IpmiBlobHandler validateBlobCommand(CrcInterface* crc, const uint8_t* reqBuf, 29 uint8_t* replyCmdBuf, size_t* dataLen, 30 ipmi_ret_t* code); 31 32 /** 33 * Call the IPMI command and process the result, including running the CRC 34 * computation for the reply message if there is one. 35 * 36 * @param[in] cmd - a funtion pointer to the ipmi command to process. 37 * @param[in] mgr - a pointer to the manager interface. 38 * @param[in] crc - a pointer to the crc interface. 39 * @param[in] reqBuf - a pointer to the ipmi request packet buffer. 40 * @param[in,out] replyCmdBuf - a pointer to the ipmi reply packet buffer. 41 * @param[in,out] dataLen - initially the request length, set to reply length 42 * on return. 43 * @return the ipmi command result. 44 */ 45 ipmi_ret_t processBlobCommand(IpmiBlobHandler cmd, ManagerInterface* mgr, 46 CrcInterface* crc, const uint8_t* reqBuf, 47 uint8_t* replyCmdBuf, size_t* dataLen); 48 } // namespace blobs 49