xref: /openbmc/phosphor-ipmi-blobs/process.hpp (revision 5250957212ebf851d49df046acd6416a0d17c749)
1ef3aeadcSPatrick Venture #pragma once
2ef3aeadcSPatrick Venture 
3067ece15SWilly Tu #include "ipmi.hpp"
4cd8dab49SPatrick Venture #include "manager.hpp"
5ef3aeadcSPatrick Venture 
6acebece3SWilliam A. Kennington III #include <ipmid/api.h>
7ef3aeadcSPatrick Venture 
8067ece15SWilly Tu #include <ipmid/api-types.hpp>
9*52509572SPatrick Williams 
10*52509572SPatrick Williams #include <functional>
11067ece15SWilly Tu #include <span>
12067ece15SWilly Tu #include <utility>
13067ece15SWilly Tu #include <vector>
14ef3aeadcSPatrick Venture 
15ef3aeadcSPatrick Venture namespace blobs
16ef3aeadcSPatrick Venture {
17ef3aeadcSPatrick Venture 
18ef3aeadcSPatrick Venture using IpmiBlobHandler =
19067ece15SWilly Tu     std::function<Resp(ManagerInterface* mgr, std::span<const uint8_t> data)>;
20ef3aeadcSPatrick Venture 
21ef3aeadcSPatrick Venture /**
22ef3aeadcSPatrick Venture  * Validate the IPMI request and determine routing.
23ef3aeadcSPatrick Venture  *
24067ece15SWilly Tu  * @param[in] cmd  Requested command
25067ece15SWilly Tu  * @param[in] data Requested data
26067ece15SWilly Tu  * @return the ipmi command handler, or nullopt on failure.
27ef3aeadcSPatrick Venture  */
28067ece15SWilly Tu IpmiBlobHandler validateBlobCommand(uint8_t cmd, std::span<const uint8_t> data);
29ef3aeadcSPatrick Venture 
30ef3aeadcSPatrick Venture /**
31ef3aeadcSPatrick Venture  * Call the IPMI command and process the result, including running the CRC
32ef3aeadcSPatrick Venture  * computation for the reply message if there is one.
33ef3aeadcSPatrick Venture  *
34ef3aeadcSPatrick Venture  * @param[in] cmd - a funtion pointer to the ipmi command to process.
35ef3aeadcSPatrick Venture  * @param[in] mgr - a pointer to the manager interface.
36067ece15SWilly Tu  * @param[in] data - Requested data.
37067ece15SWilly Tu  * @param[in,out] maxSize - Maximum ipmi reply size
38ef3aeadcSPatrick Venture  * @return the ipmi command result.
39ef3aeadcSPatrick Venture  */
40067ece15SWilly Tu Resp processBlobCommand(IpmiBlobHandler cmd, ManagerInterface* mgr,
4183f9992cSWilly Tu                         std::span<const uint8_t> data, size_t maxSize);
4203fd5b8bSPatrick Venture 
4303fd5b8bSPatrick Venture /**
4403fd5b8bSPatrick Venture  * Given an IPMI command, request buffer, and reply buffer, validate the request
4503fd5b8bSPatrick Venture  * and call processBlobCommand.
4603fd5b8bSPatrick Venture  */
4783f9992cSWilly Tu Resp handleBlobCommand(uint8_t cmd, std::vector<uint8_t> data, size_t maxSize);
48ef3aeadcSPatrick Venture } // namespace blobs
49