Patrick Venture | 123b5c0 | 2019-03-05 14:01:00 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <cstdint> |
| 4 | #include <string> |
| 5 | #include <vector> |
| 6 | |
Patrick Venture | 1470bec | 2019-03-06 07:33:12 -0800 | [diff] [blame^] | 7 | namespace ipmiblob |
Patrick Venture | 123b5c0 | 2019-03-05 14:01:00 -0800 | [diff] [blame] | 8 | { |
| 9 | |
| 10 | struct StatResponse |
| 11 | { |
| 12 | std::uint16_t blob_state; |
| 13 | std::uint32_t size; |
| 14 | std::vector<std::uint8_t> metadata; |
| 15 | }; |
| 16 | |
| 17 | class BlobInterface |
| 18 | { |
| 19 | public: |
| 20 | virtual ~BlobInterface() = default; |
| 21 | |
| 22 | /** |
| 23 | * Write metadata to a blob. |
| 24 | * |
| 25 | * @param[in] session - the session id. |
| 26 | * @param[in] offset - the offset for the metadata to write. |
| 27 | * @param[in] bytes - the bytes to send. |
| 28 | * @throws BlobException on failure. |
| 29 | */ |
| 30 | virtual void writeMeta(std::uint16_t session, std::uint32_t offset, |
| 31 | const std::vector<std::uint8_t>& bytes) = 0; |
| 32 | |
| 33 | /** |
| 34 | * Write bytes to a blob. |
| 35 | * |
| 36 | * @param[in] session - the session id. |
| 37 | * @param[in] offset - the offset to which to write the bytes. |
| 38 | * @param[in] bytes - the bytes to send. |
| 39 | * @throws BlobException on failure. |
| 40 | */ |
| 41 | virtual void writeBytes(std::uint16_t session, std::uint32_t offset, |
| 42 | const std::vector<std::uint8_t>& bytes) = 0; |
| 43 | |
| 44 | /** |
| 45 | * Get a list of the blob_ids provided by the BMC. |
| 46 | * |
| 47 | * @return list of strings, each representing a blob_id returned. |
| 48 | */ |
| 49 | virtual std::vector<std::string> getBlobList() = 0; |
| 50 | |
| 51 | /** |
| 52 | * Get the stat() on the blob_id. |
| 53 | * |
| 54 | * @param[in] id - the blob_id. |
| 55 | * @return metadata structure. |
| 56 | */ |
| 57 | virtual StatResponse getStat(const std::string& id) = 0; |
| 58 | |
| 59 | /** |
| 60 | * Attempt to open the file using the specific data interface flag. |
| 61 | * |
| 62 | * @param[in] blob - the blob_id to open. |
| 63 | * @param[in] handlerFlags - the data interface flag, if relevant. |
| 64 | * @return the session id on success. |
| 65 | * @throws BlobException on failure. |
| 66 | */ |
| 67 | virtual std::uint16_t openBlob(const std::string& id, |
| 68 | std::uint16_t handlerFlags) = 0; |
| 69 | |
| 70 | /** |
| 71 | * Attempt to close the open session. |
| 72 | * |
| 73 | * @param[in] session - the session to close. |
| 74 | */ |
| 75 | virtual void closeBlob(std::uint16_t session) = 0; |
| 76 | |
| 77 | /** |
| 78 | * Read bytes from a blob. |
| 79 | * |
| 80 | * @param[in] session - the session id. |
| 81 | * @param[in] offset - the offset to which to write the bytes. |
| 82 | * @param[in] length - the number of bytes to read. |
| 83 | * @return the bytes read |
| 84 | * @throws BlobException on failure. |
| 85 | */ |
| 86 | virtual std::vector<std::uint8_t> readBytes(std::uint16_t session, |
| 87 | std::uint32_t offset, |
| 88 | std::uint32_t length) = 0; |
| 89 | }; |
| 90 | |
Patrick Venture | 1470bec | 2019-03-06 07:33:12 -0800 | [diff] [blame^] | 91 | } // namespace ipmiblob |