Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | cd8dab4 | 2019-01-15 19:57:38 -0800 | [diff] [blame] | 3 | #include "manager.hpp" |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 4 | |
William A. Kennington III | acebece | 2019-02-07 15:15:44 -0800 | [diff] [blame] | 5 | #include <ipmid/api.h> |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 6 | |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 7 | #include <functional> |
| 8 | |
| 9 | namespace blobs |
| 10 | { |
| 11 | |
| 12 | using IpmiBlobHandler = |
| 13 | std::function<ipmi_ret_t(ManagerInterface* mgr, const uint8_t* reqBuf, |
| 14 | uint8_t* replyCmdBuf, size_t* dataLen)>; |
| 15 | |
| 16 | /** |
| 17 | * Validate the IPMI request and determine routing. |
| 18 | * |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 19 | * @param[in] reqBuf - a pointer to the ipmi request packet buffer. |
| 20 | * @param[in,out] replyCmdBuf - a pointer to the ipmi reply packet buffer. |
| 21 | * @param[in,out] dataLen - initially the request length, set to reply length |
| 22 | * on return. |
Patrick Venture | 4125880 | 2018-11-12 10:46:30 -0800 | [diff] [blame] | 23 | * @param[out] code - set to the IPMI error on failure, otherwise unset. |
| 24 | * @return the ipmi command handler, or nullptr on failure. |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 25 | */ |
Patrick Venture | de8a16e | 2019-03-07 12:48:32 -0800 | [diff] [blame] | 26 | IpmiBlobHandler validateBlobCommand(const uint8_t* reqBuf, uint8_t* replyCmdBuf, |
| 27 | size_t* dataLen, ipmi_ret_t* code); |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 28 | |
| 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. |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 35 | * @param[in] reqBuf - a pointer to the ipmi request packet buffer. |
| 36 | * @param[in,out] replyCmdBuf - a pointer to the ipmi reply packet buffer. |
| 37 | * @param[in,out] dataLen - initially the request length, set to reply length |
| 38 | * on return. |
| 39 | * @return the ipmi command result. |
| 40 | */ |
| 41 | ipmi_ret_t processBlobCommand(IpmiBlobHandler cmd, ManagerInterface* mgr, |
Patrick Venture | de8a16e | 2019-03-07 12:48:32 -0800 | [diff] [blame] | 42 | const uint8_t* reqBuf, uint8_t* replyCmdBuf, |
| 43 | size_t* dataLen); |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 44 | } // namespace blobs |