blob: cdd7f7291345b4b3aaedd2035129110d0784cb46 [file] [log] [blame]
Patrick Ventureef3aead2018-09-12 08:53:29 -07001#pragma once
2
Patrick Venturecd8dab42019-01-15 19:57:38 -08003#include "manager.hpp"
Patrick Ventureef3aead2018-09-12 08:53:29 -07004
William A. Kennington IIIacebece2019-02-07 15:15:44 -08005#include <ipmid/api.h>
Patrick Ventureef3aead2018-09-12 08:53:29 -07006
Patrick Ventureef3aead2018-09-12 08:53:29 -07007#include <functional>
8
9namespace blobs
10{
11
12using IpmiBlobHandler =
13 std::function<ipmi_ret_t(ManagerInterface* mgr, const uint8_t* reqBuf,
14 uint8_t* replyCmdBuf, size_t* dataLen)>;
15
16/**
17 * Validate the IPMI request and determine routing.
18 *
Patrick Ventureef3aead2018-09-12 08:53:29 -070019 * @param[in] reqBuf - a pointer to the ipmi request packet buffer.
20 * @param[in,out] replyCmdBuf - a pointer to the ipmi reply packet buffer.
21 * @param[in,out] dataLen - initially the request length, set to reply length
22 * on return.
Patrick Venture41258802018-11-12 10:46:30 -080023 * @param[out] code - set to the IPMI error on failure, otherwise unset.
24 * @return the ipmi command handler, or nullptr on failure.
Patrick Ventureef3aead2018-09-12 08:53:29 -070025 */
Patrick Venturede8a16e2019-03-07 12:48:32 -080026IpmiBlobHandler validateBlobCommand(const uint8_t* reqBuf, uint8_t* replyCmdBuf,
27 size_t* dataLen, ipmi_ret_t* code);
Patrick Ventureef3aead2018-09-12 08:53:29 -070028
29/**
30 * Call the IPMI command and process the result, including running the CRC
31 * computation for the reply message if there is one.
32 *
33 * @param[in] cmd - a funtion pointer to the ipmi command to process.
34 * @param[in] mgr - a pointer to the manager interface.
Patrick Ventureef3aead2018-09-12 08:53:29 -070035 * @param[in] reqBuf - a pointer to the ipmi request packet buffer.
36 * @param[in,out] replyCmdBuf - a pointer to the ipmi reply packet buffer.
37 * @param[in,out] dataLen - initially the request length, set to reply length
38 * on return.
39 * @return the ipmi command result.
40 */
41ipmi_ret_t processBlobCommand(IpmiBlobHandler cmd, ManagerInterface* mgr,
Patrick Venturede8a16e2019-03-07 12:48:32 -080042 const uint8_t* reqBuf, uint8_t* replyCmdBuf,
43 size_t* dataLen);
Patrick Ventureef3aead2018-09-12 08:53:29 -070044} // namespace blobs