blob: bd7b3c64ece60d07dbb7516aa23ad60bd182da73 [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"
6
7#include <filesystem>
8#include <fstream>
9#include <map>
10
11using namespace pldm::dbus_api;
12
13namespace pldm
14{
15namespace requester
16{
17namespace oem_ibm
18{
19
20/** @class DbusToFileHandler
21 * @brief This class can process resource dump parameters and send PLDM
22 * new file available cmd to the hypervisor. This class can be used
23 * as a pldm requester in oem-ibm path.
24 */
25class DbusToFileHandler
26{
27 public:
28 DbusToFileHandler(const DbusToFileHandler&) = delete;
29 DbusToFileHandler(DbusToFileHandler&&) = delete;
30 DbusToFileHandler& operator=(const DbusToFileHandler&) = delete;
31 DbusToFileHandler& operator=(DbusToFileHandler&&) = delete;
32 ~DbusToFileHandler() = default;
33
34 /** @brief Constructor
35 * @param[in] mctp_fd - fd of MCTP communications socket
36 * @param[in] mctp_eid - MCTP EID of host firmware
37 * @param[in] requester - pointer to a Requester object
38 * @param[in] resDumpCurrentObjPath - resource dump current object path
39 */
40 DbusToFileHandler(int mctp_fd, uint8_t mctp_eid,
41 dbus_api::Requester* requester,
42 sdbusplus::message::object_path resDumpCurrentObjPath);
43
44 /** @brief Process the new resource dump request
45 * @param[in] vspString - vsp string
46 * @param[in] resDumpReqPass - resource dump password
47 */
48 void processNewResourceDump(const std::string& vspString,
49 const std::string& resDumpReqPass);
50
Varsha Kaverappa219ace92021-04-01 02:50:11 -050051 /** @brief Process the new CSR file available
52 * @param[in] csr - CSR string
53 * @param[in] fileHandle - file Handle for new file request
54 */
55 void newCsrFileAvailable(const std::string& csr,
56 const std::string fileHandle);
57
Jayashankar Padathdb124362021-01-28 21:12:34 -060058 private:
59 /** @brief Send the new file available command request to hypervisor
60 * @param[in] fileSize - size of the file
61 */
62 void sendNewFileAvailableCmd(uint64_t fileSize);
63
Varsha Kaverappa219ace92021-04-01 02:50:11 -050064 /** @brief Send the new file available command request to hypervisor
65 * @param[in] fileSize - size of the file
66 * @param[in] fileHandle - file handle
67 * @param[in] type - file type
68 */
69 void newFileAvailableSendToHost(const uint32_t fileSize,
70 const uint32_t fileHandle,
71 const uint16_t type);
72
Jayashankar Padathdb124362021-01-28 21:12:34 -060073 /** @brief fd of MCTP communications socket */
74 int mctp_fd;
75
76 /** @brief MCTP EID of host firmware */
77 uint8_t mctp_eid;
78
79 /** @brief Pointer to a Requester object, primarily used to access API to
80 * obtain PLDM instance id.
81 */
82 dbus_api::Requester* requester;
83
84 /** @brief Hold the current resource dump object path */
85 sdbusplus::message::object_path resDumpCurrentObjPath;
86};
87
88} // namespace oem_ibm
89} // namespace requester
90} // namespace pldm