blob: a1c8d9f87ebd9e734833b4e2ea20a9ca93dd3403 [file] [log] [blame]
Sampa Misrad823cc02020-03-24 04:53:20 -05001#pragma once
2
3#include "file_io_by_type.hpp"
4
5#include <tuple>
6
7namespace pldm
8{
9namespace responder
10{
11
12using Fd = int;
13using RemainingSize = uint64_t;
14using CertDetails = std::tuple<Fd, RemainingSize>;
15using CertType = uint16_t;
16using CertMap = std::map<CertType, CertDetails>;
17
18/** @class CertHandler
19 *
20 * @brief Inherits and implements FileHandler. This class is used
21 * to read/write certificates and certificate signing requests
22 */
23class CertHandler : public FileHandler
24{
25 public:
26 /** @brief CertHandler constructor
27 */
28 CertHandler(uint32_t fileHandle, uint16_t fileType) :
29 FileHandler(fileHandle), certType(fileType)
George Liu6492f522020-06-16 10:34:05 +080030 {}
Sampa Misrad823cc02020-03-24 04:53:20 -050031
32 virtual int writeFromMemory(uint32_t offset, uint32_t length,
33 uint64_t address);
34 virtual int readIntoMemory(uint32_t offset, uint32_t& length,
35 uint64_t address);
36 virtual int read(uint32_t offset, uint32_t& length, Response& response);
37
38 virtual int write(const char* buffer, uint32_t offset, uint32_t& length);
39
40 virtual int fileAck(uint8_t /*fileStatus*/)
41 {
42 return PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
43 }
44
45 virtual int newFileAvailable(uint64_t length);
46
47 /** @brief CertHandler destructor
48 */
49 ~CertHandler()
George Liu6492f522020-06-16 10:34:05 +080050 {}
Sampa Misrad823cc02020-03-24 04:53:20 -050051
52 private:
53 uint16_t certType; //!< type of the certificate
54 static CertMap certMap; //!< holds the fd and remaining read/write size for
55 //!< each certificate
56};
57} // namespace responder
58} // namespace pldm