blob: 0bd496ffceb3f7c3320dbf33c241a721096a7e17 [file] [log] [blame]
Jinu Joy Thomasf666db12019-05-29 05:22:31 -05001#pragma once
2
3#include <functional>
4#include <map>
5
6#include "libpldm/base.h"
7
8namespace pldm
9{
10
11using Response = std::vector<uint8_t>;
12
13namespace responder
14{
15
16using 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 */
25void 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 */
35Response invokeHandler(uint8_t pldmType, uint8_t pldmCommand,
36 const pldm_msg* request, size_t payloadLength);
37
38} // namespace responder
39} // namespace pldm