1 #pragma once 2 3 #include "libpldm/platform.h" 4 5 #include "pldmd/dbus_impl_requester.hpp" 6 #include "requester/handler.hpp" 7 8 #include <filesystem> 9 #include <fstream> 10 #include <map> 11 12 namespace pldm 13 { 14 namespace requester 15 { 16 namespace 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 */ 24 class 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 38 * @param[in] handler - PLDM request handler 39 */ 40 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); 44 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 52 /** @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 59 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 65 /** @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 74 /** @brief report failure that a resource dump has failed 75 */ 76 void reportResourceDumpFailure(); 77 78 /** @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; 91 92 /** @brief PLDM request handler */ 93 pldm::requester::Handler<pldm::requester::Request>* handler; 94 }; 95 96 } // namespace oem_ibm 97 } // namespace requester 98 } // namespace pldm 99