Patrick Venture | 123b5c0 | 2019-03-05 14:01:00 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "internal/sys.hpp" |
| 4 | #include "ipmi_interface.hpp" |
| 5 | |
| 6 | #include <vector> |
| 7 | |
Patrick Venture | 1470bec | 2019-03-06 07:33:12 -0800 | [diff] [blame] | 8 | namespace ipmiblob |
Patrick Venture | 123b5c0 | 2019-03-05 14:01:00 -0800 | [diff] [blame] | 9 | { |
| 10 | |
| 11 | class IpmiHandler : public IpmiInterface |
| 12 | { |
| 13 | public: |
| 14 | explicit IpmiHandler(const internal::Sys* sys = &internal::sys_impl) : |
| 15 | sys(sys){}; |
| 16 | |
| 17 | ~IpmiHandler() = default; |
| 18 | IpmiHandler(const IpmiHandler&) = delete; |
| 19 | IpmiHandler& operator=(const IpmiHandler&) = delete; |
| 20 | IpmiHandler(IpmiHandler&&) = default; |
| 21 | IpmiHandler& operator=(IpmiHandler&&) = default; |
| 22 | |
| 23 | /** |
| 24 | * Attempt to open the device node. |
| 25 | * |
| 26 | * @throws IpmiException on failure. |
| 27 | */ |
| 28 | void open(); |
| 29 | |
| 30 | /** |
| 31 | * @throws IpmiException on failure. |
| 32 | */ |
| 33 | std::vector<std::uint8_t> |
| 34 | sendPacket(std::vector<std::uint8_t>& data) override; |
| 35 | |
| 36 | private: |
| 37 | const internal::Sys* sys; |
| 38 | /** TODO: Use a smart file descriptor when it's ready. Until then only |
| 39 | * allow moving this object. |
| 40 | */ |
| 41 | int fd = -1; |
| 42 | /* The last IPMI sequence number we used. */ |
| 43 | int sequence = 0; |
| 44 | }; |
| 45 | |
Patrick Venture | 1470bec | 2019-03-06 07:33:12 -0800 | [diff] [blame] | 46 | } // namespace ipmiblob |