Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "crc.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 | |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 8 | #include <functional> |
| 9 | |
| 10 | namespace blobs |
| 11 | { |
| 12 | |
| 13 | using IpmiBlobHandler = |
| 14 | std::function<ipmi_ret_t(ManagerInterface* mgr, const uint8_t* reqBuf, |
| 15 | uint8_t* replyCmdBuf, size_t* dataLen)>; |
| 16 | |
| 17 | /** |
| 18 | * Validate the IPMI request and determine routing. |
| 19 | * |
| 20 | * @param[in] crc - a pointer to the crc interface. |
| 21 | * @param[in] reqBuf - a pointer to the ipmi request packet buffer. |
| 22 | * @param[in,out] replyCmdBuf - a pointer to the ipmi reply packet buffer. |
| 23 | * @param[in,out] dataLen - initially the request length, set to reply length |
| 24 | * on return. |
Patrick Venture | 4125880 | 2018-11-12 10:46:30 -0800 | [diff] [blame] | 25 | * @param[out] code - set to the IPMI error on failure, otherwise unset. |
| 26 | * @return the ipmi command handler, or nullptr on failure. |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 27 | */ |
| 28 | IpmiBlobHandler validateBlobCommand(CrcInterface* crc, const uint8_t* reqBuf, |
Patrick Venture | 4125880 | 2018-11-12 10:46:30 -0800 | [diff] [blame] | 29 | uint8_t* replyCmdBuf, size_t* dataLen, |
| 30 | ipmi_ret_t* code); |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * Call the IPMI command and process the result, including running the CRC |
| 34 | * computation for the reply message if there is one. |
| 35 | * |
| 36 | * @param[in] cmd - a funtion pointer to the ipmi command to process. |
| 37 | * @param[in] mgr - a pointer to the manager interface. |
| 38 | * @param[in] crc - a pointer to the crc interface. |
| 39 | * @param[in] reqBuf - a pointer to the ipmi request packet buffer. |
| 40 | * @param[in,out] replyCmdBuf - a pointer to the ipmi reply packet buffer. |
| 41 | * @param[in,out] dataLen - initially the request length, set to reply length |
| 42 | * on return. |
| 43 | * @return the ipmi command result. |
| 44 | */ |
| 45 | ipmi_ret_t processBlobCommand(IpmiBlobHandler cmd, ManagerInterface* mgr, |
| 46 | CrcInterface* crc, const uint8_t* reqBuf, |
| 47 | uint8_t* replyCmdBuf, size_t* dataLen); |
| 48 | } // namespace blobs |