blob: e8a99063640e35828631315607be870a085aaf7d [file] [log] [blame]
Patrick Ventureef3aead2018-09-12 08:53:29 -07001#pragma once
2
3#include "crc.hpp"
4#include "manager.hpp"
5
6#include <host-ipmid/ipmid-api.h>
7
8#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.
25 * @return the ipmi command handler.
26 */
27IpmiBlobHandler validateBlobCommand(CrcInterface* crc, const uint8_t* reqBuf,
28 uint8_t* replyCmdBuf, size_t* dataLen);
29
30/**
31 * Call the IPMI command and process the result, including running the CRC
32 * computation for the reply message if there is one.
33 *
34 * @param[in] cmd - a funtion pointer to the ipmi command to process.
35 * @param[in] mgr - a pointer to the manager interface.
36 * @param[in] crc - a pointer to the crc interface.
37 * @param[in] reqBuf - a pointer to the ipmi request packet buffer.
38 * @param[in,out] replyCmdBuf - a pointer to the ipmi reply packet buffer.
39 * @param[in,out] dataLen - initially the request length, set to reply length
40 * on return.
41 * @return the ipmi command result.
42 */
43ipmi_ret_t processBlobCommand(IpmiBlobHandler cmd, ManagerInterface* mgr,
44 CrcInterface* crc, const uint8_t* reqBuf,
45 uint8_t* replyCmdBuf, size_t* dataLen);
46} // namespace blobs