1 #pragma once 2 3 #include "file_io_by_type.hpp" 4 5 #include <tuple> 6 7 namespace pldm 8 { 9 namespace responder 10 { 11 12 using Fd = int; 13 using RemainingSize = uint64_t; 14 using CertDetails = std::tuple<Fd, RemainingSize>; 15 using CertType = uint16_t; 16 using 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 */ 23 class 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 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() 50 {} 51 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 59