blob: 494df715c7b16475fb371e6c1699ed4a7cd8cef0 [file] [log] [blame]
Patrick Ventureef3aead2018-09-12 08:53:29 -07001#pragma once
2
Willy Tu067ece12022-06-16 02:07:06 -07003#include "ipmi.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>
Willy Tu067ece12022-06-16 02:07:06 -07009#include <ipmid/api-types.hpp>
10#include <span>
11#include <utility>
12#include <vector>
Patrick Ventureef3aead2018-09-12 08:53:29 -070013
14namespace blobs
15{
16
17using IpmiBlobHandler =
Willy Tu067ece12022-06-16 02:07:06 -070018 std::function<Resp(ManagerInterface* mgr, std::span<const uint8_t> data)>;
Patrick Ventureef3aead2018-09-12 08:53:29 -070019
20/**
21 * Validate the IPMI request and determine routing.
22 *
Willy Tu067ece12022-06-16 02:07:06 -070023 * @param[in] cmd Requested command
24 * @param[in] data Requested data
25 * @return the ipmi command handler, or nullopt on failure.
Patrick Ventureef3aead2018-09-12 08:53:29 -070026 */
Willy Tu067ece12022-06-16 02:07:06 -070027IpmiBlobHandler validateBlobCommand(uint8_t cmd, std::span<const uint8_t> data);
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.
Willy Tu067ece12022-06-16 02:07:06 -070035 * @param[in] data - Requested data.
36 * @param[in,out] maxSize - Maximum ipmi reply size
Patrick Ventureef3aead2018-09-12 08:53:29 -070037 * @return the ipmi command result.
38 */
Willy Tu067ece12022-06-16 02:07:06 -070039Resp processBlobCommand(IpmiBlobHandler cmd, ManagerInterface* mgr,
Willy Tu83f99922022-06-22 14:59:07 -070040 std::span<const uint8_t> data, size_t maxSize);
Patrick Venture03fd5b82020-05-07 14:51:42 -070041
42/**
43 * Given an IPMI command, request buffer, and reply buffer, validate the request
44 * and call processBlobCommand.
45 */
Willy Tu83f99922022-06-22 14:59:07 -070046Resp handleBlobCommand(uint8_t cmd, std::vector<uint8_t> data, size_t maxSize);
Patrick Ventureef3aead2018-09-12 08:53:29 -070047} // namespace blobs