blob: dc30f9ada0745b4d92cd6f9010372ba1aadb8306 [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
Willy Tu067ece12022-06-16 02:07:06 -07008#include <ipmid/api-types.hpp>
Patrick Williams52509572023-05-10 07:51:18 -05009
10#include <functional>
Willy Tu067ece12022-06-16 02:07:06 -070011#include <span>
12#include <utility>
13#include <vector>
Patrick Ventureef3aead2018-09-12 08:53:29 -070014
15namespace blobs
16{
17
18using IpmiBlobHandler =
Willy Tu067ece12022-06-16 02:07:06 -070019 std::function<Resp(ManagerInterface* mgr, std::span<const uint8_t> data)>;
Patrick Ventureef3aead2018-09-12 08:53:29 -070020
21/**
22 * Validate the IPMI request and determine routing.
23 *
Willy Tu067ece12022-06-16 02:07:06 -070024 * @param[in] cmd Requested command
25 * @param[in] data Requested data
26 * @return the ipmi command handler, or nullopt on failure.
Patrick Ventureef3aead2018-09-12 08:53:29 -070027 */
Willy Tu067ece12022-06-16 02:07:06 -070028IpmiBlobHandler validateBlobCommand(uint8_t cmd, std::span<const uint8_t> data);
Patrick Ventureef3aead2018-09-12 08:53:29 -070029
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.
Willy Tu067ece12022-06-16 02:07:06 -070036 * @param[in] data - Requested data.
37 * @param[in,out] maxSize - Maximum ipmi reply size
Patrick Ventureef3aead2018-09-12 08:53:29 -070038 * @return the ipmi command result.
39 */
Willy Tu067ece12022-06-16 02:07:06 -070040Resp processBlobCommand(IpmiBlobHandler cmd, ManagerInterface* mgr,
Willy Tu83f99922022-06-22 14:59:07 -070041 std::span<const uint8_t> data, size_t maxSize);
Patrick Venture03fd5b82020-05-07 14:51:42 -070042
43/**
44 * Given an IPMI command, request buffer, and reply buffer, validate the request
45 * and call processBlobCommand.
46 */
Willy Tu83f99922022-06-22 14:59:07 -070047Resp handleBlobCommand(uint8_t cmd, std::vector<uint8_t> data, size_t maxSize);
Patrick Ventureef3aead2018-09-12 08:53:29 -070048} // namespace blobs