blob: 390bc1a33e2d26cd0595cf6e1a2873ea8793106a [file] [log] [blame]
Patrick Ventureef3aead2018-09-12 08:53:29 -07001#pragma once
2
3#include "crc.hpp"
Patrick Venturecd8dab42019-01-15 19:57:38 -08004#include "manager.hpp"
Patrick Ventureef3aead2018-09-12 08:53:29 -07005
William A. Kennington IIIacebece2019-02-07 15:15:44 -08006#include <ipmid/api.h>
Patrick Ventureef3aead2018-09-12 08:53:29 -07007
Patrick Ventureef3aead2018-09-12 08:53:29 -07008#include <functional>
9
10namespace blobs
11{
12
13using 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.
Patrick Venture41258802018-11-12 10:46:30 -080025 * @param[out] code - set to the IPMI error on failure, otherwise unset.
26 * @return the ipmi command handler, or nullptr on failure.
Patrick Ventureef3aead2018-09-12 08:53:29 -070027 */
28IpmiBlobHandler validateBlobCommand(CrcInterface* crc, const uint8_t* reqBuf,
Patrick Venture41258802018-11-12 10:46:30 -080029 uint8_t* replyCmdBuf, size_t* dataLen,
30 ipmi_ret_t* code);
Patrick Ventureef3aead2018-09-12 08:53:29 -070031
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 */
45ipmi_ret_t processBlobCommand(IpmiBlobHandler cmd, ManagerInterface* mgr,
46 CrcInterface* crc, const uint8_t* reqBuf,
47 uint8_t* replyCmdBuf, size_t* dataLen);
48} // namespace blobs