Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Willy Tu | 067ece1 | 2022-06-16 02:07:06 -0700 | [diff] [blame] | 3 | #include "ipmi.hpp" |
Patrick Venture | cd8dab4 | 2019-01-15 19:57:38 -0800 | [diff] [blame] | 4 | #include "manager.hpp" |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 5 | |
William A. Kennington III | acebece | 2019-02-07 15:15:44 -0800 | [diff] [blame] | 6 | #include <ipmid/api.h> |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 7 | |
Willy Tu | 067ece1 | 2022-06-16 02:07:06 -0700 | [diff] [blame] | 8 | #include <ipmid/api-types.hpp> |
Patrick Williams | 5250957 | 2023-05-10 07:51:18 -0500 | [diff] [blame] | 9 | |
| 10 | #include <functional> |
Willy Tu | 067ece1 | 2022-06-16 02:07:06 -0700 | [diff] [blame] | 11 | #include <span> |
| 12 | #include <utility> |
| 13 | #include <vector> |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 14 | |
| 15 | namespace blobs |
| 16 | { |
| 17 | |
| 18 | using IpmiBlobHandler = |
Willy Tu | 067ece1 | 2022-06-16 02:07:06 -0700 | [diff] [blame] | 19 | std::function<Resp(ManagerInterface* mgr, std::span<const uint8_t> data)>; |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 20 | |
| 21 | /** |
| 22 | * Validate the IPMI request and determine routing. |
| 23 | * |
Willy Tu | 067ece1 | 2022-06-16 02:07:06 -0700 | [diff] [blame] | 24 | * @param[in] cmd Requested command |
| 25 | * @param[in] data Requested data |
| 26 | * @return the ipmi command handler, or nullopt on failure. |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 27 | */ |
Willy Tu | 067ece1 | 2022-06-16 02:07:06 -0700 | [diff] [blame] | 28 | IpmiBlobHandler validateBlobCommand(uint8_t cmd, std::span<const uint8_t> data); |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 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. |
Willy Tu | 067ece1 | 2022-06-16 02:07:06 -0700 | [diff] [blame] | 36 | * @param[in] data - Requested data. |
| 37 | * @param[in,out] maxSize - Maximum ipmi reply size |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 38 | * @return the ipmi command result. |
| 39 | */ |
Willy Tu | 067ece1 | 2022-06-16 02:07:06 -0700 | [diff] [blame] | 40 | Resp processBlobCommand(IpmiBlobHandler cmd, ManagerInterface* mgr, |
Willy Tu | 83f9992 | 2022-06-22 14:59:07 -0700 | [diff] [blame] | 41 | std::span<const uint8_t> data, size_t maxSize); |
Patrick Venture | 03fd5b8 | 2020-05-07 14:51:42 -0700 | [diff] [blame] | 42 | |
| 43 | /** |
| 44 | * Given an IPMI command, request buffer, and reply buffer, validate the request |
| 45 | * and call processBlobCommand. |
| 46 | */ |
Willy Tu | 83f9992 | 2022-06-22 14:59:07 -0700 | [diff] [blame] | 47 | Resp handleBlobCommand(uint8_t cmd, std::vector<uint8_t> data, size_t maxSize); |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 48 | } // namespace blobs |