blob: dc30f9ada0745b4d92cd6f9010372ba1aadb8306 [file] [log] [blame]
#pragma once
#include "ipmi.hpp"
#include "manager.hpp"
#include <ipmid/api.h>
#include <ipmid/api-types.hpp>
#include <functional>
#include <span>
#include <utility>
#include <vector>
namespace blobs
{
using IpmiBlobHandler =
std::function<Resp(ManagerInterface* mgr, std::span<const uint8_t> data)>;
/**
* Validate the IPMI request and determine routing.
*
* @param[in] cmd Requested command
* @param[in] data Requested data
* @return the ipmi command handler, or nullopt on failure.
*/
IpmiBlobHandler validateBlobCommand(uint8_t cmd, std::span<const uint8_t> data);
/**
* Call the IPMI command and process the result, including running the CRC
* computation for the reply message if there is one.
*
* @param[in] cmd - a funtion pointer to the ipmi command to process.
* @param[in] mgr - a pointer to the manager interface.
* @param[in] data - Requested data.
* @param[in,out] maxSize - Maximum ipmi reply size
* @return the ipmi command result.
*/
Resp processBlobCommand(IpmiBlobHandler cmd, ManagerInterface* mgr,
std::span<const uint8_t> data, size_t maxSize);
/**
* Given an IPMI command, request buffer, and reply buffer, validate the request
* and call processBlobCommand.
*/
Resp handleBlobCommand(uint8_t cmd, std::vector<uint8_t> data, size_t maxSize);
} // namespace blobs