Patrick Venture | cf2d1b1 | 2018-12-11 18:22:36 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | b5a9706 | 2018-12-13 16:55:23 -0800 | [diff] [blame] | 3 | #include "internal/sys.hpp" |
Patrick Venture | cf2d1b1 | 2018-12-11 18:22:36 -0800 | [diff] [blame] | 4 | #include "ipmi_interface.hpp" |
| 5 | |
Patrick Venture | 9b534f0 | 2018-12-13 16:10:02 -0800 | [diff] [blame] | 6 | namespace host_tool |
| 7 | { |
| 8 | |
Patrick Venture | cf2d1b1 | 2018-12-11 18:22:36 -0800 | [diff] [blame] | 9 | class IpmiHandler : public IpmiInterface |
| 10 | { |
| 11 | public: |
Patrick Venture | b5a9706 | 2018-12-13 16:55:23 -0800 | [diff] [blame] | 12 | explicit IpmiHandler(const internal::Sys* sys = &internal::sys_impl) : |
| 13 | sys(sys){}; |
Patrick Venture | cf2d1b1 | 2018-12-11 18:22:36 -0800 | [diff] [blame] | 14 | |
Patrick Venture | 2e12a43 | 2018-12-13 18:05:11 -0800 | [diff] [blame^] | 15 | ~IpmiHandler() = default; |
| 16 | IpmiHandler(const IpmiHandler&) = delete; |
| 17 | IpmiHandler& operator=(const IpmiHandler&) = delete; |
| 18 | IpmiHandler(IpmiHandler&&) = default; |
| 19 | IpmiHandler& operator=(IpmiHandler&&) = default; |
| 20 | |
| 21 | /** |
| 22 | * Attempt to open the device node. |
| 23 | * |
| 24 | * @return true on success, failure otherwise. |
| 25 | */ |
| 26 | bool open(); |
| 27 | |
Patrick Venture | 035bbbb | 2018-12-12 14:59:52 -0800 | [diff] [blame] | 28 | std::vector<std::uint8_t> |
| 29 | sendPacket(const std::vector<std::uint8_t>& data) override; |
Patrick Venture | b5a9706 | 2018-12-13 16:55:23 -0800 | [diff] [blame] | 30 | |
| 31 | private: |
| 32 | const internal::Sys* sys; |
Patrick Venture | 2e12a43 | 2018-12-13 18:05:11 -0800 | [diff] [blame^] | 33 | /** TODO: Use a smart file descriptor when it's ready. Until then only |
| 34 | * allow moving this object. |
| 35 | */ |
| 36 | int fd = -1; |
Patrick Venture | cf2d1b1 | 2018-12-11 18:22:36 -0800 | [diff] [blame] | 37 | }; |
Patrick Venture | 9b534f0 | 2018-12-13 16:10:02 -0800 | [diff] [blame] | 38 | |
| 39 | } // namespace host_tool |