blob: d415d1dece7dac2bc1fb4d4b919c0306083fe686 [file] [log] [blame]
Jayashankar Padathdb124362021-01-28 21:12:34 -06001#pragma once
2
3#include "libpldm/platform.h"
4
5#include "pldmd/dbus_impl_requester.hpp"
Sampa Misrac0c79482021-06-02 08:01:54 -05006#include "requester/handler.hpp"
Jayashankar Padathdb124362021-01-28 21:12:34 -06007
8#include <filesystem>
9#include <fstream>
10#include <map>
11
Jayashankar Padathdb124362021-01-28 21:12:34 -060012namespace pldm
13{
14namespace requester
15{
16namespace oem_ibm
17{
18
19/** @class DbusToFileHandler
20 * @brief This class can process resource dump parameters and send PLDM
21 * new file available cmd to the hypervisor. This class can be used
22 * as a pldm requester in oem-ibm path.
23 */
24class DbusToFileHandler
25{
26 public:
27 DbusToFileHandler(const DbusToFileHandler&) = delete;
28 DbusToFileHandler(DbusToFileHandler&&) = delete;
29 DbusToFileHandler& operator=(const DbusToFileHandler&) = delete;
30 DbusToFileHandler& operator=(DbusToFileHandler&&) = delete;
31 ~DbusToFileHandler() = default;
32
33 /** @brief Constructor
34 * @param[in] mctp_fd - fd of MCTP communications socket
35 * @param[in] mctp_eid - MCTP EID of host firmware
36 * @param[in] requester - pointer to a Requester object
37 * @param[in] resDumpCurrentObjPath - resource dump current object path
Sampa Misrac0c79482021-06-02 08:01:54 -050038 * @param[in] handler - PLDM request handler
Jayashankar Padathdb124362021-01-28 21:12:34 -060039 */
Sampa Misrac0c79482021-06-02 08:01:54 -050040 DbusToFileHandler(
41 int mctp_fd, uint8_t mctp_eid, dbus_api::Requester* requester,
42 sdbusplus::message::object_path resDumpCurrentObjPath,
43 pldm::requester::Handler<pldm::requester::Request>* handler);
Jayashankar Padathdb124362021-01-28 21:12:34 -060044
45 /** @brief Process the new resource dump request
46 * @param[in] vspString - vsp string
47 * @param[in] resDumpReqPass - resource dump password
48 */
49 void processNewResourceDump(const std::string& vspString,
50 const std::string& resDumpReqPass);
51
Varsha Kaverappa219ace92021-04-01 02:50:11 -050052 /** @brief Process the new CSR file available
53 * @param[in] csr - CSR string
54 * @param[in] fileHandle - file Handle for new file request
55 */
56 void newCsrFileAvailable(const std::string& csr,
57 const std::string fileHandle);
58
Jayashankar Padathdb124362021-01-28 21:12:34 -060059 private:
60 /** @brief Send the new file available command request to hypervisor
61 * @param[in] fileSize - size of the file
62 */
63 void sendNewFileAvailableCmd(uint64_t fileSize);
64
Varsha Kaverappa219ace92021-04-01 02:50:11 -050065 /** @brief Send the new file available command request to hypervisor
66 * @param[in] fileSize - size of the file
67 * @param[in] fileHandle - file handle
68 * @param[in] type - file type
69 */
70 void newFileAvailableSendToHost(const uint32_t fileSize,
71 const uint32_t fileHandle,
72 const uint16_t type);
73
Sampa Misrac0c79482021-06-02 08:01:54 -050074 /** @brief report failure that a resource dump has failed
75 */
76 void reportResourceDumpFailure();
77
Jayashankar Padathdb124362021-01-28 21:12:34 -060078 /** @brief fd of MCTP communications socket */
79 int mctp_fd;
80
81 /** @brief MCTP EID of host firmware */
82 uint8_t mctp_eid;
83
84 /** @brief Pointer to a Requester object, primarily used to access API to
85 * obtain PLDM instance id.
86 */
87 dbus_api::Requester* requester;
88
89 /** @brief Hold the current resource dump object path */
90 sdbusplus::message::object_path resDumpCurrentObjPath;
Sampa Misrac0c79482021-06-02 08:01:54 -050091
92 /** @brief PLDM request handler */
93 pldm::requester::Handler<pldm::requester::Request>* handler;
Jayashankar Padathdb124362021-01-28 21:12:34 -060094};
95
96} // namespace oem_ibm
97} // namespace requester
98} // namespace pldm