blob: b6e8b5daf53a81b6992b290c548c9079a233aa55 [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
51 private:
52 /** @brief Send the new file available command request to hypervisor
53 * @param[in] fileSize - size of the file
54 */
55 void sendNewFileAvailableCmd(uint64_t fileSize);
56
57 /** @brief fd of MCTP communications socket */
58 int mctp_fd;
59
60 /** @brief MCTP EID of host firmware */
61 uint8_t mctp_eid;
62
63 /** @brief Pointer to a Requester object, primarily used to access API to
64 * obtain PLDM instance id.
65 */
66 dbus_api::Requester* requester;
67
68 /** @brief Hold the current resource dump object path */
69 sdbusplus::message::object_path resDumpCurrentObjPath;
70};
71
72} // namespace oem_ibm
73} // namespace requester
74} // namespace pldm