blob: 739e864120d87966d9d6869d0f9ebf340ae88ae3 [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
12using namespace pldm::dbus_api;
13
14namespace pldm
15{
16namespace requester
17{
18namespace oem_ibm
19{
20
21/** @class DbusToFileHandler
22 * @brief This class can process resource dump parameters and send PLDM
23 * new file available cmd to the hypervisor. This class can be used
24 * as a pldm requester in oem-ibm path.
25 */
26class DbusToFileHandler
27{
28 public:
29 DbusToFileHandler(const DbusToFileHandler&) = delete;
30 DbusToFileHandler(DbusToFileHandler&&) = delete;
31 DbusToFileHandler& operator=(const DbusToFileHandler&) = delete;
32 DbusToFileHandler& operator=(DbusToFileHandler&&) = delete;
33 ~DbusToFileHandler() = default;
34
35 /** @brief Constructor
36 * @param[in] mctp_fd - fd of MCTP communications socket
37 * @param[in] mctp_eid - MCTP EID of host firmware
38 * @param[in] requester - pointer to a Requester object
39 * @param[in] resDumpCurrentObjPath - resource dump current object path
Sampa Misrac0c79482021-06-02 08:01:54 -050040 * @param[in] handler - PLDM request handler
Jayashankar Padathdb124362021-01-28 21:12:34 -060041 */
Sampa Misrac0c79482021-06-02 08:01:54 -050042 DbusToFileHandler(
43 int mctp_fd, uint8_t mctp_eid, dbus_api::Requester* requester,
44 sdbusplus::message::object_path resDumpCurrentObjPath,
45 pldm::requester::Handler<pldm::requester::Request>* handler);
Jayashankar Padathdb124362021-01-28 21:12:34 -060046
47 /** @brief Process the new resource dump request
48 * @param[in] vspString - vsp string
49 * @param[in] resDumpReqPass - resource dump password
50 */
51 void processNewResourceDump(const std::string& vspString,
52 const std::string& resDumpReqPass);
53
Varsha Kaverappa219ace92021-04-01 02:50:11 -050054 /** @brief Process the new CSR file available
55 * @param[in] csr - CSR string
56 * @param[in] fileHandle - file Handle for new file request
57 */
58 void newCsrFileAvailable(const std::string& csr,
59 const std::string fileHandle);
60
Jayashankar Padathdb124362021-01-28 21:12:34 -060061 private:
62 /** @brief Send the new file available command request to hypervisor
63 * @param[in] fileSize - size of the file
64 */
65 void sendNewFileAvailableCmd(uint64_t fileSize);
66
Varsha Kaverappa219ace92021-04-01 02:50:11 -050067 /** @brief Send the new file available command request to hypervisor
68 * @param[in] fileSize - size of the file
69 * @param[in] fileHandle - file handle
70 * @param[in] type - file type
71 */
72 void newFileAvailableSendToHost(const uint32_t fileSize,
73 const uint32_t fileHandle,
74 const uint16_t type);
75
Sampa Misrac0c79482021-06-02 08:01:54 -050076 /** @brief report failure that a resource dump has failed
77 */
78 void reportResourceDumpFailure();
79
Jayashankar Padathdb124362021-01-28 21:12:34 -060080 /** @brief fd of MCTP communications socket */
81 int mctp_fd;
82
83 /** @brief MCTP EID of host firmware */
84 uint8_t mctp_eid;
85
86 /** @brief Pointer to a Requester object, primarily used to access API to
87 * obtain PLDM instance id.
88 */
89 dbus_api::Requester* requester;
90
91 /** @brief Hold the current resource dump object path */
92 sdbusplus::message::object_path resDumpCurrentObjPath;
Sampa Misrac0c79482021-06-02 08:01:54 -050093
94 /** @brief PLDM request handler */
95 pldm::requester::Handler<pldm::requester::Request>* handler;
Jayashankar Padathdb124362021-01-28 21:12:34 -060096};
97
98} // namespace oem_ibm
99} // namespace requester
100} // namespace pldm