Jinu Joy Thomas | f666db1 | 2019-05-29 05:22:31 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <functional> |
| 4 | #include <map> |
| 5 | |
| 6 | #include "libpldm/base.h" |
| 7 | |
| 8 | namespace pldm |
| 9 | { |
| 10 | |
| 11 | using Response = std::vector<uint8_t>; |
| 12 | |
| 13 | namespace responder |
| 14 | { |
| 15 | |
| 16 | using Handler = |
| 17 | std::function<Response(const pldm_msg* request, size_t payloadLength)>; |
| 18 | |
| 19 | /** @brief Register a handler for input PLDM command |
| 20 | * |
| 21 | * @param[in] pldmType - PLDM type code |
| 22 | * @param[in] pldmCommand - PLDM command code |
| 23 | * @param[in] handler - PLDM command handler |
| 24 | */ |
| 25 | void registerHandler(uint8_t pldmType, uint8_t pldmCommand, Handler&& handler); |
| 26 | |
| 27 | /** @brief Invoke a handler for input PLDM command |
| 28 | * |
| 29 | * @param[in] pldmType - PLDM type code |
| 30 | * @param[in] pldmCommand - PLDM command code |
| 31 | * @param[in] request - PLDM request message |
| 32 | * @param[in] payloadLength - PLDM request message length |
| 33 | * @return PLDM Response message |
| 34 | */ |
| 35 | Response invokeHandler(uint8_t pldmType, uint8_t pldmCommand, |
| 36 | const pldm_msg* request, size_t payloadLength); |
| 37 | |
| 38 | } // namespace responder |
| 39 | } // namespace pldm |