1 #pragma once 2 3 #include "ipmi.hpp" 4 #include "manager.hpp" 5 6 #include <ipmid/api.h> 7 8 #include <ipmid/api-types.hpp> 9 10 #include <functional> 11 #include <span> 12 #include <utility> 13 #include <vector> 14 15 namespace blobs 16 { 17 18 using IpmiBlobHandler = 19 std::function<Resp(ManagerInterface* mgr, std::span<const uint8_t> data)>; 20 21 /** 22 * Validate the IPMI request and determine routing. 23 * 24 * @param[in] cmd Requested command 25 * @param[in] data Requested data 26 * @return the ipmi command handler, or nullopt on failure. 27 */ 28 IpmiBlobHandler validateBlobCommand(uint8_t cmd, std::span<const uint8_t> data); 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] data - Requested data. 37 * @param[in,out] maxSize - Maximum ipmi reply size 38 * @return the ipmi command result. 39 */ 40 Resp processBlobCommand(IpmiBlobHandler cmd, ManagerInterface* mgr, 41 std::span<const uint8_t> data, size_t maxSize); 42 43 /** 44 * Given an IPMI command, request buffer, and reply buffer, validate the request 45 * and call processBlobCommand. 46 */ 47 Resp handleBlobCommand(uint8_t cmd, std::vector<uint8_t> data, size_t maxSize); 48 } // namespace blobs 49