xref: /openbmc/pldm/libpldmresponder/base.hpp (revision 579a34a3)
1 #pragma once
2 
3 #include "libpldm/base.h"
4 
5 #include "pldmd/handler.hpp"
6 
7 #include <stdint.h>
8 
9 #include <vector>
10 
11 namespace pldm
12 {
13 namespace responder
14 {
15 namespace base
16 {
17 
18 class Handler : public CmdHandler
19 {
20   public:
21     Handler()
22     {
23         handlers.emplace(PLDM_GET_PLDM_TYPES,
24                          [this](const pldm_msg* request, size_t payloadLength) {
25                              return this->getPLDMTypes(request, payloadLength);
26                          });
27         handlers.emplace(PLDM_GET_PLDM_COMMANDS, [this](const pldm_msg* request,
28                                                         size_t payloadLength) {
29             return this->getPLDMCommands(request, payloadLength);
30         });
31         handlers.emplace(PLDM_GET_PLDM_VERSION, [this](const pldm_msg* request,
32                                                        size_t payloadLength) {
33             return this->getPLDMVersion(request, payloadLength);
34         });
35         handlers.emplace(PLDM_GET_TID,
36                          [this](const pldm_msg* request, size_t payloadLength) {
37                              return this->getTID(request, payloadLength);
38                          });
39     }
40 
41     /** @brief Handler for getPLDMTypes
42      *
43      *  @param[in] request - Request message payload
44      *  @param[in] payload_length - Request message payload length
45      *  @param[return] Response - PLDM Response message
46      */
47     Response getPLDMTypes(const pldm_msg* request, size_t payloadLength);
48 
49     /** @brief Handler for getPLDMCommands
50      *
51      *  @param[in] request - Request message payload
52      *  @param[in] payload_length - Request message payload length
53      *  @param[return] Response - PLDM Response message
54      */
55     Response getPLDMCommands(const pldm_msg* request, size_t payloadLength);
56 
57     /** @brief Handler for getPLDMCommands
58      *
59      *  @param[in] request - Request message payload
60      *  @param[in] payload_length - Request message payload length
61      *  @param[return] Response - PLDM Response message
62      */
63     Response getPLDMVersion(const pldm_msg* request, size_t payloadLength);
64 
65     /** @brief Handler for getTID
66      *
67      *  @param[in] request - Request message payload
68      *  @param[in] payload_length - Request message payload length
69      *  @param[return] Response - PLDM Response message
70      */
71     Response getTID(const pldm_msg* request, size_t payloadLength);
72 };
73 
74 } // namespace base
75 } // namespace responder
76 } // namespace pldm
77