blob: a981fabbfde59ae8cf91c238e0f71fd82c1a9ebf [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)
30 {
31 }
32
33 virtual int writeFromMemory(uint32_t offset, uint32_t length,
34 uint64_t address);
35 virtual int readIntoMemory(uint32_t offset, uint32_t& length,
36 uint64_t address);
37 virtual int read(uint32_t offset, uint32_t& length, Response& response);
38
39 virtual int write(const char* buffer, uint32_t offset, uint32_t& length);
40
41 virtual int fileAck(uint8_t /*fileStatus*/)
42 {
43 return PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
44 }
45
46 virtual int newFileAvailable(uint64_t length);
47
48 /** @brief CertHandler destructor
49 */
50 ~CertHandler()
51 {
52 }
53
54 private:
55 uint16_t certType; //!< type of the certificate
56 static CertMap certMap; //!< holds the fd and remaining read/write size for
57 //!< each certificate
58};
59} // namespace responder
60} // namespace pldm